refactor: dynamic image based on customer type

This commit is contained in:
Methapon2001 2024-08-05 15:42:00 +07:00
parent 542e48cd1d
commit 6d039862c2
6 changed files with 11 additions and 6 deletions

View file

Before

Width:  |  Height:  |  Size: 218 KiB

After

Width:  |  Height:  |  Size: 218 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 277 KiB

After

Width:  |  Height:  |  Size: 277 KiB

Before After
Before After

Binary file not shown.

After

Width:  |  Height:  |  Size: 334 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 263 KiB

View file

@ -382,6 +382,7 @@ async function editCustomerForm(id: string) {
await customerFormStore.assignFormData(id); await customerFormStore.assignFormData(id);
customerFormState.value.dialogType = 'edit'; customerFormState.value.dialogType = 'edit';
customerFormState.value.dialogModal = true; customerFormState.value.dialogModal = true;
customerFormState.value.editCustomerId = id;
} }
function createCustomerForm(customerType: 'CORP' | 'PERS') { function createCustomerForm(customerType: 'CORP' | 'PERS') {
@ -1644,8 +1645,9 @@ function createCustomerForm(customerType: 'CORP' | 'PERS') {
}) })
" "
:submit=" :submit="
() => { async () => {
customerFormStore.submitForm(); await customerFormStore.submitForm();
await fetchListCustomer();
} }
" "
:close="() => (customerFormState.dialogModal = false)" :close="() => (customerFormState.dialogModal = false)"
@ -1659,10 +1661,10 @@ function createCustomerForm(customerType: 'CORP' | 'PERS') {
customerFormState.customerImageUrl === '' || customerFormState.customerImageUrl === '' ||
customerFormState.customerImageUrl === null customerFormState.customerImageUrl === null
" "
fallback-cover="/images/customer-legal-banner-bg.jpg" :fallback-cover="`/images/customer-${customerFormData.customerType}-banner-bg.jpg`"
:img=" :img="
customerFormState.customerImageUrl || customerFormState.customerImageUrl ||
'/images/customer-legal-avartar.png' `/images/customer-${customerFormData.customerType}-avartar.png`
" "
color="hsla(var(--pink-6-hsl)/1)" color="hsla(var(--pink-6-hsl)/1)"
bg-color="hsla(var(--pink-6-hsl)/0.15)" bg-color="hsla(var(--pink-6-hsl)/0.15)"
@ -1701,7 +1703,6 @@ function createCustomerForm(customerType: 'CORP' | 'PERS') {
id="customer-form-content" id="customer-form-content"
style="height: 100%; max-height: 100%; overflow-y: auto" style="height: 100%; max-height: 100%; overflow-y: auto"
> >
{{ customerFormData.customerType }}
<FormBasicInfo <FormBasicInfo
id="form-basic-info-customer" id="form-basic-info-customer"
@save="customerFormState.saveMode = 'customer'" @save="customerFormState.saveMode = 'customer'"
@ -1738,7 +1739,7 @@ function createCustomerForm(customerType: 'CORP' | 'PERS') {
!customerFormState.customerImageUrl || !customerFormState.customerImageUrl ||
customerFormState.dialogType === 'edit' customerFormState.dialogType === 'edit'
" "
fallback-url="/images/customer-legal-avartar.png" :fallback-cover="`/images/customer-${customerFormData.customerType}-banner-bg.jpg`"
clear-button clear-button
@save="() => {}" @save="() => {}"
></ImageUploadDialog> ></ImageUploadDialog>

View file

@ -177,6 +177,10 @@ export const useCustomerForm = defineStore('form-customer', () => {
await customerStore.editById(state.value.editCustomerId, { await customerStore.editById(state.value.editCustomerId, {
...currentFormData.value, ...currentFormData.value,
status:
currentFormData.value.status !== 'CREATED'
? currentFormData.value.status
: undefined,
image: currentFormData.value.image || undefined, image: currentFormData.value.image || undefined,
customerBranch: undefined, customerBranch: undefined,
}); });