refactor: remove keycloak id from type
This commit is contained in:
parent
d7e606fb16
commit
fe34f018ac
2 changed files with 4 additions and 23 deletions
|
|
@ -52,7 +52,6 @@ const defaultFormData = {
|
|||
firstName: '',
|
||||
userRole: '',
|
||||
userType: '',
|
||||
keycloakId: '',
|
||||
profileImage: null,
|
||||
birthDate: null,
|
||||
responsibleArea: '',
|
||||
|
|
@ -97,7 +96,6 @@ const formData = ref<UserCreate>({
|
|||
firstName: '',
|
||||
userRole: '',
|
||||
userType: '',
|
||||
keycloakId: '',
|
||||
profileImage: null,
|
||||
birthDate: null,
|
||||
responsibleArea: '',
|
||||
|
|
@ -131,16 +129,6 @@ const selectorList = [
|
|||
{ label: 'AGENCY', count: 0 },
|
||||
];
|
||||
|
||||
async function createKeycloak() {
|
||||
const res = await api.post('/keycloak/user', {
|
||||
lastName: formData.value.lastNameEN,
|
||||
firstName: formData.value.firstNameEN,
|
||||
password: username.value,
|
||||
username: username.value,
|
||||
});
|
||||
return res.data;
|
||||
}
|
||||
|
||||
async function openDialog(idEdit?: string) {
|
||||
modal.value = true;
|
||||
userStore.userOption.brOpts = [];
|
||||
|
|
@ -178,7 +166,6 @@ async function openDialog(idEdit?: string) {
|
|||
firstName: foundUser.firstName,
|
||||
userRole: foundUser.userRole,
|
||||
userType: foundUser.userType,
|
||||
keycloakId: foundUser.keycloakId,
|
||||
responsibleArea: foundUser.responsibleArea,
|
||||
licenseExpireDate:
|
||||
(foundUser.licenseExpireDate &&
|
||||
|
|
@ -238,7 +225,6 @@ async function onSubmit() {
|
|||
message: 'คุณต้องการแก้ไขข้อมูล ใช่หรือไม่',
|
||||
action: async () => {
|
||||
const formDataEdit = { ...formData.value };
|
||||
delete formDataEdit.keycloakId;
|
||||
await userStore.editById(userId.value, formDataEdit);
|
||||
onClose();
|
||||
userStore.fetchList({ includeBranch: true });
|
||||
|
|
@ -253,12 +239,9 @@ async function onSubmit() {
|
|||
persistent: true,
|
||||
message: 'คุณต้องการเพิ่มบุคลากร ใช่หรือไม่',
|
||||
action: async () => {
|
||||
formData.value.keycloakId = await createKeycloak();
|
||||
if (formData.value.keycloakId) {
|
||||
const result = await userStore.create(formData.value);
|
||||
if (result) {
|
||||
await branchStore.addUser(brId.value, result.id);
|
||||
}
|
||||
const result = await userStore.create(formData.value);
|
||||
if (result) {
|
||||
await branchStore.addUser(brId.value, result.id);
|
||||
}
|
||||
onClose();
|
||||
userStore.fetchList({ includeBranch: true });
|
||||
|
|
|
|||
|
|
@ -36,7 +36,6 @@ export type User = {
|
|||
lastName: string;
|
||||
firstNameEN: string;
|
||||
firstName: string;
|
||||
keycloakId: string;
|
||||
id: string;
|
||||
profileImageUrl: string;
|
||||
code: string;
|
||||
|
|
@ -71,7 +70,6 @@ export type UserCreate = {
|
|||
firstName: string;
|
||||
userRole: string;
|
||||
userType: string;
|
||||
keycloakId?: string;
|
||||
profileImage?: File | null; // required but not strict
|
||||
birthDate?: Date | null;
|
||||
responsibleArea: string;
|
||||
|
|
@ -116,4 +114,4 @@ export type Option = {
|
|||
export type RoleData = {
|
||||
id: string;
|
||||
name: string;
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue