@greatapps/common 1.1.23 → 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.
Files changed (127) hide show
  1. package/dist/components/account/ConfigurationsMyAccountModal.mjs +121 -0
  2. package/dist/components/account/ConfigurationsMyAccountModal.mjs.map +1 -0
  3. package/dist/components/account/ConfirmGlobalPreferencesModal.mjs +45 -0
  4. package/dist/components/account/ConfirmGlobalPreferencesModal.mjs.map +1 -0
  5. package/dist/components/account/DisableTwoFactorAuthModal.mjs +67 -0
  6. package/dist/components/account/DisableTwoFactorAuthModal.mjs.map +1 -0
  7. package/dist/components/account/TwoFactorAuthModal.mjs +190 -0
  8. package/dist/components/account/TwoFactorAuthModal.mjs.map +1 -0
  9. package/dist/components/account/constants.mjs +32 -0
  10. package/dist/components/account/constants.mjs.map +1 -0
  11. package/dist/components/account/hooks/useChangeEmailForm.mjs +53 -0
  12. package/dist/components/account/hooks/useChangeEmailForm.mjs.map +1 -0
  13. package/dist/components/account/hooks/useChangePasswordForm.mjs +47 -0
  14. package/dist/components/account/hooks/useChangePasswordForm.mjs.map +1 -0
  15. package/dist/components/account/hooks/useChangePhoneForm.mjs +64 -0
  16. package/dist/components/account/hooks/useChangePhoneForm.mjs.map +1 -0
  17. package/dist/components/account/hooks/useConfigurationsModal.mjs +33 -0
  18. package/dist/components/account/hooks/useConfigurationsModal.mjs.map +1 -0
  19. package/dist/components/account/hooks/useDisableTwoFactorAuthForm.mjs +54 -0
  20. package/dist/components/account/hooks/useDisableTwoFactorAuthForm.mjs.map +1 -0
  21. package/dist/components/account/hooks/useOtpVerification.mjs +94 -0
  22. package/dist/components/account/hooks/useOtpVerification.mjs.map +1 -0
  23. package/dist/components/account/hooks/useTwoFactorAuthForm.mjs +88 -0
  24. package/dist/components/account/hooks/useTwoFactorAuthForm.mjs.map +1 -0
  25. package/dist/components/account/sections/ChangeEmailModal.mjs +180 -0
  26. package/dist/components/account/sections/ChangeEmailModal.mjs.map +1 -0
  27. package/dist/components/account/sections/ChangePasswordSection.mjs +64 -0
  28. package/dist/components/account/sections/ChangePasswordSection.mjs.map +1 -0
  29. package/dist/components/account/sections/ChangePhoneModal.mjs +182 -0
  30. package/dist/components/account/sections/ChangePhoneModal.mjs.map +1 -0
  31. package/dist/components/account/sections/MyProfileSection.mjs +312 -0
  32. package/dist/components/account/sections/MyProfileSection.mjs.map +1 -0
  33. package/dist/components/account/sections/PreferencesSection.mjs +246 -0
  34. package/dist/components/account/sections/PreferencesSection.mjs.map +1 -0
  35. package/dist/components/account/sections/SecuritySection.mjs +147 -0
  36. package/dist/components/account/sections/SecuritySection.mjs.map +1 -0
  37. package/dist/components/ui/form/ComboboxField.mjs +130 -0
  38. package/dist/components/ui/form/ComboboxField.mjs.map +1 -0
  39. package/dist/components/ui/form/FormField.mjs +103 -0
  40. package/dist/components/ui/form/FormField.mjs.map +1 -0
  41. package/dist/components/ui/form/PhoneInput.mjs +78 -0
  42. package/dist/components/ui/form/PhoneInput.mjs.map +1 -0
  43. package/dist/components/ui/form/Select.mjs.map +1 -1
  44. package/dist/components/ui/form/SelectField.mjs +80 -0
  45. package/dist/components/ui/form/SelectField.mjs.map +1 -0
  46. package/dist/components/ui/form/SwitchOptionFieldWithIcon.mjs +40 -0
  47. package/dist/components/ui/form/SwitchOptionFieldWithIcon.mjs.map +1 -0
  48. package/dist/components/ui/form/TextAreaField.mjs +56 -0
  49. package/dist/components/ui/form/TextAreaField.mjs.map +1 -0
  50. package/dist/enums/AccountSectionType.mjs +11 -0
  51. package/dist/enums/AccountSectionType.mjs.map +1 -0
  52. package/dist/hooks/useCountdownTimer.mjs +29 -0
  53. package/dist/hooks/useCountdownTimer.mjs.map +1 -0
  54. package/dist/hooks/useIsMobile.mjs +18 -0
  55. package/dist/hooks/useIsMobile.mjs.map +1 -0
  56. package/dist/hooks/usePasswordVisibility.mjs +13 -0
  57. package/dist/hooks/usePasswordVisibility.mjs.map +1 -0
  58. package/dist/index.mjs +80 -0
  59. package/dist/index.mjs.map +1 -1
  60. package/dist/modules/accounts/actions/account-management.action.mjs +163 -0
  61. package/dist/modules/accounts/actions/account-management.action.mjs.map +1 -0
  62. package/dist/modules/accounts/hooks/useAccountManagement.mjs +64 -0
  63. package/dist/modules/accounts/hooks/useAccountManagement.mjs.map +1 -0
  64. package/dist/modules/accounts/services/account.service.mjs +162 -25
  65. package/dist/modules/accounts/services/account.service.mjs.map +1 -1
  66. package/dist/modules/accounts/services/two-factor.service.mjs +77 -0
  67. package/dist/modules/accounts/services/two-factor.service.mjs.map +1 -0
  68. package/dist/server.mjs +36 -0
  69. package/dist/server.mjs.map +1 -1
  70. package/dist/utils/browser/clipboard.mjs +36 -0
  71. package/dist/utils/browser/clipboard.mjs.map +1 -0
  72. package/dist/utils/file/index.mjs +9 -0
  73. package/dist/utils/file/index.mjs.map +1 -0
  74. package/dist/utils/format/masks.mjs +56 -0
  75. package/dist/utils/format/masks.mjs.map +1 -0
  76. package/dist/utils/intl/locales.mjs +12 -0
  77. package/dist/utils/intl/locales.mjs.map +1 -0
  78. package/dist/utils/intl/timezones.mjs +41 -0
  79. package/dist/utils/intl/timezones.mjs.map +1 -0
  80. package/dist/utils/validators/account.mjs +26 -0
  81. package/dist/utils/validators/account.mjs.map +1 -0
  82. package/dist/utils/validators/common.mjs +47 -0
  83. package/dist/utils/validators/common.mjs.map +1 -0
  84. package/package.json +6 -1
  85. package/src/components/account/ConfigurationsMyAccountModal.tsx +147 -0
  86. package/src/components/account/ConfirmGlobalPreferencesModal.tsx +66 -0
  87. package/src/components/account/DisableTwoFactorAuthModal.tsx +86 -0
  88. package/src/components/account/TwoFactorAuthModal.tsx +221 -0
  89. package/src/components/account/constants.ts +29 -0
  90. package/src/components/account/hooks/useChangeEmailForm.tsx +56 -0
  91. package/src/components/account/hooks/useChangePasswordForm.tsx +59 -0
  92. package/src/components/account/hooks/useChangePhoneForm.tsx +69 -0
  93. package/src/components/account/hooks/useConfigurationsModal.ts +40 -0
  94. package/src/components/account/hooks/useDisableTwoFactorAuthForm.tsx +69 -0
  95. package/src/components/account/hooks/useOtpVerification.tsx +116 -0
  96. package/src/components/account/hooks/useTwoFactorAuthForm.tsx +114 -0
  97. package/src/components/account/sections/ChangeEmailModal.tsx +224 -0
  98. package/src/components/account/sections/ChangePasswordSection.tsx +64 -0
  99. package/src/components/account/sections/ChangePhoneModal.tsx +229 -0
  100. package/src/components/account/sections/MyProfileSection.tsx +337 -0
  101. package/src/components/account/sections/PreferencesSection.tsx +277 -0
  102. package/src/components/account/sections/SecuritySection.tsx +160 -0
  103. package/src/components/ui/form/ComboboxField.tsx +154 -0
  104. package/src/components/ui/form/FormField.tsx +130 -0
  105. package/src/components/ui/form/PhoneInput.tsx +98 -0
  106. package/src/components/ui/form/Select.tsx +1 -0
  107. package/src/components/ui/form/SelectField.tsx +118 -0
  108. package/src/components/ui/form/SwitchOptionFieldWithIcon.tsx +47 -0
  109. package/src/components/ui/form/TextAreaField.tsx +70 -0
  110. package/src/enums/AccountSectionType.ts +6 -0
  111. package/src/hooks/useCountdownTimer.ts +41 -0
  112. package/src/hooks/useIsMobile.ts +19 -0
  113. package/src/hooks/usePasswordVisibility.ts +13 -0
  114. package/src/index.ts +70 -0
  115. package/src/modules/accounts/actions/account-management.action.ts +197 -0
  116. package/src/modules/accounts/hooks/useAccountManagement.ts +79 -0
  117. package/src/modules/accounts/services/account.service.ts +229 -50
  118. package/src/modules/accounts/services/two-factor.service.ts +98 -0
  119. package/src/modules/accounts/types.ts +157 -0
  120. package/src/server.ts +21 -0
  121. package/src/utils/browser/clipboard.ts +34 -0
  122. package/src/utils/file/index.ts +5 -0
  123. package/src/utils/format/masks.ts +52 -0
  124. package/src/utils/intl/locales.ts +15 -0
  125. package/src/utils/intl/timezones.ts +53 -0
  126. package/src/utils/validators/account.ts +36 -0
  127. package/src/utils/validators/common.ts +43 -0
@@ -0,0 +1,47 @@
1
+ function isValidEmail(value) {
2
+ const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
3
+ return emailRegex.test(value.trim());
4
+ }
5
+ function isNumericString(value) {
6
+ return /^\d+$/.test(value);
7
+ }
8
+ function clampNumber(value, min, max) {
9
+ return Math.min(Math.max(value, min), max);
10
+ }
11
+ function isInRange(value, min, max) {
12
+ return !isNaN(value) && value >= min && value <= max;
13
+ }
14
+ function isConfirmationMatch(input, expected) {
15
+ return input === expected;
16
+ }
17
+ function hasExactLength(value, length) {
18
+ return value.length === length;
19
+ }
20
+ function hasMinLength(value, minLength) {
21
+ return value.length >= minLength;
22
+ }
23
+ function areFieldsRequired(...values) {
24
+ return values.every((v) => v.trim().length > 0);
25
+ }
26
+ const MIN_PHONE_LENGTH = 14;
27
+ function isNonEmptyString(value) {
28
+ return value.trim().length > 0;
29
+ }
30
+ function trimOrDefault(value, fallback) {
31
+ const trimmed = value.trim();
32
+ return trimmed.length > 0 ? trimmed : fallback;
33
+ }
34
+ export {
35
+ MIN_PHONE_LENGTH,
36
+ areFieldsRequired,
37
+ clampNumber,
38
+ hasExactLength,
39
+ hasMinLength,
40
+ isConfirmationMatch,
41
+ isInRange,
42
+ isNonEmptyString,
43
+ isNumericString,
44
+ isValidEmail,
45
+ trimOrDefault
46
+ };
47
+ //# sourceMappingURL=common.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/utils/validators/common.ts"],"sourcesContent":["export function isValidEmail(value: string): boolean {\r\n const emailRegex = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/;\r\n return emailRegex.test(value.trim());\r\n}\r\n\r\nexport function isNumericString(value: string): boolean {\r\n return /^\\d+$/.test(value);\r\n}\r\n\r\nexport function clampNumber(value: number, min: number, max: number): number {\r\n return Math.min(Math.max(value, min), max);\r\n}\r\n\r\nexport function isInRange(value: number, min: number, max: number): boolean {\r\n return !isNaN(value) && value >= min && value <= max;\r\n}\r\n\r\nexport function isConfirmationMatch(input: string, expected: string): boolean {\r\n return input === expected;\r\n}\r\n\r\nexport function hasExactLength(value: string, length: number): boolean {\r\n return value.length === length;\r\n}\r\n\r\nexport function hasMinLength(value: string, minLength: number): boolean {\r\n return value.length >= minLength;\r\n}\r\n\r\nexport function areFieldsRequired(...values: string[]): boolean {\r\n return values.every((v) => v.trim().length > 0);\r\n}\r\n\r\nexport const MIN_PHONE_LENGTH = 14;\r\n\r\nexport function isNonEmptyString(value: string): boolean {\r\n return value.trim().length > 0;\r\n}\r\n\r\nexport function trimOrDefault(value: string, fallback: string): string {\r\n const trimmed = value.trim();\r\n return trimmed.length > 0 ? trimmed : fallback;\r\n}\r\n"],"mappings":"AAAO,SAAS,aAAa,OAAwB;AACnD,QAAM,aAAa;AACnB,SAAO,WAAW,KAAK,MAAM,KAAK,CAAC;AACrC;AAEO,SAAS,gBAAgB,OAAwB;AACtD,SAAO,QAAQ,KAAK,KAAK;AAC3B;AAEO,SAAS,YAAY,OAAe,KAAa,KAAqB;AAC3E,SAAO,KAAK,IAAI,KAAK,IAAI,OAAO,GAAG,GAAG,GAAG;AAC3C;AAEO,SAAS,UAAU,OAAe,KAAa,KAAsB;AAC1E,SAAO,CAAC,MAAM,KAAK,KAAK,SAAS,OAAO,SAAS;AACnD;AAEO,SAAS,oBAAoB,OAAe,UAA2B;AAC5E,SAAO,UAAU;AACnB;AAEO,SAAS,eAAe,OAAe,QAAyB;AACrE,SAAO,MAAM,WAAW;AAC1B;AAEO,SAAS,aAAa,OAAe,WAA4B;AACtE,SAAO,MAAM,UAAU;AACzB;AAEO,SAAS,qBAAqB,QAA2B;AAC9D,SAAO,OAAO,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,SAAS,CAAC;AAChD;AAEO,MAAM,mBAAmB;AAEzB,SAAS,iBAAiB,OAAwB;AACvD,SAAO,MAAM,KAAK,EAAE,SAAS;AAC/B;AAEO,SAAS,cAAc,OAAe,UAA0B;AACrE,QAAM,UAAU,MAAM,KAAK;AAC3B,SAAO,QAAQ,SAAS,IAAI,UAAU;AACxC;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@greatapps/common",
3
- "version": "1.1.23",
3
+ "version": "1.1.25",
4
4
  "description": "Shared library for GreatApps frontend applications",
5
5
  "main": "./dist/index.mjs",
6
6
  "types": "./src/index.ts",
@@ -34,6 +34,7 @@
34
34
  "@radix-ui/react-progress": "^1.1.8",
35
35
  "@radix-ui/react-radio-group": "^1.3.8",
36
36
  "@radix-ui/react-scroll-area": "^1.2.10",
37
+ "@radix-ui/react-select": "^2.2.6",
37
38
  "@radix-ui/react-separator": "^1.1.8",
38
39
  "@radix-ui/react-switch": "^1.2.6",
39
40
  "@radix-ui/react-tabs": "^1.1.13",
@@ -52,6 +53,7 @@
52
53
  "zod": "^4.3.6"
53
54
  },
54
55
  "devDependencies": {
56
+ "@hookform/resolvers": "^5.2.2",
55
57
  "@tanstack/react-query": "^5.90.5",
56
58
  "@tanstack/react-query-devtools": "^5.90.2",
57
59
  "@types/node": "^25.3.2",
@@ -61,15 +63,18 @@
61
63
  "next": "15.5.9",
62
64
  "react": "19.1.4",
63
65
  "react-dom": "19.1.4",
66
+ "react-hook-form": "^7.71.2",
64
67
  "tsup": "^8.5.1",
65
68
  "typescript": "^5.9.3",
66
69
  "zustand": "^5.0.11"
67
70
  },
68
71
  "peerDependencies": {
72
+ "@hookform/resolvers": ">=3.0.0",
69
73
  "@tanstack/react-query": ">=5.0.0",
70
74
  "next": ">=15.0.0",
71
75
  "react": ">=19.0.0",
72
76
  "react-dom": ">=19.0.0",
77
+ "react-hook-form": ">=7.0.0",
73
78
  "sonner": ">=2.0.0",
74
79
  "zustand": ">=4.0.0"
75
80
  }
@@ -0,0 +1,147 @@
1
+ 'use client';
2
+
3
+ import { Lock, Settings2, User, X } from 'lucide-react';
4
+ import { Dialog, DialogContent, DialogHeader, DialogTitle } from '../ui/overlay/Dialog';
5
+ import { Tabs, TabsList, TabsTrigger, TabsContent } from '../ui/data-display/Tabs';
6
+ import { Button } from '../ui/buttons/Button';
7
+ import { cn } from '../../infra/utils/clsx';
8
+ import { AccountSectionType } from '../../enums/AccountSectionType';
9
+ import { MyProfileSection } from './sections/MyProfileSection';
10
+ import { PreferencesSection } from './sections/PreferencesSection';
11
+ import { ChangePasswordSection } from './sections/ChangePasswordSection';
12
+ import { SecuritySection } from './sections/SecuritySection';
13
+ import useConfigurationsModal from './hooks/useConfigurationsModal';
14
+ import useIsMobile from '../../hooks/useIsMobile';
15
+ import type { ComboboxOption } from '../ui/form/ComboboxField';
16
+
17
+ interface ConfigurationsMyAccountModalProps {
18
+ open: boolean;
19
+ onClose: () => void;
20
+ initialSection?: AccountSectionType;
21
+ hasActiveSubscription?: boolean;
22
+ currencies?: ComboboxOption[];
23
+ storageUrl?: string;
24
+ onDeleteAccount?: () => void;
25
+ }
26
+
27
+ export default function ConfigurationsMyAccountModal({
28
+ open,
29
+ onClose,
30
+ initialSection,
31
+ hasActiveSubscription,
32
+ currencies = [],
33
+ storageUrl,
34
+ onDeleteAccount,
35
+ }: ConfigurationsMyAccountModalProps) {
36
+ const isMobile = useIsMobile();
37
+ const { activeSection, setActiveSection } = useConfigurationsModal({
38
+ isOpen: open,
39
+ initialSection,
40
+ });
41
+
42
+ const tabTriggerClasses = cn(
43
+ 'border-0! px-0 py-0',
44
+
45
+ 'lg:rounded-md lg:flex lg:items-center lg:gap-2 lg:p-3 lg:justify-start lg:w-full',
46
+ 'lg:bg-white lg:hover:bg-gray-100 lg:active:bg-gray-50 lg:border-0',
47
+ 'lg:data-[state=active]:bg-gray-50',
48
+
49
+ 'flex items-center gap-1.5 px-3 py-3 justify-center whitespace-nowrap',
50
+ 'border-b-2 border-transparent',
51
+ 'data-[state=active]:bg-gray-50 rounded-lg',
52
+
53
+ 'text-gray-500 data-[state=active]:text-gray-950',
54
+ 'hover:text-gray-900 transition-colors'
55
+ );
56
+
57
+ return (
58
+ <Dialog open={open} onOpenChange={onClose}>
59
+ <DialogContent
60
+ showCloseButton={!isMobile}
61
+ overlayClassName="bg-black/20 lg:bg-black/50"
62
+ className="
63
+ flex flex-col p-0 gap-0 max-w-full! overflow-x-hidden border-0
64
+ rounded-t-2xl rounded-b-none h-[100dvh] top-0! bottom-0! left-0! right-0! translate-x-0! translate-y-0!
65
+ lg:flex-row lg:w-[892px]! lg:max-w-[892px]! lg:h-[626px]! lg:rounded-lg lg:border
66
+ lg:top-[50%]! lg:bottom-auto! lg:left-[50%]! lg:right-auto! lg:translate-x-[-50%]! lg:translate-y-[-50%]!"
67
+ >
68
+ <DialogHeader className="sr-only">
69
+ <DialogTitle>Configurações</DialogTitle>
70
+ </DialogHeader>
71
+ <div className="md:hidden flex items-center justify-between px-5 py-3 border-b border-gray-200">
72
+ <span className="text-gray-950 paragraph-medium-semibold">Configurações</span>
73
+ <button
74
+ type="button"
75
+ className="size-8 flex items-center justify-center text-gray-500 cursor-pointer"
76
+ onClick={onClose}
77
+ >
78
+ <X size={18} />
79
+ </button>
80
+ </div>
81
+ <Tabs
82
+ value={activeSection}
83
+ onValueChange={(value) => setActiveSection(value as AccountSectionType)}
84
+ orientation="vertical"
85
+ className="flex lg:flex-row flex-col w-full h-full flex-1 lg:h-full lg:pt-0 lg:gap-0"
86
+ >
87
+ <TabsList
88
+ className={cn(
89
+ 'flex gap-0 bg-transparent border-b-0',
90
+
91
+ 'lg:flex-col lg:items-stretch lg:justify-start lg:w-auto lg:min-w-60',
92
+ 'lg:border-r lg:border-gray-200 lg:pl-5 lg:pr-5 lg:pt-5 lg:gap-5 lg:overflow-x-visible lg:self-stretch',
93
+
94
+ 'flex-row items-center justify-start w-full overflow-x-auto scrollbar-hide shrink-0',
95
+ 'px-4 py-3',
96
+ '[mask-image:linear-gradient(to_right,transparent,black_16px,black_calc(100%-24px),transparent)] lg:[mask-image:none]'
97
+ )}
98
+ >
99
+ <span className="hidden lg:block paragraph-medium-semibold text-gray-950 mb-0">
100
+ Configurações
101
+ </span>
102
+
103
+ <div className="lg:flex lg:flex-col flex flex-row lg:gap-0 gap-0 lg:w-full">
104
+ <TabsTrigger value={AccountSectionType.MY_PROFILE} className={tabTriggerClasses}>
105
+ <User size={20} className="shrink-0" />
106
+ <span className="paragraph-small-medium">Meu perfil</span>
107
+ </TabsTrigger>
108
+
109
+ <TabsTrigger value={AccountSectionType.PREFERENCES} className={tabTriggerClasses}>
110
+ <Settings2 size={20} className="shrink-0" />
111
+ <span className="paragraph-small-medium">Preferências</span>
112
+ </TabsTrigger>
113
+
114
+ <TabsTrigger value={AccountSectionType.SECURITY} className={tabTriggerClasses}>
115
+ <Lock size={20} className="shrink-0" />
116
+ <span className="paragraph-small-medium">Segurança</span>
117
+ </TabsTrigger>
118
+ </div>
119
+ </TabsList>
120
+
121
+ <div className="w-full flex-1 min-h-0 lg:h-full overflow-hidden lg:overflow-visible relative">
122
+ <TabsContent value={AccountSectionType.MY_PROFILE} className="h-full! relative overflow-hidden">
123
+ <MyProfileSection onClose={onClose} storageUrl={storageUrl} />
124
+ </TabsContent>
125
+
126
+ <TabsContent value={AccountSectionType.SECURITY} className="h-full! relative overflow-hidden">
127
+ <SecuritySection
128
+ setActiveSection={setActiveSection}
129
+ onClose={onClose}
130
+ hasActiveSubscription={hasActiveSubscription}
131
+ onDeleteAccount={onDeleteAccount}
132
+ />
133
+ </TabsContent>
134
+
135
+ <TabsContent value={AccountSectionType.CHANGE_PASSWORD} className="h-full! relative overflow-hidden">
136
+ <ChangePasswordSection onBack={() => setActiveSection(AccountSectionType.SECURITY)} />
137
+ </TabsContent>
138
+
139
+ <TabsContent value={AccountSectionType.PREFERENCES} className="h-full! relative overflow-hidden">
140
+ <PreferencesSection onClose={onClose} currencies={currencies} />
141
+ </TabsContent>
142
+ </div>
143
+ </Tabs>
144
+ </DialogContent>
145
+ </Dialog>
146
+ );
147
+ }
@@ -0,0 +1,66 @@
1
+ 'use client';
2
+
3
+ import { TriangleAlert } from 'lucide-react';
4
+ import { Button } from '../ui/buttons/Button';
5
+ import {
6
+ Dialog,
7
+ DialogContent,
8
+ DialogHeader,
9
+ DialogTitle,
10
+ DialogDescription,
11
+ } from '../ui/overlay/Dialog';
12
+ import { Separator } from '../ui/data-display/Separator';
13
+
14
+ interface ConfirmGlobalPreferencesModalProps {
15
+ open: boolean;
16
+ onConfirm: () => void;
17
+ onCancel: () => void;
18
+ }
19
+
20
+ export default function ConfirmGlobalPreferencesModal({
21
+ open,
22
+ onConfirm,
23
+ onCancel,
24
+ }: ConfirmGlobalPreferencesModalProps) {
25
+ return (
26
+ <Dialog open={open} onOpenChange={onCancel}>
27
+ <DialogContent className="flex flex-col p-0 gap-0 md:w-[386px]! lg:w-[386px]! max-w-[386px]! max-[386px]:w-[calc(100%-32px)]">
28
+ <DialogHeader className="sr-only">
29
+ <DialogTitle>Alterar preferências globais</DialogTitle>
30
+ <DialogDescription>
31
+ Confirmação de alteração de preferências globais da conta
32
+ </DialogDescription>
33
+ </DialogHeader>
34
+
35
+ <div className="flex flex-col gap-3 p-5">
36
+ <div className="flex items-center justify-center bg-gray-50 rounded-lg size-10">
37
+ <TriangleAlert size={24} className="text-gray-950" />
38
+ </div>
39
+ <div className="flex flex-col gap-2">
40
+ <span className="paragraph-medium-semibold text-gray-950">
41
+ Alterar preferências globais
42
+ </span>
43
+ <span className="paragraph-small-regular text-gray-600">
44
+ Você está alterando configurações que impactam{' '}
45
+ <span className="paragraph-small-semibold text-gray-950">
46
+ todos os usuários da conta
47
+ </span>
48
+ . Deseja confirmar?
49
+ </span>
50
+ </div>
51
+ </div>
52
+
53
+ <Separator className="w-full" />
54
+
55
+ <div className="flex items-center gap-2 p-5">
56
+ <Button onClick={onConfirm} className="h-10!">
57
+ Confirmar
58
+ </Button>
59
+ <Button variant="secondary" onClick={onCancel} className="h-10!">
60
+ Cancelar
61
+ </Button>
62
+ </div>
63
+ </DialogContent>
64
+ </Dialog>
65
+ );
66
+ }
@@ -0,0 +1,86 @@
1
+ 'use client';
2
+
3
+ import { ShieldCheck } from 'lucide-react';
4
+ import { Button } from '../ui/buttons/Button';
5
+ import {
6
+ Dialog,
7
+ DialogContent,
8
+ DialogDescription,
9
+ DialogHeader,
10
+ DialogTitle,
11
+ } from '../ui/overlay/Dialog';
12
+ import { InputOTP, InputOTPGroup, InputOTPSlot } from '../ui/form/InputOtp';
13
+ import useDisableTwoFactorAuthForm from './hooks/useDisableTwoFactorAuthForm';
14
+
15
+ interface DisableTwoFactorAuthModalProps {
16
+ open: boolean;
17
+ onClose: () => void;
18
+ onSuccess?: () => void;
19
+ }
20
+
21
+ export default function DisableTwoFactorAuthModal({
22
+ open,
23
+ onClose,
24
+ onSuccess,
25
+ }: DisableTwoFactorAuthModalProps) {
26
+ const { code, setCode, isValid, isLoading, handleClose, handleSubmit } =
27
+ useDisableTwoFactorAuthForm({ onClose, onSuccess });
28
+
29
+ return (
30
+ <Dialog open={open} onOpenChange={handleClose}>
31
+ <DialogContent className="flex flex-col p-0 gap-0 max-w-full! border-0 rounded-t-2xl rounded-b-none h-dvh top-0! bottom-0! left-0! right-0! translate-x-0! translate-y-0! lg:max-w-117.5! lg:h-auto! lg:rounded-lg lg:border lg:top-[50%]! lg:left-[50%]! lg:right-auto! lg:bottom-auto! lg:translate-x-[-50%]! lg:translate-y-[-50%]!">
32
+ <form
33
+ onSubmit={(e) => {
34
+ e.preventDefault();
35
+ handleSubmit();
36
+ }}
37
+ className="flex flex-col flex-1 lg:flex-none"
38
+ >
39
+ <div className="flex flex-col gap-4 lg:gap-5 p-4 lg:p-5 flex-1 lg:flex-none">
40
+ <div className="flex items-center justify-center w-fit bg-gray-50 rounded-lg p-2">
41
+ <ShieldCheck size={20} className="text-gray-600" />
42
+ </div>
43
+ <DialogHeader className="p-0 gap-2">
44
+ <DialogTitle className="paragraph-medium-semibold text-gray-950">
45
+ Desabilitar autenticação 2FA
46
+ </DialogTitle>
47
+ <DialogDescription className="paragraph-small-regular text-gray-600">
48
+ Informe o código de 6 dígitos do seu aplicativo autenticador para confirmar a
49
+ desativação.
50
+ </DialogDescription>
51
+ </DialogHeader>
52
+
53
+ <div className="flex flex-col gap-2">
54
+ <span className="paragraph-small-medium text-gray-700">Código do autenticador</span>
55
+ <InputOTP maxLength={6} value={code} onChange={setCode}>
56
+ <InputOTPGroup className="gap-2">
57
+ {Array.from({ length: 6 }).map((_, i) => (
58
+ <InputOTPSlot
59
+ key={i}
60
+ index={i}
61
+ className="w-11! lg:w-12! h-13! lg:h-14! rounded-lg! text-lg border-gray-200"
62
+ />
63
+ ))}
64
+ </InputOTPGroup>
65
+ </InputOTP>
66
+ </div>
67
+ </div>
68
+
69
+ <div className="flex flex-row items-center gap-2 p-4 lg:p-5 border-t border-gray-200 mt-auto lg:mt-0">
70
+ <Button className="h-10! flex-1" disabled={!isValid || isLoading} type="submit">
71
+ {isLoading ? 'Desabilitando...' : 'Desabilitar 2FA'}
72
+ </Button>
73
+ <Button
74
+ variant="secondary"
75
+ className="h-10! flex-1"
76
+ type="button"
77
+ onClick={handleClose}
78
+ >
79
+ Cancelar
80
+ </Button>
81
+ </div>
82
+ </form>
83
+ </DialogContent>
84
+ </Dialog>
85
+ );
86
+ }
@@ -0,0 +1,221 @@
1
+ 'use client';
2
+
3
+ import { ArrowLeft, X, Copy, RefreshCw } from 'lucide-react';
4
+ import { Button } from '../ui/buttons/Button';
5
+ import { Dialog, DialogContent, DialogHeader, DialogTitle } from '../ui/overlay/Dialog';
6
+ import { Separator } from '../ui/data-display/Separator';
7
+ import { InputOTP, InputOTPGroup, InputOTPSlot } from '../ui/form/InputOtp';
8
+ import useTwoFactorAuthForm from './hooks/useTwoFactorAuthForm';
9
+
10
+ interface TwoFactorAuthModalProps {
11
+ open: boolean;
12
+ onClose: () => void;
13
+ onSuccess?: () => void;
14
+ }
15
+
16
+ export default function TwoFactorAuthModal({ open, onClose, onSuccess }: TwoFactorAuthModalProps) {
17
+ const {
18
+ code,
19
+ setCode,
20
+ isCodeComplete,
21
+ isGenerating,
22
+ isConfirming,
23
+ generateFailed,
24
+ retryGenerate,
25
+ qrcode,
26
+ backupCodes,
27
+ step,
28
+ handleSubmit,
29
+ handleFinalize,
30
+ handleCopyCodes,
31
+ resetForm,
32
+ } = useTwoFactorAuthForm({ onSuccess, open });
33
+
34
+ const handleClose = () => {
35
+ resetForm();
36
+ onClose();
37
+ };
38
+
39
+ if (step === 'recovery') {
40
+ return (
41
+ <Dialog open={open} onOpenChange={handleClose}>
42
+ <DialogContent
43
+ showCloseButton={false}
44
+ className="flex flex-col p-0 gap-0 max-w-full! border-0 rounded-t-2xl rounded-b-none h-[100dvh] top-0! bottom-0! left-0! right-0! translate-x-0! translate-y-0! lg:max-w-[470px]! lg:h-auto! lg:rounded-lg lg:border lg:top-[50%]! lg:left-[50%]! lg:right-auto! lg:bottom-auto! lg:translate-x-[-50%]! lg:translate-y-[-50%]!"
45
+ >
46
+ <DialogHeader className="sr-only">
47
+ <DialogTitle>Códigos de segurança</DialogTitle>
48
+ </DialogHeader>
49
+ <div className="flex items-center justify-center px-4 py-3 relative border-b border-gray-200 lg:border-b-0">
50
+ <span className="paragraph-medium-semibold text-gray-950 text-center">
51
+ Códigos de segurança
52
+ </span>
53
+ <Button
54
+ type="button"
55
+ variant="ghost"
56
+ className="size-8! p-0 absolute right-4"
57
+ onClick={handleClose}
58
+ >
59
+ <X size={18} />
60
+ </Button>
61
+ </div>
62
+
63
+ <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">
64
+ <div className="flex flex-col gap-2">
65
+ <h3 className="paragraph-medium-semibold text-gray-950 max-w-[269px]">
66
+ Salve estes códigos de recuperação de emergência
67
+ </h3>
68
+ <div className="paragraph-small-regular text-gray-600">
69
+ <p>
70
+ Se você perder acesso ao seu telefone, não será possível fazer login em sua conta
71
+ sem um código de dois fatores.
72
+ </p>
73
+ <br />
74
+ <p>Imprima, copie ou escreva em um local seguro os códigos abaixo.</p>
75
+ </div>
76
+ </div>
77
+
78
+ <div className="bg-gray-50 rounded-lg p-4 flex flex-col gap-4">
79
+ <div className="paragraph-small-medium text-gray-950 whitespace-nowrap">
80
+ {backupCodes.map((backupCode, i) => (
81
+ <p key={i}>{backupCode}</p>
82
+ ))}
83
+ </div>
84
+ <Button
85
+ type="button"
86
+ variant="secondary"
87
+ className="h-8! w-fit"
88
+ onClick={handleCopyCodes}
89
+ >
90
+ <Copy size={16} />
91
+ Copiar códigos
92
+ </Button>
93
+ </div>
94
+ </div>
95
+
96
+ <div className="flex items-center p-4 lg:p-5 border-t border-gray-200 justify-between mt-auto lg:mt-0">
97
+ <Button variant="secondary" className="h-10!" type="button" onClick={handleClose}>
98
+ Cancelar
99
+ </Button>
100
+ <Button className="h-10!" type="button" onClick={handleFinalize}>
101
+ Finalizar
102
+ </Button>
103
+ </div>
104
+ </DialogContent>
105
+ </Dialog>
106
+ );
107
+ }
108
+
109
+ return (
110
+ <Dialog open={open} onOpenChange={handleClose}>
111
+ <DialogContent
112
+ showCloseButton={false}
113
+ className="flex flex-col p-0 gap-0 max-w-full! border-0 rounded-t-2xl rounded-b-none h-[100dvh] top-0! bottom-0! left-0! right-0! translate-x-0! translate-y-0! lg:max-w-[470px]! lg:h-auto! lg:max-h-[90vh] lg:rounded-lg lg:border lg:top-[50%]! lg:left-[50%]! lg:right-auto! lg:bottom-auto! lg:translate-x-[-50%]! lg:translate-y-[-50%]!"
114
+ >
115
+ <DialogHeader className="sr-only">
116
+ <DialogTitle>Autenticação de dois fatores</DialogTitle>
117
+ </DialogHeader>
118
+ <div className="shrink-0 flex items-center justify-center px-4 py-3 relative border-b border-gray-200 lg:border-b-0">
119
+ <Button
120
+ type="button"
121
+ variant="ghost"
122
+ className="size-8! p-0 absolute left-4"
123
+ onClick={handleClose}
124
+ >
125
+ <ArrowLeft size={20} />
126
+ </Button>
127
+ <span className="paragraph-medium-semibold text-gray-950 text-center">
128
+ Autenticação de dois fatores
129
+ </span>
130
+ <Button
131
+ type="button"
132
+ variant="ghost"
133
+ className="size-8! p-0 absolute right-4"
134
+ onClick={handleClose}
135
+ >
136
+ <X size={18} />
137
+ </Button>
138
+ </div>
139
+
140
+ <form
141
+ className="flex-1 min-h-0 flex flex-col"
142
+ onSubmit={(e) => {
143
+ e.preventDefault();
144
+ if (isCodeComplete) handleSubmit();
145
+ }}
146
+ >
147
+ <div className="flex-1 min-h-0 overflow-y-auto overscroll-contain lg:overflow-visible">
148
+ <div className="flex flex-col items-center gap-4 lg:gap-8 px-4 lg:px-5 py-4 lg:py-6 pb-60 lg:pb-6">
149
+ <p className="paragraph-small-regular text-gray-950 text-center max-w-full lg:max-w-[412px]">
150
+ Instale um aplicativo autenticador no seu celular (ex.:{' '}
151
+ <a
152
+ href="https://support.google.com/accounts/answer/1066447"
153
+ target="_blank"
154
+ rel="noopener noreferrer"
155
+ className="paragraph-small-medium underline"
156
+ >
157
+ Google Authenticator
158
+ </a>
159
+ ), escaneie o QR Code ao lado ou copie a chave no aplicativo e, em seguida, digite o
160
+ código de 6 dígitos gerado para continuar.
161
+ </p>
162
+
163
+ <div className="border border-gray-200 rounded-lg overflow-hidden p-2 lg:p-3 flex items-center justify-center w-[136px] h-[136px] lg:w-[203px] lg:h-[203px]">
164
+ {generateFailed ? (
165
+ <button
166
+ type="button"
167
+ onClick={() => retryGenerate()}
168
+ className="flex flex-col items-center gap-1.5 text-center"
169
+ >
170
+ <RefreshCw size={20} className="text-gray-400" />
171
+ <span className="paragraph-xsmall-medium text-gray-500">Tentar novamente</span>
172
+ </button>
173
+ ) : isGenerating || !qrcode ? (
174
+ <div className="w-full h-full rounded bg-gray-100 animate-pulse" />
175
+ ) : (
176
+ // eslint-disable-next-line @next/next/no-img-element
177
+ <img
178
+ src={qrcode}
179
+ alt="QR Code para autenticação de dois fatores"
180
+ className="w-full h-full"
181
+ />
182
+ )}
183
+ </div>
184
+
185
+ <div className="flex items-center gap-3 w-full">
186
+ <Separator className="flex-1" />
187
+ <span className="paragraph-xsmall-medium text-gray-500 opacity-80 whitespace-nowrap">
188
+ Cole os 6 dígitos abaixo
189
+ </span>
190
+ <Separator className="flex-1" />
191
+ </div>
192
+
193
+ <div className="scroll-mt-20">
194
+ <InputOTP maxLength={6} value={code} onChange={setCode}>
195
+ <InputOTPGroup className="gap-2">
196
+ {Array.from({ length: 6 }).map((_, i) => (
197
+ <InputOTPSlot
198
+ key={i}
199
+ index={i}
200
+ className="w-11! lg:w-12! h-13! lg:h-14! rounded-lg! text-lg border-gray-200"
201
+ />
202
+ ))}
203
+ </InputOTPGroup>
204
+ </InputOTP>
205
+ </div>
206
+ </div>
207
+ </div>
208
+
209
+ <div className="shrink-0 flex items-center p-4 lg:p-5 border-t border-gray-200 justify-between gap-2 bg-white">
210
+ <Button variant="secondary" className="h-10!" type="button" onClick={handleClose}>
211
+ Cancelar
212
+ </Button>
213
+ <Button type="submit" className="h-10!" disabled={!isCodeComplete || isConfirming}>
214
+ {isConfirming ? 'Ativando...' : 'Ativar autenticação'}
215
+ </Button>
216
+ </div>
217
+ </form>
218
+ </DialogContent>
219
+ </Dialog>
220
+ );
221
+ }
@@ -0,0 +1,29 @@
1
+ import { buildTimezoneOptions } from '../../utils/intl/timezones';
2
+ import { buildLocaleOptions } from '../../utils/intl/locales';
3
+
4
+ export const GENDER_OPTIONS = [
5
+ { value: 'masculino', label: 'Masculino', apiValue: 1 },
6
+ { value: 'feminino', label: 'Feminino', apiValue: 0 },
7
+ ];
8
+
9
+ export const LANGUAGE_OPTIONS = buildLocaleOptions();
10
+
11
+ export const CURRENCY_OPTIONS = [
12
+ { value: 'BRL', label: 'BRL (R$)', displayValue: 'BRL (R$)' },
13
+ { value: 'USD', label: 'USD ($)', displayValue: 'USD ($)' },
14
+ { value: 'EUR', label: 'EUR (€)', displayValue: 'EUR (€)' },
15
+ ];
16
+
17
+ export const TIMEZONE_OPTIONS = buildTimezoneOptions();
18
+
19
+ export const TIME_FORMAT_OPTIONS = [
20
+ { value: '24h', label: '24 horas', displayValue: '24 horas' },
21
+ { value: '12h', label: '12 horas (AM/PM)', displayValue: '12 horas (AM/PM)' },
22
+ ];
23
+
24
+ export const NOTIFICATION_TYPES = [
25
+ 'Atualizações de projetos',
26
+ 'Alertas de segurança',
27
+ 'Mudanças no plano ou faturamento',
28
+ 'Manutenções programadas',
29
+ ];