@greatapps/common 1.1.24 → 1.1.25
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 +121 -0
- package/dist/components/account/ConfigurationsMyAccountModal.mjs.map +1 -0
- package/dist/components/account/ConfirmGlobalPreferencesModal.mjs +45 -0
- package/dist/components/account/ConfirmGlobalPreferencesModal.mjs.map +1 -0
- package/dist/components/account/DisableTwoFactorAuthModal.mjs +67 -0
- package/dist/components/account/DisableTwoFactorAuthModal.mjs.map +1 -0
- package/dist/components/account/TwoFactorAuthModal.mjs +190 -0
- package/dist/components/account/TwoFactorAuthModal.mjs.map +1 -0
- package/dist/components/account/constants.mjs +32 -0
- package/dist/components/account/constants.mjs.map +1 -0
- package/dist/components/account/hooks/useChangeEmailForm.mjs +53 -0
- package/dist/components/account/hooks/useChangeEmailForm.mjs.map +1 -0
- package/dist/components/account/hooks/useChangePasswordForm.mjs +47 -0
- package/dist/components/account/hooks/useChangePasswordForm.mjs.map +1 -0
- package/dist/components/account/hooks/useChangePhoneForm.mjs +64 -0
- package/dist/components/account/hooks/useChangePhoneForm.mjs.map +1 -0
- package/dist/components/account/hooks/useConfigurationsModal.mjs +33 -0
- package/dist/components/account/hooks/useConfigurationsModal.mjs.map +1 -0
- package/dist/components/account/hooks/useDisableTwoFactorAuthForm.mjs +54 -0
- package/dist/components/account/hooks/useDisableTwoFactorAuthForm.mjs.map +1 -0
- package/dist/components/account/hooks/useOtpVerification.mjs +94 -0
- package/dist/components/account/hooks/useOtpVerification.mjs.map +1 -0
- package/dist/components/account/hooks/useTwoFactorAuthForm.mjs +88 -0
- package/dist/components/account/hooks/useTwoFactorAuthForm.mjs.map +1 -0
- package/dist/components/account/sections/ChangeEmailModal.mjs +180 -0
- package/dist/components/account/sections/ChangeEmailModal.mjs.map +1 -0
- package/dist/components/account/sections/ChangePasswordSection.mjs +64 -0
- package/dist/components/account/sections/ChangePasswordSection.mjs.map +1 -0
- package/dist/components/account/sections/ChangePhoneModal.mjs +182 -0
- package/dist/components/account/sections/ChangePhoneModal.mjs.map +1 -0
- package/dist/components/account/sections/MyProfileSection.mjs +312 -0
- package/dist/components/account/sections/MyProfileSection.mjs.map +1 -0
- package/dist/components/account/sections/PreferencesSection.mjs +246 -0
- package/dist/components/account/sections/PreferencesSection.mjs.map +1 -0
- package/dist/components/account/sections/SecuritySection.mjs +147 -0
- package/dist/components/account/sections/SecuritySection.mjs.map +1 -0
- package/dist/components/ui/form/ComboboxField.mjs +130 -0
- package/dist/components/ui/form/ComboboxField.mjs.map +1 -0
- package/dist/components/ui/form/FormField.mjs +103 -0
- package/dist/components/ui/form/FormField.mjs.map +1 -0
- package/dist/components/ui/form/PhoneInput.mjs +78 -0
- package/dist/components/ui/form/PhoneInput.mjs.map +1 -0
- package/dist/components/ui/form/SelectField.mjs +80 -0
- package/dist/components/ui/form/SelectField.mjs.map +1 -0
- package/dist/components/ui/form/SwitchOptionFieldWithIcon.mjs +40 -0
- package/dist/components/ui/form/SwitchOptionFieldWithIcon.mjs.map +1 -0
- package/dist/components/ui/form/TextAreaField.mjs +56 -0
- package/dist/components/ui/form/TextAreaField.mjs.map +1 -0
- package/dist/enums/AccountSectionType.mjs +11 -0
- package/dist/enums/AccountSectionType.mjs.map +1 -0
- package/dist/hooks/useCountdownTimer.mjs +29 -0
- package/dist/hooks/useCountdownTimer.mjs.map +1 -0
- package/dist/hooks/useIsMobile.mjs +18 -0
- package/dist/hooks/useIsMobile.mjs.map +1 -0
- package/dist/hooks/usePasswordVisibility.mjs +13 -0
- package/dist/hooks/usePasswordVisibility.mjs.map +1 -0
- package/dist/index.mjs +80 -0
- package/dist/index.mjs.map +1 -1
- package/dist/modules/accounts/actions/account-management.action.mjs +163 -0
- package/dist/modules/accounts/actions/account-management.action.mjs.map +1 -0
- package/dist/modules/accounts/hooks/useAccountManagement.mjs +64 -0
- package/dist/modules/accounts/hooks/useAccountManagement.mjs.map +1 -0
- package/dist/modules/accounts/services/account.service.mjs +162 -25
- package/dist/modules/accounts/services/account.service.mjs.map +1 -1
- package/dist/modules/accounts/services/two-factor.service.mjs +77 -0
- package/dist/modules/accounts/services/two-factor.service.mjs.map +1 -0
- package/dist/server.mjs +36 -0
- package/dist/server.mjs.map +1 -1
- package/dist/utils/browser/clipboard.mjs +36 -0
- package/dist/utils/browser/clipboard.mjs.map +1 -0
- package/dist/utils/file/index.mjs +9 -0
- package/dist/utils/file/index.mjs.map +1 -0
- package/dist/utils/format/masks.mjs +56 -0
- package/dist/utils/format/masks.mjs.map +1 -0
- package/dist/utils/intl/locales.mjs +12 -0
- package/dist/utils/intl/locales.mjs.map +1 -0
- package/dist/utils/intl/timezones.mjs +41 -0
- package/dist/utils/intl/timezones.mjs.map +1 -0
- package/dist/utils/validators/account.mjs +26 -0
- package/dist/utils/validators/account.mjs.map +1 -0
- package/dist/utils/validators/common.mjs +47 -0
- package/dist/utils/validators/common.mjs.map +1 -0
- package/package.json +5 -1
- package/src/components/account/ConfigurationsMyAccountModal.tsx +147 -0
- package/src/components/account/ConfirmGlobalPreferencesModal.tsx +66 -0
- package/src/components/account/DisableTwoFactorAuthModal.tsx +86 -0
- package/src/components/account/TwoFactorAuthModal.tsx +221 -0
- package/src/components/account/constants.ts +29 -0
- package/src/components/account/hooks/useChangeEmailForm.tsx +56 -0
- package/src/components/account/hooks/useChangePasswordForm.tsx +59 -0
- package/src/components/account/hooks/useChangePhoneForm.tsx +69 -0
- package/src/components/account/hooks/useConfigurationsModal.ts +40 -0
- package/src/components/account/hooks/useDisableTwoFactorAuthForm.tsx +69 -0
- package/src/components/account/hooks/useOtpVerification.tsx +116 -0
- package/src/components/account/hooks/useTwoFactorAuthForm.tsx +114 -0
- package/src/components/account/sections/ChangeEmailModal.tsx +224 -0
- package/src/components/account/sections/ChangePasswordSection.tsx +64 -0
- package/src/components/account/sections/ChangePhoneModal.tsx +229 -0
- package/src/components/account/sections/MyProfileSection.tsx +337 -0
- package/src/components/account/sections/PreferencesSection.tsx +277 -0
- package/src/components/account/sections/SecuritySection.tsx +160 -0
- package/src/components/ui/form/ComboboxField.tsx +154 -0
- package/src/components/ui/form/FormField.tsx +130 -0
- package/src/components/ui/form/PhoneInput.tsx +98 -0
- package/src/components/ui/form/SelectField.tsx +118 -0
- package/src/components/ui/form/SwitchOptionFieldWithIcon.tsx +47 -0
- package/src/components/ui/form/TextAreaField.tsx +70 -0
- package/src/enums/AccountSectionType.ts +6 -0
- package/src/hooks/useCountdownTimer.ts +41 -0
- package/src/hooks/useIsMobile.ts +19 -0
- package/src/hooks/usePasswordVisibility.ts +13 -0
- package/src/index.ts +70 -0
- package/src/modules/accounts/actions/account-management.action.ts +197 -0
- package/src/modules/accounts/hooks/useAccountManagement.ts +79 -0
- package/src/modules/accounts/services/account.service.ts +229 -50
- package/src/modules/accounts/services/two-factor.service.ts +98 -0
- package/src/modules/accounts/types.ts +157 -0
- package/src/server.ts +21 -0
- package/src/utils/browser/clipboard.ts +34 -0
- package/src/utils/file/index.ts +5 -0
- package/src/utils/format/masks.ts +52 -0
- package/src/utils/intl/locales.ts +15 -0
- package/src/utils/intl/timezones.ts +53 -0
- package/src/utils/validators/account.ts +36 -0
- package/src/utils/validators/common.ts +43 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export type TimezoneOption = {
|
|
2
|
+
value: string;
|
|
3
|
+
label: string;
|
|
4
|
+
displayValue: string;
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
function parseOffsetMinutes(offsetStr: string): number {
|
|
8
|
+
const match = offsetStr.match(/GMT([+-])(\d+)(?::(\d+))?/);
|
|
9
|
+
if (!match) return 0;
|
|
10
|
+
const sign = match[1] === '+' ? 1 : -1;
|
|
11
|
+
return sign * (parseInt(match[2], 10) * 60 + parseInt(match[3] ?? '0', 10));
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const FALLBACK_TIMEZONES: TimezoneOption[] = [
|
|
15
|
+
{ value: 'America/Noronha', label: '(GMT-2) America/Noronha', displayValue: '(GMT-2) Noronha' },
|
|
16
|
+
{ value: 'America/Sao_Paulo', label: '(GMT-3) America/Sao Paulo', displayValue: '(GMT-3) Sao Paulo' },
|
|
17
|
+
{ value: 'America/Manaus', label: '(GMT-4) America/Manaus', displayValue: '(GMT-4) Manaus' },
|
|
18
|
+
{ value: 'America/Rio_Branco', label: '(GMT-5) America/Rio Branco', displayValue: '(GMT-5) Rio Branco' },
|
|
19
|
+
{ value: 'America/New_York', label: '(GMT-5) America/New York', displayValue: '(GMT-5) New York' },
|
|
20
|
+
{ value: 'America/Los_Angeles', label: '(GMT-8) America/Los Angeles', displayValue: '(GMT-8) Los Angeles' },
|
|
21
|
+
{ value: 'Europe/London', label: '(GMT+0) Europe/London', displayValue: '(GMT+0) London' },
|
|
22
|
+
{ value: 'Europe/Paris', label: '(GMT+1) Europe/Paris', displayValue: '(GMT+1) Paris' },
|
|
23
|
+
{ value: 'Asia/Tokyo', label: '(GMT+9) Asia/Tokyo', displayValue: '(GMT+9) Tokyo' },
|
|
24
|
+
];
|
|
25
|
+
|
|
26
|
+
export function buildTimezoneOptions(): TimezoneOption[] {
|
|
27
|
+
try {
|
|
28
|
+
const zones = Intl.supportedValuesOf('timeZone');
|
|
29
|
+
const now = new Date();
|
|
30
|
+
|
|
31
|
+
const items = zones.map((tz) => {
|
|
32
|
+
const offsetStr =
|
|
33
|
+
new Intl.DateTimeFormat('en', { timeZone: tz, timeZoneName: 'shortOffset' })
|
|
34
|
+
.formatToParts(now)
|
|
35
|
+
.find((p) => p.type === 'timeZoneName')?.value ?? 'GMT';
|
|
36
|
+
|
|
37
|
+
const city = tz.split('/').slice(1).join('/').replace(/_/g, ' ') || tz;
|
|
38
|
+
|
|
39
|
+
return {
|
|
40
|
+
value: tz,
|
|
41
|
+
label: `(${offsetStr}) ${tz.replace(/_/g, ' ')}`,
|
|
42
|
+
displayValue: `(${offsetStr}) ${city}`,
|
|
43
|
+
sort: parseOffsetMinutes(offsetStr),
|
|
44
|
+
};
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
items.sort((a, b) => a.sort - b.sort || a.label.localeCompare(b.label));
|
|
48
|
+
|
|
49
|
+
return items.map(({ value, label, displayValue }) => ({ value, label, displayValue }));
|
|
50
|
+
} catch {
|
|
51
|
+
return FALLBACK_TIMEZONES;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
export const myProfileSchema = z.object({
|
|
4
|
+
name: z.string().min(1, 'Nome é obrigatório'),
|
|
5
|
+
gender: z.string().optional(),
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
export type MyProfileFormData = z.infer<typeof myProfileSchema>;
|
|
9
|
+
|
|
10
|
+
export const changePasswordSchema = z.object({
|
|
11
|
+
currentPassword: z.string().min(1, 'Senha atual é obrigatória'),
|
|
12
|
+
newPassword: z
|
|
13
|
+
.string()
|
|
14
|
+
.min(1, 'Nova senha é obrigatória')
|
|
15
|
+
.min(8, 'Nova senha deve ter no mínimo 8 caracteres'),
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
export type ChangePasswordFormData = z.infer<typeof changePasswordSchema>;
|
|
19
|
+
|
|
20
|
+
export const changePhoneSchema = z.object({
|
|
21
|
+
phone: z
|
|
22
|
+
.string()
|
|
23
|
+
.min(1, 'Número de telefone é obrigatório')
|
|
24
|
+
.regex(/^\(\d{2}\) (\d \d{4}|\d{4})-\d{4}$/, 'Número de telefone inválido'),
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
export type ChangePhoneFormData = z.infer<typeof changePhoneSchema>;
|
|
28
|
+
|
|
29
|
+
export const changeEmailSchema = z.object({
|
|
30
|
+
email: z.string().min(1, 'E-mail é obrigatório').email('E-mail inválido'),
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
export type ChangeEmailFormData = z.infer<typeof changeEmailSchema>;
|
|
34
|
+
|
|
35
|
+
export const OTP_CODE_LENGTH = 5;
|
|
36
|
+
export const VALID_OTP_CODE = '12345';
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export function isValidEmail(value: string): boolean {
|
|
2
|
+
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
3
|
+
return emailRegex.test(value.trim());
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export function isNumericString(value: string): boolean {
|
|
7
|
+
return /^\d+$/.test(value);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function clampNumber(value: number, min: number, max: number): number {
|
|
11
|
+
return Math.min(Math.max(value, min), max);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function isInRange(value: number, min: number, max: number): boolean {
|
|
15
|
+
return !isNaN(value) && value >= min && value <= max;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function isConfirmationMatch(input: string, expected: string): boolean {
|
|
19
|
+
return input === expected;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function hasExactLength(value: string, length: number): boolean {
|
|
23
|
+
return value.length === length;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function hasMinLength(value: string, minLength: number): boolean {
|
|
27
|
+
return value.length >= minLength;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function areFieldsRequired(...values: string[]): boolean {
|
|
31
|
+
return values.every((v) => v.trim().length > 0);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export const MIN_PHONE_LENGTH = 14;
|
|
35
|
+
|
|
36
|
+
export function isNonEmptyString(value: string): boolean {
|
|
37
|
+
return value.trim().length > 0;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function trimOrDefault(value: string, fallback: string): string {
|
|
41
|
+
const trimmed = value.trim();
|
|
42
|
+
return trimmed.length > 0 ? trimmed : fallback;
|
|
43
|
+
}
|