diff --git a/src/App.vue b/src/App.vue index ad52768..8595286 100644 --- a/src/App.vue +++ b/src/App.vue @@ -16,6 +16,7 @@ import CustomerImportProgress from '@/components/CustomerImportProgress.vue' import TahesabDocSyncProgress from '@/components/TahesabDocSyncProgress.vue' import GroupSmsSendProgress from '@/components/GroupSmsSendProgress.vue' import { useUserStore } from '@/store/userStore' +import { useTahesabDocSyncStore } from '@/store/tahesabDocSyncStore' import { bootstrapAdminChat, useAdminChatService } from '@/utils/adminChat' import { supportChatMenuEnabledSetting } from '@/utils/config' @@ -66,7 +67,15 @@ watch(latestIncomingNotification, (payload) => { onMounted(async () => { await config.getConfigData() + void useTahesabDocSyncStore().hydrate() }) + +watch( + () => userStore.userInfo?.id, + (id) => { + if (id) void useTahesabDocSyncStore().hydrate() + }, +) diff --git a/src/api/tahesab.ts b/src/api/tahesab.ts index 0a2f943..6fde2af 100644 --- a/src/api/tahesab.ts +++ b/src/api/tahesab.ts @@ -38,6 +38,7 @@ export interface TahesabDocSyncState { running: boolean finished: boolean stopped: boolean + stage?: 'docs' | 'customers_out' | 'customers_in' percent: number total: number processed: number @@ -45,6 +46,9 @@ export interface TahesabDocSyncState { failed: number current: string errors: { label?: string; error?: string }[] + doc_total?: number + doc_success?: number + doc_failed?: number started_at?: string | null finished_at?: string | null } @@ -97,6 +101,16 @@ export const stopTahesabDocSync = async () => '/admin/tahesab/doc-sync/stop' ) +export const startTahesabCustomerOutbound = async () => + await useAxios.post<{ ok: boolean; message: string; doc_sync: TahesabDocSyncState }>( + '/admin/tahesab/customer-sync/outbound/start' + ) + +export const startTahesabCustomerInbound = async () => + await useAxios.post<{ ok: boolean; message: string; doc_sync: TahesabDocSyncState }>( + '/admin/tahesab/customer-sync/inbound/start' + ) + export const registerCustomerInTahesab = async (customerId: number) => await useAxios.post<{ ok: boolean; message: string; moshtari_code?: string | number }>( `/admin/customer/${customerId}/tahesab/register` diff --git a/src/components/TahesabDocSyncProgress.vue b/src/components/TahesabDocSyncProgress.vue index 469b7be..953c303 100644 --- a/src/components/TahesabDocSyncProgress.vue +++ b/src/components/TahesabDocSyncProgress.vue @@ -33,7 +33,7 @@ / {{ store.state.total }} -
در حال ارسال سندها به ته‌حساب…
+
{{ runningLabel }}
@@ -59,14 +59,12 @@
{{ outcomeInfo.text }}
-
- از {{ store.state.total }} سند، {{ store.state.processed }} مورد پردازش شد -
+
{{ reportSubtitle }}
{{ store.state.success }}
-
ارسال شد
+
{{ doneCardLabel }}
@@ -121,7 +119,7 @@ - +