feat: create citizenId relation
This commit is contained in:
parent
d66c3d7856
commit
fe3532eabd
1 changed files with 27 additions and 4 deletions
|
|
@ -10,6 +10,7 @@ import {
|
|||
CustomerBranch,
|
||||
CustomerBranchCreate,
|
||||
CustomerType,
|
||||
CitizenPayload,
|
||||
} from './types';
|
||||
import { Employee } from '../employee/types';
|
||||
import { baseUrl, manageFile } from '../utils';
|
||||
|
|
@ -312,8 +313,6 @@ const useCustomerStore = defineStore('api-customer', () => {
|
|||
const res = await api.put<
|
||||
Customer & {
|
||||
branch: CustomerBranch[];
|
||||
imageUrl: string;
|
||||
imageUploadUrl: string;
|
||||
}
|
||||
>(`/customer/${id}`, {
|
||||
...payload,
|
||||
|
|
@ -360,8 +359,15 @@ const useCustomerStore = defineStore('api-customer', () => {
|
|||
codeCustomer: string;
|
||||
},
|
||||
) {
|
||||
const { codeCustomer, statusSave, code, file, birthDate, ...payload } =
|
||||
data;
|
||||
const {
|
||||
codeCustomer,
|
||||
statusSave,
|
||||
code,
|
||||
file,
|
||||
birthDate,
|
||||
citizen,
|
||||
...payload
|
||||
} = data;
|
||||
|
||||
if (data.citizenId) {
|
||||
delete data['authorizedNameEN'];
|
||||
|
|
@ -383,6 +389,23 @@ const useCustomerStore = defineStore('api-customer', () => {
|
|||
const res = await api.post<CustomerBranch>('/customer-branch', payload);
|
||||
if (!res) return false;
|
||||
|
||||
if (citizen) {
|
||||
for (let i = 0; i < citizen.length; i++) {
|
||||
const _res = await api.post<{ id: string }>(
|
||||
`/customer-branch/${res.data.id}/citizen`,
|
||||
citizen[i],
|
||||
);
|
||||
if (_res.data.id) {
|
||||
await fileManager.putFile({
|
||||
group: 'citizen',
|
||||
parentId: res.data.id,
|
||||
file: citizen[i].file,
|
||||
fileId: _res.data.id,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return res.data;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue