@greatapps/common 1.1.666 → 1.1.668
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/account/ConfigurationsMyAccountModal.mjs +8 -6
- package/dist/components/account/ConfigurationsMyAccountModal.mjs.map +1 -1
- package/dist/components/account/ConfirmDeleteAccountModal.mjs +20 -19
- package/dist/components/account/ConfirmDeleteAccountModal.mjs.map +1 -1
- package/dist/components/account/ConfirmGlobalPreferencesModal.mjs +10 -11
- package/dist/components/account/ConfirmGlobalPreferencesModal.mjs.map +1 -1
- package/dist/components/account/DeleteAccountModal.mjs +34 -28
- package/dist/components/account/DeleteAccountModal.mjs.map +1 -1
- package/dist/components/account/DisableTwoFactorAuthModal.mjs +7 -5
- package/dist/components/account/DisableTwoFactorAuthModal.mjs.map +1 -1
- package/dist/components/account/IsntPossibleDeleteAccountModal.mjs +8 -9
- package/dist/components/account/IsntPossibleDeleteAccountModal.mjs.map +1 -1
- package/dist/components/account/TwoFactorAuthModal.mjs +22 -23
- package/dist/components/account/TwoFactorAuthModal.mjs.map +1 -1
- package/dist/components/account/hooks/useChangeEmailForm.mjs +5 -3
- package/dist/components/account/hooks/useChangeEmailForm.mjs.map +1 -1
- package/dist/components/account/hooks/useChangePasswordForm.mjs +26 -3
- package/dist/components/account/hooks/useChangePasswordForm.mjs.map +1 -1
- package/dist/components/account/hooks/useChangePhoneForm.mjs +18 -9
- package/dist/components/account/hooks/useChangePhoneForm.mjs.map +1 -1
- package/dist/components/account/hooks/useDisableTwoFactorAuthForm.mjs +26 -3
- package/dist/components/account/hooks/useDisableTwoFactorAuthForm.mjs.map +1 -1
- package/dist/components/account/hooks/useOtpVerification.mjs +19 -3
- package/dist/components/account/hooks/useOtpVerification.mjs.map +1 -1
- package/dist/components/account/hooks/useTwoFactorAuthForm.mjs +27 -4
- package/dist/components/account/hooks/useTwoFactorAuthForm.mjs.map +1 -1
- package/dist/components/account/sections/ChangeEmailModal.mjs +25 -28
- package/dist/components/account/sections/ChangeEmailModal.mjs.map +1 -1
- package/dist/components/account/sections/ChangePasswordSection.mjs +8 -6
- package/dist/components/account/sections/ChangePasswordSection.mjs.map +1 -1
- package/dist/components/account/sections/ChangePhoneModal.mjs +24 -27
- package/dist/components/account/sections/ChangePhoneModal.mjs.map +1 -1
- package/dist/components/account/sections/MyProfileSection.mjs +37 -22
- package/dist/components/account/sections/MyProfileSection.mjs.map +1 -1
- package/dist/components/account/sections/PreferencesSection.mjs +48 -24
- package/dist/components/account/sections/PreferencesSection.mjs.map +1 -1
- package/dist/components/account/sections/SecuritySection.mjs +11 -9
- package/dist/components/account/sections/SecuritySection.mjs.map +1 -1
- package/dist/components/account/sections/TokenSection.mjs +24 -8
- package/dist/components/account/sections/TokenSection.mjs.map +1 -1
- package/dist/i18n/config.mjs +13 -0
- package/dist/i18n/config.mjs.map +1 -0
- package/dist/i18n/country-language.mjs +74 -0
- package/dist/i18n/country-language.mjs.map +1 -0
- package/dist/i18n/messages/en-us.mjs +219 -0
- package/dist/i18n/messages/en-us.mjs.map +1 -0
- package/dist/i18n/messages/es-es.mjs +219 -0
- package/dist/i18n/messages/es-es.mjs.map +1 -0
- package/dist/i18n/messages/index.mjs +16 -0
- package/dist/i18n/messages/index.mjs.map +1 -0
- package/dist/i18n/messages/pt-br.mjs +224 -0
- package/dist/i18n/messages/pt-br.mjs.map +1 -0
- package/dist/i18n/normalize.mjs +12 -0
- package/dist/i18n/normalize.mjs.map +1 -0
- package/dist/i18n/resolve-locale.mjs +42 -0
- package/dist/i18n/resolve-locale.mjs.map +1 -0
- package/dist/i18n.mjs +14 -0
- package/dist/i18n.mjs.map +1 -0
- package/dist/providers/auth.provider.mjs +9 -1
- package/dist/providers/auth.provider.mjs.map +1 -1
- package/dist/server.mjs +2 -0
- package/dist/server.mjs.map +1 -1
- package/dist/utils/intl/cookie-domain.mjs +17 -0
- package/dist/utils/intl/cookie-domain.mjs.map +1 -0
- package/dist/utils/intl/locale-cookie.mjs +13 -0
- package/dist/utils/intl/locale-cookie.mjs.map +1 -0
- package/dist/utils/intl/locales.mjs +3 -2
- package/dist/utils/intl/locales.mjs.map +1 -1
- package/package.json +7 -1
- package/src/components/account/ConfigurationsMyAccountModal.tsx +10 -6
- package/src/components/account/ConfirmDeleteAccountModal.tsx +22 -13
- package/src/components/account/ConfirmGlobalPreferencesModal.tsx +12 -10
- package/src/components/account/DeleteAccountModal.tsx +34 -24
- package/src/components/account/DisableTwoFactorAuthModal.tsx +11 -6
- package/src/components/account/IsntPossibleDeleteAccountModal.tsx +8 -6
- package/src/components/account/TwoFactorAuthModal.tsx +33 -29
- package/src/components/account/hooks/useChangeEmailForm.tsx +5 -3
- package/src/components/account/hooks/useChangePasswordForm.tsx +20 -6
- package/src/components/account/hooks/useChangePhoneForm.tsx +16 -10
- package/src/components/account/hooks/useDisableTwoFactorAuthForm.tsx +20 -6
- package/src/components/account/hooks/useOtpVerification.tsx +16 -4
- package/src/components/account/hooks/useTwoFactorAuthForm.tsx +21 -7
- package/src/components/account/sections/ChangeEmailModal.tsx +35 -21
- package/src/components/account/sections/ChangePasswordSection.tsx +10 -6
- package/src/components/account/sections/ChangePhoneModal.tsx +50 -22
- package/src/components/account/sections/MyProfileSection.tsx +37 -23
- package/src/components/account/sections/PreferencesSection.tsx +52 -25
- package/src/components/account/sections/SecuritySection.tsx +19 -10
- package/src/components/account/sections/TokenSection.tsx +22 -10
- package/src/i18n/config.ts +17 -0
- package/src/i18n/country-language.ts +60 -0
- package/src/i18n/messages/en-us.ts +234 -0
- package/src/i18n/messages/es-es.ts +235 -0
- package/src/i18n/messages/index.ts +24 -0
- package/src/i18n/messages/pt-br.ts +244 -0
- package/src/i18n/normalize.ts +15 -0
- package/src/i18n/resolve-locale.ts +77 -0
- package/src/i18n.ts +10 -0
- package/src/providers/auth.provider.tsx +13 -1
- package/src/server.ts +2 -0
- package/src/utils/intl/cookie-domain.ts +29 -0
- package/src/utils/intl/locale-cookie.ts +18 -0
- package/src/utils/intl/locales.ts +3 -2
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
+
import { useTranslations } from 'next-intl';
|
|
3
4
|
import { IconChevronLeft, IconX, IconMail } from '@tabler/icons-react';
|
|
4
5
|
import { Button } from '../../ui/buttons/Button';
|
|
5
6
|
import { Dialog, DialogContent, DialogHeader, DialogTitle } from '../../ui/overlay/Dialog';
|
|
@@ -20,6 +21,7 @@ interface ChangeEmailModalProps {
|
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
export function ChangeEmailModal({ open, onClose }: ChangeEmailModalProps) {
|
|
24
|
+
const translate = useTranslations();
|
|
23
25
|
const { user } = useAuth();
|
|
24
26
|
const invalidateUser = useInvalidateUser();
|
|
25
27
|
|
|
@@ -53,7 +55,7 @@ export function ChangeEmailModal({ open, onClose }: ChangeEmailModalProps) {
|
|
|
53
55
|
reset: resetOtp,
|
|
54
56
|
} = useOtpVerification({
|
|
55
57
|
onSuccess: handleSuccess,
|
|
56
|
-
successMessage: '
|
|
58
|
+
successMessage: translate('common.account.changeEmail.emailChanged'),
|
|
57
59
|
validateFn: async (token) => {
|
|
58
60
|
const result = await confirmEmailChangeAction(token, emailToVerify);
|
|
59
61
|
return result.success;
|
|
@@ -91,7 +93,7 @@ export function ChangeEmailModal({ open, onClose }: ChangeEmailModalProps) {
|
|
|
91
93
|
<IconChevronLeft size={20} className="text-gray-950" />
|
|
92
94
|
</Button>
|
|
93
95
|
<DialogTitle className="paragraph-medium-semibold text-gray-950 text-center flex-1">
|
|
94
|
-
|
|
96
|
+
{translate('common.account.changeEmail.title')}
|
|
95
97
|
</DialogTitle>
|
|
96
98
|
<Button variant="ghost" className="size-8! p-0" onClick={handleClose}>
|
|
97
99
|
<IconX size={18} className="text-gray-500" />
|
|
@@ -100,11 +102,11 @@ export function ChangeEmailModal({ open, onClose }: ChangeEmailModalProps) {
|
|
|
100
102
|
) : (
|
|
101
103
|
<>
|
|
102
104
|
<DialogHeader className="sr-only">
|
|
103
|
-
<DialogTitle>
|
|
105
|
+
<DialogTitle>{translate('common.account.changeEmail.title')}</DialogTitle>
|
|
104
106
|
</DialogHeader>
|
|
105
107
|
<div className="flex items-center justify-center px-4 py-3 relative border-b border-gray-200 lg:border-b-0">
|
|
106
108
|
<span className="paragraph-medium-semibold text-gray-950 text-center">
|
|
107
|
-
|
|
109
|
+
{translate('common.account.changeEmail.title')}
|
|
108
110
|
</span>
|
|
109
111
|
<Button
|
|
110
112
|
variant="ghost"
|
|
@@ -133,10 +135,16 @@ export function ChangeEmailModal({ open, onClose }: ChangeEmailModalProps) {
|
|
|
133
135
|
</div>
|
|
134
136
|
|
|
135
137
|
<div className="flex flex-col gap-1">
|
|
136
|
-
<h3 className="paragraph-medium-semibold text-gray-950">
|
|
138
|
+
<h3 className="paragraph-medium-semibold text-gray-950">
|
|
139
|
+
{translate('common.account.otp.validationCode')}
|
|
140
|
+
</h3>
|
|
137
141
|
<p className="paragraph-small-regular text-gray-600">
|
|
138
|
-
|
|
139
|
-
|
|
142
|
+
{translate.rich('common.account.changeEmail.sentCodeTo', {
|
|
143
|
+
email: user?.email ?? '',
|
|
144
|
+
b: (chunks) => (
|
|
145
|
+
<span className="font-semibold text-gray-950 break-all">{chunks}</span>
|
|
146
|
+
),
|
|
147
|
+
})}
|
|
140
148
|
</p>
|
|
141
149
|
</div>
|
|
142
150
|
|
|
@@ -153,7 +161,9 @@ export function ChangeEmailModal({ open, onClose }: ChangeEmailModalProps) {
|
|
|
153
161
|
</InputOTPGroup>
|
|
154
162
|
</InputOTP>
|
|
155
163
|
{hasError && (
|
|
156
|
-
<p className="paragraph-small-regular text-red-500">
|
|
164
|
+
<p className="paragraph-small-regular text-red-500">
|
|
165
|
+
{translate('common.account.otp.incorrectCode')}
|
|
166
|
+
</p>
|
|
157
167
|
)}
|
|
158
168
|
</div>
|
|
159
169
|
|
|
@@ -163,14 +173,16 @@ export function ChangeEmailModal({ open, onClose }: ChangeEmailModalProps) {
|
|
|
163
173
|
onClick={handleResend}
|
|
164
174
|
className="paragraph-small-medium text-gray-950 underline cursor-pointer hover:text-gray-700 w-fit"
|
|
165
175
|
>
|
|
166
|
-
|
|
176
|
+
{translate('common.account.otp.resend')}
|
|
167
177
|
</button>
|
|
168
178
|
) : (
|
|
169
179
|
<p className="paragraph-small-regular text-gray-500">
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
180
|
+
{translate.rich('common.account.otp.resendIn', {
|
|
181
|
+
time: formatTimer(timer),
|
|
182
|
+
b: (chunks) => (
|
|
183
|
+
<span className="paragraph-small-semibold text-gray-950">{chunks}</span>
|
|
184
|
+
),
|
|
185
|
+
})}
|
|
174
186
|
</p>
|
|
175
187
|
)}
|
|
176
188
|
</div>
|
|
@@ -179,10 +191,12 @@ export function ChangeEmailModal({ open, onClose }: ChangeEmailModalProps) {
|
|
|
179
191
|
|
|
180
192
|
<div className="flex items-center justify-between px-4 lg:px-5 py-4 lg:py-5 mt-auto lg:mt-0">
|
|
181
193
|
<Button variant="secondary" className="h-10!" type="button" onClick={handleClose}>
|
|
182
|
-
|
|
194
|
+
{translate('common.actions.cancel')}
|
|
183
195
|
</Button>
|
|
184
196
|
<Button className="h-10!" type="submit" disabled={!isValidLength || isLoading}>
|
|
185
|
-
{isLoading
|
|
197
|
+
{isLoading
|
|
198
|
+
? translate('common.account.otp.validating')
|
|
199
|
+
: translate('common.account.changeEmail.confirm')}
|
|
186
200
|
</Button>
|
|
187
201
|
</div>
|
|
188
202
|
</form>
|
|
@@ -191,16 +205,16 @@ export function ChangeEmailModal({ open, onClose }: ChangeEmailModalProps) {
|
|
|
191
205
|
<div className="flex flex-col gap-5 lg:gap-6 px-4 lg:px-5 py-5 lg:py-6 flex-1 lg:flex-none">
|
|
192
206
|
<div className="flex flex-col gap-1">
|
|
193
207
|
<span className="paragraph-medium-semibold text-gray-950">
|
|
194
|
-
|
|
208
|
+
{translate('common.account.changeEmail.updateTitle')}
|
|
195
209
|
</span>
|
|
196
210
|
<span className="paragraph-small-regular text-gray-600">
|
|
197
|
-
|
|
211
|
+
{translate('common.account.changeEmail.updateDescription')}
|
|
198
212
|
</span>
|
|
199
213
|
</div>
|
|
200
214
|
|
|
201
215
|
<FormField
|
|
202
|
-
label=
|
|
203
|
-
placeholder=
|
|
216
|
+
label={translate('common.account.changeEmail.newEmail')}
|
|
217
|
+
placeholder={translate('common.account.changeEmail.newEmailPlaceholder')}
|
|
204
218
|
type="email"
|
|
205
219
|
{...register('email')}
|
|
206
220
|
error={!!errors.email}
|
|
@@ -211,10 +225,10 @@ export function ChangeEmailModal({ open, onClose }: ChangeEmailModalProps) {
|
|
|
211
225
|
|
|
212
226
|
<div className="flex items-center justify-between p-4 lg:p-5 border-t border-gray-200 mt-auto lg:mt-0">
|
|
213
227
|
<Button variant="secondary" className="h-10!" type="button" onClick={handleClose}>
|
|
214
|
-
|
|
228
|
+
{translate('common.actions.cancel')}
|
|
215
229
|
</Button>
|
|
216
230
|
<Button className="h-10!" type="submit" disabled={isSubmitting}>
|
|
217
|
-
{isSubmitting ? '
|
|
231
|
+
{isSubmitting ? translate('common.actions.sending') : translate('common.actions.continue')}
|
|
218
232
|
</Button>
|
|
219
233
|
</div>
|
|
220
234
|
</form>
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import { IconLock, IconX } from '@tabler/icons-react';
|
|
4
|
+
import { useTranslations } from 'next-intl';
|
|
4
5
|
import { Button } from '../../ui/buttons/Button';
|
|
5
6
|
import { FormField } from '../../ui/form/FormField';
|
|
6
7
|
import useChangePasswordForm from '../hooks/useChangePasswordForm';
|
|
@@ -11,6 +12,7 @@ interface ChangePasswordSectionProps {
|
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
export function ChangePasswordSection({ onBack }: ChangePasswordSectionProps) {
|
|
15
|
+
const translate = useTranslations();
|
|
14
16
|
const { register, handleSubmit, errors } = useChangePasswordForm({
|
|
15
17
|
onSuccess: onBack,
|
|
16
18
|
});
|
|
@@ -23,7 +25,9 @@ export function ChangePasswordSection({ onBack }: ChangePasswordSectionProps) {
|
|
|
23
25
|
className="flex-1 overflow-y-auto px-4 pb-5 lg:p-5 flex flex-col h-full lg:h-full gap-5 lg:gap-6"
|
|
24
26
|
>
|
|
25
27
|
<div className="flex items-center justify-between">
|
|
26
|
-
<span className="paragraph-medium-semibold text-gray-950">
|
|
28
|
+
<span className="paragraph-medium-semibold text-gray-950">
|
|
29
|
+
{translate('common.account.changePassword.title')}
|
|
30
|
+
</span>
|
|
27
31
|
<Button type="button" variant="ghost" className="size-8! p-0" onClick={onBack}>
|
|
28
32
|
<IconX size={18} />
|
|
29
33
|
</Button>
|
|
@@ -31,9 +35,9 @@ export function ChangePasswordSection({ onBack }: ChangePasswordSectionProps) {
|
|
|
31
35
|
|
|
32
36
|
<div className="flex flex-col gap-4">
|
|
33
37
|
<FormField
|
|
34
|
-
label=
|
|
38
|
+
label={translate('common.account.changePassword.currentPassword')}
|
|
35
39
|
type="password"
|
|
36
|
-
placeholder=
|
|
40
|
+
placeholder={translate('common.account.changePassword.currentPasswordPlaceholder')}
|
|
37
41
|
leftIcon={IconLock}
|
|
38
42
|
error={!!errors.currentPassword}
|
|
39
43
|
errorMessage={errors.currentPassword?.message}
|
|
@@ -43,9 +47,9 @@ export function ChangePasswordSection({ onBack }: ChangePasswordSectionProps) {
|
|
|
43
47
|
{...register('currentPassword')}
|
|
44
48
|
/>
|
|
45
49
|
<FormField
|
|
46
|
-
label=
|
|
50
|
+
label={translate('common.account.changePassword.newPassword')}
|
|
47
51
|
type="password"
|
|
48
|
-
placeholder=
|
|
52
|
+
placeholder={translate('common.account.changePassword.newPasswordPlaceholder')}
|
|
49
53
|
leftIcon={IconLock}
|
|
50
54
|
error={!!errors.newPassword}
|
|
51
55
|
errorMessage={errors.newPassword?.message}
|
|
@@ -57,7 +61,7 @@ export function ChangePasswordSection({ onBack }: ChangePasswordSectionProps) {
|
|
|
57
61
|
</div>
|
|
58
62
|
|
|
59
63
|
<Button type="submit" className="w-fit h-10!">
|
|
60
|
-
|
|
64
|
+
{translate('common.account.changePassword.submit')}
|
|
61
65
|
</Button>
|
|
62
66
|
</form>
|
|
63
67
|
);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
+
import { useTranslations } from 'next-intl';
|
|
3
4
|
import { IconChevronLeft, IconX, IconMessage } from '@tabler/icons-react';
|
|
4
5
|
import { Button } from '../../ui/buttons/Button';
|
|
5
6
|
import { Dialog, DialogContent, DialogHeader, DialogTitle } from '../../ui/overlay/Dialog';
|
|
@@ -20,6 +21,7 @@ interface ChangePhoneModalProps {
|
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
export function ChangePhoneModal({ open, onClose }: ChangePhoneModalProps) {
|
|
24
|
+
const translate = useTranslations();
|
|
23
25
|
const { user } = useAuth();
|
|
24
26
|
const invalidateUser = useInvalidateUser();
|
|
25
27
|
|
|
@@ -70,7 +72,7 @@ export function ChangePhoneModal({ open, onClose }: ChangePhoneModalProps) {
|
|
|
70
72
|
reset: resetOtp,
|
|
71
73
|
} = useOtpVerification({
|
|
72
74
|
onSuccess: handleSuccess,
|
|
73
|
-
successMessage: '
|
|
75
|
+
successMessage: translate('common.account.changePhone.phoneChanged'),
|
|
74
76
|
validateFn: async (token) => {
|
|
75
77
|
const result = await confirmPhoneChangeAction(token, submittedPhone.local, submittedPhone.ddi);
|
|
76
78
|
return result.success;
|
|
@@ -108,7 +110,7 @@ export function ChangePhoneModal({ open, onClose }: ChangePhoneModalProps) {
|
|
|
108
110
|
<IconChevronLeft size={20} className="text-gray-950" />
|
|
109
111
|
</Button>
|
|
110
112
|
<DialogTitle className="paragraph-medium-semibold text-gray-950 text-center flex-1">
|
|
111
|
-
|
|
113
|
+
{translate('common.account.changePhone.titleEdit')}
|
|
112
114
|
</DialogTitle>
|
|
113
115
|
<Button variant="ghost" className="size-8! p-0" onClick={handleClose}>
|
|
114
116
|
<IconX size={18} className="text-gray-500" />
|
|
@@ -117,11 +119,17 @@ export function ChangePhoneModal({ open, onClose }: ChangePhoneModalProps) {
|
|
|
117
119
|
) : (
|
|
118
120
|
<>
|
|
119
121
|
<DialogHeader className="sr-only">
|
|
120
|
-
<DialogTitle>
|
|
122
|
+
<DialogTitle>
|
|
123
|
+
{hasExistingPhone
|
|
124
|
+
? translate('common.account.changePhone.titleEdit')
|
|
125
|
+
: translate('common.account.changePhone.titleAdd')}
|
|
126
|
+
</DialogTitle>
|
|
121
127
|
</DialogHeader>
|
|
122
128
|
<div className="flex items-center justify-center px-4 py-3 relative border-b border-gray-200 lg:border-b-0">
|
|
123
129
|
<span className="paragraph-medium-semibold text-gray-950 text-center">
|
|
124
|
-
{hasExistingPhone
|
|
130
|
+
{hasExistingPhone
|
|
131
|
+
? translate('common.account.changePhone.titleEdit')
|
|
132
|
+
: translate('common.account.changePhone.titleAdd')}
|
|
125
133
|
</span>
|
|
126
134
|
<Button
|
|
127
135
|
variant="ghost"
|
|
@@ -150,10 +158,14 @@ export function ChangePhoneModal({ open, onClose }: ChangePhoneModalProps) {
|
|
|
150
158
|
</div>
|
|
151
159
|
|
|
152
160
|
<div className="flex flex-col gap-1">
|
|
153
|
-
<h3 className="paragraph-medium-semibold text-gray-950">
|
|
161
|
+
<h3 className="paragraph-medium-semibold text-gray-950">
|
|
162
|
+
{translate('common.account.otp.validationCode')}
|
|
163
|
+
</h3>
|
|
154
164
|
<p className="paragraph-small-regular text-gray-600">
|
|
155
|
-
|
|
156
|
-
|
|
165
|
+
{translate.rich('common.account.changePhone.sentCodeTo', {
|
|
166
|
+
phone: currentPhoneDisplay,
|
|
167
|
+
b: (chunks) => <span className="font-semibold text-gray-950">{chunks}</span>,
|
|
168
|
+
})}
|
|
157
169
|
</p>
|
|
158
170
|
</div>
|
|
159
171
|
|
|
@@ -170,7 +182,9 @@ export function ChangePhoneModal({ open, onClose }: ChangePhoneModalProps) {
|
|
|
170
182
|
</InputOTPGroup>
|
|
171
183
|
</InputOTP>
|
|
172
184
|
{hasError && (
|
|
173
|
-
<p className="paragraph-small-regular text-red-500">
|
|
185
|
+
<p className="paragraph-small-regular text-red-500">
|
|
186
|
+
{translate('common.account.otp.incorrectCode')}
|
|
187
|
+
</p>
|
|
174
188
|
)}
|
|
175
189
|
</div>
|
|
176
190
|
|
|
@@ -180,14 +194,16 @@ export function ChangePhoneModal({ open, onClose }: ChangePhoneModalProps) {
|
|
|
180
194
|
onClick={handleResend}
|
|
181
195
|
className="paragraph-small-medium text-gray-950 underline cursor-pointer hover:text-gray-700 w-fit"
|
|
182
196
|
>
|
|
183
|
-
|
|
197
|
+
{translate('common.account.otp.resend')}
|
|
184
198
|
</button>
|
|
185
199
|
) : (
|
|
186
200
|
<p className="paragraph-small-regular text-gray-500">
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
201
|
+
{translate.rich('common.account.otp.resendIn', {
|
|
202
|
+
time: formatTimer(timer),
|
|
203
|
+
b: (chunks) => (
|
|
204
|
+
<span className="paragraph-small-semibold text-gray-950">{chunks}</span>
|
|
205
|
+
),
|
|
206
|
+
})}
|
|
191
207
|
</p>
|
|
192
208
|
)}
|
|
193
209
|
</div>
|
|
@@ -196,10 +212,12 @@ export function ChangePhoneModal({ open, onClose }: ChangePhoneModalProps) {
|
|
|
196
212
|
|
|
197
213
|
<div className="flex items-center justify-between px-4 lg:px-5 py-4 lg:py-5 mt-auto lg:mt-0">
|
|
198
214
|
<Button variant="secondary" className="h-10!" type="button" onClick={handleClose}>
|
|
199
|
-
|
|
215
|
+
{translate('common.actions.cancel')}
|
|
200
216
|
</Button>
|
|
201
217
|
<Button className="h-10!" type="submit" disabled={!isValidLength || isLoading}>
|
|
202
|
-
{isLoading
|
|
218
|
+
{isLoading
|
|
219
|
+
? translate('common.account.otp.validating')
|
|
220
|
+
: translate('common.account.changePhone.confirm')}
|
|
203
221
|
</Button>
|
|
204
222
|
</div>
|
|
205
223
|
</form>
|
|
@@ -208,17 +226,23 @@ export function ChangePhoneModal({ open, onClose }: ChangePhoneModalProps) {
|
|
|
208
226
|
<div className="flex flex-col gap-5 lg:gap-6 px-4 lg:px-5 py-5 lg:py-6 flex-1 lg:flex-none">
|
|
209
227
|
<div className="flex flex-col gap-1">
|
|
210
228
|
<span className="paragraph-medium-semibold text-gray-950">
|
|
211
|
-
{hasExistingPhone
|
|
229
|
+
{hasExistingPhone
|
|
230
|
+
? translate('common.account.changePhone.updateTitle')
|
|
231
|
+
: translate('common.account.changePhone.addTitle')}
|
|
212
232
|
</span>
|
|
213
233
|
<span className="paragraph-small-regular text-gray-600">
|
|
214
234
|
{hasExistingPhone
|
|
215
|
-
? '
|
|
216
|
-
: '
|
|
235
|
+
? translate('common.account.changePhone.updateDescription')
|
|
236
|
+
: translate('common.account.changePhone.addDescription')}
|
|
217
237
|
</span>
|
|
218
238
|
</div>
|
|
219
239
|
|
|
220
240
|
<PhoneInput
|
|
221
|
-
label={
|
|
241
|
+
label={
|
|
242
|
+
hasExistingPhone
|
|
243
|
+
? translate('common.account.changePhone.newNumber')
|
|
244
|
+
: translate('common.account.changePhone.numberLabel')
|
|
245
|
+
}
|
|
222
246
|
placeholder="(00) 0 0000-0000"
|
|
223
247
|
value={phoneValue}
|
|
224
248
|
onChange={handlePhoneChange}
|
|
@@ -229,12 +253,16 @@ export function ChangePhoneModal({ open, onClose }: ChangePhoneModalProps) {
|
|
|
229
253
|
|
|
230
254
|
<div className="flex items-center justify-between p-4 lg:p-5 border-t border-gray-200 mt-auto lg:mt-0">
|
|
231
255
|
<Button variant="secondary" className="h-10!" type="button" onClick={handleClose}>
|
|
232
|
-
|
|
256
|
+
{translate('common.actions.cancel')}
|
|
233
257
|
</Button>
|
|
234
258
|
<Button className="h-10!" type="submit" disabled={isSubmitting}>
|
|
235
259
|
{isSubmitting
|
|
236
|
-
?
|
|
237
|
-
|
|
260
|
+
? hasExistingPhone
|
|
261
|
+
? translate('common.actions.sending')
|
|
262
|
+
: translate('common.actions.saving')
|
|
263
|
+
: hasExistingPhone
|
|
264
|
+
? translate('common.actions.continue')
|
|
265
|
+
: translate('common.actions.save')}
|
|
238
266
|
</Button>
|
|
239
267
|
</div>
|
|
240
268
|
</form>
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { useState, useRef } from 'react';
|
|
4
4
|
import Image from 'next/image';
|
|
5
|
+
import { useTranslations } from 'next-intl';
|
|
5
6
|
import { useForm } from 'react-hook-form';
|
|
6
7
|
import { zodResolver } from '@hookform/resolvers/zod';
|
|
7
8
|
import { toast } from 'sonner';
|
|
@@ -26,6 +27,13 @@ interface MyProfileSectionProps {
|
|
|
26
27
|
}
|
|
27
28
|
|
|
28
29
|
export function MyProfileSection({ onClose, storageUrl }: MyProfileSectionProps) {
|
|
30
|
+
const translate = useTranslations();
|
|
31
|
+
const genderOptions = GENDER_OPTIONS.map((option) => ({
|
|
32
|
+
...option,
|
|
33
|
+
label: translate(
|
|
34
|
+
`common.account.profile.genderOptions.${option.value === 'masculino' ? 'male' : 'female'}`,
|
|
35
|
+
),
|
|
36
|
+
}));
|
|
29
37
|
const { user } = useAuth();
|
|
30
38
|
const updateAccountUser = useUpdateAccountUser();
|
|
31
39
|
const fileInputRef = useRef<HTMLInputElement>(null);
|
|
@@ -86,16 +94,20 @@ export function MyProfileSection({ onClose, storageUrl }: MyProfileSectionProps)
|
|
|
86
94
|
form.reset(data);
|
|
87
95
|
setSelectedPhoto(null);
|
|
88
96
|
setPhotoRemoved(false);
|
|
89
|
-
toast.custom((
|
|
90
|
-
<Toast
|
|
97
|
+
toast.custom((toastId) => (
|
|
98
|
+
<Toast
|
|
99
|
+
variant="success"
|
|
100
|
+
message={translate('common.account.profile.savedSuccess')}
|
|
101
|
+
toastId={toastId}
|
|
102
|
+
/>
|
|
91
103
|
));
|
|
92
104
|
onClose();
|
|
93
105
|
} catch (error) {
|
|
94
|
-
toast.custom((
|
|
106
|
+
toast.custom((toastId) => (
|
|
95
107
|
<Toast
|
|
96
108
|
variant="error"
|
|
97
|
-
message={error instanceof Error ? error.message : '
|
|
98
|
-
toastId={
|
|
109
|
+
message={error instanceof Error ? error.message : translate('common.account.profile.saveError')}
|
|
110
|
+
toastId={toastId}
|
|
99
111
|
/>
|
|
100
112
|
));
|
|
101
113
|
}
|
|
@@ -113,14 +125,14 @@ export function MyProfileSection({ onClose, storageUrl }: MyProfileSectionProps)
|
|
|
113
125
|
/>
|
|
114
126
|
<div className="absolute inset-0 overflow-y-auto overscroll-contain px-4 pb-20 lg:p-5 lg:static lg:flex-1 lg:min-h-0 lg:overscroll-auto flex flex-col gap-5 lg:gap-6">
|
|
115
127
|
<span className="paragraph-medium-semibold text-gray-950 hidden lg:block">
|
|
116
|
-
|
|
128
|
+
{translate('common.account.profile.title')}
|
|
117
129
|
</span>
|
|
118
130
|
<div className="flex flex-col gap-5">
|
|
119
131
|
<div className="flex items-center gap-4">
|
|
120
132
|
{avatarPreview ? (
|
|
121
133
|
<Image
|
|
122
134
|
src={avatarPreview}
|
|
123
|
-
alt=
|
|
135
|
+
alt={translate('common.account.profile.avatarAlt')}
|
|
124
136
|
width={48}
|
|
125
137
|
height={48}
|
|
126
138
|
className="size-12 rounded-full object-cover cursor-pointer"
|
|
@@ -142,7 +154,7 @@ export function MyProfileSection({ onClose, storageUrl }: MyProfileSectionProps)
|
|
|
142
154
|
type="button"
|
|
143
155
|
onClick={() => fileInputRef.current?.click()}
|
|
144
156
|
>
|
|
145
|
-
|
|
157
|
+
{translate('common.account.profile.changePhoto')}
|
|
146
158
|
</Button>
|
|
147
159
|
<Button
|
|
148
160
|
type="button"
|
|
@@ -160,7 +172,7 @@ export function MyProfileSection({ onClose, storageUrl }: MyProfileSectionProps)
|
|
|
160
172
|
type="button"
|
|
161
173
|
onClick={() => fileInputRef.current?.click()}
|
|
162
174
|
>
|
|
163
|
-
|
|
175
|
+
{translate('common.account.profile.changePhoto')}
|
|
164
176
|
</Button>
|
|
165
177
|
)}
|
|
166
178
|
</div>
|
|
@@ -169,31 +181,31 @@ export function MyProfileSection({ onClose, storageUrl }: MyProfileSectionProps)
|
|
|
169
181
|
<div className="flex flex-col gap-4">
|
|
170
182
|
<div className="flex gap-4">
|
|
171
183
|
<FormField
|
|
172
|
-
label=
|
|
173
|
-
placeholder=
|
|
184
|
+
label={translate('common.account.profile.name')}
|
|
185
|
+
placeholder={translate('common.account.profile.namePlaceholder')}
|
|
174
186
|
error={!!errors.name}
|
|
175
187
|
errorMessage={errors.name?.message}
|
|
176
188
|
{...register('name')}
|
|
177
189
|
/>
|
|
178
190
|
<FormField
|
|
179
|
-
label=
|
|
180
|
-
placeholder=
|
|
191
|
+
label={translate('common.account.profile.lastName')}
|
|
192
|
+
placeholder={translate('common.account.profile.lastNamePlaceholder')}
|
|
181
193
|
error={!!errors.last_name}
|
|
182
194
|
errorMessage={errors.last_name?.message}
|
|
183
195
|
{...register('last_name')}
|
|
184
196
|
/>
|
|
185
197
|
</div>
|
|
186
198
|
<SelectField
|
|
187
|
-
label=
|
|
188
|
-
placeholder=
|
|
189
|
-
options={
|
|
199
|
+
label={translate('common.account.profile.gender')}
|
|
200
|
+
placeholder={translate('common.account.profile.genderPlaceholder')}
|
|
201
|
+
options={genderOptions}
|
|
190
202
|
value={watch('gender')}
|
|
191
203
|
className="h-10!"
|
|
192
204
|
onChange={(value) => setValue('gender', value as string)}
|
|
193
205
|
/>
|
|
194
206
|
<div className="relative">
|
|
195
207
|
<PhoneInput
|
|
196
|
-
label=
|
|
208
|
+
label={translate('common.account.profile.phone')}
|
|
197
209
|
value={user?.phone ?? ''}
|
|
198
210
|
disabled
|
|
199
211
|
classnameContainer="bg-gray-50 border-0!"
|
|
@@ -203,7 +215,7 @@ export function MyProfileSection({ onClose, storageUrl }: MyProfileSectionProps)
|
|
|
203
215
|
className="absolute right-3 top-5.5 h-10 flex items-center paragraph-xsmall-semibold text-gray-950 underline cursor-pointer"
|
|
204
216
|
onClick={() => setChangePhoneOpen(true)}
|
|
205
217
|
>
|
|
206
|
-
|
|
218
|
+
{translate('common.account.profile.change')}
|
|
207
219
|
</button>
|
|
208
220
|
</div>
|
|
209
221
|
</div>
|
|
@@ -211,11 +223,13 @@ export function MyProfileSection({ onClose, storageUrl }: MyProfileSectionProps)
|
|
|
211
223
|
<Separator />
|
|
212
224
|
|
|
213
225
|
<div className="flex flex-col gap-4">
|
|
214
|
-
<span className="paragraph-medium-semibold text-gray-600">
|
|
226
|
+
<span className="paragraph-medium-semibold text-gray-600">
|
|
227
|
+
{translate('common.account.profile.accessData')}
|
|
228
|
+
</span>
|
|
215
229
|
<div className="relative">
|
|
216
230
|
<div className='cursor-not-allowed'>
|
|
217
231
|
<FormField
|
|
218
|
-
label=
|
|
232
|
+
label={translate('common.account.profile.email')}
|
|
219
233
|
value={user?.email ?? ''}
|
|
220
234
|
disabled
|
|
221
235
|
classnameContainer="bg-gray-50 border-0!"
|
|
@@ -226,7 +240,7 @@ export function MyProfileSection({ onClose, storageUrl }: MyProfileSectionProps)
|
|
|
226
240
|
className="absolute right-3 top-5.5 h-10 flex items-center paragraph-xsmall-semibold text-gray-950 underline cursor-pointer"
|
|
227
241
|
onClick={() => setChangeEmailOpen(true)}
|
|
228
242
|
>
|
|
229
|
-
|
|
243
|
+
{translate('common.account.profile.change')}
|
|
230
244
|
</button>
|
|
231
245
|
</div>
|
|
232
246
|
</div>
|
|
@@ -247,10 +261,10 @@ export function MyProfileSection({ onClose, storageUrl }: MyProfileSectionProps)
|
|
|
247
261
|
onClose();
|
|
248
262
|
}}
|
|
249
263
|
>
|
|
250
|
-
|
|
264
|
+
{translate('common.actions.cancel')}
|
|
251
265
|
</Button>
|
|
252
266
|
<Button className="h-10! cursor-pointer" type="submit" disabled={isSubmitting}>
|
|
253
|
-
{isSubmitting ? '
|
|
267
|
+
{isSubmitting ? translate('common.actions.saving') : translate('common.actions.saveChanges')}
|
|
254
268
|
</Button>
|
|
255
269
|
</div>
|
|
256
270
|
</form>
|