migrate transaction tag store to composition API and typescript

This commit is contained in:
MaysWind
2025-01-11 19:53:09 +08:00
parent dc59d3954a
commit ffae9e81a7
17 changed files with 427 additions and 375 deletions
+45
View File
@@ -1,3 +1,48 @@
export class TransactionTag implements TransactionTagInfoResponse {
public id: string;
public name: string;
public displayOrder: number;
public hidden: boolean;
private constructor(id: string, name: string, displayOrder: number, hidden: boolean) {
this.id = id;
this.name = name;
this.displayOrder = displayOrder;
this.hidden = hidden;
}
public toCreateRequest(): TransactionTagCreateRequest {
return {
name: this.name
};
}
public toModifyRequest(): TransactionTagModifyRequest {
return {
id: this.id,
name: this.name
};
}
public static of(tagResponse: TransactionTagInfoResponse): TransactionTag {
return new TransactionTag(tagResponse.id, tagResponse.name, tagResponse.displayOrder, tagResponse.hidden);
}
public static ofMany(tagResponses: TransactionTagInfoResponse[]): TransactionTag[] {
const tags: TransactionTag[] = [];
for (const tagResponse of tagResponses) {
tags.push(TransactionTag.of(tagResponse));
}
return tags;
}
public static createNewTag(): TransactionTag {
return new TransactionTag('', '', 0, false);
}
}
export interface TransactionTagCreateRequest {
readonly name: string;
}