fix policy dir
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const applicationId = route.params.application_id as string
|
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)
|
const policy = computed(() => data.value?.data)
|
||||||
|
|
||||||
// ── Accept plan ──────────────────────────────────────────────────────────────
|
// ── Accept plan ──────────────────────────────────────────────────────────────
|
||||||
@@ -24,7 +24,7 @@ function openAccept(quote: any, plan: any) {
|
|||||||
async function submitAccept() {
|
async function submitAccept() {
|
||||||
accepting.value = true
|
accepting.value = true
|
||||||
try {
|
try {
|
||||||
await $policy(`/car-policies/${applicationId}/accept`, {
|
await $policy(`/policies/${applicationId}/accept`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: {
|
body: {
|
||||||
quote_id: selectedQuote.value.quote_id,
|
quote_id: selectedQuote.value.quote_id,
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ const statusItems = ref<SelectItem[]>([
|
|||||||
watch(debouncedSearch, () => { page.value = 1 })
|
watch(debouncedSearch, () => { page.value = 1 })
|
||||||
watch(statusFilter, () => { 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(() => ({
|
query: computed(() => ({
|
||||||
page_size: 20,
|
page_size: 20,
|
||||||
page: page.value,
|
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="bg-gray-50 rounded-lg p-3 space-y-1.5 text-sm">
|
||||||
<div class="flex justify-between">
|
<div class="flex justify-between">
|
||||||
<span class="text-gray-500">Plate</span>
|
<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>
|
||||||
<div class="flex justify-between">
|
<div class="flex justify-between">
|
||||||
<span class="text-gray-500">Vehicle</span>
|
<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>
|
||||||
<div class="flex justify-between">
|
<div class="flex justify-between">
|
||||||
<span class="text-gray-500">Value</span>
|
<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>
|
||||||
<div v-if="policy.policy_number" class="flex justify-between">
|
<div v-if="policy.policy_number" class="flex justify-between">
|
||||||
<span class="text-gray-500">Policy #</span>
|
<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>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ const carForm = ref({
|
|||||||
chassis_number: '',
|
chassis_number: '',
|
||||||
engine_number: ''
|
engine_number: ''
|
||||||
},
|
},
|
||||||
selected_providers: [] as { id: string, email: string }[]
|
selected_providers: [] as { provider_id: string, email: string }[]
|
||||||
})
|
})
|
||||||
|
|
||||||
const useTypeItems = ref<SelectItem[]>([
|
const useTypeItems = ref<SelectItem[]>([
|
||||||
@@ -143,16 +143,19 @@ const { data: providersData, pending: providersPending } = useProviders('/provid
|
|||||||
const providerItems = computed(() => providersData.value?.data ?? [])
|
const providerItems = computed(() => providersData.value?.data ?? [])
|
||||||
|
|
||||||
function toggleProvider(provider: any) {
|
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) {
|
if (idx >= 0) {
|
||||||
carForm.value.selected_providers.splice(idx, 1)
|
carForm.value.selected_providers.splice(idx, 1)
|
||||||
} else {
|
} 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) {
|
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() {
|
async function submitCarPolicy() {
|
||||||
submitting.value = true
|
submitting.value = true
|
||||||
try {
|
try {
|
||||||
const data = await $policy('/car-policies', {
|
const data = await $policy('/policies', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: {
|
body: {
|
||||||
|
policy_type: 'car',
|
||||||
applicant_info: applicantInfo.value,
|
applicant_info: applicantInfo.value,
|
||||||
car_details: carForm.value.car_details,
|
policy_details: carForm.value.car_details,
|
||||||
selected_providers: carForm.value.selected_providers
|
selected_providers: carForm.value.selected_providers
|
||||||
}
|
}
|
||||||
}) as any
|
}) as any
|
||||||
@@ -176,7 +180,7 @@ async function submitCarPolicy() {
|
|||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
toast.add({
|
toast.add({
|
||||||
title: 'Failed to submit policy',
|
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'
|
color: 'red'
|
||||||
})
|
})
|
||||||
} finally {
|
} 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-if="carForm.selected_providers.length > 0" class="flex flex-wrap gap-2 pt-2 border-t">
|
||||||
<div
|
<div
|
||||||
v-for="p in carForm.selected_providers"
|
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"
|
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" />
|
<UIcon name="i-heroicons-building-office" class="w-3.5 h-3.5 text-primary-500" />
|
||||||
<span class="text-primary-800 font-medium">
|
<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>
|
</span>
|
||||||
<UButton
|
<UButton
|
||||||
icon="i-heroicons-x-mark"
|
icon="i-heroicons-x-mark"
|
||||||
size="xs" color="gray" variant="ghost"
|
size="xs" color="gray" variant="ghost"
|
||||||
class="w-4 h-4 p-0"
|
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>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ const isIssueFormValid = computed(() =>
|
|||||||
async function submitIssuePolicy() {
|
async function submitIssuePolicy() {
|
||||||
issuing.value = true
|
issuing.value = true
|
||||||
try {
|
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' })
|
toast.add({ title: 'Policy issued successfully', color: 'green' })
|
||||||
isIssueOpen.value = false
|
isIssueOpen.value = false
|
||||||
await refresh()
|
await refresh()
|
||||||
|
|||||||
Reference in New Issue
Block a user