From c8d940857f7781e1393c1093f92b0fb044fc3208 Mon Sep 17 00:00:00 2001 From: Wattana Chaidee Date: Fri, 9 Feb 2024 12:27:51 +0700 Subject: [PATCH] #179 #176 #175 add user address field. --- components/admin/profile/updateInfo.tsx | 14 +++ .../admin/profile/updateInfoViewModel.ts | 18 +++- components/admin/user/create.tsx | 11 +++ components/admin/user/createViewModel.ts | 1 + components/admin/user/update.tsx | 25 +++++ components/admin/user/updateViewModel.ts | 2 + components/admin/user/userViewModel.ts | 14 +++ components/admin/user/view.tsx | 9 ++ components/auth/register/index.tsx | 2 +- components/auth/register/registerUser.tsx | 11 +++ components/auth/register/viewModel.ts | 17 +++- graphql.schema.json | 84 +++++++++++++++++ i18n/translations.en.json | 2 + i18n/translations.la.json | 2 + i18n/translations.th.json | 2 + lib/generated/graphql.tsx | 92 +++++++++++++++++++ lib/services/profile/me.ts | 1 + lib/services/profile/profile.graphql | 3 + lib/services/profile/profileService.ts | 8 +- lib/services/register/register.graphql | 3 + lib/services/register/registerService.ts | 8 +- lib/services/user/user.graphql | 6 ++ lib/services/user/user.ts | 1 + lib/services/user/userService.ts | 7 ++ 24 files changed, 336 insertions(+), 7 deletions(-) diff --git a/components/admin/profile/updateInfo.tsx b/components/admin/profile/updateInfo.tsx index d33af687..fe604d45 100644 --- a/components/admin/profile/updateInfo.tsx +++ b/components/admin/profile/updateInfo.tsx @@ -109,6 +109,20 @@ const ProfileInfoUpdate = () => { /> {errors.telephone} + + + (viewModel.address = evt.target.value)} + disabled={viewModel.isSubmitting} + value={viewModel.address} + /> + {errors.address} + {viewModel.submitError.length > 0 && ( {viewModel.submitError} diff --git a/components/admin/profile/updateInfoViewModel.ts b/components/admin/profile/updateInfoViewModel.ts index 5e648667..f87a22f0 100644 --- a/components/admin/profile/updateInfoViewModel.ts +++ b/components/admin/profile/updateInfoViewModel.ts @@ -8,6 +8,7 @@ export class ProfileUpdateInfoViewModel extends BaseFormViewModel { _firstName: string = ""; _lastName: string = ""; _telephone: string = ""; + _address: string = ""; constructor(readonly me: Me, readonly profileService: IProfileService) { super(); @@ -18,6 +19,8 @@ export class ProfileUpdateInfoViewModel extends BaseFormViewModel { lastName: computed, _telephone: observable, telephone: computed, + _address: observable, + address: computed, save: action, validate: action, }); @@ -30,6 +33,7 @@ export class ProfileUpdateInfoViewModel extends BaseFormViewModel { this.firstName = this.me.firstName; this.lastName = this.me.lastName; this.telephone = this.me.telephone || ""; + this.address = this.me.address || ""; } public get firstName(): string { @@ -65,6 +69,17 @@ export class ProfileUpdateInfoViewModel extends BaseFormViewModel { } } + public get address(): string { + return this._address; + } + public set address(value: string) { + this._address = value; + delete this.fieldErrors["address"]; + if (this.submitError.length > 0) { + this.submitError = ""; + } + } + public async save(): Promise { this.isSubmitting = true; @@ -91,7 +106,8 @@ export class ProfileUpdateInfoViewModel extends BaseFormViewModel { return this.profileService.updateProfile( this.firstName, this.lastName, - this.telephone + this.telephone, + this.address ); } diff --git a/components/admin/user/create.tsx b/components/admin/user/create.tsx index a4288445..8f0d20f7 100644 --- a/components/admin/user/create.tsx +++ b/components/admin/user/create.tsx @@ -123,6 +123,17 @@ const UserCreate = () => { /> {errors.telephone} + + + (viewModel.address = evt.target.value)} + disabled={isSubmitting} + /> + {errors.address} +