refactor: handle name trim

This commit is contained in:
Thanaphon Frappet 2024-11-29 13:33:07 +07:00
parent 5c39f9756a
commit 9fa735c529
5 changed files with 114 additions and 25 deletions

View file

@ -1,6 +1,10 @@
import { ref, toRaw, watch } from 'vue';
import { defineStore } from 'pinia';
import { CustomerBranchCreate, CustomerCreate } from 'stores/customer/types';
import {
CustomerBranchCreate,
CustomerCreate,
CustomerType,
} from 'stores/customer/types';
import { Employee, EmployeeCreate } from 'stores/employee/types';
import { useI18n } from 'vue-i18n';
@ -29,7 +33,7 @@ export const useCustomerForm = defineStore('form-customer', () => {
customerBranch: [],
selectedImage: '',
status: 'CREATED',
customerType: 'CORP',
customerType: CustomerType.Corporate,
registeredBranchId: branchStore.currentMyBranch?.id || '',
image: null,
};
@ -1092,6 +1096,20 @@ export const useEmployeeForm = defineStore('form-employee', () => {
selectedImage: string;
list: { url: string; imgFile: File | null; name: string }[];
}) {
currentFromDataEmployee.value.firstName =
currentFromDataEmployee.value.firstName.trim();
currentFromDataEmployee.value.middleName =
currentFromDataEmployee.value.middleName?.trim();
currentFromDataEmployee.value.lastName =
currentFromDataEmployee.value.lastName.trim();
currentFromDataEmployee.value.firstNameEN =
currentFromDataEmployee.value.firstNameEN.trim();
currentFromDataEmployee.value.middleNameEN =
currentFromDataEmployee.value.middleNameEN?.trim();
currentFromDataEmployee.value.lastNameEN =
currentFromDataEmployee.value.lastNameEN.trim();
if (state.value.dialogType === 'create') {
const res = await employeeStore.create(
{