text area

This commit is contained in:
Sirttas
2026-06-07 22:06:53 +02:00
parent 47bd728530
commit 023693c4c8
10 changed files with 46 additions and 325 deletions
+3 -29
View File
@@ -2,39 +2,13 @@ import {characterRuleBookApi, ruleBookApi} from "@/mammon";
import {
CharacterRuleBookResponse,
CreateRuleBookRequest,
ItemExchangeRuleClauseResponseRateEnum,
RuleBookResponse,
RuleResponse,
SetCharacterRuleBookRequest
} from "@/generated/mammon";
import {defineStore} from "pinia";
import {ref, triggerRef} from "vue";
export const activityTypes = {
itemBought: {key: "ITEM_BOUGHT", name: "Item Bought"},
itemSold: {key: "ITEM_SOLD", name: "Item Sold"},
itemAcquiredManually: {key: "ITEM_ACQUIRED_MANUALLY", name: "Item Acquired Manually"},
itemConsumedManually: {key: "ITEM_CONSUME_MANUALLY", name: "Item Consumed Manually"},
bountyEarned: {key: "BOUNTY_EARNED", name: "Bounty Earned"},
// itemManufactured: {id: "ITEM_MANUFACTURED", name: "Item Manufactured"}
} as const;
export type Activity = { key: ActivityType, name: string }
export type ActivityType = typeof activityTypes[keyof typeof activityTypes]['key'];
export type Rules = { [key: ActivityType]: RuleResponse; };
export type RuleBook = RuleBookResponse & { rules: Rules }
export const activityTypeHasRate = (key: ActivityType): boolean => key !== activityTypes.bountyEarned.key;
export const ratesTypes = {
None: {key: "NONE", name: "0 ISK"},
Value: {key: "VALUE", name: "Value"},
JitaBuy: {key: "JITA_BUY", name: "Jita Buy Order"},
JitaSell: {key: "JITA_SELL", name: "Jita Sell Order"},
EveEstimate: {key: "EVE_ESTIMATE", name: "Eve Estimate"},
} as const;
export type Rate = { key: ItemExchangeRuleClauseResponseRateEnum, name: string }
export type RuleBook = RuleBookResponse;
export const useRuleBooksStore = defineStore('rule-books', () => {
const ruleBooks = ref<RuleBook[]>([]);
@@ -59,7 +33,7 @@ export const useRuleBooksStore = defineStore('rule-books', () => {
const create = (ruleBook: CreateRuleBookRequest) => ruleBookApi.createRuleBook(ruleBook).then(response => addRuleBook(response.data));
const update = (ruleBookId: string, ruleBook: CreateRuleBookRequest) => ruleBookApi.updateRuleBook(ruleBookId, ruleBook).then(response => replaceRuleBook(response.data));
const refresh = () => ruleBookApi.findAllRuleBooks().then(response => ruleBooks.value = response.data as RuleBook[]);
const refresh = () => ruleBookApi.findAllRuleBooks().then(response => ruleBooks.value = response.data);
refresh();
@@ -68,7 +42,7 @@ export const useRuleBooksStore = defineStore('rule-books', () => {
export const findCharacterRuleBookByCharacterId = (characterId: number): Promise<CharacterRuleBookResponse> => characterRuleBookApi.findCharacterRuleBookByCharacterId(characterId)
.then(response => response.data)
.catch(() => ({characterId, rules: {}}));
.catch(() => ({characterId, ruleBookId: '', bindings: {}}));
export const setCharacterRuleBookForCharacter = (characterId: number, ruleBook: SetCharacterRuleBookRequest): Promise<CharacterRuleBookResponse> => characterRuleBookApi.setCharacterRuleBookForCharacter(characterId, ruleBook)
.then(response => response.data);