diff --git a/packages/wallet/frontend/src/components/settings/ChangePasswordForm.tsx b/packages/wallet/frontend/src/components/settings/ChangePasswordForm.tsx index 53c390958..e3ba04c27 100644 --- a/packages/wallet/frontend/src/components/settings/ChangePasswordForm.tsx +++ b/packages/wallet/frontend/src/components/settings/ChangePasswordForm.tsx @@ -94,7 +94,7 @@ export const ChangePasswordForm = () => { /> {isCurrentPasswordVisible ? : } @@ -109,7 +109,7 @@ export const ChangePasswordForm = () => { /> {isNewPasswordVisible ? : } @@ -126,7 +126,7 @@ export const ChangePasswordForm = () => { /> {isConfirmNewPasswordVisible ? : } diff --git a/packages/wallet/frontend/src/components/settings/PersonalSettingsForm.tsx b/packages/wallet/frontend/src/components/settings/PersonalSettingsForm.tsx index 3ebfe2936..b35a7f11c 100644 --- a/packages/wallet/frontend/src/components/settings/PersonalSettingsForm.tsx +++ b/packages/wallet/frontend/src/components/settings/PersonalSettingsForm.tsx @@ -1,12 +1,5 @@ import { Button } from '@/ui/Button' -import { Form } from '@/ui/forms/Form' -import { useZodForm } from '@/lib/hooks/useZodForm' import { Input } from '@/ui/forms/Input' -import { useEffect, useState } from 'react' -import { profileSchema, userService } from '@/lib/api/user' -import { useDialog } from '@/lib/hooks/useDialog' -import { ErrorDialog } from '../dialogs/ErrorDialog' -import { getObjectKeys } from '@/utils/helpers' import { ChangePasswordForm } from './ChangePasswordForm' import { usePasswordContext } from '@/lib/context/password' import { UserResponse } from '@wallet/shared' @@ -17,124 +10,30 @@ type PersonalSettingsFormProps = { // TODO: Can these details be updated by the user when switching to GateHub? export const PersonalSettingsForm = ({ user }: PersonalSettingsFormProps) => { - const [isReadOnly, setIsReadOnly] = useState(true) const { isChangePassword, setIsChangePassword } = usePasswordContext() - const [openDialog, closeDialog] = useDialog() - const profileForm = useZodForm({ - schema: profileSchema, - defaultValues: user - }) - - useEffect(() => { - profileForm.setFocus('firstName') - }, [isReadOnly, profileForm]) return ( <>
-

Profile

+

Details

-
{ - const response = await userService.updateProfile(data) - - if (!response) { - openDialog( - - ) - return - } - - if (response.success) { - setIsReadOnly(!isReadOnly) - } else { - const { errors, message } = response - - if (errors) { - getObjectKeys(errors).map((field) => - profileForm.setError(field, { - message: errors[field] - }) - ) - } - if (message) { - profileForm.setError('root', { message }) - } - } - }} - readOnly={isReadOnly} - > +
+
+
- - {!isReadOnly && ( -
- - -
- )} - - {isReadOnly && ( -
- - {!isChangePassword ? ( - - ) : ( - - )} -
- )} - {isChangePassword && } -
+
+
{ value={user.address} />
-
+
{ value={user.email} />
+
+ {!isChangePassword ? ( + + ) : ( + + )} +
+ {isChangePassword && } ) } diff --git a/packages/wallet/frontend/src/lib/api/user.ts b/packages/wallet/frontend/src/lib/api/user.ts index d86f9ef25..7614aea5c 100644 --- a/packages/wallet/frontend/src/lib/api/user.ts +++ b/packages/wallet/frontend/src/lib/api/user.ts @@ -16,11 +16,6 @@ import { IframeResponse } from '@wallet/shared' -export const profileSchema = z.object({ - firstName: z.string().min(1, { message: 'First name is required' }), - lastName: z.string().min(1, { message: 'Last name is required' }) -}) - export const resetPasswordSchema = z .object({ password: z @@ -117,10 +112,6 @@ type VerifyEmailResponse = SuccessResponse | VerifyEmailError type MeResult = SuccessResponse type MeResponse = MeResult | ErrorResponse -type ProfileArgs = z.infer -type ProfileError = ErrorResponse -type ProfileResponse = SuccessResponse | ProfileError - type ChangePasswordArgs = z.infer type ChangePasswordError = ErrorResponse type ChangePasswordResponse = SuccessResponse | ChangePasswordError @@ -137,7 +128,6 @@ interface UserService { checkToken: (token: string, cookies?: string) => Promise verifyEmail: (args: VerifyEmailArgs) => Promise me: (cookies?: string) => Promise - updateProfile: (args: ProfileArgs) => Promise changePassword: (args: ChangePasswordArgs) => Promise resendVerifyEmail: ( args: ResendVerificationEmailArgs @@ -288,22 +278,6 @@ const createUserService = (): UserService => ({ } }, - async updateProfile(args) { - try { - const response = await httpClient - .post('updateProfile', { - json: args - }) - .json() - return response - } catch (error) { - return getError( - error, - 'Something went wrong while updating your profile. Please try again.' - ) - } - }, - async changePassword(args) { try { const response = await httpClient diff --git a/packages/wallet/frontend/src/pages/auth/login.tsx b/packages/wallet/frontend/src/pages/auth/login.tsx index f1e8abbcf..213412f79 100644 --- a/packages/wallet/frontend/src/pages/auth/login.tsx +++ b/packages/wallet/frontend/src/pages/auth/login.tsx @@ -121,7 +121,7 @@ const LoginPage: NextPageWithLayout = () => { /> {isPasswordVisible ? : } diff --git a/packages/wallet/frontend/src/pages/auth/reset/[token].tsx b/packages/wallet/frontend/src/pages/auth/reset/[token].tsx index a7995cdc1..5225d4e09 100644 --- a/packages/wallet/frontend/src/pages/auth/reset/[token].tsx +++ b/packages/wallet/frontend/src/pages/auth/reset/[token].tsx @@ -95,7 +95,7 @@ const ResetPasswordPage: NextPageWithLayout = ({ /> {isPasswordVisible ? : } @@ -112,7 +112,7 @@ const ResetPasswordPage: NextPageWithLayout = ({ /> {isConfirmPasswordVisible ? : } diff --git a/packages/wallet/frontend/src/pages/auth/signup.tsx b/packages/wallet/frontend/src/pages/auth/signup.tsx index 5485fd1b3..7c665280a 100644 --- a/packages/wallet/frontend/src/pages/auth/signup.tsx +++ b/packages/wallet/frontend/src/pages/auth/signup.tsx @@ -101,7 +101,7 @@ const SignUpPage: NextPageWithLayout = () => { /> {isPasswordVisible ? : } @@ -116,7 +116,7 @@ const SignUpPage: NextPageWithLayout = () => { /> {isRepeatPasswordVisible ? : } diff --git a/packages/wallet/frontend/src/pages/settings/index.tsx b/packages/wallet/frontend/src/pages/settings/index.tsx index dcf13fbe5..487a5b641 100644 --- a/packages/wallet/frontend/src/pages/settings/index.tsx +++ b/packages/wallet/frontend/src/pages/settings/index.tsx @@ -23,7 +23,7 @@ const AccountSettingsPage: NextPageWithLayout = ({ : '/bird-envelope-light.webp' return ( <> - +