From ff2d7b18b562fd9c5cb14adcc0e595888061fef3 Mon Sep 17 00:00:00 2001 From: HaimKortovich Date: Mon, 30 Mar 2026 12:48:29 -0500 Subject: [PATCH] fix policy dir --- app/pages/policies/[application_id].vue | 4 ++-- app/pages/policies/index.vue | 10 +++++----- app/pages/policies/new.vue | 24 ++++++++++++++---------- app/pages/tasks/[id].vue | 2 +- 4 files changed, 22 insertions(+), 18 deletions(-) diff --git a/app/pages/policies/[application_id].vue b/app/pages/policies/[application_id].vue index bdd8290..4f51bb1 100644 --- a/app/pages/policies/[application_id].vue +++ b/app/pages/policies/[application_id].vue @@ -2,7 +2,7 @@ const route = useRoute() const applicationId = route.params.application_id as string -const { data, error, pending, refresh } = usePolicy(`/car-policies/${applicationId}`) +const { data, error, pending, refresh } = usePolicy(`/policies/${applicationId}`) const policy = computed(() => data.value?.data) // ── Accept plan ────────────────────────────────────────────────────────────── @@ -24,7 +24,7 @@ function openAccept(quote: any, plan: any) { async function submitAccept() { accepting.value = true try { - await $policy(`/car-policies/${applicationId}/accept`, { + await $policy(`/policies/${applicationId}/accept`, { method: 'POST', body: { quote_id: selectedQuote.value.quote_id, diff --git a/app/pages/policies/index.vue b/app/pages/policies/index.vue index 020dc8b..d5eccb2 100644 --- a/app/pages/policies/index.vue +++ b/app/pages/policies/index.vue @@ -18,7 +18,7 @@ const statusItems = ref([ watch(debouncedSearch, () => { page.value = 1 }) watch(statusFilter, () => { page.value = 1 }) -const { data, error, pending, refresh } = usePolicy('/car-policies', { +const { data, error, pending, refresh } = usePolicy('/policies', { query: computed(() => ({ page_size: 20, page: page.value, @@ -155,19 +155,19 @@ const clientTypeColor = (ct: string) =>
Plate - {{ policy.plate }} + {{ policy.policy_details.plate }}
Vehicle - {{ policy.year }} {{ policy.make }} {{ policy.model }} + {{ policy.policy_details.year }} {{ policy.policy_details.make }} {{ policy.policy_details.model }}
Value - ${{ Number(policy.car_value).toLocaleString() }} + ${{ Number(policy.policy_details.car_value).toLocaleString() }}
Policy # - {{ policy.policy_number }} + {{ policy.policy_details.policy_number }}
diff --git a/app/pages/policies/new.vue b/app/pages/policies/new.vue index 9380e53..0228d53 100644 --- a/app/pages/policies/new.vue +++ b/app/pages/policies/new.vue @@ -100,7 +100,7 @@ const carForm = ref({ chassis_number: '', engine_number: '' }, - selected_providers: [] as { id: string, email: string }[] + selected_providers: [] as { provider_id: string, email: string }[] }) const useTypeItems = ref([ @@ -143,16 +143,19 @@ const { data: providersData, pending: providersPending } = useProviders('/provid const providerItems = computed(() => providersData.value?.data ?? []) function toggleProvider(provider: any) { - const idx = carForm.value.selected_providers.findIndex(p => p.id === provider.provider_id) + const idx = carForm.value.selected_providers.findIndex(p => p.provider_id === provider.provider_id) if (idx >= 0) { carForm.value.selected_providers.splice(idx, 1) } else { - carForm.value.selected_providers.push({ id: provider.provider_id, email: provider.email }) + carForm.value.selected_providers.push({ + provider_id: provider.provider_id, + email: provider.email + }) } } function isProviderSelected(provider: any) { - return carForm.value.selected_providers.some(p => p.id === provider.provider_id) + return carForm.value.selected_providers.some(p => p.provider_id === provider.provider_id) } // --------------------------------------------------------------------------- @@ -162,11 +165,12 @@ function isProviderSelected(provider: any) { async function submitCarPolicy() { submitting.value = true try { - const data = await $policy('/car-policies', { + const data = await $policy('/policies', { method: 'POST', body: { + policy_type: 'car', applicant_info: applicantInfo.value, - car_details: carForm.value.car_details, + policy_details: carForm.value.car_details, selected_providers: carForm.value.selected_providers } }) as any @@ -176,7 +180,7 @@ async function submitCarPolicy() { } catch (e: any) { toast.add({ title: 'Failed to submit policy', - description: e?.data?.errors ? JSON.stringify(e.data.errors) : e.message, + description: e?.data?.error ? JSON.stringify(e.data.error) : e.message, color: 'red' }) } finally { @@ -460,18 +464,18 @@ const isCarFormValid = computed(() => {
- {{ providerItems.find(x => x.provider_id === p.id)?.name ?? p.id }} + {{ providerItems.find(x => x.provider_id === p.provider_id)?.name ?? p.provider_id }}
diff --git a/app/pages/tasks/[id].vue b/app/pages/tasks/[id].vue index 0e22767..429fd43 100644 --- a/app/pages/tasks/[id].vue +++ b/app/pages/tasks/[id].vue @@ -76,7 +76,7 @@ const isIssueFormValid = computed(() => async function submitIssuePolicy() { issuing.value = true try { - await $task(`/tasks/${id}/issue-policy`, { method: 'POST', body: issueForm.value }) + await $tasks(`/tasks/${id}/issue-policy`, { method: 'POST', body: issueForm.value }) toast.add({ title: 'Policy issued successfully', color: 'green' }) isIssueOpen.value = false await refresh()