@greatapps/common 1.1.217 → 1.1.219
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 +5 -5
- package/dist/components/account/ConfigurationsMyAccountModal.mjs.map +1 -1
- package/dist/components/account/ConfirmDeleteAccountModal.mjs +2 -2
- package/dist/components/account/ConfirmDeleteAccountModal.mjs.map +1 -1
- package/dist/components/account/ConfirmGlobalPreferencesModal.mjs +2 -2
- package/dist/components/account/ConfirmGlobalPreferencesModal.mjs.map +1 -1
- package/dist/components/account/DeleteAccountModal.mjs +3 -3
- package/dist/components/account/DeleteAccountModal.mjs.map +1 -1
- package/dist/components/account/DisableTwoFactorAuthModal.mjs +2 -2
- package/dist/components/account/DisableTwoFactorAuthModal.mjs.map +1 -1
- package/dist/components/account/IsntPossibleDeleteAccountModal.mjs +2 -2
- package/dist/components/account/IsntPossibleDeleteAccountModal.mjs.map +1 -1
- package/dist/components/account/TwoFactorAuthModal.mjs +6 -6
- package/dist/components/account/TwoFactorAuthModal.mjs.map +1 -1
- package/dist/components/account/hooks/useChangePhoneForm.mjs.map +1 -1
- package/dist/components/account/hooks/useTwoFactorAuthForm.mjs.map +1 -1
- package/dist/components/account/sections/ChangeEmailModal.mjs +6 -6
- package/dist/components/account/sections/ChangeEmailModal.mjs.map +1 -1
- package/dist/components/account/sections/ChangePasswordSection.mjs +4 -4
- package/dist/components/account/sections/ChangePasswordSection.mjs.map +1 -1
- package/dist/components/account/sections/ChangePhoneModal.mjs +5 -5
- package/dist/components/account/sections/ChangePhoneModal.mjs.map +1 -1
- package/dist/components/account/sections/MyProfileSection.mjs +3 -3
- package/dist/components/account/sections/MyProfileSection.mjs.map +1 -1
- package/dist/components/account/sections/PreferencesSection.mjs +6 -6
- package/dist/components/account/sections/PreferencesSection.mjs.map +1 -1
- package/dist/components/account/sections/SecuritySection.mjs +3 -3
- package/dist/components/account/sections/SecuritySection.mjs.map +1 -1
- package/dist/components/embeds/CrispEmbed.mjs.map +1 -1
- package/dist/components/embeds/FrillEmbed.mjs.map +1 -1
- package/dist/components/layouts/AppMobileNavBar.mjs.map +1 -1
- package/dist/components/layouts/AppNavBar.mjs.map +1 -1
- package/dist/components/layouts/MdSideBarNavigation.mjs +2 -2
- package/dist/components/layouts/MdSideBarNavigation.mjs.map +1 -1
- package/dist/components/layouts/NavBar.mjs +2 -2
- package/dist/components/layouts/NavBar.mjs.map +1 -1
- package/dist/components/layouts/NotificationsPopover.mjs +4 -4
- package/dist/components/layouts/NotificationsPopover.mjs.map +1 -1
- package/dist/components/layouts/ProfilePopover.mjs +2 -2
- package/dist/components/layouts/ProfilePopover.mjs.map +1 -1
- package/dist/components/layouts/UsersSelectorPopover.mjs +5 -5
- package/dist/components/layouts/UsersSelectorPopover.mjs.map +1 -1
- package/dist/components/navigation/CancelledSubscriptionBanner.mjs.map +1 -1
- package/dist/components/navigation/NavItemsContext.mjs.map +1 -1
- package/dist/components/navigation/ProjectSelectorPopover.mjs +6 -6
- package/dist/components/navigation/ProjectSelectorPopover.mjs.map +1 -1
- package/dist/components/navigation/shells/TabsMobileShell.mjs.map +1 -1
- package/dist/components/navigation/subcomponents/ProjectSelector.mjs +5 -5
- package/dist/components/navigation/subcomponents/ProjectSelector.mjs.map +1 -1
- package/dist/components/pages/notifications/Notifications.mjs +5 -5
- package/dist/components/pages/notifications/Notifications.mjs.map +1 -1
- package/dist/components/ui/buttons/Button.mjs.map +1 -1
- package/dist/components/ui/buttons/CancelButton.mjs.map +1 -1
- package/dist/components/ui/buttons/CopyButton.mjs +2 -2
- package/dist/components/ui/buttons/CopyButton.mjs.map +1 -1
- package/dist/components/ui/data-display/Accordion.mjs +2 -2
- package/dist/components/ui/data-display/Accordion.mjs.map +1 -1
- package/dist/components/ui/data-display/Badge.mjs.map +1 -1
- package/dist/components/ui/data-display/Card.mjs.map +1 -1
- package/dist/components/ui/data-display/Pagination.mjs +7 -7
- package/dist/components/ui/data-display/Pagination.mjs.map +1 -1
- package/dist/components/ui/data-display/ScrollArea.mjs.map +1 -1
- package/dist/components/ui/data-display/Separator.mjs.map +1 -1
- package/dist/components/ui/data-display/Table.mjs.map +1 -1
- package/dist/components/ui/data-display/Tabs.mjs.map +1 -1
- package/dist/components/ui/feedback/CircularProgress.mjs.map +1 -1
- package/dist/components/ui/feedback/DefaultCircularProgress.mjs.map +1 -1
- package/dist/components/ui/feedback/LoadingOverlay.mjs.map +1 -1
- package/dist/components/ui/feedback/Progress.mjs.map +1 -1
- package/dist/components/ui/feedback/Toast.mjs +7 -7
- package/dist/components/ui/feedback/Toast.mjs.map +1 -1
- package/dist/components/ui/form/Calendar.mjs +7 -7
- package/dist/components/ui/form/Calendar.mjs.map +1 -1
- package/dist/components/ui/form/Checkbox.mjs +2 -2
- package/dist/components/ui/form/Checkbox.mjs.map +1 -1
- package/dist/components/ui/form/ComboboxField.mjs +4 -4
- package/dist/components/ui/form/ComboboxField.mjs.map +1 -1
- package/dist/components/ui/form/DatePicker.mjs.map +1 -1
- package/dist/components/ui/form/DateRangePicker.mjs +2 -2
- package/dist/components/ui/form/DateRangePicker.mjs.map +1 -1
- package/dist/components/ui/form/FormField.mjs +3 -3
- package/dist/components/ui/form/FormField.mjs.map +1 -1
- package/dist/components/ui/form/Input.mjs.map +1 -1
- package/dist/components/ui/form/InputOtp.mjs +2 -2
- package/dist/components/ui/form/InputOtp.mjs.map +1 -1
- package/dist/components/ui/form/PhoneInput.mjs.map +1 -1
- package/dist/components/ui/form/RadioGroup.mjs +2 -2
- package/dist/components/ui/form/RadioGroup.mjs.map +1 -1
- package/dist/components/ui/form/Select.mjs +6 -6
- package/dist/components/ui/form/Select.mjs.map +1 -1
- package/dist/components/ui/form/Switch.mjs.map +1 -1
- package/dist/components/ui/form/SwitchOptionFieldWithIcon.mjs.map +1 -1
- package/dist/components/ui/form/Textarea.mjs.map +1 -1
- package/dist/components/ui/overlay/Command.mjs +2 -2
- package/dist/components/ui/overlay/Command.mjs.map +1 -1
- package/dist/components/ui/overlay/Dialog.mjs +2 -2
- package/dist/components/ui/overlay/Dialog.mjs.map +1 -1
- package/dist/components/ui/overlay/Popover.mjs.map +1 -1
- package/dist/components/ui/overlay/Sheet.mjs +2 -2
- package/dist/components/ui/overlay/Sheet.mjs.map +1 -1
- package/dist/components/ui/overlay/Tooltip.mjs.map +1 -1
- package/dist/components/widgets/notifications/NotificationCard.mjs +2 -2
- package/dist/components/widgets/notifications/NotificationCard.mjs.map +1 -1
- package/dist/hooks/copy-to-clipboard.hook.mjs.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/middleware.mjs.map +1 -1
- package/dist/modules/accounts/actions/account-management.action.mjs.map +1 -1
- package/dist/modules/accounts/actions/find-current-account.action.mjs.map +1 -1
- package/dist/modules/accounts/actions/list-currencies.action.mjs.map +1 -1
- package/dist/modules/accounts/actions/list-timezones.action.mjs.map +1 -1
- package/dist/modules/accounts/hooks/current-account.hook.mjs.map +1 -1
- package/dist/modules/accounts/hooks/useAccountManagement.mjs.map +1 -1
- package/dist/modules/accounts/hooks/useCurrencies.mjs.map +1 -1
- package/dist/modules/accounts/hooks/useTimezones.mjs.map +1 -1
- package/dist/modules/accounts/services/account.service.mjs.map +1 -1
- package/dist/modules/auth/hooks/login.hook.mjs.map +1 -1
- package/dist/modules/auth/hooks/logout.hook.mjs.map +1 -1
- package/dist/modules/auth/hooks/register.hook.mjs.map +1 -1
- package/dist/modules/ia-credits/actions/list-ia-credits.action.mjs.map +1 -1
- package/dist/modules/projects/actions/add-project-user.action.mjs.map +1 -1
- package/dist/modules/projects/actions/list-all-account-users.action.mjs.map +1 -1
- package/dist/modules/projects/actions/list-available-users.action.mjs.map +1 -1
- package/dist/modules/projects/actions/list-project-users.action.mjs.map +1 -1
- package/dist/modules/projects/actions/remove-project-user.action.mjs.map +1 -1
- package/dist/modules/projects/hooks/add-project-user.hook.mjs.map +1 -1
- package/dist/modules/projects/hooks/list-all-account-users.hook.mjs.map +1 -1
- package/dist/modules/projects/hooks/list-available-users.hook.mjs.map +1 -1
- package/dist/modules/projects/hooks/list-project-users.hook.mjs.map +1 -1
- package/dist/modules/projects/hooks/remove-project-user.hook.mjs.map +1 -1
- package/dist/modules/subscriptions/actions/list-subscriptions.action.mjs.map +1 -1
- package/dist/modules/subscriptions/hooks/find-active-subscription.hook.mjs.map +1 -1
- package/dist/modules/subscriptions/hooks/list-subscriptions.hook.mjs.map +1 -1
- package/dist/modules/users/action/find-user-by-id.action.mjs.map +1 -1
- package/dist/modules/users/action/list-messages.action.mjs.map +1 -1
- package/dist/modules/users/action/mark-all-messages-as-read.action.mjs.map +1 -1
- package/dist/modules/users/action/mark-message-as-read.action.mjs.map +1 -1
- package/dist/modules/users/hooks/messages.hook.mjs.map +1 -1
- package/dist/modules/whitelabel/actions/find-whitelabel-styles.action.mjs.map +1 -1
- package/dist/modules/whitelabel/actions/find-whitelabel.action.mjs.map +1 -1
- package/dist/modules/whitelabel/services/whitelabel-styles.service.mjs.map +1 -1
- package/dist/providers/whitelabel.provider.mjs.map +1 -1
- package/dist/utils/countries.mjs.map +1 -1
- package/dist/utils/safeServerAction.mjs.map +1 -1
- package/dist/utils/withAction.mjs.map +1 -1
- package/package.json +89 -90
- package/src/components/account/ConfigurationsMyAccountModal.tsx +5 -5
- package/src/components/account/ConfirmDeleteAccountModal.tsx +55 -55
- package/src/components/account/ConfirmGlobalPreferencesModal.tsx +2 -2
- package/src/components/account/DeleteAccountModal.tsx +130 -130
- package/src/components/account/DisableTwoFactorAuthModal.tsx +2 -2
- package/src/components/account/IsntPossibleDeleteAccountModal.tsx +49 -49
- package/src/components/account/TwoFactorAuthModal.tsx +6 -6
- package/src/components/account/hooks/useChangePhoneForm.tsx +81 -81
- package/src/components/account/hooks/useTwoFactorAuthForm.tsx +101 -101
- package/src/components/account/sections/ChangeEmailModal.tsx +6 -6
- package/src/components/account/sections/ChangePasswordSection.tsx +4 -4
- package/src/components/account/sections/ChangePhoneModal.tsx +231 -231
- package/src/components/account/sections/MyProfileSection.tsx +3 -3
- package/src/components/account/sections/PreferencesSection.tsx +6 -6
- package/src/components/account/sections/SecuritySection.tsx +3 -3
- package/src/components/embeds/CrispEmbed.tsx +101 -101
- package/src/components/embeds/FrillEmbed.tsx +119 -119
- package/src/components/layouts/AppMobileNavBar.tsx +111 -111
- package/src/components/layouts/AppNavBar.tsx +57 -57
- package/src/components/layouts/MdSideBarNavigation.tsx +4 -4
- package/src/components/layouts/NavBar.tsx +120 -120
- package/src/components/layouts/NotificationsPopover.tsx +4 -4
- package/src/components/layouts/ProfilePopover.tsx +2 -2
- package/src/components/layouts/UsersSelectorPopover.tsx +238 -238
- package/src/components/navigation/CancelledSubscriptionBanner.tsx +69 -69
- package/src/components/navigation/NavItemsContext.ts +20 -20
- package/src/components/navigation/ProjectSelectorPopover.tsx +6 -6
- package/src/components/navigation/shells/TabsMobileShell.tsx +72 -72
- package/src/components/navigation/subcomponents/ProjectSelector.tsx +5 -5
- package/src/components/pages/notifications/Notifications.tsx +160 -160
- package/src/components/ui/buttons/Button.tsx +57 -57
- package/src/components/ui/buttons/CancelButton.tsx +14 -14
- package/src/components/ui/buttons/CopyButton.tsx +54 -54
- package/src/components/ui/data-display/Accordion.tsx +81 -81
- package/src/components/ui/data-display/Badge.tsx +47 -47
- package/src/components/ui/data-display/Card.tsx +93 -93
- package/src/components/ui/data-display/Pagination.tsx +126 -126
- package/src/components/ui/data-display/ScrollArea.tsx +59 -59
- package/src/components/ui/data-display/Separator.tsx +29 -29
- package/src/components/ui/data-display/Table.tsx +117 -117
- package/src/components/ui/data-display/Tabs.tsx +67 -67
- package/src/components/ui/feedback/CircularProgress.tsx +75 -75
- package/src/components/ui/feedback/DefaultCircularProgress.tsx +61 -61
- package/src/components/ui/feedback/LoadingOverlay.tsx +31 -31
- package/src/components/ui/feedback/Progress.tsx +40 -40
- package/src/components/ui/feedback/Toast.tsx +101 -101
- package/src/components/ui/form/Calendar.tsx +228 -228
- package/src/components/ui/form/Checkbox.tsx +31 -31
- package/src/components/ui/form/ComboboxField.tsx +4 -4
- package/src/components/ui/form/DatePicker.tsx +97 -97
- package/src/components/ui/form/DateRangePicker.tsx +108 -108
- package/src/components/ui/form/FormField.tsx +6 -5
- package/src/components/ui/form/Input.tsx +20 -20
- package/src/components/ui/form/InputOtp.tsx +80 -80
- package/src/components/ui/form/PhoneInput.tsx +205 -205
- package/src/components/ui/form/RadioGroup.tsx +45 -45
- package/src/components/ui/form/Select.tsx +200 -200
- package/src/components/ui/form/Switch.tsx +32 -32
- package/src/components/ui/form/SwitchOptionFieldWithIcon.tsx +2 -2
- package/src/components/ui/form/Textarea.tsx +19 -19
- package/src/components/ui/overlay/Command.tsx +185 -185
- package/src/components/ui/overlay/Dialog.tsx +151 -151
- package/src/components/ui/overlay/Popover.tsx +49 -49
- package/src/components/ui/overlay/Sheet.tsx +166 -166
- package/src/components/ui/overlay/Tooltip.tsx +62 -62
- package/src/components/widgets/notifications/NotificationCard.tsx +68 -68
- package/src/hooks/copy-to-clipboard.hook.tsx +67 -67
- package/src/index.ts +355 -355
- package/src/middleware.ts +4 -4
- package/src/modules/accounts/actions/account-management.action.ts +90 -90
- package/src/modules/accounts/actions/find-current-account.action.ts +9 -9
- package/src/modules/accounts/actions/list-currencies.action.ts +8 -8
- package/src/modules/accounts/actions/list-timezones.action.ts +8 -8
- package/src/modules/accounts/hooks/current-account.hook.tsx +22 -22
- package/src/modules/accounts/hooks/useAccountManagement.ts +85 -85
- package/src/modules/accounts/hooks/useCurrencies.ts +15 -15
- package/src/modules/accounts/hooks/useTimezones.ts +15 -15
- package/src/modules/accounts/services/account.service.ts +236 -236
- package/src/modules/accounts/types.ts +214 -214
- package/src/modules/auth/hooks/login.hook.tsx +13 -13
- package/src/modules/auth/hooks/logout.hook.tsx +11 -11
- package/src/modules/auth/hooks/register.hook.tsx +11 -11
- package/src/modules/ia-credits/actions/list-ia-credits.action.ts +8 -8
- package/src/modules/projects/actions/add-project-user.action.ts +9 -9
- package/src/modules/projects/actions/list-all-account-users.action.ts +9 -9
- package/src/modules/projects/actions/list-available-users.action.ts +9 -9
- package/src/modules/projects/actions/list-project-users.action.ts +9 -9
- package/src/modules/projects/actions/remove-project-user.action.ts +9 -9
- package/src/modules/projects/hooks/add-project-user.hook.ts +69 -69
- package/src/modules/projects/hooks/list-all-account-users.hook.ts +34 -34
- package/src/modules/projects/hooks/list-available-users.hook.ts +33 -33
- package/src/modules/projects/hooks/list-project-users.hook.ts +33 -33
- package/src/modules/projects/hooks/remove-project-user.hook.ts +69 -69
- package/src/modules/subscriptions/actions/list-subscriptions.action.ts +9 -9
- package/src/modules/subscriptions/hooks/find-active-subscription.hook.ts +19 -19
- package/src/modules/subscriptions/hooks/list-subscriptions.hook.ts +17 -17
- package/src/modules/users/action/find-user-by-id.action.ts +8 -8
- package/src/modules/users/action/list-messages.action.ts +12 -12
- package/src/modules/users/action/mark-all-messages-as-read.action.ts +8 -8
- package/src/modules/users/action/mark-message-as-read.action.ts +8 -8
- package/src/modules/users/hooks/messages.hook.ts +60 -60
- package/src/modules/whitelabel/actions/find-whitelabel-styles.action.ts +14 -14
- package/src/modules/whitelabel/actions/find-whitelabel.action.ts +23 -23
- package/src/modules/whitelabel/services/whitelabel-styles.service.ts +98 -98
- package/src/modules/whitelabel/styles-schema.ts +37 -37
- package/src/providers/whitelabel.provider.tsx +46 -46
- package/src/utils/countries.ts +224 -224
- package/src/utils/safeServerAction.ts +21 -21
- package/src/utils/withAction.ts +13 -13
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/account/sections/ChangeEmailModal.tsx"],"sourcesContent":["'use client';\r\n\r\nimport { ChevronLeft, X, Mail } from 'lucide-react';\r\nimport { Button } from '../../ui/buttons/Button';\r\nimport { Dialog, DialogContent, DialogHeader, DialogTitle } from '../../ui/overlay/Dialog';\r\nimport { Separator } from '../../ui/data-display/Separator';\r\nimport { InputOTP, InputOTPGroup, InputOTPSlot } from '../../ui/form/InputOtp';\r\nimport { FormField } from '../../ui/form/FormField';\r\nimport { formatTimer } from '../../../utils/format/masks';\r\nimport { OTP_CODE_LENGTH } from '../../../utils/validators/account';\r\nimport { useAuth } from '../../../providers/auth.provider';\r\nimport { useInvalidateUser } from '../../../modules/auth/hooks/useUserQuery';\r\nimport { confirmEmailChangeAction } from '../../../modules/accounts/actions/account-management.action';\r\nimport useChangeEmailForm from '../hooks/useChangeEmailForm';\r\nimport useOtpVerification from '../hooks/useOtpVerification';\r\n\r\ninterface ChangeEmailModalProps {\r\n open: boolean;\r\n onClose: () => void;\r\n}\r\n\r\nexport function ChangeEmailModal({ open, onClose }: ChangeEmailModalProps) {\r\n const { user } = useAuth();\r\n const invalidateUser = useInvalidateUser();\r\n\r\n const {\r\n showVerification,\r\n emailToVerify,\r\n isSubmitting,\r\n errors,\r\n register,\r\n handleContinue,\r\n handleBack,\r\n resetForm,\r\n } = useChangeEmailForm();\r\n\r\n const handleSuccess = () => {\r\n invalidateUser();\r\n resetForm();\r\n onClose();\r\n };\r\n\r\n const {\r\n code,\r\n isLoading,\r\n hasError,\r\n timer,\r\n canResend,\r\n isValidLength,\r\n handleCodeChange,\r\n handleValidate,\r\n handleResend,\r\n reset: resetOtp,\r\n } = useOtpVerification({\r\n onSuccess: handleSuccess,\r\n successMessage: 'E-mail alterado com sucesso',\r\n validateFn: async (token) => {\r\n const result = await confirmEmailChangeAction(token, emailToVerify);\r\n return result.success;\r\n },\r\n resendFn: async () => {\r\n const { requestEmailChangeAction } = await import('../../../modules/accounts/actions/account-management.action');\r\n const result = await requestEmailChangeAction(emailToVerify);\r\n if (!result.success) {\r\n throw new Error(result.error);\r\n }\r\n },\r\n });\r\n\r\n const handleClose = () => {\r\n resetForm();\r\n resetOtp();\r\n onClose();\r\n };\r\n\r\n const handleBackFromVerification = () => {\r\n resetOtp();\r\n handleBack();\r\n };\r\n\r\n return (\r\n <Dialog open={open} onOpenChange={handleClose}>\r\n <DialogContent\r\n showCloseButton={false}\r\n overlayClassName=\"z-[1002]\"\r\n 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-125! 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%]! z-[1003]!\"\r\n >\r\n {showVerification ? (\r\n <DialogHeader className=\"flex flex-row items-center justify-between px-4 py-3 border-b border-gray-200 lg:border-b-0\">\r\n <Button variant=\"ghost\" className=\"size-8! p-0\" onClick={handleBackFromVerification}>\r\n <ChevronLeft size={20} className=\"text-gray-950\" />\r\n </Button>\r\n <DialogTitle className=\"paragraph-medium-semibold text-gray-950 text-center flex-1\">\r\n Alterar e-mail\r\n </DialogTitle>\r\n <Button variant=\"ghost\" className=\"size-8! p-0\" onClick={handleClose}>\r\n <X size={18} className=\"text-gray-500\" />\r\n </Button>\r\n </DialogHeader>\r\n ) : (\r\n <>\r\n <DialogHeader className=\"sr-only\">\r\n <DialogTitle>Alterar e-mail</DialogTitle>\r\n </DialogHeader>\r\n <div className=\"flex items-center justify-center px-4 py-3 relative border-b border-gray-200 lg:border-b-0\">\r\n <span className=\"paragraph-medium-semibold text-gray-950 text-center\">\r\n Alterar e-mail\r\n </span>\r\n <Button\r\n variant=\"ghost\"\r\n className=\"absolute right-2 size-8! p-0\"\r\n onClick={handleClose}\r\n >\r\n <X size={18} className=\"text-gray-500\" />\r\n </Button>\r\n </div>\r\n </>\r\n )}\r\n\r\n <div className={`${showVerification ? 'w-full' : 'w-1/2'} h-0.75 bg-pages-300`} />\r\n\r\n {showVerification ? (\r\n <form\r\n onSubmit={(e) => {\r\n e.preventDefault();\r\n handleValidate();\r\n }}\r\n className=\"flex flex-col flex-1 lg:flex-none\"\r\n >\r\n <div className=\"px-4 lg:px-5 py-5 lg:py-6 flex flex-col gap-4 flex-1 lg:flex-none\">\r\n <div className=\"flex items-center justify-center size-12 bg-white rounded-lg shadow-xs border border-gray-200\">\r\n <Mail size={20} className=\"text-gray-950\" />\r\n </div>\r\n\r\n <div className=\"flex flex-col gap-1\">\r\n <h3 className=\"paragraph-medium-semibold text-gray-950\">Código de validação</h3>\r\n <p className=\"paragraph-small-regular text-gray-600\">\r\n Enviamos um código de validação para o E-mail{' '}\r\n <span className=\"font-semibold text-gray-950 break-all\">{user?.email}.</span>\r\n </p>\r\n </div>\r\n\r\n <div className=\"flex flex-col gap-2\">\r\n <InputOTP maxLength={OTP_CODE_LENGTH} value={code} onChange={handleCodeChange}>\r\n <InputOTPGroup className=\"flex flex-row gap-2\">\r\n {[...Array(OTP_CODE_LENGTH)].map((_, i) => (\r\n <InputOTPSlot\r\n key={i}\r\n index={i}\r\n className={`uppercase text-2xl font-medium w-11 lg:w-12 h-13 lg:h-14 rounded-lg border bg-white shadow-none [&_div.animate-caret-blink]:bg-gray-950 ${hasError ? 'border-red-500' : 'border-gray-200'}`}\r\n />\r\n ))}\r\n </InputOTPGroup>\r\n </InputOTP>\r\n {hasError && (\r\n <p className=\"paragraph-small-regular text-red-500\">Código incorreto</p>\r\n )}\r\n </div>\r\n\r\n {canResend ? (\r\n <button\r\n type=\"button\"\r\n onClick={handleResend}\r\n className=\"paragraph-small-medium text-gray-950 underline cursor-pointer hover:text-gray-700 w-fit\"\r\n >\r\n Reenviar código\r\n </button>\r\n ) : (\r\n <p className=\"paragraph-small-regular text-gray-500\">\r\n Reenviar em{' '}\r\n <span className=\"paragraph-small-semibold text-gray-950\">\r\n {formatTimer(timer)}\r\n </span>\r\n </p>\r\n )}\r\n </div>\r\n\r\n <Separator />\r\n\r\n <div className=\"flex items-center justify-between px-4 lg:px-5 py-4 lg:py-5 mt-auto lg:mt-0\">\r\n <Button variant=\"secondary\" className=\"h-10!\" type=\"button\" onClick={handleClose}>\r\n Cancelar\r\n </Button>\r\n <Button className=\"h-10!\" type=\"submit\" disabled={!isValidLength || isLoading}>\r\n {isLoading ? 'Validando...' : 'Alterar e-mail'}\r\n </Button>\r\n </div>\r\n </form>\r\n ) : (\r\n <form onSubmit={handleContinue} className=\"flex flex-col flex-1 lg:flex-none\">\r\n <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\">\r\n <div className=\"flex flex-col gap-1\">\r\n <span className=\"paragraph-medium-semibold text-gray-950\">\r\n Atualizar E-mail de contato\r\n </span>\r\n <span className=\"paragraph-small-regular text-gray-600\">\r\n Informe o seu novo E-mail para manter seu contato atualizado.\r\n </span>\r\n </div>\r\n\r\n <FormField\r\n label=\"Novo e-mail\"\r\n placeholder=\"Digite seu novo e-mail\"\r\n type=\"email\"\r\n {...register('email')}\r\n error={!!errors.email}\r\n errorMessage={errors.email?.message}\r\n leftIcon={Mail}\r\n />\r\n </div>\r\n\r\n <div className=\"flex items-center justify-between p-4 lg:p-5 border-t border-gray-200 mt-auto lg:mt-0\">\r\n <Button variant=\"secondary\" className=\"h-10!\" type=\"button\" onClick={handleClose}>\r\n Cancelar\r\n </Button>\r\n <Button className=\"h-10!\" type=\"submit\" disabled={isSubmitting}>\r\n {isSubmitting ? 'Enviando...' : 'Continuar'}\r\n </Button>\r\n </div>\r\n </form>\r\n )}\r\n </DialogContent>\r\n </Dialog>\r\n );\r\n}\r\n"],"mappings":";AAwFU,SAYA,UAVI,KAFJ;AAtFV,SAAS,aAAa,GAAG,YAAY;AACrC,SAAS,cAAc;AACvB,SAAS,QAAQ,eAAe,cAAc,mBAAmB;AACjE,SAAS,iBAAiB;AAC1B,SAAS,UAAU,eAAe,oBAAoB;AACtD,SAAS,iBAAiB;AAC1B,SAAS,mBAAmB;AAC5B,SAAS,uBAAuB;AAChC,SAAS,eAAe;AACxB,SAAS,yBAAyB;AAClC,SAAS,gCAAgC;AACzC,OAAO,wBAAwB;AAC/B,OAAO,wBAAwB;AAOxB,SAAS,iBAAiB,EAAE,MAAM,QAAQ,GAA0B;AACzE,QAAM,EAAE,KAAK,IAAI,QAAQ;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oBAAC,UAAO,WAAU,SAAQ,MAAK,UAAS,UAAU,cAC/C,yBAAe,gBAAgB,aAClC;AAAA,aACF;AAAA,WACF;AAAA;AAAA;AAAA,EAEJ,GACF;AAEJ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/account/sections/ChangeEmailModal.tsx"],"sourcesContent":["'use client';\r\n\r\nimport { IconChevronLeft, IconX, IconMail } from '@tabler/icons-react';\r\nimport { Button } from '../../ui/buttons/Button';\r\nimport { Dialog, DialogContent, DialogHeader, DialogTitle } from '../../ui/overlay/Dialog';\r\nimport { Separator } from '../../ui/data-display/Separator';\r\nimport { InputOTP, InputOTPGroup, InputOTPSlot } from '../../ui/form/InputOtp';\r\nimport { FormField } from '../../ui/form/FormField';\r\nimport { formatTimer } from '../../../utils/format/masks';\r\nimport { OTP_CODE_LENGTH } from '../../../utils/validators/account';\r\nimport { useAuth } from '../../../providers/auth.provider';\r\nimport { useInvalidateUser } from '../../../modules/auth/hooks/useUserQuery';\r\nimport { confirmEmailChangeAction } from '../../../modules/accounts/actions/account-management.action';\r\nimport useChangeEmailForm from '../hooks/useChangeEmailForm';\r\nimport useOtpVerification from '../hooks/useOtpVerification';\r\n\r\ninterface ChangeEmailModalProps {\r\n open: boolean;\r\n onClose: () => void;\r\n}\r\n\r\nexport function ChangeEmailModal({ open, onClose }: ChangeEmailModalProps) {\r\n const { user } = useAuth();\r\n const invalidateUser = useInvalidateUser();\r\n\r\n const {\r\n showVerification,\r\n emailToVerify,\r\n isSubmitting,\r\n errors,\r\n register,\r\n handleContinue,\r\n handleBack,\r\n resetForm,\r\n } = useChangeEmailForm();\r\n\r\n const handleSuccess = () => {\r\n invalidateUser();\r\n resetForm();\r\n onClose();\r\n };\r\n\r\n const {\r\n code,\r\n isLoading,\r\n hasError,\r\n timer,\r\n canResend,\r\n isValidLength,\r\n handleCodeChange,\r\n handleValidate,\r\n handleResend,\r\n reset: resetOtp,\r\n } = useOtpVerification({\r\n onSuccess: handleSuccess,\r\n successMessage: 'E-mail alterado com sucesso',\r\n validateFn: async (token) => {\r\n const result = await confirmEmailChangeAction(token, emailToVerify);\r\n return result.success;\r\n },\r\n resendFn: async () => {\r\n const { requestEmailChangeAction } = await import('../../../modules/accounts/actions/account-management.action');\r\n const result = await requestEmailChangeAction(emailToVerify);\r\n if (!result.success) {\r\n throw new Error(result.error);\r\n }\r\n },\r\n });\r\n\r\n const handleClose = () => {\r\n resetForm();\r\n resetOtp();\r\n onClose();\r\n };\r\n\r\n const handleBackFromVerification = () => {\r\n resetOtp();\r\n handleBack();\r\n };\r\n\r\n return (\r\n <Dialog open={open} onOpenChange={handleClose}>\r\n <DialogContent\r\n showCloseButton={false}\r\n overlayClassName=\"z-[1002]\"\r\n 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-125! 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%]! z-[1003]!\"\r\n >\r\n {showVerification ? (\r\n <DialogHeader className=\"flex flex-row items-center justify-between px-4 py-3 border-b border-gray-200 lg:border-b-0\">\r\n <Button variant=\"ghost\" className=\"size-8! p-0\" onClick={handleBackFromVerification}>\r\n <IconChevronLeft size={20} className=\"text-gray-950\" />\r\n </Button>\r\n <DialogTitle className=\"paragraph-medium-semibold text-gray-950 text-center flex-1\">\r\n Alterar e-mail\r\n </DialogTitle>\r\n <Button variant=\"ghost\" className=\"size-8! p-0\" onClick={handleClose}>\r\n <IconX size={18} className=\"text-gray-500\" />\r\n </Button>\r\n </DialogHeader>\r\n ) : (\r\n <>\r\n <DialogHeader className=\"sr-only\">\r\n <DialogTitle>Alterar e-mail</DialogTitle>\r\n </DialogHeader>\r\n <div className=\"flex items-center justify-center px-4 py-3 relative border-b border-gray-200 lg:border-b-0\">\r\n <span className=\"paragraph-medium-semibold text-gray-950 text-center\">\r\n Alterar e-mail\r\n </span>\r\n <Button\r\n variant=\"ghost\"\r\n className=\"absolute right-2 size-8! p-0\"\r\n onClick={handleClose}\r\n >\r\n <IconX size={18} className=\"text-gray-500\" />\r\n </Button>\r\n </div>\r\n </>\r\n )}\r\n\r\n <div className={`${showVerification ? 'w-full' : 'w-1/2'} h-0.75 bg-pages-300`} />\r\n\r\n {showVerification ? (\r\n <form\r\n onSubmit={(e) => {\r\n e.preventDefault();\r\n handleValidate();\r\n }}\r\n className=\"flex flex-col flex-1 lg:flex-none\"\r\n >\r\n <div className=\"px-4 lg:px-5 py-5 lg:py-6 flex flex-col gap-4 flex-1 lg:flex-none\">\r\n <div className=\"flex items-center justify-center size-12 bg-white rounded-lg shadow-xs border border-gray-200\">\r\n <IconMail size={20} className=\"text-gray-950\" />\r\n </div>\r\n\r\n <div className=\"flex flex-col gap-1\">\r\n <h3 className=\"paragraph-medium-semibold text-gray-950\">Código de validação</h3>\r\n <p className=\"paragraph-small-regular text-gray-600\">\r\n Enviamos um código de validação para o E-mail{' '}\r\n <span className=\"font-semibold text-gray-950 break-all\">{user?.email}.</span>\r\n </p>\r\n </div>\r\n\r\n <div className=\"flex flex-col gap-2\">\r\n <InputOTP maxLength={OTP_CODE_LENGTH} value={code} onChange={handleCodeChange}>\r\n <InputOTPGroup className=\"flex flex-row gap-2\">\r\n {[...Array(OTP_CODE_LENGTH)].map((_, i) => (\r\n <InputOTPSlot\r\n key={i}\r\n index={i}\r\n className={`uppercase text-2xl font-medium w-11 lg:w-12 h-13 lg:h-14 rounded-lg border bg-white shadow-none [&_div.animate-caret-blink]:bg-gray-950 ${hasError ? 'border-red-500' : 'border-gray-200'}`}\r\n />\r\n ))}\r\n </InputOTPGroup>\r\n </InputOTP>\r\n {hasError && (\r\n <p className=\"paragraph-small-regular text-red-500\">Código incorreto</p>\r\n )}\r\n </div>\r\n\r\n {canResend ? (\r\n <button\r\n type=\"button\"\r\n onClick={handleResend}\r\n className=\"paragraph-small-medium text-gray-950 underline cursor-pointer hover:text-gray-700 w-fit\"\r\n >\r\n Reenviar código\r\n </button>\r\n ) : (\r\n <p className=\"paragraph-small-regular text-gray-500\">\r\n Reenviar em{' '}\r\n <span className=\"paragraph-small-semibold text-gray-950\">\r\n {formatTimer(timer)}\r\n </span>\r\n </p>\r\n )}\r\n </div>\r\n\r\n <Separator />\r\n\r\n <div className=\"flex items-center justify-between px-4 lg:px-5 py-4 lg:py-5 mt-auto lg:mt-0\">\r\n <Button variant=\"secondary\" className=\"h-10!\" type=\"button\" onClick={handleClose}>\r\n Cancelar\r\n </Button>\r\n <Button className=\"h-10!\" type=\"submit\" disabled={!isValidLength || isLoading}>\r\n {isLoading ? 'Validando...' : 'Alterar e-mail'}\r\n </Button>\r\n </div>\r\n </form>\r\n ) : (\r\n <form onSubmit={handleContinue} className=\"flex flex-col flex-1 lg:flex-none\">\r\n <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\">\r\n <div className=\"flex flex-col gap-1\">\r\n <span className=\"paragraph-medium-semibold text-gray-950\">\r\n Atualizar E-mail de contato\r\n </span>\r\n <span className=\"paragraph-small-regular text-gray-600\">\r\n Informe o seu novo E-mail para manter seu contato atualizado.\r\n </span>\r\n </div>\r\n\r\n <FormField\r\n label=\"Novo e-mail\"\r\n placeholder=\"Digite seu novo e-mail\"\r\n type=\"email\"\r\n {...register('email')}\r\n error={!!errors.email}\r\n errorMessage={errors.email?.message}\r\n leftIcon={IconMail}\r\n />\r\n </div>\r\n\r\n <div className=\"flex items-center justify-between p-4 lg:p-5 border-t border-gray-200 mt-auto lg:mt-0\">\r\n <Button variant=\"secondary\" className=\"h-10!\" type=\"button\" onClick={handleClose}>\r\n Cancelar\r\n </Button>\r\n <Button className=\"h-10!\" type=\"submit\" disabled={isSubmitting}>\r\n {isSubmitting ? 'Enviando...' : 'Continuar'}\r\n </Button>\r\n </div>\r\n </form>\r\n )}\r\n </DialogContent>\r\n </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;AAAA,kCAAC,UAAK,WAAU,2CAA0C,yCAE1D;AAAA,cACA,oBAAC,UAAK,WAAU,yCAAwC,2EAExD;AAAA,eACF;AAAA,YAEA;AAAA,cAAC;AAAA;AAAA,gBACC,OAAM;AAAA,gBACN,aAAY;AAAA,gBACZ,MAAK;AAAA,gBACJ,GAAG,SAAS,OAAO;AAAA,gBACpB,OAAO,CAAC,CAAC,OAAO;AAAA,gBAChB,cAAc,OAAO,OAAO;AAAA,gBAC5B,UAAU;AAAA;AAAA,YACZ;AAAA,aACF;AAAA,UAEA,qBAAC,SAAI,WAAU,yFACb;AAAA,gCAAC,UAAO,SAAQ,aAAY,WAAU,SAAQ,MAAK,UAAS,SAAS,aAAa,sBAElF;AAAA,YACA,oBAAC,UAAO,WAAU,SAAQ,MAAK,UAAS,UAAU,cAC/C,yBAAe,gBAAgB,aAClC;AAAA,aACF;AAAA,WACF;AAAA;AAAA;AAAA,EAEJ,GACF;AAEJ;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
-
import {
|
|
3
|
+
import { IconArrowLeft, IconLock } from "@tabler/icons-react";
|
|
4
4
|
import { Button } from "../../ui/buttons/Button";
|
|
5
5
|
import { FormField } from "../../ui/form/FormField";
|
|
6
6
|
import useChangePasswordForm from "../hooks/useChangePasswordForm";
|
|
@@ -18,7 +18,7 @@ function ChangePasswordSection({ onBack }) {
|
|
|
18
18
|
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",
|
|
19
19
|
children: [
|
|
20
20
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
|
|
21
|
-
/* @__PURE__ */ jsx(Button, { type: "button", variant: "ghost", className: "size-8! p-0", onClick: onBack, children: /* @__PURE__ */ jsx(
|
|
21
|
+
/* @__PURE__ */ jsx(Button, { type: "button", variant: "ghost", className: "size-8! p-0", onClick: onBack, children: /* @__PURE__ */ jsx(IconArrowLeft, { size: 20 }) }),
|
|
22
22
|
/* @__PURE__ */ jsx("span", { className: "paragraph-medium-semibold text-gray-950", children: "Alterar senha" })
|
|
23
23
|
] }),
|
|
24
24
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-4", children: [
|
|
@@ -28,7 +28,7 @@ function ChangePasswordSection({ onBack }) {
|
|
|
28
28
|
label: "Senha atual",
|
|
29
29
|
type: "password",
|
|
30
30
|
placeholder: "Digite sua senha atual",
|
|
31
|
-
leftIcon:
|
|
31
|
+
leftIcon: IconLock,
|
|
32
32
|
error: !!errors.currentPassword,
|
|
33
33
|
errorMessage: errors.currentPassword?.message,
|
|
34
34
|
classnameContainer: "h-10!",
|
|
@@ -43,7 +43,7 @@ function ChangePasswordSection({ onBack }) {
|
|
|
43
43
|
label: "Nova senha",
|
|
44
44
|
type: "password",
|
|
45
45
|
placeholder: "Digite sua nova senha",
|
|
46
|
-
leftIcon:
|
|
46
|
+
leftIcon: IconLock,
|
|
47
47
|
error: !!errors.newPassword,
|
|
48
48
|
errorMessage: errors.newPassword?.message,
|
|
49
49
|
classnameContainer: "h-10!",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/account/sections/ChangePasswordSection.tsx"],"sourcesContent":["'use client';\r\n\r\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/account/sections/ChangePasswordSection.tsx"],"sourcesContent":["'use client';\r\n\r\nimport { IconArrowLeft, IconLock } from '@tabler/icons-react';\r\nimport { Button } from '../../ui/buttons/Button';\r\nimport { FormField } from '../../ui/form/FormField';\r\nimport useChangePasswordForm from '../hooks/useChangePasswordForm';\r\nimport usePasswordVisibility from '../../../hooks/usePasswordVisibility';\r\n\r\ninterface ChangePasswordSectionProps {\r\n onBack: () => void;\r\n}\r\n\r\nexport function ChangePasswordSection({ onBack }: ChangePasswordSectionProps) {\r\n const { register, handleSubmit, errors } = useChangePasswordForm({\r\n onSuccess: onBack,\r\n });\r\n const { showPassword: showCurrentPw, togglePassword: toggleCurrentPw } = usePasswordVisibility();\r\n const { showPassword: showNewPw, togglePassword: toggleNewPw } = usePasswordVisibility();\r\n\r\n return (\r\n <form\r\n onSubmit={handleSubmit}\r\n 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\"\r\n >\r\n <div className=\"flex items-center gap-3\">\r\n <Button type=\"button\" variant=\"ghost\" className=\"size-8! p-0\" onClick={onBack}>\r\n <IconArrowLeft size={20} />\r\n </Button>\r\n <span className=\"paragraph-medium-semibold text-gray-950\">Alterar senha</span>\r\n </div>\r\n\r\n <div className=\"flex flex-col gap-4\">\r\n <FormField\r\n label=\"Senha atual\"\r\n type=\"password\"\r\n placeholder=\"Digite sua senha atual\"\r\n leftIcon={IconLock}\r\n error={!!errors.currentPassword}\r\n errorMessage={errors.currentPassword?.message}\r\n classnameContainer=\"h-10!\"\r\n showPassword={showCurrentPw}\r\n onTogglePassword={toggleCurrentPw}\r\n {...register('currentPassword')}\r\n />\r\n <FormField\r\n label=\"Nova senha\"\r\n type=\"password\"\r\n placeholder=\"Digite sua nova senha\"\r\n leftIcon={IconLock}\r\n error={!!errors.newPassword}\r\n errorMessage={errors.newPassword?.message}\r\n classnameContainer=\"h-10!\"\r\n showPassword={showNewPw}\r\n onTogglePassword={toggleNewPw}\r\n {...register('newPassword')}\r\n />\r\n </div>\r\n\r\n <Button type=\"submit\" className=\"w-fit h-10!\">\r\n Salvar nova senha\r\n </Button>\r\n </form>\r\n );\r\n}\r\n"],"mappings":";AAwBM,SAEI,KAFJ;AAtBN,SAAS,eAAe,gBAAgB;AACxC,SAAS,cAAc;AACvB,SAAS,iBAAiB;AAC1B,OAAO,2BAA2B;AAClC,OAAO,2BAA2B;AAM3B,SAAS,sBAAsB,EAAE,OAAO,GAA+B;AAC5E,QAAM,EAAE,UAAU,cAAc,OAAO,IAAI,sBAAsB;AAAA,IAC/D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IconMessage } from "@tabler/icons-react";
|
|
4
4
|
import { Button } from "../../ui/buttons/Button";
|
|
5
5
|
import { Dialog, DialogContent, DialogHeader, DialogTitle } from "../../ui/overlay/Dialog";
|
|
6
6
|
import { Separator } from "../../ui/data-display/Separator";
|
|
@@ -78,9 +78,9 @@ function ChangePhoneModal({ open, onClose }) {
|
|
|
78
78
|
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-125! 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%]! z-[1003]!",
|
|
79
79
|
children: [
|
|
80
80
|
showVerification ? /* @__PURE__ */ jsxs(DialogHeader, { className: "flex flex-row items-center justify-between px-4 py-3 border-b border-gray-200 lg:border-b-0", children: [
|
|
81
|
-
/* @__PURE__ */ jsx(Button, { variant: "ghost", className: "size-8! p-0", onClick: handleBackFromVerification, children: /* @__PURE__ */ jsx(
|
|
81
|
+
/* @__PURE__ */ jsx(Button, { variant: "ghost", className: "size-8! p-0", onClick: handleBackFromVerification, children: /* @__PURE__ */ jsx(IconChevronLeft, { size: 20, className: "text-gray-950" }) }),
|
|
82
82
|
/* @__PURE__ */ jsx(DialogTitle, { className: "paragraph-medium-semibold text-gray-950 text-center flex-1", children: "Alterar telefone" }),
|
|
83
|
-
/* @__PURE__ */ jsx(Button, { variant: "ghost", className: "size-8! p-0", onClick: handleClose, children: /* @__PURE__ */ jsx(
|
|
83
|
+
/* @__PURE__ */ jsx(Button, { variant: "ghost", className: "size-8! p-0", onClick: handleClose, children: /* @__PURE__ */ jsx(IconX, { size: 18, className: "text-gray-500" }) })
|
|
84
84
|
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
85
85
|
/* @__PURE__ */ jsx(DialogHeader, { className: "sr-only", children: /* @__PURE__ */ jsx(DialogTitle, { children: "Alterar telefone" }) }),
|
|
86
86
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center px-4 py-3 relative border-b border-gray-200 lg:border-b-0", children: [
|
|
@@ -91,7 +91,7 @@ function ChangePhoneModal({ open, onClose }) {
|
|
|
91
91
|
variant: "ghost",
|
|
92
92
|
className: "absolute right-2 size-8! p-0",
|
|
93
93
|
onClick: handleClose,
|
|
94
|
-
children: /* @__PURE__ */ jsx(
|
|
94
|
+
children: /* @__PURE__ */ jsx(IconX, { size: 18, className: "text-gray-500" })
|
|
95
95
|
}
|
|
96
96
|
)
|
|
97
97
|
] })
|
|
@@ -107,7 +107,7 @@ function ChangePhoneModal({ open, onClose }) {
|
|
|
107
107
|
className: "flex flex-col flex-1 lg:flex-none",
|
|
108
108
|
children: [
|
|
109
109
|
/* @__PURE__ */ jsxs("div", { className: "px-4 lg:px-5 py-5 lg:py-6 flex flex-col gap-4 flex-1 lg:flex-none", children: [
|
|
110
|
-
/* @__PURE__ */ jsx("div", { className: "flex items-center justify-center size-12 bg-white rounded-lg shadow-xs border border-gray-200", children: /* @__PURE__ */ jsx(
|
|
110
|
+
/* @__PURE__ */ jsx("div", { className: "flex items-center justify-center size-12 bg-white rounded-lg shadow-xs border border-gray-200", children: /* @__PURE__ */ jsx(IconMessage, { size: 20, className: "text-gray-950" }) }),
|
|
111
111
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
112
112
|
/* @__PURE__ */ jsx("h3", { className: "paragraph-medium-semibold text-gray-950", children: "C\xF3digo de valida\xE7\xE3o" }),
|
|
113
113
|
/* @__PURE__ */ jsxs("p", { className: "paragraph-small-regular text-gray-600", children: [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/account/sections/ChangePhoneModal.tsx"],"sourcesContent":["'use client';\n\nimport { ChevronLeft, X, MessageSquare } from 'lucide-react';\nimport { Button } from '../../ui/buttons/Button';\nimport { Dialog, DialogContent, DialogHeader, DialogTitle } from '../../ui/overlay/Dialog';\nimport { Separator } from '../../ui/data-display/Separator';\nimport { InputOTP, InputOTPGroup, InputOTPSlot } from '../../ui/form/InputOtp';\nimport PhoneInput from '../../ui/form/PhoneInput';\nimport { formatTimer, formatPhone } from '../../../utils/format/masks';\nimport { OTP_CODE_LENGTH } from '../../../utils/validators/account';\nimport { useAuth } from '../../../providers/auth.provider';\nimport { useInvalidateUser } from '../../../modules/auth/hooks/useUserQuery';\nimport { confirmPhoneChangeAction } from '../../../modules/accounts/actions/account-management.action';\nimport useChangePhoneForm from '../hooks/useChangePhoneForm';\nimport useOtpVerification from '../hooks/useOtpVerification';\n\ninterface ChangePhoneModalProps {\n open: boolean;\n onClose: () => void;\n}\n\nexport function ChangePhoneModal({ open, onClose }: ChangePhoneModalProps) {\n const { user } = useAuth();\n const invalidateUser = useInvalidateUser();\n\n const currentPhoneDisplay = user?.phone\n ? formatPhone(\n user.ddi && user.phone.startsWith(user.ddi) ? user.phone.slice(user.ddi.length) : user.phone\n )\n : '';\n\n const {\n showVerification,\n phoneValue,\n phoneError,\n isSubmitting,\n submittedPhone,\n handlePhoneChange,\n handleContinue,\n handleBack,\n resetForm,\n } = useChangePhoneForm();\n\n const handleSuccess = () => {\n invalidateUser();\n resetForm();\n onClose();\n };\n\n const {\n code,\n isLoading,\n hasError,\n timer,\n canResend,\n isValidLength,\n handleCodeChange,\n handleValidate,\n handleResend,\n reset: resetOtp,\n } = useOtpVerification({\n onSuccess: handleSuccess,\n successMessage: 'Telefone alterado',\n validateFn: async (token) => {\n const result = await confirmPhoneChangeAction(token, submittedPhone.local, submittedPhone.ddi);\n return result.success;\n },\n resendFn: async () => {\n const { requestPhoneChangeAction } = await import('../../../modules/accounts/actions/account-management.action');\n const result = await requestPhoneChangeAction(submittedPhone.local, submittedPhone.ddi);\n if (!result.success) {\n throw new Error(result.error);\n }\n },\n });\n\n const handleClose = () => {\n resetForm();\n resetOtp();\n onClose();\n };\n\n const handleBackFromVerification = () => {\n resetOtp();\n handleBack();\n };\n\n return (\n <Dialog open={open} onOpenChange={handleClose}>\n <DialogContent\n showCloseButton={false}\n overlayClassName=\"z-[1002]\"\n 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-125! 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%]! z-[1003]!\"\n >\n {showVerification ? (\n <DialogHeader className=\"flex flex-row items-center justify-between px-4 py-3 border-b border-gray-200 lg:border-b-0\">\n <Button variant=\"ghost\" className=\"size-8! p-0\" onClick={handleBackFromVerification}>\n <ChevronLeft size={20} className=\"text-gray-950\" />\n </Button>\n <DialogTitle className=\"paragraph-medium-semibold text-gray-950 text-center flex-1\">\n Alterar telefone\n </DialogTitle>\n <Button variant=\"ghost\" className=\"size-8! p-0\" onClick={handleClose}>\n <X size={18} className=\"text-gray-500\" />\n </Button>\n </DialogHeader>\n ) : (\n <>\n <DialogHeader className=\"sr-only\">\n <DialogTitle>Alterar telefone</DialogTitle>\n </DialogHeader>\n <div className=\"flex items-center justify-center px-4 py-3 relative border-b border-gray-200 lg:border-b-0\">\n <span className=\"paragraph-medium-semibold text-gray-950 text-center\">\n Alterar telefone\n </span>\n <Button\n variant=\"ghost\"\n className=\"absolute right-2 size-8! p-0\"\n onClick={handleClose}\n >\n <X size={18} className=\"text-gray-500\" />\n </Button>\n </div>\n </>\n )}\n\n <div className={`${showVerification ? 'w-full' : 'w-1/2'} h-0.75 bg-pages-300`} />\n\n {showVerification ? (\n <form\n onSubmit={(e) => {\n e.preventDefault();\n handleValidate();\n }}\n className=\"flex flex-col flex-1 lg:flex-none\"\n >\n <div className=\"px-4 lg:px-5 py-5 lg:py-6 flex flex-col gap-4 flex-1 lg:flex-none\">\n <div className=\"flex items-center justify-center size-12 bg-white rounded-lg shadow-xs border border-gray-200\">\n <MessageSquare size={20} className=\"text-gray-950\" />\n </div>\n\n <div className=\"flex flex-col gap-1\">\n <h3 className=\"paragraph-medium-semibold text-gray-950\">Código de validação</h3>\n <p className=\"paragraph-small-regular text-gray-600\">\n Enviamos um código de validação para o número atual{' '}\n <span className=\"font-semibold text-gray-950\">{currentPhoneDisplay}.</span>\n </p>\n </div>\n\n <div className=\"flex flex-col gap-2\">\n <InputOTP maxLength={OTP_CODE_LENGTH} value={code} onChange={handleCodeChange}>\n <InputOTPGroup className=\"flex flex-row gap-2\">\n {[...Array(OTP_CODE_LENGTH)].map((_, i) => (\n <InputOTPSlot\n key={i}\n index={i}\n className={`uppercase text-2xl font-medium w-11 lg:w-12 h-13 lg:h-14 rounded-lg border bg-white shadow-none [&_div.animate-caret-blink]:bg-gray-950 ${hasError ? 'border-red-500' : 'border-gray-200'}`}\n />\n ))}\n </InputOTPGroup>\n </InputOTP>\n {hasError && (\n <p className=\"paragraph-small-regular text-red-500\">Código incorreto</p>\n )}\n </div>\n\n {canResend ? (\n <button\n type=\"button\"\n onClick={handleResend}\n className=\"paragraph-small-medium text-gray-950 underline cursor-pointer hover:text-gray-700 w-fit\"\n >\n Reenviar código\n </button>\n ) : (\n <p className=\"paragraph-small-regular text-gray-500\">\n Reenviar em{' '}\n <span className=\"paragraph-small-semibold text-gray-950\">\n {formatTimer(timer)}\n </span>\n </p>\n )}\n </div>\n\n <Separator />\n\n <div className=\"flex items-center justify-between px-4 lg:px-5 py-4 lg:py-5 mt-auto lg:mt-0\">\n <Button variant=\"secondary\" className=\"h-10!\" type=\"button\" onClick={handleClose}>\n Cancelar\n </Button>\n <Button className=\"h-10!\" type=\"submit\" disabled={!isValidLength || isLoading}>\n {isLoading ? 'Validando...' : 'Alterar telefone'}\n </Button>\n </div>\n </form>\n ) : (\n <form onSubmit={handleContinue} className=\"flex flex-col flex-1 lg:flex-none\">\n <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\">\n <div className=\"flex flex-col gap-1\">\n <span className=\"paragraph-medium-semibold text-gray-950\">\n Atualizar telefone de contato\n </span>\n <span className=\"paragraph-small-regular text-gray-600\">\n Informe o novo número para manter seu contato atualizado.\n </span>\n </div>\n\n <PhoneInput\n label=\"Novo número\"\n placeholder=\"(00) 0 0000-0000\"\n value={phoneValue}\n onChange={handlePhoneChange}\n error={!!phoneError}\n errorMessage={phoneError}\n />\n </div>\n\n <div className=\"flex items-center justify-between p-4 lg:p-5 border-t border-gray-200 mt-auto lg:mt-0\">\n <Button variant=\"secondary\" className=\"h-10!\" type=\"button\" onClick={handleClose}>\n Cancelar\n </Button>\n <Button className=\"h-10!\" type=\"submit\" disabled={isSubmitting}>\n {isSubmitting ? 'Enviando...' : 'Continuar'}\n </Button>\n </div>\n </form>\n )}\n </DialogContent>\n </Dialog>\n );\n}\n"],"mappings":";AA+FU,SAYA,UAVI,KAFJ;AA7FV,SAAS,aAAa,GAAG,qBAAqB;AAC9C,SAAS,cAAc;AACvB,SAAS,QAAQ,eAAe,cAAc,mBAAmB;AACjE,SAAS,iBAAiB;AAC1B,SAAS,UAAU,eAAe,oBAAoB;AACtD,OAAO,gBAAgB;AACvB,SAAS,aAAa,mBAAmB;AACzC,SAAS,uBAAuB;AAChC,SAAS,eAAe;AACxB,SAAS,yBAAyB;AAClC,SAAS,gCAAgC;AACzC,OAAO,wBAAwB;AAC/B,OAAO,wBAAwB;AAOxB,SAAS,iBAAiB,EAAE,MAAM,QAAQ,GAA0B;AACzE,QAAM,EAAE,KAAK,IAAI,QAAQ;AACzB,QAAM,iBAAiB,kBAAkB;AAEzC,QAAM,sBAAsB,MAAM,QAC9B;AAAA,IACE,KAAK,OAAO,KAAK,MAAM,WAAW,KAAK,GAAG,IAAI,KAAK,MAAM,MAAM,KAAK,IAAI,MAAM,IAAI,KAAK;AAAA,EACzF,IACA;AAEJ,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AA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;AAEJ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/account/sections/ChangePhoneModal.tsx"],"sourcesContent":["'use client';\r\n\r\nimport { IconChevronLeft, IconX, IconMessage } from '@tabler/icons-react';\r\nimport { Button } from '../../ui/buttons/Button';\r\nimport { Dialog, DialogContent, DialogHeader, DialogTitle } from '../../ui/overlay/Dialog';\r\nimport { Separator } from '../../ui/data-display/Separator';\r\nimport { InputOTP, InputOTPGroup, InputOTPSlot } from '../../ui/form/InputOtp';\r\nimport PhoneInput from '../../ui/form/PhoneInput';\r\nimport { formatTimer, formatPhone } from '../../../utils/format/masks';\r\nimport { OTP_CODE_LENGTH } from '../../../utils/validators/account';\r\nimport { useAuth } from '../../../providers/auth.provider';\r\nimport { useInvalidateUser } from '../../../modules/auth/hooks/useUserQuery';\r\nimport { confirmPhoneChangeAction } from '../../../modules/accounts/actions/account-management.action';\r\nimport useChangePhoneForm from '../hooks/useChangePhoneForm';\r\nimport useOtpVerification from '../hooks/useOtpVerification';\r\n\r\ninterface ChangePhoneModalProps {\r\n open: boolean;\r\n onClose: () => void;\r\n}\r\n\r\nexport function ChangePhoneModal({ open, onClose }: ChangePhoneModalProps) {\r\n const { user } = useAuth();\r\n const invalidateUser = useInvalidateUser();\r\n\r\n const currentPhoneDisplay = user?.phone\r\n ? formatPhone(\r\n user.ddi && user.phone.startsWith(user.ddi) ? user.phone.slice(user.ddi.length) : user.phone\r\n )\r\n : '';\r\n\r\n const {\r\n showVerification,\r\n phoneValue,\r\n phoneError,\r\n isSubmitting,\r\n submittedPhone,\r\n handlePhoneChange,\r\n handleContinue,\r\n handleBack,\r\n resetForm,\r\n } = useChangePhoneForm();\r\n\r\n const handleSuccess = () => {\r\n invalidateUser();\r\n resetForm();\r\n onClose();\r\n };\r\n\r\n const {\r\n code,\r\n isLoading,\r\n hasError,\r\n timer,\r\n canResend,\r\n isValidLength,\r\n handleCodeChange,\r\n handleValidate,\r\n handleResend,\r\n reset: resetOtp,\r\n } = useOtpVerification({\r\n onSuccess: handleSuccess,\r\n successMessage: 'Telefone alterado',\r\n validateFn: async (token) => {\r\n const result = await confirmPhoneChangeAction(token, submittedPhone.local, submittedPhone.ddi);\r\n return result.success;\r\n },\r\n resendFn: async () => {\r\n const { requestPhoneChangeAction } = await import('../../../modules/accounts/actions/account-management.action');\r\n const result = await requestPhoneChangeAction(submittedPhone.local, submittedPhone.ddi);\r\n if (!result.success) {\r\n throw new Error(result.error);\r\n }\r\n },\r\n });\r\n\r\n const handleClose = () => {\r\n resetForm();\r\n resetOtp();\r\n onClose();\r\n };\r\n\r\n const handleBackFromVerification = () => {\r\n resetOtp();\r\n handleBack();\r\n };\r\n\r\n return (\r\n <Dialog open={open} onOpenChange={handleClose}>\r\n <DialogContent\r\n showCloseButton={false}\r\n overlayClassName=\"z-[1002]\"\r\n 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-125! 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%]! z-[1003]!\"\r\n >\r\n {showVerification ? (\r\n <DialogHeader className=\"flex flex-row items-center justify-between px-4 py-3 border-b border-gray-200 lg:border-b-0\">\r\n <Button variant=\"ghost\" className=\"size-8! p-0\" onClick={handleBackFromVerification}>\r\n <IconChevronLeft size={20} className=\"text-gray-950\" />\r\n </Button>\r\n <DialogTitle className=\"paragraph-medium-semibold text-gray-950 text-center flex-1\">\r\n Alterar telefone\r\n </DialogTitle>\r\n <Button variant=\"ghost\" className=\"size-8! p-0\" onClick={handleClose}>\r\n <IconX size={18} className=\"text-gray-500\" />\r\n </Button>\r\n </DialogHeader>\r\n ) : (\r\n <>\r\n <DialogHeader className=\"sr-only\">\r\n <DialogTitle>Alterar telefone</DialogTitle>\r\n </DialogHeader>\r\n <div className=\"flex items-center justify-center px-4 py-3 relative border-b border-gray-200 lg:border-b-0\">\r\n <span className=\"paragraph-medium-semibold text-gray-950 text-center\">\r\n Alterar telefone\r\n </span>\r\n <Button\r\n variant=\"ghost\"\r\n className=\"absolute right-2 size-8! p-0\"\r\n onClick={handleClose}\r\n >\r\n <IconX size={18} className=\"text-gray-500\" />\r\n </Button>\r\n </div>\r\n </>\r\n )}\r\n\r\n <div className={`${showVerification ? 'w-full' : 'w-1/2'} h-0.75 bg-pages-300`} />\r\n\r\n {showVerification ? (\r\n <form\r\n onSubmit={(e) => {\r\n e.preventDefault();\r\n handleValidate();\r\n }}\r\n className=\"flex flex-col flex-1 lg:flex-none\"\r\n >\r\n <div className=\"px-4 lg:px-5 py-5 lg:py-6 flex flex-col gap-4 flex-1 lg:flex-none\">\r\n <div className=\"flex items-center justify-center size-12 bg-white rounded-lg shadow-xs border border-gray-200\">\r\n <IconMessage size={20} className=\"text-gray-950\" />\r\n </div>\r\n\r\n <div className=\"flex flex-col gap-1\">\r\n <h3 className=\"paragraph-medium-semibold text-gray-950\">Código de validação</h3>\r\n <p className=\"paragraph-small-regular text-gray-600\">\r\n Enviamos um código de validação para o número atual{' '}\r\n <span className=\"font-semibold text-gray-950\">{currentPhoneDisplay}.</span>\r\n </p>\r\n </div>\r\n\r\n <div className=\"flex flex-col gap-2\">\r\n <InputOTP maxLength={OTP_CODE_LENGTH} value={code} onChange={handleCodeChange}>\r\n <InputOTPGroup className=\"flex flex-row gap-2\">\r\n {[...Array(OTP_CODE_LENGTH)].map((_, i) => (\r\n <InputOTPSlot\r\n key={i}\r\n index={i}\r\n className={`uppercase text-2xl font-medium w-11 lg:w-12 h-13 lg:h-14 rounded-lg border bg-white shadow-none [&_div.animate-caret-blink]:bg-gray-950 ${hasError ? 'border-red-500' : 'border-gray-200'}`}\r\n />\r\n ))}\r\n </InputOTPGroup>\r\n </InputOTP>\r\n {hasError && (\r\n <p className=\"paragraph-small-regular text-red-500\">Código incorreto</p>\r\n )}\r\n </div>\r\n\r\n {canResend ? (\r\n <button\r\n type=\"button\"\r\n onClick={handleResend}\r\n className=\"paragraph-small-medium text-gray-950 underline cursor-pointer hover:text-gray-700 w-fit\"\r\n >\r\n Reenviar código\r\n </button>\r\n ) : (\r\n <p className=\"paragraph-small-regular text-gray-500\">\r\n Reenviar em{' '}\r\n <span className=\"paragraph-small-semibold text-gray-950\">\r\n {formatTimer(timer)}\r\n </span>\r\n </p>\r\n )}\r\n </div>\r\n\r\n <Separator />\r\n\r\n <div className=\"flex items-center justify-between px-4 lg:px-5 py-4 lg:py-5 mt-auto lg:mt-0\">\r\n <Button variant=\"secondary\" className=\"h-10!\" type=\"button\" onClick={handleClose}>\r\n Cancelar\r\n </Button>\r\n <Button className=\"h-10!\" type=\"submit\" disabled={!isValidLength || isLoading}>\r\n {isLoading ? 'Validando...' : 'Alterar telefone'}\r\n </Button>\r\n </div>\r\n </form>\r\n ) : (\r\n <form onSubmit={handleContinue} className=\"flex flex-col flex-1 lg:flex-none\">\r\n <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\">\r\n <div className=\"flex flex-col gap-1\">\r\n <span className=\"paragraph-medium-semibold text-gray-950\">\r\n Atualizar telefone de contato\r\n </span>\r\n <span className=\"paragraph-small-regular text-gray-600\">\r\n Informe o novo número para manter seu contato atualizado.\r\n </span>\r\n </div>\r\n\r\n <PhoneInput\r\n label=\"Novo número\"\r\n placeholder=\"(00) 0 0000-0000\"\r\n value={phoneValue}\r\n onChange={handlePhoneChange}\r\n error={!!phoneError}\r\n errorMessage={phoneError}\r\n />\r\n </div>\r\n\r\n <div className=\"flex items-center justify-between p-4 lg:p-5 border-t border-gray-200 mt-auto lg:mt-0\">\r\n <Button variant=\"secondary\" className=\"h-10!\" type=\"button\" onClick={handleClose}>\r\n Cancelar\r\n </Button>\r\n <Button className=\"h-10!\" type=\"submit\" disabled={isSubmitting}>\r\n {isSubmitting ? 'Enviando...' : 'Continuar'}\r\n </Button>\r\n </div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AA,gBACA,oBAAC,UAAO,WAAU,SAAQ,MAAK,UAAS,UAAU,CAAC,iBAAiB,WACjE,sBAAY,iBAAiB,oBAChC;AAAA,iBACF;AAAA;AAAA;AAAA,QACF,IAEA,qBAAC,UAAK,UAAU,gBAAgB,WAAU,qCACxC;AAAA,+BAAC,SAAI,WAAU,8EACb;AAAA,iCAAC,SAAI,WAAU,uBACb;AAAA,kCAAC,UAAK,WAAU,2CAA0C,2CAE1D;AAAA,cACA,oBAAC,UAAK,WAAU,yCAAwC,0EAExD;AAAA,eACF;AAAA,YAEA;AAAA,cAAC;AAAA;AAAA,gBACC,OAAM;AAAA,gBACN,aAAY;AAAA,gBACZ,OAAO;AAAA,gBACP,UAAU;AAAA,gBACV,OAAO,CAAC,CAAC;AAAA,gBACT,cAAc;AAAA;AAAA,YAChB;AAAA,aACF;AAAA,UAEA,qBAAC,SAAI,WAAU,yFACb;AAAA,gCAAC,UAAO,SAAQ,aAAY,WAAU,SAAQ,MAAK,UAAS,SAAS,aAAa,sBAElF;AAAA,YACA,oBAAC,UAAO,WAAU,SAAQ,MAAK,UAAS,UAAU,cAC/C,yBAAe,gBAAgB,aAClC;AAAA,aACF;AAAA,WACF;AAAA;AAAA;AAAA,EAEJ,GACF;AAEJ;","names":[]}
|
|
@@ -5,7 +5,7 @@ import Image from "next/image";
|
|
|
5
5
|
import { useForm } from "react-hook-form";
|
|
6
6
|
import { zodResolver } from "@hookform/resolvers/zod";
|
|
7
7
|
import { toast } from "sonner";
|
|
8
|
-
import {
|
|
8
|
+
import { IconUpload, IconTrash } from "@tabler/icons-react";
|
|
9
9
|
import { Button } from "../../ui/buttons/Button";
|
|
10
10
|
import { Separator } from "../../ui/data-display/Separator";
|
|
11
11
|
import { Toast } from "../../ui/feedback/Toast";
|
|
@@ -142,7 +142,7 @@ function MyProfileSection({ onClose, storageUrl }) {
|
|
|
142
142
|
{
|
|
143
143
|
className: "size-12 rounded-full bg-gray-50 border border-dashed border-gray-200 flex items-center justify-center cursor-pointer",
|
|
144
144
|
onClick: () => fileInputRef.current?.click(),
|
|
145
|
-
children: /* @__PURE__ */ jsx(
|
|
145
|
+
children: /* @__PURE__ */ jsx(IconUpload, { size: 20, className: "text-gray-400" })
|
|
146
146
|
}
|
|
147
147
|
),
|
|
148
148
|
avatarPreview ? /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
@@ -163,7 +163,7 @@ function MyProfileSection({ onClose, storageUrl }) {
|
|
|
163
163
|
variant: "ghost",
|
|
164
164
|
className: "h-8!",
|
|
165
165
|
onClick: handleRemovePhoto,
|
|
166
|
-
children: /* @__PURE__ */ jsx(
|
|
166
|
+
children: /* @__PURE__ */ jsx(IconTrash, { size: 16, className: "text-gray-500" })
|
|
167
167
|
}
|
|
168
168
|
)
|
|
169
169
|
] }) : /* @__PURE__ */ jsx(
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/account/sections/MyProfileSection.tsx"],"sourcesContent":["'use client';\r\n\r\nimport { useState, useRef } from 'react';\r\nimport Image from 'next/image';\r\nimport { useForm } from 'react-hook-form';\r\nimport { zodResolver } from '@hookform/resolvers/zod';\r\nimport { toast } from 'sonner';\r\nimport { Upload, Trash } from 'lucide-react';\r\nimport { Button } from '../../ui/buttons/Button';\r\nimport { Separator } from '../../ui/data-display/Separator';\r\nimport { Toast } from '../../ui/feedback/Toast';\r\nimport { Dialog, DialogContent, DialogHeader, DialogTitle } from '../../ui/overlay/Dialog';\r\nimport { FormField } from '../../ui/form/FormField';\r\nimport { SelectField } from '../../ui/form/SelectField';\r\nimport PhoneInput from '../../ui/form/PhoneInput';\r\nimport { useAuth } from '../../../providers/auth.provider';\r\nimport { UserProfile } from '../../../modules/users/schema';\r\nimport { myProfileSchema, type MyProfileFormData } from '../../../utils/validators/account';\r\nimport {\r\n useUpdateAccountUser,\r\n useDeleteAccount,\r\n useDeleteAccountUser,\r\n} from '../../../modules/accounts/hooks/useAccountManagement';\r\nimport { GENDER_OPTIONS } from '../constants';\r\nimport { ChangePhoneModal } from './ChangePhoneModal';\r\nimport { ChangeEmailModal } from './ChangeEmailModal';\r\n\r\ninterface MyProfileSectionProps {\r\n onClose: () => void;\r\n storageUrl?: string;\r\n}\r\n\r\nexport function MyProfileSection({ onClose, storageUrl }: MyProfileSectionProps) {\r\n const { user, logout } = useAuth();\r\n const updateAccountUser = useUpdateAccountUser();\r\n const deleteAccount = useDeleteAccount();\r\n const deleteAccountUser = useDeleteAccountUser();\r\n const fileInputRef = useRef<HTMLInputElement>(null);\r\n const [selectedPhoto, setSelectedPhoto] = useState<File | null>(null);\r\n const [photoRemoved, setPhotoRemoved] = useState(false);\r\n const [changePhoneOpen, setChangePhoneOpen] = useState(false);\r\n const [changeEmailOpen, setChangeEmailOpen] = useState(false);\r\n const [deleteConfirmOpen, setDeleteConfirmOpen] = useState(false);\r\n\r\n const isOwner = user?.profile === UserProfile.owner;\r\n const isDeleting = deleteAccount.isPending || deleteAccountUser.isPending;\r\n\r\n const form = useForm<MyProfileFormData>({\r\n resolver: zodResolver(myProfileSchema),\r\n mode: 'onChange',\r\n defaultValues: {\r\n name: user?.name ?? '',\r\n last_name: user?.last_name ?? '',\r\n gender: GENDER_OPTIONS.find((g) => g.apiValue === user?.gender)?.value ?? '',\r\n },\r\n });\r\n\r\n const {\r\n register,\r\n handleSubmit,\r\n watch,\r\n setValue,\r\n formState: { errors, isSubmitting },\r\n } = form;\r\n\r\n const baseStorageUrl = storageUrl ?? process.env.NEXT_PUBLIC_STORAGE_URL ?? '';\r\n\r\n const avatarPreview = selectedPhoto\r\n ? URL.createObjectURL(selectedPhoto)\r\n : !photoRemoved && user?.photo\r\n ? `${baseStorageUrl}/${user.photo}`\r\n : null;\r\n\r\n const handlePhotoChange = (e: React.ChangeEvent<HTMLInputElement>) => {\r\n const file = e.target.files?.[0] ?? null;\r\n if (file) {\r\n setSelectedPhoto(file);\r\n setPhotoRemoved(false);\r\n }\r\n };\r\n\r\n const handleRemovePhoto = () => {\r\n setSelectedPhoto(null);\r\n setPhotoRemoved(true);\r\n };\r\n\r\n const handleDelete = async () => {\r\n try {\r\n if (isOwner) {\r\n await deleteAccount.mutateAsync();\r\n } else {\r\n await deleteAccountUser.mutateAsync(user!.id);\r\n }\r\n await logout();\r\n } catch (error) {\r\n toast.custom((t) => (\r\n <Toast\r\n variant=\"error\"\r\n message={error instanceof Error ? error.message : 'Erro ao excluir. Tente novamente.'}\r\n toastId={t}\r\n />\r\n ));\r\n setDeleteConfirmOpen(false);\r\n }\r\n };\r\n\r\n const onSubmit = async (data: MyProfileFormData) => {\r\n try {\r\n await updateAccountUser.mutateAsync({\r\n name: data.name,\r\n last_name: data.last_name,\r\n gender: GENDER_OPTIONS.find((g) => g.value === data.gender)?.apiValue,\r\n ...(selectedPhoto ? { photo: selectedPhoto } : {}),\r\n ...(photoRemoved ? { photo: '' } : {}),\r\n });\r\n\r\n form.reset(data);\r\n setSelectedPhoto(null);\r\n setPhotoRemoved(false);\r\n toast.custom((t) => (\r\n <Toast variant=\"success\" message=\"Perfil atualizado com sucesso\" toastId={t} />\r\n ));\r\n onClose();\r\n } catch (error) {\r\n toast.custom((t) => (\r\n <Toast\r\n variant=\"error\"\r\n message={error instanceof Error ? error.message : 'Erro ao atualizar perfil'}\r\n toastId={t}\r\n />\r\n ));\r\n }\r\n };\r\n\r\n return (\r\n <>\r\n <form onSubmit={handleSubmit(onSubmit)} className=\"lg:h-full lg:flex lg:flex-col\">\r\n <input\r\n ref={fileInputRef}\r\n type=\"file\"\r\n accept=\"image/*\"\r\n className=\"hidden\"\r\n onChange={handlePhotoChange}\r\n />\r\n <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\">\r\n <span className=\"paragraph-medium-semibold text-gray-950 hidden lg:block\">\r\n Meu perfil\r\n </span>\r\n <div className=\"flex flex-col gap-5\">\r\n <div className=\"flex items-center gap-4\">\r\n {avatarPreview ? (\r\n <Image\r\n src={avatarPreview}\r\n alt=\"Foto do usuário\"\r\n width={48}\r\n height={48}\r\n className=\"size-12 rounded-full object-cover cursor-pointer\"\r\n onClick={() => fileInputRef.current?.click()}\r\n />\r\n ) : (\r\n <div\r\n className=\"size-12 rounded-full bg-gray-50 border border-dashed border-gray-200 flex items-center justify-center cursor-pointer\"\r\n onClick={() => fileInputRef.current?.click()}\r\n >\r\n <Upload size={20} className=\"text-gray-400\" />\r\n </div>\r\n )}\r\n {avatarPreview ? (\r\n <div className=\"flex items-center gap-2\">\r\n <Button\r\n variant=\"secondary\"\r\n className=\"w-fit h-8!\"\r\n type=\"button\"\r\n onClick={() => fileInputRef.current?.click()}\r\n >\r\n Alterar foto\r\n </Button>\r\n <Button\r\n type=\"button\"\r\n variant=\"ghost\"\r\n className=\"h-8!\"\r\n onClick={handleRemovePhoto}\r\n >\r\n <Trash size={16} className=\"text-gray-500\" />\r\n </Button>\r\n </div>\r\n ) : (\r\n <Button\r\n variant=\"secondary\"\r\n className=\"w-fit h-8!\"\r\n type=\"button\"\r\n onClick={() => fileInputRef.current?.click()}\r\n >\r\n Alterar foto\r\n </Button>\r\n )}\r\n </div>\r\n\r\n <div className=\"flex flex-col gap-8\">\r\n <div className=\"flex flex-col gap-4\">\r\n <div className=\"flex gap-4\">\r\n <FormField\r\n label=\"Nome\"\r\n placeholder=\"Digite seu nome\"\r\n error={!!errors.name}\r\n errorMessage={errors.name?.message}\r\n {...register('name')}\r\n />\r\n <FormField\r\n label=\"Sobrenome\"\r\n placeholder=\"Digite seu sobrenome\"\r\n error={!!errors.last_name}\r\n errorMessage={errors.last_name?.message}\r\n {...register('last_name')}\r\n />\r\n </div>\r\n <SelectField\r\n label=\"Gênero\"\r\n placeholder=\"Selecione seu gênero\"\r\n options={GENDER_OPTIONS}\r\n value={watch('gender')}\r\n className=\"h-10!\"\r\n onChange={(value) => setValue('gender', value as string)}\r\n />\r\n <div className=\"relative\">\r\n <PhoneInput\r\n label=\"Telefone\"\r\n value={user?.phone ?? ''}\r\n disabled\r\n classnameContainer=\"bg-gray-50 border-0!\"\r\n />\r\n <button\r\n type=\"button\"\r\n className=\"absolute right-3 top-5.5 h-10 flex items-center paragraph-xsmall-semibold text-gray-950 underline cursor-pointer\"\r\n onClick={() => setChangePhoneOpen(true)}\r\n >\r\n Alterar\r\n </button>\r\n </div>\r\n </div>\r\n\r\n <Separator />\r\n\r\n <div className=\"flex flex-col gap-4\">\r\n <span className=\"paragraph-medium-semibold text-gray-600\">Dados de acesso</span>\r\n <div className=\"relative\">\r\n <div className='cursor-not-allowed'>\r\n <FormField\r\n label=\"E-mail\"\r\n value={user?.email ?? ''}\r\n disabled\r\n classnameContainer=\"bg-gray-50 border-0!\"\r\n />\r\n </div>\r\n <button\r\n type=\"button\"\r\n className=\"absolute right-3 top-5.5 h-10 flex items-center paragraph-xsmall-semibold text-gray-950 underline cursor-pointer\"\r\n onClick={() => setChangeEmailOpen(true)}\r\n >\r\n Alterar\r\n </button>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n\r\n <div className=\"fixed bottom-0 left-0 right-0 lg:static flex items-center h-20 px-4 lg:px-5 border-t border-gray-200 justify-between bg-white z-10\">\r\n <Button\r\n variant=\"secondary\"\r\n className=\"h-10!\"\r\n type=\"button\"\r\n disabled={isSubmitting}\r\n onClick={() => {\r\n form.reset();\r\n setSelectedPhoto(null);\r\n setPhotoRemoved(false);\r\n onClose();\r\n }}\r\n >\r\n Cancelar\r\n </Button>\r\n <Button className=\"h-10! cursor-pointer\" type=\"submit\" disabled={isSubmitting}>\r\n {isSubmitting ? 'Salvando...' : 'Salvar alterações'}\r\n </Button>\r\n </div>\r\n </form>\r\n\r\n <ChangePhoneModal open={changePhoneOpen} onClose={() => setChangePhoneOpen(false)} />\r\n <ChangeEmailModal open={changeEmailOpen} onClose={() => setChangeEmailOpen(false)} />\r\n\r\n <Dialog open={deleteConfirmOpen} onOpenChange={setDeleteConfirmOpen}>\r\n <DialogContent className=\"max-w-sm! gap-5\">\r\n <DialogHeader>\r\n <DialogTitle className=\"paragraph-large-semibold text-gray-950\">\r\n {isOwner ? 'Excluir conta' : 'Excluir usuário'}\r\n </DialogTitle>\r\n </DialogHeader>\r\n <p className=\"paragraph-small-regular text-gray-600\">\r\n {isOwner\r\n ? 'Tem certeza que deseja excluir sua conta? Todos os dados serão apagados permanentemente e essa ação não pode ser desfeita.'\r\n : 'Tem certeza que deseja excluir seu usuário? Você perderá acesso a esta conta permanentemente.'}\r\n </p>\r\n <div className=\"flex items-center gap-3 justify-end\">\r\n <Button\r\n type=\"button\"\r\n variant=\"secondary\"\r\n className=\"h-10!\"\r\n disabled={isDeleting}\r\n onClick={() => setDeleteConfirmOpen(false)}\r\n >\r\n Cancelar\r\n </Button>\r\n <Button\r\n type=\"button\"\r\n className=\"h-10! bg-red-600 hover:bg-red-700 text-white border-0!\"\r\n disabled={isDeleting}\r\n onClick={handleDelete}\r\n >\r\n {isDeleting ? 'Excluindo...' : 'Confirmar exclusão'}\r\n </Button>\r\n </div>\r\n </DialogContent>\r\n </Dialog>\r\n </>\r\n );\r\n}\r\n"],"mappings":";AAgGQ,SAuCJ,UAvCI,KAwEQ,YAxER;AA9FR,SAAS,UAAU,cAAc;AACjC,OAAO,WAAW;AAClB,SAAS,eAAe;AACxB,SAAS,mBAAmB;AAC5B,SAAS,aAAa;AACtB,SAAS,QAAQ,aAAa;AAC9B,SAAS,cAAc;AACvB,SAAS,iBAAiB;AAC1B,SAAS,aAAa;AACtB,SAAS,QAAQ,eAAe,cAAc,mBAAmB;AACjE,SAAS,iBAAiB;AAC1B,SAAS,mBAAmB;AAC5B,OAAO,gBAAgB;AACvB,SAAS,eAAe;AACxB,SAAS,mBAAmB;AAC5B,SAAS,uBAA+C;AACxD;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,sBAAsB;AAC/B,SAAS,wBAAwB;AACjC,SAAS,wBAAwB;AAO1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,YAER,uBAAa,iBAAiB;AAAA;AAAA,QACjC;AAAA,SACF;AAAA,OACF,GACF;AAAA,KACF;AAEJ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/account/sections/MyProfileSection.tsx"],"sourcesContent":["'use client';\r\n\r\nimport { useState, useRef } from 'react';\r\nimport Image from 'next/image';\r\nimport { useForm } from 'react-hook-form';\r\nimport { zodResolver } from '@hookform/resolvers/zod';\r\nimport { toast } from 'sonner';\r\nimport { IconUpload, IconTrash } from '@tabler/icons-react';\r\nimport { Button } from '../../ui/buttons/Button';\r\nimport { Separator } from '../../ui/data-display/Separator';\r\nimport { Toast } from '../../ui/feedback/Toast';\r\nimport { Dialog, DialogContent, DialogHeader, DialogTitle } from '../../ui/overlay/Dialog';\r\nimport { FormField } from '../../ui/form/FormField';\r\nimport { SelectField } from '../../ui/form/SelectField';\r\nimport PhoneInput from '../../ui/form/PhoneInput';\r\nimport { useAuth } from '../../../providers/auth.provider';\r\nimport { UserProfile } from '../../../modules/users/schema';\r\nimport { myProfileSchema, type MyProfileFormData } from '../../../utils/validators/account';\r\nimport {\r\n useUpdateAccountUser,\r\n useDeleteAccount,\r\n useDeleteAccountUser,\r\n} from '../../../modules/accounts/hooks/useAccountManagement';\r\nimport { GENDER_OPTIONS } from '../constants';\r\nimport { ChangePhoneModal } from './ChangePhoneModal';\r\nimport { ChangeEmailModal } from './ChangeEmailModal';\r\n\r\ninterface MyProfileSectionProps {\r\n onClose: () => void;\r\n storageUrl?: string;\r\n}\r\n\r\nexport function MyProfileSection({ onClose, storageUrl }: MyProfileSectionProps) {\r\n const { user, logout } = useAuth();\r\n const updateAccountUser = useUpdateAccountUser();\r\n const deleteAccount = useDeleteAccount();\r\n const deleteAccountUser = useDeleteAccountUser();\r\n const fileInputRef = useRef<HTMLInputElement>(null);\r\n const [selectedPhoto, setSelectedPhoto] = useState<File | null>(null);\r\n const [photoRemoved, setPhotoRemoved] = useState(false);\r\n const [changePhoneOpen, setChangePhoneOpen] = useState(false);\r\n const [changeEmailOpen, setChangeEmailOpen] = useState(false);\r\n const [deleteConfirmOpen, setDeleteConfirmOpen] = useState(false);\r\n\r\n const isOwner = user?.profile === UserProfile.owner;\r\n const isDeleting = deleteAccount.isPending || deleteAccountUser.isPending;\r\n\r\n const form = useForm<MyProfileFormData>({\r\n resolver: zodResolver(myProfileSchema),\r\n mode: 'onChange',\r\n defaultValues: {\r\n name: user?.name ?? '',\r\n last_name: user?.last_name ?? '',\r\n gender: GENDER_OPTIONS.find((g) => g.apiValue === user?.gender)?.value ?? '',\r\n },\r\n });\r\n\r\n const {\r\n register,\r\n handleSubmit,\r\n watch,\r\n setValue,\r\n formState: { errors, isSubmitting },\r\n } = form;\r\n\r\n const baseStorageUrl = storageUrl ?? process.env.NEXT_PUBLIC_STORAGE_URL ?? '';\r\n\r\n const avatarPreview = selectedPhoto\r\n ? URL.createObjectURL(selectedPhoto)\r\n : !photoRemoved && user?.photo\r\n ? `${baseStorageUrl}/${user.photo}`\r\n : null;\r\n\r\n const handlePhotoChange = (e: React.ChangeEvent<HTMLInputElement>) => {\r\n const file = e.target.files?.[0] ?? null;\r\n if (file) {\r\n setSelectedPhoto(file);\r\n setPhotoRemoved(false);\r\n }\r\n };\r\n\r\n const handleRemovePhoto = () => {\r\n setSelectedPhoto(null);\r\n setPhotoRemoved(true);\r\n };\r\n\r\n const handleDelete = async () => {\r\n try {\r\n if (isOwner) {\r\n await deleteAccount.mutateAsync();\r\n } else {\r\n await deleteAccountUser.mutateAsync(user!.id);\r\n }\r\n await logout();\r\n } catch (error) {\r\n toast.custom((t) => (\r\n <Toast\r\n variant=\"error\"\r\n message={error instanceof Error ? error.message : 'Erro ao excluir. Tente novamente.'}\r\n toastId={t}\r\n />\r\n ));\r\n setDeleteConfirmOpen(false);\r\n }\r\n };\r\n\r\n const onSubmit = async (data: MyProfileFormData) => {\r\n try {\r\n await updateAccountUser.mutateAsync({\r\n name: data.name,\r\n last_name: data.last_name,\r\n gender: GENDER_OPTIONS.find((g) => g.value === data.gender)?.apiValue,\r\n ...(selectedPhoto ? { photo: selectedPhoto } : {}),\r\n ...(photoRemoved ? { photo: '' } : {}),\r\n });\r\n\r\n form.reset(data);\r\n setSelectedPhoto(null);\r\n setPhotoRemoved(false);\r\n toast.custom((t) => (\r\n <Toast variant=\"success\" message=\"Perfil atualizado com sucesso\" toastId={t} />\r\n ));\r\n onClose();\r\n } catch (error) {\r\n toast.custom((t) => (\r\n <Toast\r\n variant=\"error\"\r\n message={error instanceof Error ? error.message : 'Erro ao atualizar perfil'}\r\n toastId={t}\r\n />\r\n ));\r\n }\r\n };\r\n\r\n return (\r\n <>\r\n <form onSubmit={handleSubmit(onSubmit)} className=\"lg:h-full lg:flex lg:flex-col\">\r\n <input\r\n ref={fileInputRef}\r\n type=\"file\"\r\n accept=\"image/*\"\r\n className=\"hidden\"\r\n onChange={handlePhotoChange}\r\n />\r\n <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\">\r\n <span className=\"paragraph-medium-semibold text-gray-950 hidden lg:block\">\r\n Meu perfil\r\n </span>\r\n <div className=\"flex flex-col gap-5\">\r\n <div className=\"flex items-center gap-4\">\r\n {avatarPreview ? (\r\n <Image\r\n src={avatarPreview}\r\n alt=\"Foto do usuário\"\r\n width={48}\r\n height={48}\r\n className=\"size-12 rounded-full object-cover cursor-pointer\"\r\n onClick={() => fileInputRef.current?.click()}\r\n />\r\n ) : (\r\n <div\r\n className=\"size-12 rounded-full bg-gray-50 border border-dashed border-gray-200 flex items-center justify-center cursor-pointer\"\r\n onClick={() => fileInputRef.current?.click()}\r\n >\r\n <IconUpload size={20} className=\"text-gray-400\" />\r\n </div>\r\n )}\r\n {avatarPreview ? (\r\n <div className=\"flex items-center gap-2\">\r\n <Button\r\n variant=\"secondary\"\r\n className=\"w-fit h-8!\"\r\n type=\"button\"\r\n onClick={() => fileInputRef.current?.click()}\r\n >\r\n Alterar foto\r\n </Button>\r\n <Button\r\n type=\"button\"\r\n variant=\"ghost\"\r\n className=\"h-8!\"\r\n onClick={handleRemovePhoto}\r\n >\r\n <IconTrash size={16} className=\"text-gray-500\" />\r\n </Button>\r\n </div>\r\n ) : (\r\n <Button\r\n variant=\"secondary\"\r\n className=\"w-fit h-8!\"\r\n type=\"button\"\r\n onClick={() => fileInputRef.current?.click()}\r\n >\r\n Alterar foto\r\n </Button>\r\n )}\r\n </div>\r\n\r\n <div className=\"flex flex-col gap-8\">\r\n <div className=\"flex flex-col gap-4\">\r\n <div className=\"flex gap-4\">\r\n <FormField\r\n label=\"Nome\"\r\n placeholder=\"Digite seu nome\"\r\n error={!!errors.name}\r\n errorMessage={errors.name?.message}\r\n {...register('name')}\r\n />\r\n <FormField\r\n label=\"Sobrenome\"\r\n placeholder=\"Digite seu sobrenome\"\r\n error={!!errors.last_name}\r\n errorMessage={errors.last_name?.message}\r\n {...register('last_name')}\r\n />\r\n </div>\r\n <SelectField\r\n label=\"Gênero\"\r\n placeholder=\"Selecione seu gênero\"\r\n options={GENDER_OPTIONS}\r\n value={watch('gender')}\r\n className=\"h-10!\"\r\n onChange={(value) => setValue('gender', value as string)}\r\n />\r\n <div className=\"relative\">\r\n <PhoneInput\r\n label=\"Telefone\"\r\n value={user?.phone ?? ''}\r\n disabled\r\n classnameContainer=\"bg-gray-50 border-0!\"\r\n />\r\n <button\r\n type=\"button\"\r\n className=\"absolute right-3 top-5.5 h-10 flex items-center paragraph-xsmall-semibold text-gray-950 underline cursor-pointer\"\r\n onClick={() => setChangePhoneOpen(true)}\r\n >\r\n Alterar\r\n </button>\r\n </div>\r\n </div>\r\n\r\n <Separator />\r\n\r\n <div className=\"flex flex-col gap-4\">\r\n <span className=\"paragraph-medium-semibold text-gray-600\">Dados de acesso</span>\r\n <div className=\"relative\">\r\n <div className='cursor-not-allowed'>\r\n <FormField\r\n label=\"E-mail\"\r\n value={user?.email ?? ''}\r\n disabled\r\n classnameContainer=\"bg-gray-50 border-0!\"\r\n />\r\n </div>\r\n <button\r\n type=\"button\"\r\n className=\"absolute right-3 top-5.5 h-10 flex items-center paragraph-xsmall-semibold text-gray-950 underline cursor-pointer\"\r\n onClick={() => setChangeEmailOpen(true)}\r\n >\r\n Alterar\r\n </button>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n\r\n <div className=\"fixed bottom-0 left-0 right-0 lg:static flex items-center h-20 px-4 lg:px-5 border-t border-gray-200 justify-between bg-white z-10\">\r\n <Button\r\n variant=\"secondary\"\r\n className=\"h-10!\"\r\n type=\"button\"\r\n disabled={isSubmitting}\r\n onClick={() => {\r\n form.reset();\r\n setSelectedPhoto(null);\r\n setPhotoRemoved(false);\r\n onClose();\r\n }}\r\n >\r\n Cancelar\r\n </Button>\r\n <Button className=\"h-10! cursor-pointer\" type=\"submit\" disabled={isSubmitting}>\r\n {isSubmitting ? 'Salvando...' : 'Salvar alterações'}\r\n </Button>\r\n </div>\r\n </form>\r\n\r\n <ChangePhoneModal open={changePhoneOpen} onClose={() => setChangePhoneOpen(false)} />\r\n <ChangeEmailModal open={changeEmailOpen} onClose={() => setChangeEmailOpen(false)} />\r\n\r\n <Dialog open={deleteConfirmOpen} onOpenChange={setDeleteConfirmOpen}>\r\n <DialogContent className=\"max-w-sm! gap-5\">\r\n <DialogHeader>\r\n <DialogTitle className=\"paragraph-large-semibold text-gray-950\">\r\n {isOwner ? 'Excluir conta' : 'Excluir usuário'}\r\n </DialogTitle>\r\n </DialogHeader>\r\n <p className=\"paragraph-small-regular text-gray-600\">\r\n {isOwner\r\n ? 'Tem certeza que deseja excluir sua conta? Todos os dados serão apagados permanentemente e essa ação não pode ser desfeita.'\r\n : 'Tem certeza que deseja excluir seu usuário? Você perderá acesso a esta conta permanentemente.'}\r\n </p>\r\n <div className=\"flex items-center gap-3 justify-end\">\r\n <Button\r\n type=\"button\"\r\n variant=\"secondary\"\r\n className=\"h-10!\"\r\n disabled={isDeleting}\r\n onClick={() => setDeleteConfirmOpen(false)}\r\n >\r\n Cancelar\r\n </Button>\r\n <Button\r\n type=\"button\"\r\n className=\"h-10! bg-red-600 hover:bg-red-700 text-white border-0!\"\r\n disabled={isDeleting}\r\n onClick={handleDelete}\r\n >\r\n {isDeleting ? 'Excluindo...' : 'Confirmar exclusão'}\r\n </Button>\r\n </div>\r\n </DialogContent>\r\n </Dialog>\r\n </>\r\n );\r\n}\r\n"],"mappings":";AAgGQ,SAuCJ,UAvCI,KAwEQ,YAxER;AA9FR,SAAS,UAAU,cAAc;AACjC,OAAO,WAAW;AAClB,SAAS,eAAe;AACxB,SAAS,mBAAmB;AAC5B,SAAS,aAAa;AACtB,SAAS,YAAY,iBAAiB;AACtC,SAAS,cAAc;AACvB,SAAS,iBAAiB;AAC1B,SAAS,aAAa;AACtB,SAAS,QAAQ,eAAe,cAAc,mBAAmB;AACjE,SAAS,iBAAiB;AAC1B,SAAS,mBAAmB;AAC5B,OAAO,gBAAgB;AACvB,SAAS,eAAe;AACxB,SAAS,mBAAmB;AAC5B,SAAS,uBAA+C;AACxD;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,sBAAsB;AAC/B,SAAS,wBAAwB;AACjC,SAAS,wBAAwB;AAO1B,SAAS,iBAAiB,EAAE,SAAS,WAAW,GAA0B;AAC/E,QAAM,EAAE,MAAM,OAAO,IAAI,QAAQ;AACjC,QAAM,oBAAoB,qBAAqB;AAC/C,QAAM,gBAAgB,iBAAiB;AACvC,QAAM,oBAAoB,qBAAqB;AAC/C,QAAM,eAAe,OAAyB,IAAI;AAClD,QAAM,CAAC,eAAe,gBAAgB,IAAI,SAAsB,IAAI;AACpE,QAAM,CAAC,cAAc,eAAe,IAAI,SAAS,KAAK;AACtD,QAAM,CAAC,iBAAiB,kBAAkB,IAAI,SAAS,KAAK;AAC5D,QAAM,CAAC,iBAAiB,kBAAkB,IAAI,SAAS,KAAK;AAC5D,QAAM,CAAC,mBAA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AA,YACD;AAAA;AAAA,QAED;AAAA,QACA,oBAAC,UAAO,WAAU,wBAAuB,MAAK,UAAS,UAAU,cAC9D,yBAAe,gBAAgB,2BAClC;AAAA,SACF;AAAA,OACF;AAAA,IAEA,oBAAC,oBAAiB,MAAM,iBAAiB,SAAS,MAAM,mBAAmB,KAAK,GAAG;AAAA,IACnF,oBAAC,oBAAiB,MAAM,iBAAiB,SAAS,MAAM,mBAAmB,KAAK,GAAG;AAAA,IAEnF,oBAAC,UAAO,MAAM,mBAAmB,cAAc,sBAC7C,+BAAC,iBAAc,WAAU,mBACvB;AAAA,0BAAC,gBACC,8BAAC,eAAY,WAAU,0CACpB,oBAAU,kBAAkB,sBAC/B,GACF;AAAA,MACA,oBAAC,OAAE,WAAU,yCACV,oBACG,2IACA,0GACN;AAAA,MACA,qBAAC,SAAI,WAAU,uCACb;AAAA;AAAA,UAAC;AAAA;AAAA,YACC,MAAK;AAAA,YACL,SAAQ;AAAA,YACR,WAAU;AAAA,YACV,UAAU;AAAA,YACV,SAAS,MAAM,qBAAqB,KAAK;AAAA,YAC1C;AAAA;AAAA,QAED;AAAA,QACA;AAAA,UAAC;AAAA;AAAA,YACC,MAAK;AAAA,YACL,WAAU;AAAA,YACV,UAAU;AAAA,YACV,SAAS;AAAA,YAER,uBAAa,iBAAiB;AAAA;AAAA,QACjC;AAAA,SACF;AAAA,OACF,GACF;AAAA,KACF;AAEJ;","names":[]}
|
|
@@ -3,7 +3,7 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import { useState, useEffect } from "react";
|
|
4
4
|
import { useForm } from "react-hook-form";
|
|
5
5
|
import { toast } from "sonner";
|
|
6
|
-
import {
|
|
6
|
+
import { IconLock, IconMail, IconMessageCircle } from "@tabler/icons-react";
|
|
7
7
|
import { Button } from "../../ui/buttons/Button";
|
|
8
8
|
import { Separator } from "../../ui/data-display/Separator";
|
|
9
9
|
import { Toast } from "../../ui/feedback/Toast";
|
|
@@ -139,7 +139,7 @@ function PreferencesSection({ onClose }) {
|
|
|
139
139
|
options: currencies,
|
|
140
140
|
value: watch("currency"),
|
|
141
141
|
onChange: (value) => setValue("currency", value, { shouldDirty: true }),
|
|
142
|
-
icon: !canEditPreferences ? /* @__PURE__ */ jsx(
|
|
142
|
+
icon: !canEditPreferences ? /* @__PURE__ */ jsx(IconLock, { className: "size-4 text-gray-400" }) : void 0,
|
|
143
143
|
disabled: !canEditPreferences
|
|
144
144
|
}
|
|
145
145
|
)
|
|
@@ -158,7 +158,7 @@ function PreferencesSection({ onClose }) {
|
|
|
158
158
|
options: timezones,
|
|
159
159
|
value: watch("timezone"),
|
|
160
160
|
onChange: (value) => setValue("timezone", value, { shouldDirty: true }),
|
|
161
|
-
icon: !canEditPreferences ? /* @__PURE__ */ jsx(
|
|
161
|
+
icon: !canEditPreferences ? /* @__PURE__ */ jsx(IconLock, { className: "size-4 text-gray-400" }) : void 0,
|
|
162
162
|
disabled: !canEditPreferences
|
|
163
163
|
}
|
|
164
164
|
),
|
|
@@ -172,7 +172,7 @@ function PreferencesSection({ onClose }) {
|
|
|
172
172
|
options: TIME_FORMAT_OPTIONS,
|
|
173
173
|
value: watch("timeFormat"),
|
|
174
174
|
onChange: (value) => setValue("timeFormat", value, { shouldDirty: true }),
|
|
175
|
-
icon: /* @__PURE__ */ jsx(
|
|
175
|
+
icon: /* @__PURE__ */ jsx(IconLock, { className: "size-4 text-gray-400" }),
|
|
176
176
|
disabled: true
|
|
177
177
|
}
|
|
178
178
|
)
|
|
@@ -186,7 +186,7 @@ function PreferencesSection({ onClose }) {
|
|
|
186
186
|
/* @__PURE__ */ jsx(
|
|
187
187
|
SwitchOptionFieldWithIcon,
|
|
188
188
|
{
|
|
189
|
-
icon:
|
|
189
|
+
icon: IconMessageCircle,
|
|
190
190
|
label: "WhatsApp",
|
|
191
191
|
description: "Receber notifica\xE7\xF5es importantes por WhatsApp",
|
|
192
192
|
checked: receiveSms,
|
|
@@ -196,7 +196,7 @@ function PreferencesSection({ onClose }) {
|
|
|
196
196
|
/* @__PURE__ */ jsx(
|
|
197
197
|
SwitchOptionFieldWithIcon,
|
|
198
198
|
{
|
|
199
|
-
icon:
|
|
199
|
+
icon: IconMail,
|
|
200
200
|
label: "E-mail",
|
|
201
201
|
description: "Receber notifica\xE7\xF5es e atualiza\xE7\xF5es por email",
|
|
202
202
|
checked: receiveEmail,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/account/sections/PreferencesSection.tsx"],"sourcesContent":["'use client';\r\n\r\nimport { useState, useEffect } from 'react';\r\nimport { useForm } from 'react-hook-form';\r\nimport { toast } from 'sonner';\r\nimport { Lock, Mail, MessageCircle } from 'lucide-react';\r\nimport { Button } from '../../ui/buttons/Button';\r\nimport { Separator } from '../../ui/data-display/Separator';\r\nimport { Toast } from '../../ui/feedback/Toast';\r\nimport { ComboboxField } from '../../ui/form/ComboboxField';\r\nimport { SelectField } from '../../ui/form/SelectField';\r\nimport SwitchOptionFieldWithIcon from '../../ui/form/SwitchOptionFieldWithIcon';\r\nimport ConfirmGlobalPreferencesModal from '../ConfirmGlobalPreferencesModal';\r\nimport { useAuth } from '../../../providers/auth.provider';\r\nimport { UserProfile } from '../../../modules/users/schema';\r\nimport type { UpdateAccountRequest } from '../../../modules/accounts/types';\r\nimport {\r\n useUpdateAccountUser,\r\n useUpdateAccount,\r\n} from '../../../modules/accounts/hooks/useAccountManagement';\r\nimport {\r\n LANGUAGE_OPTIONS,\r\n TIME_FORMAT_OPTIONS,\r\n NOTIFICATION_TYPES,\r\n} from '../constants';\r\nimport { useTimezones } from '../../../modules/accounts/hooks/useTimezones';\r\nimport { useCurrencies } from '../../../modules/accounts/hooks/useCurrencies';\r\n\r\ninterface PreferencesFormValues {\r\n language: string;\r\n currency: string;\r\n timezone: string;\r\n timeFormat: string;\r\n receive_sms: boolean;\r\n receive_email: boolean;\r\n}\r\n\r\ninterface PreferencesSectionProps {\r\n onClose: () => void;\r\n}\r\n\r\nexport function PreferencesSection({ onClose }: PreferencesSectionProps) {\r\n const { data: timezones = [] } = useTimezones();\r\n const { data: currencies = [] } = useCurrencies();\r\n const { user, account } = useAuth();\r\n const canEditPreferences =\r\n user?.profile === UserProfile.owner || user?.profile === UserProfile.admin;\r\n const updateAccountUser = useUpdateAccountUser();\r\n const updateAccount = useUpdateAccount();\r\n const [confirmGlobalOpen, setConfirmGlobalOpen] = useState(false);\r\n const [pendingSubmit, setPendingSubmit] = useState<{\r\n data: PreferencesFormValues;\r\n accountFields: UpdateAccountRequest;\r\n } | null>(null);\r\n const [isSaving, setIsSaving] = useState(false);\r\n\r\n const { watch, setValue, handleSubmit, reset, formState: { dirtyFields } } =\r\n useForm<PreferencesFormValues>({\r\n defaultValues: {\r\n language: '',\r\n currency: '',\r\n timezone: '',\r\n timeFormat: '24h',\r\n receive_sms: false,\r\n receive_email: false,\r\n },\r\n });\r\n\r\n useEffect(() => {\r\n if (!user || !account) return;\r\n reset({\r\n language: LANGUAGE_OPTIONS.find(\r\n (o) => o.apiValue === user.language?.toLowerCase()\r\n )?.value ?? 'pt-BR',\r\n currency: account.currency,\r\n timezone: account.timezone,\r\n timeFormat: '24h',\r\n receive_sms: user.receive_sms ?? false,\r\n receive_email: user.receive_email ?? false,\r\n });\r\n }, [user, account, reset]);\r\n\r\n const receiveSms = watch('receive_sms');\r\n const receiveEmail = watch('receive_email');\r\n\r\n const doSave = async (data: PreferencesFormValues, accountFields: UpdateAccountRequest) => {\r\n setIsSaving(true);\r\n try {\r\n const apiLanguage = LANGUAGE_OPTIONS.find((o) => o.value === data.language)?.apiValue ?? data.language.toLowerCase();\r\n await updateAccountUser.mutateAsync({\r\n language: apiLanguage,\r\n receive_sms: data.receive_sms,\r\n receive_email: data.receive_email,\r\n });\r\n\r\n if (canEditPreferences && Object.keys(accountFields).length > 0) {\r\n await updateAccount.mutateAsync(accountFields);\r\n }\r\n\r\n reset(data);\r\n toast.custom((t) => (\r\n <Toast variant=\"success\" message=\"Preferências salvas com sucesso\" toastId={t} />\r\n ));\r\n onClose();\r\n } catch (error) {\r\n toast.custom((t) => (\r\n <Toast\r\n variant=\"error\"\r\n message={error instanceof Error ? error.message : 'Erro ao salvar preferências'}\r\n toastId={t}\r\n />\r\n ));\r\n } finally {\r\n setIsSaving(false);\r\n }\r\n };\r\n\r\n const onSubmit = (data: PreferencesFormValues) => {\r\n const accountFields: UpdateAccountRequest = {\r\n ...(canEditPreferences && dirtyFields.currency && { currency: data.currency }),\r\n ...(canEditPreferences && dirtyFields.timezone && { timezone: data.timezone }),\r\n };\r\n const globalFieldChanged = Object.keys(accountFields).length > 0;\r\n\r\n if (globalFieldChanged) {\r\n setPendingSubmit({ data, accountFields });\r\n setConfirmGlobalOpen(true);\r\n } else {\r\n doSave(data, accountFields);\r\n }\r\n };\r\n\r\n const handleConfirmGlobal = () => {\r\n setConfirmGlobalOpen(false);\r\n if (pendingSubmit) {\r\n doSave(pendingSubmit.data, pendingSubmit.accountFields);\r\n setPendingSubmit(null);\r\n }\r\n };\r\n\r\n const handleCancelGlobal = () => {\r\n setConfirmGlobalOpen(false);\r\n setPendingSubmit(null);\r\n };\r\n\r\n return (\r\n <>\r\n <form onSubmit={handleSubmit(onSubmit)} className=\"lg:h-full lg:flex lg:flex-col\">\r\n <div className=\"absolute inset-0 overflow-y-auto overscroll-contain px-4 pb-36 lg:p-5 lg:static lg:flex-1 lg:min-h-0 lg:overscroll-auto flex flex-col gap-5 lg:gap-6\">\r\n <span className=\"paragraph-medium-semibold text-gray-950\">Preferências</span>\r\n <div className=\"flex flex-col gap-8\">\r\n <div className=\"flex flex-col lg:flex-row items-center gap-3\">\r\n <ComboboxField\r\n label=\"Idioma\"\r\n placeholder=\"Selecione o idioma\"\r\n searchPlaceholder=\"Buscar idioma...\"\r\n containerClassName=\"w-full\"\r\n options={LANGUAGE_OPTIONS}\r\n value={watch('language')}\r\n onChange={(value) => setValue('language', value, { shouldDirty: true })}\r\n />\r\n <ComboboxField\r\n label=\"Moeda\"\r\n placeholder=\"Selecione a moeda\"\r\n searchPlaceholder=\"Buscar moeda...\"\r\n containerClassName=\"w-full\"\r\n options={currencies}\r\n value={watch('currency')}\r\n onChange={(value) => setValue('currency', value, { shouldDirty: true })}\r\n icon={!canEditPreferences ? <Lock className=\"size-4 text-gray-400\" /> : undefined}\r\n disabled={!canEditPreferences}\r\n />\r\n </div>\r\n\r\n <Separator />\r\n\r\n <div className=\"flex flex-col gap-4\">\r\n <span className=\"paragraph-medium-semibold text-gray-600\">Exibição hora</span>\r\n <div className=\"flex flex-col lg:flex-row items-center gap-3\">\r\n <ComboboxField\r\n label=\"Fuso horário\"\r\n placeholder=\"Selecione o fuso horário\"\r\n searchPlaceholder=\"Buscar fuso horário...\"\r\n containerClassName=\"w-full\"\r\n options={timezones}\r\n value={watch('timezone')}\r\n onChange={(value) => setValue('timezone', value, { shouldDirty: true })}\r\n icon={!canEditPreferences ? <Lock className=\"size-4 text-gray-400\" /> : undefined}\r\n disabled={!canEditPreferences}\r\n />\r\n <SelectField\r\n label=\"Formato hora\"\r\n placeholder=\"Selecione o formato\"\r\n className=\"h-10!\"\r\n containerClassName=\"w-full\"\r\n options={TIME_FORMAT_OPTIONS}\r\n value={watch('timeFormat')}\r\n onChange={(value) =>\r\n setValue('timeFormat', value as string, { shouldDirty: true })\r\n }\r\n icon={<Lock className=\"size-4 text-gray-400\" />}\r\n disabled\r\n />\r\n </div>\r\n </div>\r\n\r\n <Separator />\r\n\r\n <div className=\"flex flex-col gap-4\">\r\n <span className=\"paragraph-medium-semibold text-gray-600\">Notificações</span>\r\n <div className=\"flex flex-col gap-3\">\r\n <div className=\"flex flex-col border border-gray-200 rounded-lg\">\r\n <SwitchOptionFieldWithIcon\r\n icon={MessageCircle}\r\n label=\"WhatsApp\"\r\n description=\"Receber notificações importantes por WhatsApp\"\r\n checked={receiveSms}\r\n onCheckedChange={(val: boolean) => setValue('receive_sms', val, { shouldDirty: true })}\r\n />\r\n <SwitchOptionFieldWithIcon\r\n icon={Mail}\r\n label=\"E-mail\"\r\n description=\"Receber notificações e atualizações por email\"\r\n checked={receiveEmail}\r\n onCheckedChange={(val: boolean) => setValue('receive_email', val, { shouldDirty: true })}\r\n hideBorderBottom={true}\r\n />\r\n </div>\r\n <div className=\"flex flex-col gap-4 p-5 pb-6 rounded-lg bg-gray-50\">\r\n <span className=\"paragraph-small-semibold text-gray-950\">\r\n Tipos de notificações incluem:\r\n </span>\r\n <div className=\"flex flex-col\">\r\n {NOTIFICATION_TYPES.map((type) => (\r\n <div key={type} className=\"flex items-center gap-2\">\r\n <div className=\"size-1 rounded-full bg-gray-600\" />\r\n <span className=\"paragraph-small-medium text-gray-600\">{type}</span>\r\n </div>\r\n ))}\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n\r\n <div className=\"fixed bottom-0 left-0 right-0 lg:static flex items-center h-20 px-4 lg:px-5 border-t border-gray-200 justify-between bg-white z-10\">\r\n <Button\r\n variant=\"secondary\"\r\n className=\"h-10!\"\r\n type=\"button\"\r\n disabled={isSaving}\r\n onClick={() => {\r\n reset();\r\n onClose();\r\n }}\r\n >\r\n Cancelar\r\n </Button>\r\n <Button className=\"h-10!\" type=\"submit\" disabled={isSaving}>\r\n {isSaving ? 'Salvando...' : 'Salvar alterações'}\r\n </Button>\r\n </div>\r\n </form>\r\n\r\n <ConfirmGlobalPreferencesModal\r\n open={confirmGlobalOpen}\r\n onConfirm={handleConfirmGlobal}\r\n onCancel={handleCancelGlobal}\r\n />\r\n </>\r\n );\r\n}\r\n"],"mappings":";AAqGQ,SA6CJ,UA7CI,KAkDI,YAlDJ;AAnGR,SAAS,UAAU,iBAAiB;AACpC,SAAS,eAAe;AACxB,SAAS,aAAa;AACtB,SAAS,MAAM,MAAM,qBAAqB;AAC1C,SAAS,cAAc;AACvB,SAAS,iBAAiB;AAC1B,SAAS,aAAa;AACtB,SAAS,qBAAqB;AAC9B,SAAS,mBAAmB;AAC5B,OAAO,+BAA+B;AACtC,OAA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AAK,WAAU,0CAAyC,kDAEzD;AAAA,gBACA,oBAAC,SAAI,WAAU,iBACZ,6BAAmB,IAAI,CAAC,SACvB,qBAAC,SAAe,WAAU,2BACxB;AAAA,sCAAC,SAAI,WAAU,mCAAkC;AAAA,kBACjD,oBAAC,UAAK,WAAU,wCAAwC,gBAAK;AAAA,qBAFrD,IAGV,CACD,GACH;AAAA,iBACF;AAAA,eACF;AAAA,aACF;AAAA,WACF;AAAA,SACF;AAAA,MAEA,qBAAC,SAAI,WAAU,sIACb;AAAA;AAAA,UAAC;AAAA;AAAA,YACC,SAAQ;AAAA,YACR,WAAU;AAAA,YACV,MAAK;AAAA,YACL,UAAU;AAAA,YACV,SAAS,MAAM;AACb,oBAAM;AACN,sBAAQ;AAAA,YACV;AAAA,YACD;AAAA;AAAA,QAED;AAAA,QACA,oBAAC,UAAO,WAAU,SAAQ,MAAK,UAAS,UAAU,UAC/C,qBAAW,gBAAgB,2BAC9B;AAAA,SACF;AAAA,OACF;AAAA,IAEA;AAAA,MAAC;AAAA;AAAA,QACC,MAAM;AAAA,QACN,WAAW;AAAA,QACX,UAAU;AAAA;AAAA,IACZ;AAAA,KACF;AAEJ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/account/sections/PreferencesSection.tsx"],"sourcesContent":["'use client';\r\n\r\nimport { useState, useEffect } from 'react';\r\nimport { useForm } from 'react-hook-form';\r\nimport { toast } from 'sonner';\r\nimport { IconLock, IconMail, IconMessageCircle } from '@tabler/icons-react';\r\nimport { Button } from '../../ui/buttons/Button';\r\nimport { Separator } from '../../ui/data-display/Separator';\r\nimport { Toast } from '../../ui/feedback/Toast';\r\nimport { ComboboxField } from '../../ui/form/ComboboxField';\r\nimport { SelectField } from '../../ui/form/SelectField';\r\nimport SwitchOptionFieldWithIcon from '../../ui/form/SwitchOptionFieldWithIcon';\r\nimport ConfirmGlobalPreferencesModal from '../ConfirmGlobalPreferencesModal';\r\nimport { useAuth } from '../../../providers/auth.provider';\r\nimport { UserProfile } from '../../../modules/users/schema';\r\nimport type { UpdateAccountRequest } from '../../../modules/accounts/types';\r\nimport {\r\n useUpdateAccountUser,\r\n useUpdateAccount,\r\n} from '../../../modules/accounts/hooks/useAccountManagement';\r\nimport {\r\n LANGUAGE_OPTIONS,\r\n TIME_FORMAT_OPTIONS,\r\n NOTIFICATION_TYPES,\r\n} from '../constants';\r\nimport { useTimezones } from '../../../modules/accounts/hooks/useTimezones';\r\nimport { useCurrencies } from '../../../modules/accounts/hooks/useCurrencies';\r\n\r\ninterface PreferencesFormValues {\r\n language: string;\r\n currency: string;\r\n timezone: string;\r\n timeFormat: string;\r\n receive_sms: boolean;\r\n receive_email: boolean;\r\n}\r\n\r\ninterface PreferencesSectionProps {\r\n onClose: () => void;\r\n}\r\n\r\nexport function PreferencesSection({ onClose }: PreferencesSectionProps) {\r\n const { data: timezones = [] } = useTimezones();\r\n const { data: currencies = [] } = useCurrencies();\r\n const { user, account } = useAuth();\r\n const canEditPreferences =\r\n user?.profile === UserProfile.owner || user?.profile === UserProfile.admin;\r\n const updateAccountUser = useUpdateAccountUser();\r\n const updateAccount = useUpdateAccount();\r\n const [confirmGlobalOpen, setConfirmGlobalOpen] = useState(false);\r\n const [pendingSubmit, setPendingSubmit] = useState<{\r\n data: PreferencesFormValues;\r\n accountFields: UpdateAccountRequest;\r\n } | null>(null);\r\n const [isSaving, setIsSaving] = useState(false);\r\n\r\n const { watch, setValue, handleSubmit, reset, formState: { dirtyFields } } =\r\n useForm<PreferencesFormValues>({\r\n defaultValues: {\r\n language: '',\r\n currency: '',\r\n timezone: '',\r\n timeFormat: '24h',\r\n receive_sms: false,\r\n receive_email: false,\r\n },\r\n });\r\n\r\n useEffect(() => {\r\n if (!user || !account) return;\r\n reset({\r\n language: LANGUAGE_OPTIONS.find(\r\n (o) => o.apiValue === user.language?.toLowerCase()\r\n )?.value ?? 'pt-BR',\r\n currency: account.currency,\r\n timezone: account.timezone,\r\n timeFormat: '24h',\r\n receive_sms: user.receive_sms ?? false,\r\n receive_email: user.receive_email ?? false,\r\n });\r\n }, [user, account, reset]);\r\n\r\n const receiveSms = watch('receive_sms');\r\n const receiveEmail = watch('receive_email');\r\n\r\n const doSave = async (data: PreferencesFormValues, accountFields: UpdateAccountRequest) => {\r\n setIsSaving(true);\r\n try {\r\n const apiLanguage = LANGUAGE_OPTIONS.find((o) => o.value === data.language)?.apiValue ?? data.language.toLowerCase();\r\n await updateAccountUser.mutateAsync({\r\n language: apiLanguage,\r\n receive_sms: data.receive_sms,\r\n receive_email: data.receive_email,\r\n });\r\n\r\n if (canEditPreferences && Object.keys(accountFields).length > 0) {\r\n await updateAccount.mutateAsync(accountFields);\r\n }\r\n\r\n reset(data);\r\n toast.custom((t) => (\r\n <Toast variant=\"success\" message=\"Preferências salvas com sucesso\" toastId={t} />\r\n ));\r\n onClose();\r\n } catch (error) {\r\n toast.custom((t) => (\r\n <Toast\r\n variant=\"error\"\r\n message={error instanceof Error ? error.message : 'Erro ao salvar preferências'}\r\n toastId={t}\r\n />\r\n ));\r\n } finally {\r\n setIsSaving(false);\r\n }\r\n };\r\n\r\n const onSubmit = (data: PreferencesFormValues) => {\r\n const accountFields: UpdateAccountRequest = {\r\n ...(canEditPreferences && dirtyFields.currency && { currency: data.currency }),\r\n ...(canEditPreferences && dirtyFields.timezone && { timezone: data.timezone }),\r\n };\r\n const globalFieldChanged = Object.keys(accountFields).length > 0;\r\n\r\n if (globalFieldChanged) {\r\n setPendingSubmit({ data, accountFields });\r\n setConfirmGlobalOpen(true);\r\n } else {\r\n doSave(data, accountFields);\r\n }\r\n };\r\n\r\n const handleConfirmGlobal = () => {\r\n setConfirmGlobalOpen(false);\r\n if (pendingSubmit) {\r\n doSave(pendingSubmit.data, pendingSubmit.accountFields);\r\n setPendingSubmit(null);\r\n }\r\n };\r\n\r\n const handleCancelGlobal = () => {\r\n setConfirmGlobalOpen(false);\r\n setPendingSubmit(null);\r\n };\r\n\r\n return (\r\n <>\r\n <form onSubmit={handleSubmit(onSubmit)} className=\"lg:h-full lg:flex lg:flex-col\">\r\n <div className=\"absolute inset-0 overflow-y-auto overscroll-contain px-4 pb-36 lg:p-5 lg:static lg:flex-1 lg:min-h-0 lg:overscroll-auto flex flex-col gap-5 lg:gap-6\">\r\n <span className=\"paragraph-medium-semibold text-gray-950\">Preferências</span>\r\n <div className=\"flex flex-col gap-8\">\r\n <div className=\"flex flex-col lg:flex-row items-center gap-3\">\r\n <ComboboxField\r\n label=\"Idioma\"\r\n placeholder=\"Selecione o idioma\"\r\n searchPlaceholder=\"Buscar idioma...\"\r\n containerClassName=\"w-full\"\r\n options={LANGUAGE_OPTIONS}\r\n value={watch('language')}\r\n onChange={(value) => setValue('language', value, { shouldDirty: true })}\r\n />\r\n <ComboboxField\r\n label=\"Moeda\"\r\n placeholder=\"Selecione a moeda\"\r\n searchPlaceholder=\"Buscar moeda...\"\r\n containerClassName=\"w-full\"\r\n options={currencies}\r\n value={watch('currency')}\r\n onChange={(value) => setValue('currency', value, { shouldDirty: true })}\r\n icon={!canEditPreferences ? <IconLock className=\"size-4 text-gray-400\" /> : undefined}\r\n disabled={!canEditPreferences}\r\n />\r\n </div>\r\n\r\n <Separator />\r\n\r\n <div className=\"flex flex-col gap-4\">\r\n <span className=\"paragraph-medium-semibold text-gray-600\">Exibição hora</span>\r\n <div className=\"flex flex-col lg:flex-row items-center gap-3\">\r\n <ComboboxField\r\n label=\"Fuso horário\"\r\n placeholder=\"Selecione o fuso horário\"\r\n searchPlaceholder=\"Buscar fuso horário...\"\r\n containerClassName=\"w-full\"\r\n options={timezones}\r\n value={watch('timezone')}\r\n onChange={(value) => setValue('timezone', value, { shouldDirty: true })}\r\n icon={!canEditPreferences ? <IconLock className=\"size-4 text-gray-400\" /> : undefined}\r\n disabled={!canEditPreferences}\r\n />\r\n <SelectField\r\n label=\"Formato hora\"\r\n placeholder=\"Selecione o formato\"\r\n className=\"h-10!\"\r\n containerClassName=\"w-full\"\r\n options={TIME_FORMAT_OPTIONS}\r\n value={watch('timeFormat')}\r\n onChange={(value) =>\r\n setValue('timeFormat', value as string, { shouldDirty: true })\r\n }\r\n icon={<IconLock className=\"size-4 text-gray-400\" />}\r\n disabled\r\n />\r\n </div>\r\n </div>\r\n\r\n <Separator />\r\n\r\n <div className=\"flex flex-col gap-4\">\r\n <span className=\"paragraph-medium-semibold text-gray-600\">Notificações</span>\r\n <div className=\"flex flex-col gap-3\">\r\n <div className=\"flex flex-col border border-gray-200 rounded-lg\">\r\n <SwitchOptionFieldWithIcon\r\n icon={IconMessageCircle}\r\n label=\"WhatsApp\"\r\n description=\"Receber notificações importantes por WhatsApp\"\r\n checked={receiveSms}\r\n onCheckedChange={(val: boolean) => setValue('receive_sms', val, { shouldDirty: true })}\r\n />\r\n <SwitchOptionFieldWithIcon\r\n icon={IconMail}\r\n label=\"E-mail\"\r\n description=\"Receber notificações e atualizações por email\"\r\n checked={receiveEmail}\r\n onCheckedChange={(val: boolean) => setValue('receive_email', val, { shouldDirty: true })}\r\n hideBorderBottom={true}\r\n />\r\n </div>\r\n <div className=\"flex flex-col gap-4 p-5 pb-6 rounded-lg bg-gray-50\">\r\n <span className=\"paragraph-small-semibold text-gray-950\">\r\n Tipos de notificações incluem:\r\n </span>\r\n <div className=\"flex flex-col\">\r\n {NOTIFICATION_TYPES.map((type) => (\r\n <div key={type} className=\"flex items-center gap-2\">\r\n <div className=\"size-1 rounded-full bg-gray-600\" />\r\n <span className=\"paragraph-small-medium text-gray-600\">{type}</span>\r\n </div>\r\n ))}\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n\r\n <div className=\"fixed bottom-0 left-0 right-0 lg:static flex items-center h-20 px-4 lg:px-5 border-t border-gray-200 justify-between bg-white z-10\">\r\n <Button\r\n variant=\"secondary\"\r\n className=\"h-10!\"\r\n type=\"button\"\r\n disabled={isSaving}\r\n onClick={() => {\r\n reset();\r\n onClose();\r\n }}\r\n >\r\n Cancelar\r\n </Button>\r\n <Button className=\"h-10!\" type=\"submit\" disabled={isSaving}>\r\n {isSaving ? 'Salvando...' : 'Salvar alterações'}\r\n </Button>\r\n </div>\r\n </form>\r\n\r\n <ConfirmGlobalPreferencesModal\r\n open={confirmGlobalOpen}\r\n onConfirm={handleConfirmGlobal}\r\n onCancel={handleCancelGlobal}\r\n />\r\n </>\r\n );\r\n}\r\n"],"mappings":";AAqGQ,SA6CJ,UA7CI,KAkDI,YAlDJ;AAnGR,SAAS,UAAU,iBAAiB;AACpC,SAAS,eAAe;AACxB,SAAS,aAAa;AACtB,SAAS,UAAU,UAAU,yBAAyB;AACtD,SAAS,cAAc;AACvB,SAAS,iBAAiB;AAC1B,SAAS,aAAa;AACtB,SAAS,qBAAqB;AAC9B,SAAS,mBAAmB;AAC5B,OAAO,+BAA+B;AACtC,OAAO,mCAAmC;AAC1C,SAAS,eAAe;AACxB,SAAS,mBAAmB;AAE5B;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,oBAAoB;AAC7B,SAAS,qBAAqB;AAevB,SAAS,mBAAmB,EAAE,QAAQ,GAA4B;AACvE,QAAM,EAAE,MAAM,YAAY,CAAC,EAAE,IAAI,aAAa;AAC9C,QAAM,EAAE,MAAM,aAAa,CAAC,EAAE,IAAI,cAAc;AAChD,QAAM,EAAE,MAAM,QAAQ,IAAI,QAAQ;AAClC,QAAM,qBACJ,MAAM,YAAY,YAAY,SAAS,MAAM,YAAY,YAAY;AACvE,QAAM,oBAAoB,qBAAqB;AAC/C,QAAM,gBAAgB,iBAAiB;AACvC,QAAM,CAAC,mBAAmB,oBAAoB,IAAI,SAAS,KAAK;AAChE,QAAM,CAAC,eAAe,gBAAgB,IAAI,SAGhC,IAAI;AACd,QAAM,CAAC,UAAU,WAAW,IAAI,SAAS,KAAK;AAE9C,QAAM,EAAE,OAAO,UAAU,cAAc,OAAO,WAAW,EAAE,YAAY,EAAE,IACvE,QAA+B;AAAA,IAC7B,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|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useState, useCallback } from "react";
|
|
4
|
-
import {
|
|
4
|
+
import { IconLock, IconTool } from "@tabler/icons-react";
|
|
5
5
|
import { Badge } from "../../ui/data-display/Badge";
|
|
6
6
|
import { Button } from "../../ui/buttons/Button";
|
|
7
7
|
import { useAuth } from "../../../providers/auth.provider";
|
|
@@ -50,7 +50,7 @@ function SecuritySection({
|
|
|
50
50
|
onClick: handleToggleTwoFactor,
|
|
51
51
|
children: [
|
|
52
52
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-1 items-start lg:items-center gap-4 lg:gap-5", children: [
|
|
53
|
-
/* @__PURE__ */ jsx("div", { className: "size-10 rounded-lg bg-gray-50 flex items-center justify-center shrink-0", children: /* @__PURE__ */ jsx(
|
|
53
|
+
/* @__PURE__ */ jsx("div", { className: "size-10 rounded-lg bg-gray-50 flex items-center justify-center shrink-0", children: /* @__PURE__ */ jsx(IconTool, { size: 20, className: "text-gray-950" }) }),
|
|
54
54
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1.5 flex-1", children: [
|
|
55
55
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
56
56
|
/* @__PURE__ */ jsx("span", { className: "paragraph-small-semibold text-gray-950", children: "Autentica\xE7\xE3o de dois fatores" }),
|
|
@@ -87,7 +87,7 @@ function SecuritySection({
|
|
|
87
87
|
onClick: () => setActiveSection(AccountSectionType.CHANGE_PASSWORD),
|
|
88
88
|
children: [
|
|
89
89
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-1 items-start lg:items-center gap-4 lg:gap-5", children: [
|
|
90
|
-
/* @__PURE__ */ jsx("div", { className: "size-10 rounded-lg bg-gray-50 flex items-center justify-center shrink-0", children: /* @__PURE__ */ jsx(
|
|
90
|
+
/* @__PURE__ */ jsx("div", { className: "size-10 rounded-lg bg-gray-50 flex items-center justify-center shrink-0", children: /* @__PURE__ */ jsx(IconLock, { size: 20, className: "text-gray-950" }) }),
|
|
91
91
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1.5 flex-1", children: [
|
|
92
92
|
/* @__PURE__ */ jsx("span", { className: "paragraph-small-semibold text-gray-950", children: "Alterar senha de acesso" }),
|
|
93
93
|
/* @__PURE__ */ jsx("span", { className: "paragraph-small-regular text-gray-600", children: "Atualize sua senha sempre que necess\xE1rio para manter sua conta segura." })
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/account/sections/SecuritySection.tsx"],"sourcesContent":["'use client';\r\n\r\nimport { useState, useCallback } from 'react';\r\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/account/sections/SecuritySection.tsx"],"sourcesContent":["'use client';\r\n\r\nimport { useState, useCallback } from 'react';\r\nimport { IconLock, IconTool } from '@tabler/icons-react';\r\nimport { Badge } from '../../ui/data-display/Badge';\r\nimport { Button } from '../../ui/buttons/Button';\r\nimport { useAuth } from '../../../providers/auth.provider';\r\nimport { useQueryClient } from '@tanstack/react-query';\r\nimport { USER_QUERY_KEY } from '../../../modules/auth/hooks/useUserQuery';\r\nimport { AccountSectionType } from '../../../enums/AccountSectionType';\r\nimport TwoFactorAuthModal from '../TwoFactorAuthModal';\r\nimport DisableTwoFactorAuthModal from '../DisableTwoFactorAuthModal';\r\n\r\ninterface SecuritySectionProps {\r\n setActiveSection: (section: AccountSectionType) => void;\r\n onClose: () => void;\r\n hasActiveSubscription?: boolean;\r\n onDeleteAccount?: () => void;\r\n}\r\n\r\nexport function SecuritySection({\r\n setActiveSection,\r\n onClose,\r\n hasActiveSubscription,\r\n onDeleteAccount,\r\n}: SecuritySectionProps) {\r\n const { user } = useAuth();\r\n const queryClient = useQueryClient();\r\n\r\n const twoFactorAuth = user?.two_factor_authentication ?? false;\r\n const [twoFactorOpen, setTwoFactorOpen] = useState(false);\r\n const [disableTwoFactorOpen, setDisableTwoFactorOpen] = useState(false);\r\n\r\n const handleToggleTwoFactor = useCallback(() => {\r\n if (twoFactorAuth) {\r\n setDisableTwoFactorOpen(true);\r\n } else {\r\n setTwoFactorOpen(true);\r\n }\r\n }, [twoFactorAuth]);\r\n\r\n const handleDisableTwoFactorSuccess = useCallback(() => {\r\n queryClient.invalidateQueries({ queryKey: USER_QUERY_KEY });\r\n setDisableTwoFactorOpen(false);\r\n }, [queryClient]);\r\n\r\n const handleEnableTwoFactorSuccess = useCallback(() => {\r\n queryClient.invalidateQueries({ queryKey: USER_QUERY_KEY });\r\n setTwoFactorOpen(false);\r\n }, [queryClient]);\r\n\r\n const handleDeleteAccount = useCallback(() => {\r\n onDeleteAccount?.();\r\n }, [onDeleteAccount]);\r\n\r\n return (\r\n <>\r\n <div className=\"h-full overflow-y-auto overscroll-contain px-4 pb-20 lg:p-5 lg:pt-5 flex flex-col gap-5 lg:gap-6 lg:pb-31 lg:overscroll-auto\">\r\n <span className=\"paragraph-medium-semibold text-gray-950 hidden lg:block\">Segurança</span>\r\n\r\n <div className=\"border border-gray-200 rounded-lg overflow-hidden\">\r\n <div\r\n className=\"flex flex-col lg:flex-row lg:items-center gap-4 lg:gap-5 p-4 lg:p-5 border-b border-gray-200 cursor-pointer hover:bg-gray-25 transition-colors\"\r\n onClick={handleToggleTwoFactor}\r\n >\r\n <div className=\"flex flex-1 items-start lg:items-center gap-4 lg:gap-5\">\r\n <div className=\"size-10 rounded-lg bg-gray-50 flex items-center justify-center shrink-0\">\r\n <IconTool size={20} className=\"text-gray-950\" />\r\n </div>\r\n <div className=\"flex flex-col gap-1.5 flex-1\">\r\n <div className=\"flex flex-wrap items-center gap-2\">\r\n <span className=\"paragraph-small-semibold text-gray-950\">\r\n Autenticação de dois fatores\r\n </span>\r\n <Badge\r\n className={`paragraph-xsmall-semibold rounded-lg ${twoFactorAuth ? 'text-green-600 bg-green-50' : 'text-gray-600 bg-gray-50'}`}\r\n >\r\n {twoFactorAuth ? 'Habilitado' : 'Desabilitado'}\r\n </Badge>\r\n </div>\r\n <span className=\"paragraph-small-regular text-gray-600\">\r\n Envio de código de segurança (e-mail ou sms) para o usuário acessar o sistema\r\n </span>\r\n </div>\r\n </div>\r\n <Button\r\n variant=\"secondary\"\r\n className=\"h-10! shrink-0 w-full lg:w-auto\"\r\n onClick={(e) => {\r\n e.stopPropagation();\r\n handleToggleTwoFactor();\r\n }}\r\n >\r\n {twoFactorAuth ? 'Desabilitar' : 'Habilitar'}\r\n </Button>\r\n </div>\r\n\r\n <div\r\n className=\"flex flex-col lg:flex-row lg:items-center gap-4 lg:gap-5 p-4 lg:p-5 cursor-pointer hover:bg-gray-25 transition-colors\"\r\n onClick={() => setActiveSection(AccountSectionType.CHANGE_PASSWORD)}\r\n >\r\n <div className=\"flex flex-1 items-start lg:items-center gap-4 lg:gap-5\">\r\n <div className=\"size-10 rounded-lg bg-gray-50 flex items-center justify-center shrink-0\">\r\n <IconLock size={20} className=\"text-gray-950\" />\r\n </div>\r\n <div className=\"flex flex-col gap-1.5 flex-1\">\r\n <span className=\"paragraph-small-semibold text-gray-950\">\r\n Alterar senha de acesso\r\n </span>\r\n <span className=\"paragraph-small-regular text-gray-600\">\r\n Atualize sua senha sempre que necessário para manter sua conta segura.\r\n </span>\r\n </div>\r\n </div>\r\n <Button\r\n variant=\"secondary\"\r\n className=\"h-10! shrink-0 w-full lg:w-auto\"\r\n onClick={(e) => {\r\n e.stopPropagation();\r\n setActiveSection(AccountSectionType.CHANGE_PASSWORD);\r\n }}\r\n >\r\n Alterar senha\r\n </Button>\r\n </div>\r\n </div>\r\n\r\n {onDeleteAccount && (\r\n <button\r\n type=\"button\"\r\n className=\"paragraph-small-semibold text-red-600 bg-red-50 rounded-lg px-3 py-2 cursor-pointer hover:bg-red-100 transition-colors w-fit\"\r\n onClick={handleDeleteAccount}\r\n >\r\n Excluir minha conta\r\n </button>\r\n )}\r\n </div>\r\n\r\n <div className=\"fixed bottom-0 left-0 right-0 lg:absolute flex items-center h-20 px-4 lg:px-5 border-t border-gray-200 justify-between bg-white z-10\">\r\n <Button variant=\"secondary\" className=\"h-10!\" type=\"button\" onClick={onClose}>\r\n Cancelar\r\n </Button>\r\n <Button className=\"h-10!\" onClick={onClose}>\r\n Salvar alterações\r\n </Button>\r\n </div>\r\n\r\n <DisableTwoFactorAuthModal\r\n open={disableTwoFactorOpen}\r\n onClose={() => setDisableTwoFactorOpen(false)}\r\n onSuccess={handleDisableTwoFactorSuccess}\r\n />\r\n <TwoFactorAuthModal\r\n open={twoFactorOpen}\r\n onClose={() => setTwoFactorOpen(false)}\r\n onSuccess={handleEnableTwoFactorSuccess}\r\n />\r\n </>\r\n );\r\n}\r\n"],"mappings":";AAwDI,mBAEI,KAYQ,YAdZ;AAtDJ,SAAS,UAAU,mBAAmB;AACtC,SAAS,UAAU,gBAAgB;AACnC,SAAS,aAAa;AACtB,SAAS,cAAc;AACvB,SAAS,eAAe;AACxB,SAAS,sBAAsB;AAC/B,SAAS,sBAAsB;AAC/B,SAAS,0BAA0B;AACnC,OAAO,wBAAwB;AAC/B,OAAO,+BAA+B;AAS/B,SAAS,gBAAgB;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAyB;AACvB,QAAM,EAAE,KAAK,IAAI,QAAQ;AACzB,QAAM,cAAc,eAAe;AAEnC,QAAM,gBAAgB,MAAM,6BAA6B;AACzD,QAAM,CAAC,eAAe,gBAAgB,IAAI,SAAS,KAAK;AACxD,QAAM,CAAC,sBAAsB,uBAAuB,IAAI,SAAS,KAAK;AAEtE,QAAM,wBAAwB,YAAY,MAAM;AAC9C,QAAI,eAAe;AACjB,8BAAwB,IAAI;AAAA,IAC9B,OAAO;AACL,uBAAiB,IAAI;AAAA,IACvB;AAAA,EACF,GAAG,CAAC,aAAa,CAAC;AAElB,QAAM,gCAAgC,YAAY,MAAM;AACtD,gBAAY,kBAAkB,EAAE,UAAU,eAAe,CAAC;AAC1D,4BAAwB,KAAK;AAA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