fix policy dir
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -18,7 +18,7 @@ const statusItems = ref<SelectItem[]>([
|
||||
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) =>
|
||||
<div class="bg-gray-50 rounded-lg p-3 space-y-1.5 text-sm">
|
||||
<div class="flex justify-between">
|
||||
<span class="text-gray-500">Plate</span>
|
||||
<span class="font-medium font-mono">{{ policy.plate }}</span>
|
||||
<span class="font-medium font-mono">{{ policy.policy_details.plate }}</span>
|
||||
</div>
|
||||
<div class="flex justify-between">
|
||||
<span class="text-gray-500">Vehicle</span>
|
||||
<span class="font-medium">{{ policy.year }} {{ policy.make }} {{ policy.model }}</span>
|
||||
<span class="font-medium">{{ policy.policy_details.year }} {{ policy.policy_details.make }} {{ policy.policy_details.model }}</span>
|
||||
</div>
|
||||
<div class="flex justify-between">
|
||||
<span class="text-gray-500">Value</span>
|
||||
<span class="font-medium">${{ Number(policy.car_value).toLocaleString() }}</span>
|
||||
<span class="font-medium">${{ Number(policy.policy_details.car_value).toLocaleString() }}</span>
|
||||
</div>
|
||||
<div v-if="policy.policy_number" class="flex justify-between">
|
||||
<span class="text-gray-500">Policy #</span>
|
||||
<span class="font-medium font-mono text-green-600">{{ policy.policy_number }}</span>
|
||||
<span class="font-medium font-mono text-green-600">{{ policy.policy_details.policy_number }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -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<SelectItem[]>([
|
||||
@@ -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(() => {
|
||||
<div v-if="carForm.selected_providers.length > 0" class="flex flex-wrap gap-2 pt-2 border-t">
|
||||
<div
|
||||
v-for="p in carForm.selected_providers"
|
||||
:key="p.id"
|
||||
:key="p.provider_id"
|
||||
class="flex items-center gap-1.5 px-3 py-1 bg-primary-50 border border-primary-200 rounded-full text-sm"
|
||||
>
|
||||
<UIcon name="i-heroicons-building-office" class="w-3.5 h-3.5 text-primary-500" />
|
||||
<span class="text-primary-800 font-medium">
|
||||
{{ providerItems.find(x => x.provider_id === p.id)?.name ?? p.id }}
|
||||
{{ providerItems.find(x => x.provider_id === p.provider_id)?.name ?? p.provider_id }}
|
||||
</span>
|
||||
<UButton
|
||||
icon="i-heroicons-x-mark"
|
||||
size="xs" color="gray" variant="ghost"
|
||||
class="w-4 h-4 p-0"
|
||||
@click="carForm.selected_providers = carForm.selected_providers.filter(x => x.id !== p.id)"
|
||||
@click="carForm.selected_providers = carForm.selected_providers.filter(x => x.provider_id !== p.provider_id)"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user