diff --git a/src/services/accountService.ts b/src/services/accountService.ts index 9226d3c..7fd87cd 100644 --- a/src/services/accountService.ts +++ b/src/services/accountService.ts @@ -26,6 +26,12 @@ function mapAccountFromApi(data: Record): Account { lastSyncTime: data.last_sync_time as string | undefined, accountCode: data.account_code as string | undefined, accountType: data.account_type as 'asset' | 'liability' | undefined, + tags: (data.tags as { id: number; name: string; color: string; created_at: string }[] | undefined)?.map(t => ({ + id: t.id, + name: t.name, + color: t.color, + createdAt: t.created_at, + })), }; } @@ -66,6 +72,7 @@ export async function createAccount(data: AccountFormInput): Promise { payment_date: data.paymentDate, warning_threshold: data.warningThreshold, account_code: data.accountCode, + tag_ids: data.tagIds, }; const response = await api.post>('/accounts', payload); if (!response.data) { @@ -91,6 +98,7 @@ export async function updateAccount(id: number, data: Partial) if (data.warningThreshold !== undefined) payload.warning_threshold = data.warningThreshold; if (data.accountCode !== undefined) payload.account_code = data.accountCode; if (data.accountType !== undefined) payload.account_type = data.accountType; + if (data.tagIds !== undefined) payload.tag_ids = data.tagIds; const response = await api.put>(`/accounts/${id}`, payload); if (!response.data) { diff --git a/src/types/index.ts b/src/types/index.ts index 272ca48..3a80d4e 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -149,6 +149,7 @@ export interface Account { lastSyncTime?: string; accountCode?: string; accountType?: 'asset' | 'liability'; + tags?: Tag[]; } // Budget Interface @@ -294,6 +295,7 @@ export interface AccountFormInput { warningThreshold?: number; accountCode?: string; accountType?: 'asset' | 'liability'; + tagIds?: number[]; } export interface TransferFormInput {