@greatapps/common 1.1.676 → 1.1.677
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/account/ConfigurationsMyAccountModal.mjs +8 -6
- package/dist/components/account/ConfigurationsMyAccountModal.mjs.map +1 -1
- package/dist/components/account/ConfirmDeleteAccountModal.mjs +20 -19
- package/dist/components/account/ConfirmDeleteAccountModal.mjs.map +1 -1
- package/dist/components/account/ConfirmGlobalPreferencesModal.mjs +10 -11
- package/dist/components/account/ConfirmGlobalPreferencesModal.mjs.map +1 -1
- package/dist/components/account/DeleteAccountModal.mjs +34 -28
- package/dist/components/account/DeleteAccountModal.mjs.map +1 -1
- package/dist/components/account/DisableTwoFactorAuthModal.mjs +7 -5
- package/dist/components/account/DisableTwoFactorAuthModal.mjs.map +1 -1
- package/dist/components/account/IsntPossibleDeleteAccountModal.mjs +8 -9
- package/dist/components/account/IsntPossibleDeleteAccountModal.mjs.map +1 -1
- package/dist/components/account/TwoFactorAuthModal.mjs +22 -23
- package/dist/components/account/TwoFactorAuthModal.mjs.map +1 -1
- package/dist/components/account/constants.mjs +4 -4
- package/dist/components/account/constants.mjs.map +1 -1
- package/dist/components/account/hooks/useChangeEmailForm.mjs +5 -3
- package/dist/components/account/hooks/useChangeEmailForm.mjs.map +1 -1
- package/dist/components/account/hooks/useChangePasswordForm.mjs +26 -3
- package/dist/components/account/hooks/useChangePasswordForm.mjs.map +1 -1
- package/dist/components/account/hooks/useChangePhoneForm.mjs +18 -9
- package/dist/components/account/hooks/useChangePhoneForm.mjs.map +1 -1
- package/dist/components/account/hooks/useDisableTwoFactorAuthForm.mjs +26 -3
- package/dist/components/account/hooks/useDisableTwoFactorAuthForm.mjs.map +1 -1
- package/dist/components/account/hooks/useOtpVerification.mjs +19 -3
- package/dist/components/account/hooks/useOtpVerification.mjs.map +1 -1
- package/dist/components/account/hooks/useTwoFactorAuthForm.mjs +27 -4
- package/dist/components/account/hooks/useTwoFactorAuthForm.mjs.map +1 -1
- package/dist/components/account/sections/ChangeEmailModal.mjs +25 -28
- package/dist/components/account/sections/ChangeEmailModal.mjs.map +1 -1
- package/dist/components/account/sections/ChangePasswordSection.mjs +8 -6
- package/dist/components/account/sections/ChangePasswordSection.mjs.map +1 -1
- package/dist/components/account/sections/ChangePhoneModal.mjs +24 -27
- package/dist/components/account/sections/ChangePhoneModal.mjs.map +1 -1
- package/dist/components/account/sections/MyProfileSection.mjs +37 -22
- package/dist/components/account/sections/MyProfileSection.mjs.map +1 -1
- package/dist/components/account/sections/PreferencesSection.mjs +48 -24
- package/dist/components/account/sections/PreferencesSection.mjs.map +1 -1
- package/dist/components/account/sections/SecuritySection.mjs +11 -9
- package/dist/components/account/sections/SecuritySection.mjs.map +1 -1
- package/dist/components/account/sections/TokenSection.mjs +24 -8
- package/dist/components/account/sections/TokenSection.mjs.map +1 -1
- package/dist/components/layouts/AppMobileNavBar.mjs +2 -148
- package/dist/components/layouts/AppMobileNavBar.mjs.map +1 -1
- package/dist/components/layouts/NavBar.mjs +5 -3
- package/dist/components/layouts/NavBar.mjs.map +1 -1
- package/dist/components/layouts/NotificationsPopover.mjs +5 -3
- package/dist/components/layouts/NotificationsPopover.mjs.map +1 -1
- package/dist/components/layouts/ProfilePopover.mjs +6 -4
- package/dist/components/layouts/ProfilePopover.mjs.map +1 -1
- package/dist/components/layouts/UsersSelectorPopover.mjs +9 -7
- package/dist/components/layouts/UsersSelectorPopover.mjs.map +1 -1
- package/dist/components/modals/BuyCreditsModal.mjs +17 -18
- package/dist/components/modals/BuyCreditsModal.mjs.map +1 -1
- package/dist/components/modals/CreditsDisabledModal.mjs +6 -4
- package/dist/components/modals/CreditsDisabledModal.mjs.map +1 -1
- package/dist/components/modals/PaidPlanRequiredModal.mjs +5 -3
- package/dist/components/modals/PaidPlanRequiredModal.mjs.map +1 -1
- package/dist/components/modals/cards/AddCardModal.mjs +64 -46
- package/dist/components/modals/cards/AddCardModal.mjs.map +1 -1
- package/dist/components/modals/cards/CannotDeleteCardModal.mjs +9 -7
- package/dist/components/modals/cards/CannotDeleteCardModal.mjs.map +1 -1
- package/dist/components/modals/cards/CardFormFields.mjs +65 -51
- package/dist/components/modals/cards/CardFormFields.mjs.map +1 -1
- package/dist/components/modals/cards/DeleteCardModal.mjs +10 -8
- package/dist/components/modals/cards/DeleteCardModal.mjs.map +1 -1
- package/dist/components/navigation/CancelledSubscriptionBanner.mjs +4 -2
- package/dist/components/navigation/CancelledSubscriptionBanner.mjs.map +1 -1
- package/dist/components/navigation/OverdueInvoiceBanner.mjs +4 -2
- package/dist/components/navigation/OverdueInvoiceBanner.mjs.map +1 -1
- package/dist/components/navigation/PendingCancellationBanner.mjs +4 -6
- package/dist/components/navigation/PendingCancellationBanner.mjs.map +1 -1
- package/dist/components/navigation/ProjectSelectorPopover.mjs +8 -6
- package/dist/components/navigation/ProjectSelectorPopover.mjs.map +1 -1
- package/dist/components/navigation/UpcomingInvoiceBanner.mjs +4 -6
- package/dist/components/navigation/UpcomingInvoiceBanner.mjs.map +1 -1
- package/dist/components/navigation/subcomponents/BottomLinks.mjs +5 -3
- package/dist/components/navigation/subcomponents/BottomLinks.mjs.map +1 -1
- package/dist/components/navigation/subcomponents/CreditsCard.mjs +3 -1
- package/dist/components/navigation/subcomponents/CreditsCard.mjs.map +1 -1
- package/dist/components/navigation/subcomponents/PlanCard.mjs +3 -1
- package/dist/components/navigation/subcomponents/PlanCard.mjs.map +1 -1
- package/dist/components/navigation/subcomponents/ProjectSelector.mjs +5 -3
- package/dist/components/navigation/subcomponents/ProjectSelector.mjs.map +1 -1
- package/dist/components/pages/NotFoundPage.mjs +5 -3
- package/dist/components/pages/NotFoundPage.mjs.map +1 -1
- package/dist/components/pages/notifications/Notifications.mjs +13 -10
- package/dist/components/pages/notifications/Notifications.mjs.map +1 -1
- package/dist/components/ui/buttons/CopyButton.mjs +9 -5
- package/dist/components/ui/buttons/CopyButton.mjs.map +1 -1
- package/dist/components/ui/data-display/CardItem.mjs +7 -5
- package/dist/components/ui/data-display/CardItem.mjs.map +1 -1
- package/dist/components/ui/data-display/PaymentInfoCard.mjs +10 -8
- package/dist/components/ui/data-display/PaymentInfoCard.mjs.map +1 -1
- package/dist/components/ui/feedback/CircularProgress.mjs.map +1 -1
- package/dist/components/ui/feedback/DefaultCircularProgress.mjs +3 -1
- package/dist/components/ui/feedback/DefaultCircularProgress.mjs.map +1 -1
- package/dist/components/ui/form/ComboboxField.mjs +11 -6
- package/dist/components/ui/form/ComboboxField.mjs.map +1 -1
- package/dist/components/ui/form/DatePicker.mjs +5 -2
- package/dist/components/ui/form/DatePicker.mjs.map +1 -1
- package/dist/components/ui/form/DateRangePicker.mjs +5 -2
- package/dist/components/ui/form/DateRangePicker.mjs.map +1 -1
- package/dist/components/ui/form/PhoneInput.mjs +5 -3
- package/dist/components/ui/form/PhoneInput.mjs.map +1 -1
- package/dist/components/ui/form/SelectField.mjs +6 -3
- package/dist/components/ui/form/SelectField.mjs.map +1 -1
- package/dist/components/widgets/ImageUpload/ImageCropModal.mjs +11 -18
- package/dist/components/widgets/ImageUpload/ImageCropModal.mjs.map +1 -1
- package/dist/components/widgets/ImageUpload/ImageTooSmallModal.mjs +6 -15
- package/dist/components/widgets/ImageUpload/ImageTooSmallModal.mjs.map +1 -1
- package/dist/i18n/config.mjs +13 -0
- package/dist/i18n/config.mjs.map +1 -0
- package/dist/i18n/country-language.mjs +74 -0
- package/dist/i18n/country-language.mjs.map +1 -0
- package/dist/i18n/messages/en-us.mjs +494 -0
- package/dist/i18n/messages/en-us.mjs.map +1 -0
- package/dist/i18n/messages/es-es.mjs +494 -0
- package/dist/i18n/messages/es-es.mjs.map +1 -0
- package/dist/i18n/messages/index.mjs +16 -0
- package/dist/i18n/messages/index.mjs.map +1 -0
- package/dist/i18n/messages/pt-br.mjs +507 -0
- package/dist/i18n/messages/pt-br.mjs.map +1 -0
- package/dist/i18n/normalize.mjs +12 -0
- package/dist/i18n/normalize.mjs.map +1 -0
- package/dist/i18n/resolve-locale.mjs +42 -0
- package/dist/i18n/resolve-locale.mjs.map +1 -0
- package/dist/i18n.mjs +14 -0
- package/dist/i18n.mjs.map +1 -0
- package/dist/index.mjs +19 -3
- package/dist/index.mjs.map +1 -1
- package/dist/modules/accounts/hooks/use-currency-formatter.hook.mjs +20 -0
- package/dist/modules/accounts/hooks/use-currency-formatter.hook.mjs.map +1 -0
- package/dist/modules/cards/hooks/handle-delete-card.hook.mjs +2 -1
- package/dist/modules/cards/hooks/handle-delete-card.hook.mjs.map +1 -1
- package/dist/modules/images/utils/validate-image.mjs +8 -8
- package/dist/modules/images/utils/validate-image.mjs.map +1 -1
- package/dist/modules/plans/hooks/list-plans.hook.mjs +2 -2
- package/dist/modules/plans/hooks/list-plans.hook.mjs.map +1 -1
- package/dist/modules/plans/services/plans.service.mjs +1 -1
- package/dist/modules/plans/services/plans.service.mjs.map +1 -1
- package/dist/modules/plans/types/plan.type.mjs +5 -1
- package/dist/modules/plans/types/plan.type.mjs.map +1 -1
- package/dist/modules/plans/utils/map-api-plan-to-ui.mjs +61 -35
- package/dist/modules/plans/utils/map-api-plan-to-ui.mjs.map +1 -1
- package/dist/modules/projects/services/projects.service.mjs +9 -0
- package/dist/modules/projects/services/projects.service.mjs.map +1 -1
- package/dist/modules/subscriptions/utils/periodicity.mjs +20 -14
- package/dist/modules/subscriptions/utils/periodicity.mjs.map +1 -1
- package/dist/providers/auth.provider.mjs +9 -1
- package/dist/providers/auth.provider.mjs.map +1 -1
- package/dist/server.mjs +2 -0
- package/dist/server.mjs.map +1 -1
- package/dist/utils/format/currency.mjs +32 -4
- package/dist/utils/format/currency.mjs.map +1 -1
- package/dist/utils/intl/cookie-domain.mjs +17 -0
- package/dist/utils/intl/cookie-domain.mjs.map +1 -0
- package/dist/utils/intl/locale-cookie.mjs +13 -0
- package/dist/utils/intl/locale-cookie.mjs.map +1 -0
- package/dist/utils/intl/locales.mjs +3 -2
- package/dist/utils/intl/locales.mjs.map +1 -1
- package/package.json +7 -1
- package/src/components/account/ConfigurationsMyAccountModal.tsx +10 -6
- package/src/components/account/ConfirmDeleteAccountModal.tsx +22 -13
- package/src/components/account/ConfirmGlobalPreferencesModal.tsx +12 -10
- package/src/components/account/DeleteAccountModal.tsx +34 -24
- package/src/components/account/DisableTwoFactorAuthModal.tsx +11 -6
- package/src/components/account/IsntPossibleDeleteAccountModal.tsx +8 -6
- package/src/components/account/TwoFactorAuthModal.tsx +33 -29
- package/src/components/account/constants.ts +8 -5
- package/src/components/account/hooks/useChangeEmailForm.tsx +5 -3
- package/src/components/account/hooks/useChangePasswordForm.tsx +20 -6
- package/src/components/account/hooks/useChangePhoneForm.tsx +16 -10
- package/src/components/account/hooks/useDisableTwoFactorAuthForm.tsx +20 -6
- package/src/components/account/hooks/useOtpVerification.tsx +16 -4
- package/src/components/account/hooks/useTwoFactorAuthForm.tsx +21 -7
- package/src/components/account/sections/ChangeEmailModal.tsx +35 -21
- package/src/components/account/sections/ChangePasswordSection.tsx +10 -6
- package/src/components/account/sections/ChangePhoneModal.tsx +50 -22
- package/src/components/account/sections/MyProfileSection.tsx +37 -23
- package/src/components/account/sections/PreferencesSection.tsx +52 -25
- package/src/components/account/sections/SecuritySection.tsx +19 -10
- package/src/components/account/sections/TokenSection.tsx +22 -10
- package/src/components/layouts/AppMobileNavBar.tsx +1 -154
- package/src/components/layouts/NavBar.tsx +5 -3
- package/src/components/layouts/NotificationsPopover.tsx +5 -3
- package/src/components/layouts/ProfilePopover.tsx +6 -4
- package/src/components/layouts/UsersSelectorPopover.tsx +9 -7
- package/src/components/modals/BuyCreditsModal.tsx +18 -16
- package/src/components/modals/CreditsDisabledModal.tsx +6 -6
- package/src/components/modals/PaidPlanRequiredModal.tsx +5 -3
- package/src/components/modals/cards/AddCardModal.tsx +89 -62
- package/src/components/modals/cards/CannotDeleteCardModal.tsx +9 -8
- package/src/components/modals/cards/CardFormFields.tsx +93 -75
- package/src/components/modals/cards/DeleteCardModal.tsx +10 -8
- package/src/components/navigation/CancelledSubscriptionBanner.tsx +4 -2
- package/src/components/navigation/OverdueInvoiceBanner.tsx +4 -2
- package/src/components/navigation/PendingCancellationBanner.tsx +4 -2
- package/src/components/navigation/ProjectSelectorPopover.tsx +8 -6
- package/src/components/navigation/UpcomingInvoiceBanner.tsx +4 -2
- package/src/components/navigation/subcomponents/BottomLinks.tsx +5 -3
- package/src/components/navigation/subcomponents/CreditsCard.tsx +3 -1
- package/src/components/navigation/subcomponents/PlanCard.tsx +3 -1
- package/src/components/navigation/subcomponents/ProjectSelector.tsx +5 -3
- package/src/components/pages/NotFoundPage.tsx +5 -3
- package/src/components/pages/notifications/Notifications.tsx +13 -10
- package/src/components/ui/buttons/CopyButton.tsx +10 -5
- package/src/components/ui/data-display/CardItem.tsx +7 -5
- package/src/components/ui/data-display/PaymentInfoCard.tsx +10 -8
- package/src/components/ui/feedback/CircularProgress.tsx +4 -0
- package/src/components/ui/feedback/DefaultCircularProgress.tsx +3 -1
- package/src/components/ui/form/ComboboxField.tsx +11 -6
- package/src/components/ui/form/DatePicker.tsx +5 -2
- package/src/components/ui/form/DateRangePicker.tsx +5 -2
- package/src/components/ui/form/PhoneInput.tsx +5 -3
- package/src/components/ui/form/SelectField.tsx +6 -3
- package/src/components/widgets/ImageUpload/ImageCropModal.tsx +19 -11
- package/src/components/widgets/ImageUpload/ImageTooSmallModal.tsx +6 -5
- package/src/i18n/config.ts +17 -0
- package/src/i18n/country-language.ts +60 -0
- package/src/i18n/messages/en-us.ts +514 -0
- package/src/i18n/messages/es-es.ts +515 -0
- package/src/i18n/messages/index.ts +24 -0
- package/src/i18n/messages/pt-br.ts +538 -0
- package/src/i18n/normalize.ts +15 -0
- package/src/i18n/resolve-locale.ts +77 -0
- package/src/i18n.ts +10 -0
- package/src/index.ts +13 -2
- package/src/modules/accounts/hooks/use-currency-formatter.hook.tsx +32 -0
- package/src/modules/cards/hooks/handle-delete-card.hook.ts +8 -3
- package/src/modules/images/utils/validate-image.ts +23 -8
- package/src/modules/plans/hooks/list-plans.hook.ts +2 -2
- package/src/modules/plans/services/plans.service.ts +1 -1
- package/src/modules/plans/types/plan.type.ts +4 -0
- package/src/modules/plans/utils/map-api-plan-to-ui.ts +109 -47
- package/src/modules/projects/services/projects.service.ts +12 -0
- package/src/modules/subscriptions/utils/periodicity.ts +29 -12
- package/src/providers/auth.provider.tsx +13 -1
- package/src/server.ts +2 -0
- package/src/utils/format/currency.ts +62 -7
- package/src/utils/intl/cookie-domain.ts +29 -0
- package/src/utils/intl/locale-cookie.ts +18 -0
- package/src/utils/intl/locales.ts +3 -2
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useTranslations } from "next-intl";
|
|
3
4
|
import { IconAlertTriangle } from "@tabler/icons-react";
|
|
4
5
|
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from "../ui/overlay/Dialog";
|
|
5
6
|
import { Button } from "../ui/buttons/Button";
|
|
6
7
|
import { useAccountModals } from "../../store/useAccountModals";
|
|
7
8
|
function IsntPossibleDeleteAccountModal() {
|
|
9
|
+
const translate = useTranslations();
|
|
8
10
|
const { activeModal, close, config } = useAccountModals();
|
|
9
11
|
const { onGoToSubscription } = config;
|
|
10
12
|
const open = activeModal === "isntPossibleDelete";
|
|
@@ -12,25 +14,22 @@ function IsntPossibleDeleteAccountModal() {
|
|
|
12
14
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-5", children: [
|
|
13
15
|
/* @__PURE__ */ jsx("div", { className: "flex items-center justify-center w-fit bg-red-50 rounded-lg p-2.5", children: /* @__PURE__ */ jsx(IconAlertTriangle, { size: 20, className: "text-red-500" }) }),
|
|
14
16
|
/* @__PURE__ */ jsxs(DialogHeader, { className: "p-0 gap-2", children: [
|
|
15
|
-
/* @__PURE__ */ jsx(DialogTitle, { className: "paragraph-medium-semibold text-gray-950", children: "
|
|
16
|
-
/* @__PURE__ */
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
/* @__PURE__ */ jsx("span", { className: "font-semibold text-gray-950", children: "primeiro cancele a assinatura" }),
|
|
20
|
-
" na p\xE1gina Assinatura e depois tente novamente."
|
|
21
|
-
] })
|
|
17
|
+
/* @__PURE__ */ jsx(DialogTitle, { className: "paragraph-medium-semibold text-gray-950", children: translate("common.account.cantDelete.title") }),
|
|
18
|
+
/* @__PURE__ */ jsx(DialogDescription, { className: "paragraph-small-regular text-gray-600", children: translate.rich("common.account.cantDelete.description", {
|
|
19
|
+
b: (chunks) => /* @__PURE__ */ jsx("span", { className: "font-semibold text-gray-950", children: chunks })
|
|
20
|
+
}) })
|
|
22
21
|
] })
|
|
23
22
|
] }),
|
|
24
23
|
/* @__PURE__ */ jsx("div", { className: "h-px bg-gray-200 -mx-6" }),
|
|
25
24
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-row items-center gap-2", children: [
|
|
26
|
-
/* @__PURE__ */ jsx(Button, { className: "h-10 flex-1", onClick: close, children: "
|
|
25
|
+
/* @__PURE__ */ jsx(Button, { className: "h-10 flex-1", onClick: close, children: translate("common.account.cantDelete.confirm") }),
|
|
27
26
|
/* @__PURE__ */ jsx(
|
|
28
27
|
Button,
|
|
29
28
|
{
|
|
30
29
|
variant: "secondary",
|
|
31
30
|
className: "h-10 flex-1",
|
|
32
31
|
onClick: onGoToSubscription ?? close,
|
|
33
|
-
children: "
|
|
32
|
+
children: translate("common.account.cantDelete.goToSubscription")
|
|
34
33
|
}
|
|
35
34
|
)
|
|
36
35
|
] })
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/account/IsntPossibleDeleteAccountModal.tsx"],"sourcesContent":["'use client';\n\nimport { IconAlertTriangle } from '@tabler/icons-react';\nimport { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from '../ui/overlay/Dialog';\nimport { Button } from '../ui/buttons/Button';\nimport { useAccountModals } from '../../store/useAccountModals';\n\nexport default function IsntPossibleDeleteAccountModal() {\n const { activeModal, close, config } = useAccountModals();\n const { onGoToSubscription } = config;\n const open = activeModal === 'isntPossibleDelete';\n\n return (\n <Dialog open={open} onOpenChange={close}>\n <DialogContent className=\"max-w-[calc(100%-2rem)]! w-full rounded-lg border sm:max-w-[400px]! lg:max-w-[470px]! lg:top-[50%]! lg:left-[50%]! lg:right-auto! lg:bottom-auto! lg:translate-x-[-50%]! lg:translate-y-[-50%]!\">\n <div className=\"flex flex-col gap-5\">\n <div className=\"flex items-center justify-center w-fit bg-red-50 rounded-lg p-2.5\">\n <IconAlertTriangle size={20} className=\"text-red-500\" />\n </div>\n <DialogHeader className=\"p-0 gap-2\">\n <DialogTitle className=\"paragraph-medium-semibold text-gray-950\">\n
|
|
1
|
+
{"version":3,"sources":["../../../src/components/account/IsntPossibleDeleteAccountModal.tsx"],"sourcesContent":["'use client';\n\nimport { useTranslations } from 'next-intl';\nimport { IconAlertTriangle } from '@tabler/icons-react';\nimport { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from '../ui/overlay/Dialog';\nimport { Button } from '../ui/buttons/Button';\nimport { useAccountModals } from '../../store/useAccountModals';\n\nexport default function IsntPossibleDeleteAccountModal() {\n const translate = useTranslations();\n const { activeModal, close, config } = useAccountModals();\n const { onGoToSubscription } = config;\n const open = activeModal === 'isntPossibleDelete';\n\n return (\n <Dialog open={open} onOpenChange={close}>\n <DialogContent className=\"max-w-[calc(100%-2rem)]! w-full rounded-lg border sm:max-w-[400px]! lg:max-w-[470px]! lg:top-[50%]! lg:left-[50%]! lg:right-auto! lg:bottom-auto! lg:translate-x-[-50%]! lg:translate-y-[-50%]!\">\n <div className=\"flex flex-col gap-5\">\n <div className=\"flex items-center justify-center w-fit bg-red-50 rounded-lg p-2.5\">\n <IconAlertTriangle size={20} className=\"text-red-500\" />\n </div>\n <DialogHeader className=\"p-0 gap-2\">\n <DialogTitle className=\"paragraph-medium-semibold text-gray-950\">\n {translate('common.account.cantDelete.title')}\n </DialogTitle>\n <DialogDescription className=\"paragraph-small-regular text-gray-600\">\n {translate.rich('common.account.cantDelete.description', {\n b: (chunks) => <span className=\"font-semibold text-gray-950\">{chunks}</span>,\n })}\n </DialogDescription>\n </DialogHeader>\n </div>\n\n <div className=\"h-px bg-gray-200 -mx-6\" />\n\n <div className=\"flex flex-row items-center gap-2\">\n <Button className=\"h-10 flex-1\" onClick={close}>\n {translate('common.account.cantDelete.confirm')}\n </Button>\n <Button\n variant=\"secondary\"\n className=\"h-10 flex-1\"\n onClick={onGoToSubscription ?? close}\n >\n {translate('common.account.cantDelete.goToSubscription')}\n </Button>\n </div>\n </DialogContent>\n </Dialog>\n );\n}\n"],"mappings":";AAmBY,cAEF,YAFE;AAjBZ,SAAS,uBAAuB;AAChC,SAAS,yBAAyB;AAClC,SAAS,QAAQ,eAAe,mBAAmB,cAAc,mBAAmB;AACpF,SAAS,cAAc;AACvB,SAAS,wBAAwB;AAElB,SAAR,iCAAkD;AACvD,QAAM,YAAY,gBAAgB;AAClC,QAAM,EAAE,aAAa,OAAO,OAAO,IAAI,iBAAiB;AACxD,QAAM,EAAE,mBAAmB,IAAI;AAC/B,QAAM,OAAO,gBAAgB;AAE7B,SACE,oBAAC,UAAO,MAAY,cAAc,OAChC,+BAAC,iBAAc,WAAU,mMACvB;AAAA,yBAAC,SAAI,WAAU,uBACb;AAAA,0BAAC,SAAI,WAAU,qEACb,8BAAC,qBAAkB,MAAM,IAAI,WAAU,gBAAe,GACxD;AAAA,MACA,qBAAC,gBAAa,WAAU,aACtB;AAAA,4BAAC,eAAY,WAAU,2CACpB,oBAAU,iCAAiC,GAC9C;AAAA,QACA,oBAAC,qBAAkB,WAAU,yCAC1B,oBAAU,KAAK,yCAAyC;AAAA,UACvD,GAAG,CAAC,WAAW,oBAAC,UAAK,WAAU,+BAA+B,kBAAO;AAAA,QACvE,CAAC,GACH;AAAA,SACF;AAAA,OACF;AAAA,IAEA,oBAAC,SAAI,WAAU,0BAAyB;AAAA,IAExC,qBAAC,SAAI,WAAU,oCACb;AAAA,0BAAC,UAAO,WAAU,eAAc,SAAS,OACtC,oBAAU,mCAAmC,GAChD;AAAA,MACA;AAAA,QAAC;AAAA;AAAA,UACC,SAAQ;AAAA,UACR,WAAU;AAAA,UACV,SAAS,sBAAsB;AAAA,UAE9B,oBAAU,4CAA4C;AAAA;AAAA,MACzD;AAAA,OACF;AAAA,KACF,GACF;AAEJ;","names":[]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useTranslations } from "next-intl";
|
|
3
4
|
import { IconX, IconCopy, IconRefresh } from "@tabler/icons-react";
|
|
4
5
|
import { Button } from "../ui/buttons/Button";
|
|
5
6
|
import { Dialog, DialogContent, DialogHeader, DialogTitle } from "../ui/overlay/Dialog";
|
|
@@ -8,6 +9,7 @@ import { InputOTP, InputOTPGroup, InputOTPSlot } from "../ui/form/InputOtp";
|
|
|
8
9
|
import { REGEXP_ONLY_DIGITS } from "input-otp";
|
|
9
10
|
import useTwoFactorAuthForm from "./hooks/useTwoFactorAuthForm";
|
|
10
11
|
function TwoFactorAuthModal({ open, onClose, onSuccess }) {
|
|
12
|
+
const translate = useTranslations();
|
|
11
13
|
const {
|
|
12
14
|
code,
|
|
13
15
|
setCode,
|
|
@@ -36,9 +38,9 @@ function TwoFactorAuthModal({ open, onClose, onSuccess }) {
|
|
|
36
38
|
overlayClassName: "z-[1010]",
|
|
37
39
|
className: "z-[1011] flex flex-col p-0 gap-0 max-w-full sm:max-w-full border-0 rounded-t-2xl rounded-b-none h-[100dvh] top-0 bottom-0 left-0 right-0 translate-x-0 translate-y-0 lg:max-w-[470px] lg:h-auto lg:rounded-lg lg:border lg:top-[50%] lg:left-[50%] lg:right-auto lg:bottom-auto lg:translate-x-[-50%] lg:translate-y-[-50%]",
|
|
38
40
|
children: [
|
|
39
|
-
/* @__PURE__ */ jsx(DialogHeader, { className: "sr-only", children: /* @__PURE__ */ jsx(DialogTitle, { children: "
|
|
41
|
+
/* @__PURE__ */ jsx(DialogHeader, { className: "sr-only", children: /* @__PURE__ */ jsx(DialogTitle, { children: translate("common.account.twoFactor.recoveryTitle") }) }),
|
|
40
42
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center px-4 py-3 relative border-b border-gray-200 lg:border-b-0", children: [
|
|
41
|
-
/* @__PURE__ */ jsx("span", { className: "paragraph-medium-semibold text-gray-950 text-center", children: "
|
|
43
|
+
/* @__PURE__ */ jsx("span", { className: "paragraph-medium-semibold text-gray-950 text-center", children: translate("common.account.twoFactor.recoveryTitle") }),
|
|
42
44
|
/* @__PURE__ */ jsx(
|
|
43
45
|
Button,
|
|
44
46
|
{
|
|
@@ -52,11 +54,11 @@ function TwoFactorAuthModal({ open, onClose, onSuccess }) {
|
|
|
52
54
|
] }),
|
|
53
55
|
/* @__PURE__ */ jsxs("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", children: [
|
|
54
56
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
55
|
-
/* @__PURE__ */ jsx("h3", { className: "paragraph-medium-semibold text-gray-950 max-w-[269px]", children: "
|
|
57
|
+
/* @__PURE__ */ jsx("h3", { className: "paragraph-medium-semibold text-gray-950 max-w-[269px]", children: translate("common.account.twoFactor.recoveryHeading") }),
|
|
56
58
|
/* @__PURE__ */ jsxs("div", { className: "paragraph-small-regular text-gray-600", children: [
|
|
57
|
-
/* @__PURE__ */ jsx("p", { children: "
|
|
59
|
+
/* @__PURE__ */ jsx("p", { children: translate("common.account.twoFactor.recoveryText1") }),
|
|
58
60
|
/* @__PURE__ */ jsx("br", {}),
|
|
59
|
-
/* @__PURE__ */ jsx("p", { children: "
|
|
61
|
+
/* @__PURE__ */ jsx("p", { children: translate("common.account.twoFactor.recoveryText2") })
|
|
60
62
|
] })
|
|
61
63
|
] }),
|
|
62
64
|
/* @__PURE__ */ jsxs("div", { className: "bg-gray-50 rounded-lg p-4 flex flex-col gap-4", children: [
|
|
@@ -70,15 +72,15 @@ function TwoFactorAuthModal({ open, onClose, onSuccess }) {
|
|
|
70
72
|
onClick: handleCopyCodes,
|
|
71
73
|
children: [
|
|
72
74
|
/* @__PURE__ */ jsx(IconCopy, { size: 16 }),
|
|
73
|
-
"
|
|
75
|
+
translate("common.account.twoFactor.copyCodes")
|
|
74
76
|
]
|
|
75
77
|
}
|
|
76
78
|
)
|
|
77
79
|
] })
|
|
78
80
|
] }),
|
|
79
81
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center p-4 lg:p-5 border-t border-gray-200 justify-between mt-auto lg:mt-0", children: [
|
|
80
|
-
/* @__PURE__ */ jsx(Button, { variant: "secondary", className: "h-10!", type: "button", onClick: handleClose, children: "
|
|
81
|
-
/* @__PURE__ */ jsx(Button, { className: "h-10!", type: "button", onClick: handleFinalize, children: "
|
|
82
|
+
/* @__PURE__ */ jsx(Button, { variant: "secondary", className: "h-10!", type: "button", onClick: handleClose, children: translate("common.actions.cancel") }),
|
|
83
|
+
/* @__PURE__ */ jsx(Button, { className: "h-10!", type: "button", onClick: handleFinalize, children: translate("common.account.twoFactor.finish") })
|
|
82
84
|
] })
|
|
83
85
|
]
|
|
84
86
|
}
|
|
@@ -91,9 +93,9 @@ function TwoFactorAuthModal({ open, onClose, onSuccess }) {
|
|
|
91
93
|
overlayClassName: "z-[1010]",
|
|
92
94
|
className: "z-[1011] flex flex-col p-0 gap-0 max-w-full sm:max-w-full border-0 rounded-t-2xl rounded-b-none h-[100dvh] top-0 bottom-0 left-0 right-0 translate-x-0 translate-y-0 lg:max-w-[470px] lg:h-auto lg:max-h-[90vh] lg:rounded-lg lg:border lg:top-[50%] lg:left-[50%] lg:right-auto lg:bottom-auto lg:translate-x-[-50%] lg:translate-y-[-50%]",
|
|
93
95
|
children: [
|
|
94
|
-
/* @__PURE__ */ jsx(DialogHeader, { className: "sr-only", children: /* @__PURE__ */ jsx(DialogTitle, { children: "
|
|
96
|
+
/* @__PURE__ */ jsx(DialogHeader, { className: "sr-only", children: /* @__PURE__ */ jsx(DialogTitle, { children: translate("common.account.twoFactor.title") }) }),
|
|
95
97
|
/* @__PURE__ */ jsxs("div", { className: "shrink-0 flex items-center justify-center px-4 py-3 relative border-b border-gray-200 lg:border-b-0", children: [
|
|
96
|
-
/* @__PURE__ */ jsx("span", { className: "paragraph-medium-semibold text-gray-950 text-center", children: "
|
|
98
|
+
/* @__PURE__ */ jsx("span", { className: "paragraph-medium-semibold text-gray-950 text-center", children: translate("common.account.twoFactor.title") }),
|
|
97
99
|
/* @__PURE__ */ jsx(
|
|
98
100
|
Button,
|
|
99
101
|
{
|
|
@@ -115,21 +117,18 @@ function TwoFactorAuthModal({ open, onClose, onSuccess }) {
|
|
|
115
117
|
},
|
|
116
118
|
children: [
|
|
117
119
|
/* @__PURE__ */ jsx("div", { className: "flex-1 min-h-0 overflow-y-auto overscroll-contain lg:overflow-visible", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center gap-4 lg:gap-8 px-4 lg:px-5 py-4 lg:py-6 pb-60 lg:pb-6", children: [
|
|
118
|
-
/* @__PURE__ */
|
|
119
|
-
|
|
120
|
-
" ",
|
|
121
|
-
/* @__PURE__ */ jsx(
|
|
120
|
+
/* @__PURE__ */ jsx("p", { className: "paragraph-small-regular text-gray-950 text-center max-w-full lg:max-w-[412px]", children: translate.rich("common.account.twoFactor.instructions", {
|
|
121
|
+
link: (chunks) => /* @__PURE__ */ jsx(
|
|
122
122
|
"a",
|
|
123
123
|
{
|
|
124
124
|
href: "https://support.google.com/accounts/answer/1066447",
|
|
125
125
|
target: "_blank",
|
|
126
126
|
rel: "noopener noreferrer",
|
|
127
127
|
className: "paragraph-small-medium underline",
|
|
128
|
-
children:
|
|
128
|
+
children: chunks
|
|
129
129
|
}
|
|
130
|
-
)
|
|
131
|
-
|
|
132
|
-
] }),
|
|
130
|
+
)
|
|
131
|
+
}) }),
|
|
133
132
|
/* @__PURE__ */ jsx("div", { className: "border border-gray-200 rounded-lg overflow-hidden p-2 lg:p-3 flex items-center justify-center w-[136px] h-[136px] lg:w-[203px] lg:h-[203px]", children: generateFailed ? /* @__PURE__ */ jsxs(
|
|
134
133
|
"button",
|
|
135
134
|
{
|
|
@@ -138,7 +137,7 @@ function TwoFactorAuthModal({ open, onClose, onSuccess }) {
|
|
|
138
137
|
className: "flex flex-col items-center gap-1.5 text-center",
|
|
139
138
|
children: [
|
|
140
139
|
/* @__PURE__ */ jsx(IconRefresh, { size: 20, className: "text-gray-400" }),
|
|
141
|
-
/* @__PURE__ */ jsx("span", { className: "paragraph-xsmall-medium text-gray-500", children: "
|
|
140
|
+
/* @__PURE__ */ jsx("span", { className: "paragraph-xsmall-medium text-gray-500", children: translate("common.account.twoFactor.retry") })
|
|
142
141
|
]
|
|
143
142
|
}
|
|
144
143
|
) : isGenerating || !qrcode ? /* @__PURE__ */ jsx("div", { className: "skeleton w-full h-full rounded" }) : (
|
|
@@ -147,14 +146,14 @@ function TwoFactorAuthModal({ open, onClose, onSuccess }) {
|
|
|
147
146
|
"img",
|
|
148
147
|
{
|
|
149
148
|
src: qrcode,
|
|
150
|
-
alt: "
|
|
149
|
+
alt: translate("common.account.twoFactor.qrAlt"),
|
|
151
150
|
className: "w-full h-full"
|
|
152
151
|
}
|
|
153
152
|
)
|
|
154
153
|
) }),
|
|
155
154
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3 w-full", children: [
|
|
156
155
|
/* @__PURE__ */ jsx(Separator, { className: "flex-1" }),
|
|
157
|
-
/* @__PURE__ */ jsx("span", { className: "paragraph-xsmall-medium text-gray-500 opacity-80 whitespace-nowrap", children: "
|
|
156
|
+
/* @__PURE__ */ jsx("span", { className: "paragraph-xsmall-medium text-gray-500 opacity-80 whitespace-nowrap", children: translate("common.account.twoFactor.pasteDigits") }),
|
|
158
157
|
/* @__PURE__ */ jsx(Separator, { className: "flex-1" })
|
|
159
158
|
] }),
|
|
160
159
|
/* @__PURE__ */ jsx("div", { className: "scroll-mt-20", children: /* @__PURE__ */ jsx(InputOTP, { maxLength: 6, pattern: REGEXP_ONLY_DIGITS, value: code, onChange: setCode, children: /* @__PURE__ */ jsx(InputOTPGroup, { className: "gap-2", children: Array.from({ length: 6 }).map((_, i) => /* @__PURE__ */ jsx(
|
|
@@ -167,8 +166,8 @@ function TwoFactorAuthModal({ open, onClose, onSuccess }) {
|
|
|
167
166
|
)) }) }) })
|
|
168
167
|
] }) }),
|
|
169
168
|
/* @__PURE__ */ jsxs("div", { className: "shrink-0 flex items-center p-4 lg:p-5 border-t border-gray-200 justify-between gap-2 bg-white", children: [
|
|
170
|
-
/* @__PURE__ */ jsx(Button, { variant: "secondary", className: "h-10!", type: "button", onClick: handleClose, children: "
|
|
171
|
-
/* @__PURE__ */ jsx(Button, { type: "submit", className: "h-10!", disabled: !isCodeComplete || isConfirming, children: isConfirming ? "
|
|
169
|
+
/* @__PURE__ */ jsx(Button, { variant: "secondary", className: "h-10!", type: "button", onClick: handleClose, children: translate("common.actions.cancel") }),
|
|
170
|
+
/* @__PURE__ */ jsx(Button, { type: "submit", className: "h-10!", disabled: !isCodeComplete || isConfirming, children: isConfirming ? translate("common.account.twoFactor.activating") : translate("common.account.twoFactor.activate") })
|
|
172
171
|
] })
|
|
173
172
|
]
|
|
174
173
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/account/TwoFactorAuthModal.tsx"],"sourcesContent":["'use client';\n\nimport { IconX, IconCopy, IconRefresh } from '@tabler/icons-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 { REGEXP_ONLY_DIGITS } from 'input-otp';\nimport useTwoFactorAuthForm from './hooks/useTwoFactorAuthForm';\n\ninterface TwoFactorAuthModalProps {\n open: boolean;\n onClose: () => void;\n onSuccess?: () => void;\n}\n\nexport default function TwoFactorAuthModal({ open, onClose, onSuccess }: TwoFactorAuthModalProps) {\n const {\n code,\n setCode,\n isCodeComplete,\n isGenerating,\n isConfirming,\n generateFailed,\n retryGenerate,\n qrcode,\n backupCodes,\n step,\n handleSubmit,\n handleFinalize,\n handleCopyCodes,\n resetForm,\n } = useTwoFactorAuthForm({ onSuccess, open });\n\n const handleClose = () => {\n resetForm();\n onClose();\n };\n\n if (step === 'recovery') {\n return (\n <Dialog open={open} onOpenChange={handleClose}>\n <DialogContent\n showCloseButton={false}\n overlayClassName=\"z-[1010]\"\n className=\"z-[1011] flex flex-col p-0 gap-0 max-w-full sm:max-w-full border-0 rounded-t-2xl rounded-b-none h-[100dvh] top-0 bottom-0 left-0 right-0 translate-x-0 translate-y-0 lg:max-w-[470px] lg:h-auto lg:rounded-lg lg:border lg:top-[50%] lg:left-[50%] lg:right-auto lg:bottom-auto lg:translate-x-[-50%] lg:translate-y-[-50%]\"\n >\n <DialogHeader className=\"sr-only\">\n <DialogTitle>Códigos de segurança</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 Códigos de segurança\n </span>\n <Button\n type=\"button\"\n variant=\"ghost\"\n className=\"size-8! p-0 absolute right-4\"\n onClick={handleClose}\n >\n <IconX size={18} />\n </Button>\n </div>\n\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-2\">\n <h3 className=\"paragraph-medium-semibold text-gray-950 max-w-[269px]\">\n Salve estes códigos de recuperação de emergência\n </h3>\n <div className=\"paragraph-small-regular text-gray-600\">\n <p>\n Se você perder acesso ao seu telefone, não será possível fazer login em sua conta\n sem um código de dois fatores.\n </p>\n <br />\n <p>Imprima, copie ou escreva em um local seguro os códigos abaixo.</p>\n </div>\n </div>\n\n <div className=\"bg-gray-50 rounded-lg p-4 flex flex-col gap-4\">\n <div className=\"paragraph-small-medium text-gray-950 whitespace-nowrap\">\n {backupCodes.map((backupCode, i) => (\n <p key={i}>{backupCode}</p>\n ))}\n </div>\n <Button\n type=\"button\"\n variant=\"secondary\"\n className=\"h-8! w-fit\"\n onClick={handleCopyCodes}\n >\n <IconCopy size={16} />\n Copiar códigos\n </Button>\n </div>\n </div>\n\n <div className=\"flex items-center p-4 lg:p-5 border-t border-gray-200 justify-between 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=\"button\" onClick={handleFinalize}>\n Finalizar\n </Button>\n </div>\n </DialogContent>\n </Dialog>\n );\n }\n\n return (\n <Dialog open={open} onOpenChange={handleClose}>\n <DialogContent\n showCloseButton={false}\n overlayClassName=\"z-[1010]\"\n className=\"z-[1011] flex flex-col p-0 gap-0 max-w-full sm:max-w-full border-0 rounded-t-2xl rounded-b-none h-[100dvh] top-0 bottom-0 left-0 right-0 translate-x-0 translate-y-0 lg:max-w-[470px] lg:h-auto lg:max-h-[90vh] lg:rounded-lg lg:border lg:top-[50%] lg:left-[50%] lg:right-auto lg:bottom-auto lg:translate-x-[-50%] lg:translate-y-[-50%]\"\n >\n <DialogHeader className=\"sr-only\">\n <DialogTitle>Autenticação de dois fatores</DialogTitle>\n </DialogHeader>\n <div className=\"shrink-0 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 Autenticação de dois fatores\n </span>\n <Button\n type=\"button\"\n variant=\"ghost\"\n className=\"size-8! p-0 absolute right-4\"\n onClick={handleClose}\n >\n <IconX size={18} />\n </Button>\n </div>\n\n <form\n className=\"flex-1 min-h-0 flex flex-col\"\n onSubmit={(e) => {\n e.preventDefault();\n if (isCodeComplete) handleSubmit();\n }}\n >\n <div className=\"flex-1 min-h-0 overflow-y-auto overscroll-contain lg:overflow-visible\">\n <div className=\"flex flex-col items-center gap-4 lg:gap-8 px-4 lg:px-5 py-4 lg:py-6 pb-60 lg:pb-6\">\n <p className=\"paragraph-small-regular text-gray-950 text-center max-w-full lg:max-w-[412px]\">\n Instale um aplicativo autenticador no seu celular (ex.:{' '}\n <a\n href=\"https://support.google.com/accounts/answer/1066447\"\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"paragraph-small-medium underline\"\n >\n Google Authenticator\n </a>\n ), escaneie o QR Code ao lado ou copie a chave no aplicativo e, em seguida, digite o\n código de 6 dígitos gerado para continuar.\n </p>\n\n <div className=\"border border-gray-200 rounded-lg overflow-hidden p-2 lg:p-3 flex items-center justify-center w-[136px] h-[136px] lg:w-[203px] lg:h-[203px]\">\n {generateFailed ? (\n <button\n type=\"button\"\n onClick={() => retryGenerate()}\n className=\"flex flex-col items-center gap-1.5 text-center\"\n >\n <IconRefresh size={20} className=\"text-gray-400\" />\n <span className=\"paragraph-xsmall-medium text-gray-500\">Tentar novamente</span>\n </button>\n ) : isGenerating || !qrcode ? (\n <div className=\"skeleton w-full h-full rounded\" />\n ) : (\n // eslint-disable-next-line @next/next/no-img-element\n <img\n src={qrcode}\n alt=\"QR Code para autenticação de dois fatores\"\n className=\"w-full h-full\"\n />\n )}\n </div>\n\n <div className=\"flex items-center gap-3 w-full\">\n <Separator className=\"flex-1\" />\n <span className=\"paragraph-xsmall-medium text-gray-500 opacity-80 whitespace-nowrap\">\n Cole os 6 dígitos abaixo\n </span>\n <Separator className=\"flex-1\" />\n </div>\n\n <div className=\"scroll-mt-20\">\n <InputOTP maxLength={6} pattern={REGEXP_ONLY_DIGITS} value={code} onChange={setCode}>\n <InputOTPGroup className=\"gap-2\">\n {Array.from({ length: 6 }).map((_, i) => (\n <InputOTPSlot\n key={i}\n index={i}\n className=\"w-11! lg:w-12! h-13! lg:h-14! rounded-lg! text-lg border-gray-200\"\n />\n ))}\n </InputOTPGroup>\n </InputOTP>\n </div>\n </div>\n </div>\n\n <div className=\"shrink-0 flex items-center p-4 lg:p-5 border-t border-gray-200 justify-between gap-2 bg-white\">\n <Button variant=\"secondary\" className=\"h-10!\" type=\"button\" onClick={handleClose}>\n Cancelar\n </Button>\n <Button type=\"submit\" className=\"h-10!\" disabled={!isCodeComplete || isConfirming}>\n {isConfirming ? 'Ativando...' : 'Ativar autenticação'}\n </Button>\n </div>\n </form>\n </DialogContent>\n </Dialog>\n );\n}\n"],"mappings":";AAgDY,cAEF,YAFE;AA9CZ,SAAS,OAAO,UAAU,mBAAmB;AAC7C,SAAS,cAAc;AACvB,SAAS,QAAQ,eAAe,cAAc,mBAAmB;AACjE,SAAS,iBAAiB;AAC1B,SAAS,UAAU,eAAe,oBAAoB;AACtD,SAAS,0BAA0B;AACnC,OAAO,0BAA0B;AAQlB,SAAR,mBAAoC,EAAE,MAAM,SAAS,UAAU,GAA4B;AAChG,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI,qBAAqB,EAAE,WAAW,KAAK,CAAC;AAE5C,QAAM,cAAc,MAAM;AACxB,cAAU;AACV,YAAQ;AAAA,EACV;AAEA,MAAI,SAAS,YAAY;AACvB,WACE,oBAAC,UAAO,MAAY,cAAc,aAChC;AAAA,MAAC;AAAA;AAAA,QACC,iBAAiB;AAAA,QACjB,kBAAiB;AAAA,QACjB,WAAU;AAAA,QAEV;AAAA,8BAAC,gBAAa,WAAU,WACtB,8BAAC,eAAY,wCAAoB,GACnC;AAAA,UACA,qBAAC,SAAI,WAAU,8FACb;AAAA,gCAAC,UAAK,WAAU,uDAAsD,wCAEtE;AAAA,YACA;AAAA,cAAC;AAAA;AAAA,gBACC,MAAK;AAAA,gBACL,SAAQ;AAAA,gBACR,WAAU;AAAA,g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,OAAO,MAAM,UAAU,SAC1E,8BAAC,iBAAc,WAAU,SACtB,gBAAM,KAAK,EAAE,QAAQ,EAAE,CAAC,EAAE,IAAI,CAAC,GAAG,MACjC;AAAA,kBAAC;AAAA;AAAA,oBAEC,OAAO;AAAA,oBACP,WAAU;AAAA;AAAA,kBAFL;AAAA,gBAGP,CACD,GACH,GACF,GACF;AAAA,iBACF,GACF;AAAA,cAEA,qBAAC,SAAI,WAAU,iGACb;AAAA,oCAAC,UAAO,SAAQ,aAAY,WAAU,SAAQ,MAAK,UAAS,SAAS,aAAa,sBAElF;AAAA,gBACA,oBAAC,UAAO,MAAK,UAAS,WAAU,SAAQ,UAAU,CAAC,kBAAkB,cAClE,yBAAe,gBAAgB,6BAClC;AAAA,iBACF;AAAA;AAAA;AAAA,QACF;AAAA;AAAA;AAAA,EACF,GACF;AAEJ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../src/components/account/TwoFactorAuthModal.tsx"],"sourcesContent":["'use client';\n\nimport { useTranslations } from 'next-intl';\nimport { IconX, IconCopy, IconRefresh } from '@tabler/icons-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 { REGEXP_ONLY_DIGITS } from 'input-otp';\nimport useTwoFactorAuthForm from './hooks/useTwoFactorAuthForm';\n\ninterface TwoFactorAuthModalProps {\n open: boolean;\n onClose: () => void;\n onSuccess?: () => void;\n}\n\nexport default function TwoFactorAuthModal({ open, onClose, onSuccess }: TwoFactorAuthModalProps) {\n const translate = useTranslations();\n const {\n code,\n setCode,\n isCodeComplete,\n isGenerating,\n isConfirming,\n generateFailed,\n retryGenerate,\n qrcode,\n backupCodes,\n step,\n handleSubmit,\n handleFinalize,\n handleCopyCodes,\n resetForm,\n } = useTwoFactorAuthForm({ onSuccess, open });\n\n const handleClose = () => {\n resetForm();\n onClose();\n };\n\n if (step === 'recovery') {\n return (\n <Dialog open={open} onOpenChange={handleClose}>\n <DialogContent\n showCloseButton={false}\n overlayClassName=\"z-[1010]\"\n className=\"z-[1011] flex flex-col p-0 gap-0 max-w-full sm:max-w-full border-0 rounded-t-2xl rounded-b-none h-[100dvh] top-0 bottom-0 left-0 right-0 translate-x-0 translate-y-0 lg:max-w-[470px] lg:h-auto lg:rounded-lg lg:border lg:top-[50%] lg:left-[50%] lg:right-auto lg:bottom-auto lg:translate-x-[-50%] lg:translate-y-[-50%]\"\n >\n <DialogHeader className=\"sr-only\">\n <DialogTitle>{translate('common.account.twoFactor.recoveryTitle')}</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 {translate('common.account.twoFactor.recoveryTitle')}\n </span>\n <Button\n type=\"button\"\n variant=\"ghost\"\n className=\"size-8! p-0 absolute right-4\"\n onClick={handleClose}\n >\n <IconX size={18} />\n </Button>\n </div>\n\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-2\">\n <h3 className=\"paragraph-medium-semibold text-gray-950 max-w-[269px]\">\n {translate('common.account.twoFactor.recoveryHeading')}\n </h3>\n <div className=\"paragraph-small-regular text-gray-600\">\n <p>{translate('common.account.twoFactor.recoveryText1')}</p>\n <br />\n <p>{translate('common.account.twoFactor.recoveryText2')}</p>\n </div>\n </div>\n\n <div className=\"bg-gray-50 rounded-lg p-4 flex flex-col gap-4\">\n <div className=\"paragraph-small-medium text-gray-950 whitespace-nowrap\">\n {backupCodes.map((backupCode, i) => (\n <p key={i}>{backupCode}</p>\n ))}\n </div>\n <Button\n type=\"button\"\n variant=\"secondary\"\n className=\"h-8! w-fit\"\n onClick={handleCopyCodes}\n >\n <IconCopy size={16} />\n {translate('common.account.twoFactor.copyCodes')}\n </Button>\n </div>\n </div>\n\n <div className=\"flex items-center p-4 lg:p-5 border-t border-gray-200 justify-between mt-auto lg:mt-0\">\n <Button variant=\"secondary\" className=\"h-10!\" type=\"button\" onClick={handleClose}>\n {translate('common.actions.cancel')}\n </Button>\n <Button className=\"h-10!\" type=\"button\" onClick={handleFinalize}>\n {translate('common.account.twoFactor.finish')}\n </Button>\n </div>\n </DialogContent>\n </Dialog>\n );\n }\n\n return (\n <Dialog open={open} onOpenChange={handleClose}>\n <DialogContent\n showCloseButton={false}\n overlayClassName=\"z-[1010]\"\n className=\"z-[1011] flex flex-col p-0 gap-0 max-w-full sm:max-w-full border-0 rounded-t-2xl rounded-b-none h-[100dvh] top-0 bottom-0 left-0 right-0 translate-x-0 translate-y-0 lg:max-w-[470px] lg:h-auto lg:max-h-[90vh] lg:rounded-lg lg:border lg:top-[50%] lg:left-[50%] lg:right-auto lg:bottom-auto lg:translate-x-[-50%] lg:translate-y-[-50%]\"\n >\n <DialogHeader className=\"sr-only\">\n <DialogTitle>{translate('common.account.twoFactor.title')}</DialogTitle>\n </DialogHeader>\n <div className=\"shrink-0 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 {translate('common.account.twoFactor.title')}\n </span>\n <Button\n type=\"button\"\n variant=\"ghost\"\n className=\"size-8! p-0 absolute right-4\"\n onClick={handleClose}\n >\n <IconX size={18} />\n </Button>\n </div>\n\n <form\n className=\"flex-1 min-h-0 flex flex-col\"\n onSubmit={(e) => {\n e.preventDefault();\n if (isCodeComplete) handleSubmit();\n }}\n >\n <div className=\"flex-1 min-h-0 overflow-y-auto overscroll-contain lg:overflow-visible\">\n <div className=\"flex flex-col items-center gap-4 lg:gap-8 px-4 lg:px-5 py-4 lg:py-6 pb-60 lg:pb-6\">\n <p className=\"paragraph-small-regular text-gray-950 text-center max-w-full lg:max-w-[412px]\">\n {translate.rich('common.account.twoFactor.instructions', {\n link: (chunks) => (\n <a\n href=\"https://support.google.com/accounts/answer/1066447\"\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"paragraph-small-medium underline\"\n >\n {chunks}\n </a>\n ),\n })}\n </p>\n\n <div className=\"border border-gray-200 rounded-lg overflow-hidden p-2 lg:p-3 flex items-center justify-center w-[136px] h-[136px] lg:w-[203px] lg:h-[203px]\">\n {generateFailed ? (\n <button\n type=\"button\"\n onClick={() => retryGenerate()}\n className=\"flex flex-col items-center gap-1.5 text-center\"\n >\n <IconRefresh size={20} className=\"text-gray-400\" />\n <span className=\"paragraph-xsmall-medium text-gray-500\">\n {translate('common.account.twoFactor.retry')}\n </span>\n </button>\n ) : isGenerating || !qrcode ? (\n <div className=\"skeleton w-full h-full rounded\" />\n ) : (\n // eslint-disable-next-line @next/next/no-img-element\n <img\n src={qrcode}\n alt={translate('common.account.twoFactor.qrAlt')}\n className=\"w-full h-full\"\n />\n )}\n </div>\n\n <div className=\"flex items-center gap-3 w-full\">\n <Separator className=\"flex-1\" />\n <span className=\"paragraph-xsmall-medium text-gray-500 opacity-80 whitespace-nowrap\">\n {translate('common.account.twoFactor.pasteDigits')}\n </span>\n <Separator className=\"flex-1\" />\n </div>\n\n <div className=\"scroll-mt-20\">\n <InputOTP maxLength={6} pattern={REGEXP_ONLY_DIGITS} value={code} onChange={setCode}>\n <InputOTPGroup className=\"gap-2\">\n {Array.from({ length: 6 }).map((_, i) => (\n <InputOTPSlot\n key={i}\n index={i}\n className=\"w-11! lg:w-12! h-13! lg:h-14! rounded-lg! text-lg border-gray-200\"\n />\n ))}\n </InputOTPGroup>\n </InputOTP>\n </div>\n </div>\n </div>\n\n <div className=\"shrink-0 flex items-center p-4 lg:p-5 border-t border-gray-200 justify-between gap-2 bg-white\">\n <Button variant=\"secondary\" className=\"h-10!\" type=\"button\" onClick={handleClose}>\n {translate('common.actions.cancel')}\n </Button>\n <Button type=\"submit\" className=\"h-10!\" disabled={!isCodeComplete || isConfirming}>\n {isConfirming\n ? translate('common.account.twoFactor.activating')\n : translate('common.account.twoFactor.activate')}\n </Button>\n </div>\n </form>\n </DialogContent>\n </Dialog>\n );\n}\n"],"mappings":";AAkDY,cAEF,YAFE;AAhDZ,SAAS,uBAAuB;AAChC,SAAS,OAAO,UAAU,mBAAmB;AAC7C,SAAS,cAAc;AACvB,SAAS,QAAQ,eAAe,cAAc,mBAAmB;AACjE,SAAS,iBAAiB;AAC1B,SAAS,UAAU,eAAe,oBAAoB;AACtD,SAAS,0BAA0B;AACnC,OAAO,0BAA0B;AAQlB,SAAR,mBAAoC,EAAE,MAAM,SAAS,UAAU,GAA4B;AAChG,QAAM,YAAY,gBAAgB;AAClC,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI,qBAAqB,EAAE,WAAW,KAAK,CAAC;AAE5C,QAAM,cAAc,MAAM;AACxB,cAAU;AACV,YAAQ;AAAA,EACV;AAEA,MAAI,SAAS,YAAY;AACvB,WACE,oBAAC,UAAO,MAAY,cAAc,aAChC;AAAA,MAAC;AAAA;AAAA,QACC,iBAAiB;AAAA,QACjB,kBAAiB;AAAA,QACjB,WAAU;AAAA,QAEV;AAAA,8BAAC,gBAAa,WAAU,WACtB,8BAAC,eAAa,oBAAU,wCAAwC,GAAE,GACpE;AAAA,UACA,qBAAC,SAAI,WAAU,8FACb;AAAA,gCAAC,UAAK,WAAU,uDACb,oBAAU,wCAAwC,GACrD;AAAA,YACA;AAAA,cAAC;AAAA;AAAA,gBACC,MAAK;AAAA,gBACL,SAAQ;AAAA,gBACR,WAAU;AAAA,gBACV,SAAS;AAAA,gBAET,8BAAC,SAAM,MAAM,IAAI;AAAA;AAAA,YACnB;AAAA,aACF;AAAA,UAEA,qBAAC,SAAI,WAAU,8EACb;AAAA,iCAAC,SAAI,WA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,WAAW,GAAG,SAAS,oBAAoB,OAAO,MAAM,UAAU,SAC1E,8BAAC,iBAAc,WAAU,SACtB,gBAAM,KAAK,EAAE,QAAQ,EAAE,CAAC,EAAE,IAAI,CAAC,GAAG,MACjC;AAAA,kBAAC;AAAA;AAAA,oBAEC,OAAO;AAAA,oBACP,WAAU;AAAA;AAAA,kBAFL;AAAA,gBAGP,CACD,GACH,GACF,GACF;AAAA,iBACF,GACF;AAAA,cAEA,qBAAC,SAAI,WAAU,iGACb;AAAA,oCAAC,UAAO,SAAQ,aAAY,WAAU,SAAQ,MAAK,UAAS,SAAS,aAClE,oBAAU,uBAAuB,GACpC;AAAA,gBACA,oBAAC,UAAO,MAAK,UAAS,WAAU,SAAQ,UAAU,CAAC,kBAAkB,cAClE,yBACG,UAAU,qCAAqC,IAC/C,UAAU,mCAAmC,GACnD;AAAA,iBACF;AAAA;AAAA;AAAA,QACF;AAAA;AAAA;AAAA,EACF,GACF;AAEJ;","names":[]}
|
|
@@ -14,10 +14,10 @@ const TIME_FORMAT_OPTIONS = [
|
|
|
14
14
|
{ value: "12h", label: "12 horas (AM/PM)", displayValue: "12 horas (AM/PM)" }
|
|
15
15
|
];
|
|
16
16
|
const NOTIFICATION_TYPES = [
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
17
|
+
"common.account.notificationTypes.projectUpdates",
|
|
18
|
+
"common.account.notificationTypes.securityAlerts",
|
|
19
|
+
"common.account.notificationTypes.planBilling",
|
|
20
|
+
"common.account.notificationTypes.scheduledMaintenance"
|
|
21
21
|
];
|
|
22
22
|
export {
|
|
23
23
|
CURRENCY_OPTIONS,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/account/constants.ts"],"sourcesContent":["import { buildLocaleOptions } from '../../utils/intl/locales';\r\n\r\nexport const GENDER_OPTIONS = [\r\n { value: 'masculino', label: 'Masculino', apiValue: 1 },\r\n { value: 'feminino', label: 'Feminino', apiValue: 0 },\r\n];\r\n\r\nexport const LANGUAGE_OPTIONS = buildLocaleOptions();\r\n\r\nexport const CURRENCY_OPTIONS = [\r\n { value: 'BRL', label: 'BRL (R$)', displayValue: 'BRL (R$)' },\r\n { value: 'USD', label: 'USD ($)', displayValue: 'USD ($)' },\r\n { value: 'EUR', label: 'EUR (€)', displayValue: 'EUR (€)' },\r\n];\r\n\r\nexport const TIME_FORMAT_OPTIONS = [\r\n { value: '24h', label: '24 horas', displayValue: '24 horas' },\r\n { value: '12h', label: '12 horas (AM/PM)', displayValue: '12 horas (AM/PM)' },\r\n];\r\n\r\
|
|
1
|
+
{"version":3,"sources":["../../../src/components/account/constants.ts"],"sourcesContent":["import { buildLocaleOptions } from '../../utils/intl/locales';\r\n\r\nexport const GENDER_OPTIONS = [\r\n { value: 'masculino', label: 'Masculino', apiValue: 1 },\r\n { value: 'feminino', label: 'Feminino', apiValue: 0 },\r\n];\r\n\r\nexport const LANGUAGE_OPTIONS = buildLocaleOptions();\r\n\r\nexport const CURRENCY_OPTIONS = [\r\n { value: 'BRL', label: 'BRL (R$)', displayValue: 'BRL (R$)' },\r\n { value: 'USD', label: 'USD ($)', displayValue: 'USD ($)' },\r\n { value: 'EUR', label: 'EUR (€)', displayValue: 'EUR (€)' },\r\n];\r\n\r\nexport const TIME_FORMAT_OPTIONS = [\r\n { value: '24h', label: '24 horas', displayValue: '24 horas' },\r\n { value: '12h', label: '12 horas (AM/PM)', displayValue: '12 horas (AM/PM)' },\r\n];\r\n\r\n// Catalog keys — consumers call translate(type) to get the localized label.\r\n// pt-br values: 'Atualizações de projetos' | 'Alertas de segurança' |\r\n// 'Mudanças no plano ou faturamento' | 'Manutenções programadas'\r\nexport const NOTIFICATION_TYPES = [\r\n 'common.account.notificationTypes.projectUpdates',\r\n 'common.account.notificationTypes.securityAlerts',\r\n 'common.account.notificationTypes.planBilling',\r\n 'common.account.notificationTypes.scheduledMaintenance',\r\n] as const;\r\n"],"mappings":"AAAA,SAAS,0BAA0B;AAE5B,MAAM,iBAAiB;AAAA,EAC5B,EAAE,OAAO,aAAa,OAAO,aAAa,UAAU,EAAE;AAAA,EACtD,EAAE,OAAO,YAAY,OAAO,YAAY,UAAU,EAAE;AACtD;AAEO,MAAM,mBAAmB,mBAAmB;AAE5C,MAAM,mBAAmB;AAAA,EAC9B,EAAE,OAAO,OAAO,OAAO,YAAY,cAAc,WAAW;AAAA,EAC5D,EAAE,OAAO,OAAO,OAAO,WAAW,cAAc,UAAU;AAAA,EAC1D,EAAE,OAAO,OAAO,OAAO,gBAAW,cAAc,eAAU;AAC5D;AAEO,MAAM,sBAAsB;AAAA,EACjC,EAAE,OAAO,OAAO,OAAO,YAAY,cAAc,WAAW;AAAA,EAC5D,EAAE,OAAO,OAAO,OAAO,oBAAoB,cAAc,mBAAmB;AAC9E;AAKO,MAAM,qBAAqB;AAAA,EAChC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;","names":[]}
|
|
@@ -3,11 +3,13 @@ import { jsx } from "react/jsx-runtime";
|
|
|
3
3
|
import { useState, useCallback } from "react";
|
|
4
4
|
import { useForm } from "react-hook-form";
|
|
5
5
|
import { zodResolver } from "@hookform/resolvers/zod";
|
|
6
|
+
import { useTranslations } from "next-intl";
|
|
6
7
|
import { toast } from "sonner";
|
|
7
8
|
import { Toast } from "../../ui/feedback/Toast";
|
|
8
9
|
import { changeEmailSchema } from "../../../utils/validators/account";
|
|
9
10
|
import { requestEmailChangeAction } from "../../../modules/accounts/actions/account-management.action";
|
|
10
11
|
function useChangeEmailForm() {
|
|
12
|
+
const translate = useTranslations();
|
|
11
13
|
const [showVerification, setShowVerification] = useState(false);
|
|
12
14
|
const { register, handleSubmit, reset, watch, formState: { errors, isSubmitting } } = useForm({
|
|
13
15
|
resolver: zodResolver(changeEmailSchema),
|
|
@@ -17,12 +19,12 @@ function useChangeEmailForm() {
|
|
|
17
19
|
const handleContinue = handleSubmit(async (data) => {
|
|
18
20
|
const result = await requestEmailChangeAction(data.email);
|
|
19
21
|
if (!result.success) {
|
|
20
|
-
toast.custom((
|
|
22
|
+
toast.custom((toastId) => /* @__PURE__ */ jsx(
|
|
21
23
|
Toast,
|
|
22
24
|
{
|
|
23
25
|
variant: "error",
|
|
24
|
-
message: result.error ?? "
|
|
25
|
-
toastId
|
|
26
|
+
message: result.error ?? translate("common.account.changeEmail.emailExistsError"),
|
|
27
|
+
toastId
|
|
26
28
|
}
|
|
27
29
|
));
|
|
28
30
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/account/hooks/useChangeEmailForm.tsx"],"sourcesContent":["'use client';\r\n\r\nimport { useState, useCallback } from 'react';\r\nimport { useForm } from 'react-hook-form';\r\nimport { zodResolver } from '@hookform/resolvers/zod';\r\nimport { toast } from 'sonner';\r\nimport { Toast } from '../../ui/feedback/Toast';\r\nimport { changeEmailSchema, type ChangeEmailFormData } from '../../../utils/validators/account';\r\nimport { requestEmailChangeAction } from '../../../modules/accounts/actions/account-management.action';\r\n\r\nexport default function useChangeEmailForm() {\r\n const [showVerification, setShowVerification] = useState(false);\r\n\r\n const { register, handleSubmit, reset, watch, formState: { errors, isSubmitting } } = useForm<ChangeEmailFormData>({\r\n resolver: zodResolver(changeEmailSchema),\r\n mode: 'onChange',\r\n defaultValues: { email: '' },\r\n });\r\n\r\n const handleContinue = handleSubmit(async (data) => {\r\n const result = await requestEmailChangeAction(data.email);\r\n\r\n if (!result.success) {\r\n toast.custom((
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/account/hooks/useChangeEmailForm.tsx"],"sourcesContent":["'use client';\r\n\r\nimport { useState, useCallback } from 'react';\r\nimport { useForm } from 'react-hook-form';\r\nimport { zodResolver } from '@hookform/resolvers/zod';\r\nimport { useTranslations } from 'next-intl';\r\nimport { toast } from 'sonner';\r\nimport { Toast } from '../../ui/feedback/Toast';\r\nimport { changeEmailSchema, type ChangeEmailFormData } from '../../../utils/validators/account';\r\nimport { requestEmailChangeAction } from '../../../modules/accounts/actions/account-management.action';\r\n\r\nexport default function useChangeEmailForm() {\r\n const translate = useTranslations();\r\n const [showVerification, setShowVerification] = useState(false);\r\n\r\n const { register, handleSubmit, reset, watch, formState: { errors, isSubmitting } } = useForm<ChangeEmailFormData>({\r\n resolver: zodResolver(changeEmailSchema),\r\n mode: 'onChange',\r\n defaultValues: { email: '' },\r\n });\r\n\r\n const handleContinue = handleSubmit(async (data) => {\r\n const result = await requestEmailChangeAction(data.email);\r\n\r\n if (!result.success) {\r\n toast.custom((toastId) => (\r\n <Toast\r\n variant=\"error\"\r\n message={result.error ?? translate('common.account.changeEmail.emailExistsError')}\r\n toastId={toastId}\r\n />\r\n ));\r\n return;\r\n }\r\n\r\n setShowVerification(true);\r\n });\r\n\r\n const handleBack = useCallback(() => {\r\n setShowVerification(false);\r\n }, []);\r\n\r\n const resetForm = useCallback(() => {\r\n reset();\r\n setShowVerification(false);\r\n }, [reset]);\r\n\r\n return {\r\n showVerification,\r\n emailToVerify: watch('email'),\r\n isSubmitting,\r\n errors,\r\n register,\r\n handleContinue,\r\n handleBack,\r\n resetForm,\r\n };\r\n}\r\n"],"mappings":";AA0BQ;AAxBR,SAAS,UAAU,mBAAmB;AACtC,SAAS,eAAe;AACxB,SAAS,mBAAmB;AAC5B,SAAS,uBAAuB;AAChC,SAAS,aAAa;AACtB,SAAS,aAAa;AACtB,SAAS,yBAAmD;AAC5D,SAAS,gCAAgC;AAE1B,SAAR,qBAAsC;AAC3C,QAAM,YAAY,gBAAgB;AAClC,QAAM,CAAC,kBAAkB,mBAAmB,IAAI,SAAS,KAAK;AAE9D,QAAM,EAAE,UAAU,cAAc,OAAO,OAAO,WAAW,EAAE,QAAQ,aAAa,EAAE,IAAI,QAA6B;AAAA,IACjH,UAAU,YAAY,iBAAiB;AAAA,IACvC,MAAM;AAAA,IACN,eAAe,EAAE,OAAO,GAAG;AAAA,EAC7B,CAAC;AAED,QAAM,iBAAiB,aAAa,OAAO,SAAS;AAClD,UAAM,SAAS,MAAM,yBAAyB,KAAK,KAAK;AAExD,QAAI,CAAC,OAAO,SAAS;AACnB,YAAM,OAAO,CAAC,YACZ;AAAA,QAAC;AAAA;AAAA,UACC,SAAQ;AAAA,UACR,SAAS,OAAO,SAAS,UAAU,6CAA6C;AAAA,UAChF;AAAA;AAAA,MACF,CACD;AACD;AAAA,IACF;AAEA,wBAAoB,IAAI;AAAA,EAC1B,CAAC;AAED,QAAM,aAAa,YAAY,MAAM;AACnC,wBAAoB,KAAK;AAAA,EAC3B,GAAG,CAAC,CAAC;AAEL,QAAM,YAAY,YAAY,MAAM;AAClC,UAAM;AACN,wBAAoB,KAAK;AAAA,EAC3B,GAAG,CAAC,KAAK,CAAC;AAEV,SAAO;AAAA,IACL;AAAA,IACA,eAAe,MAAM,OAAO;AAAA,IAC5B;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
|
|
@@ -3,11 +3,13 @@ import { jsx } from "react/jsx-runtime";
|
|
|
3
3
|
import { useForm } from "react-hook-form";
|
|
4
4
|
import { zodResolver } from "@hookform/resolvers/zod";
|
|
5
5
|
import { useMutation } from "@tanstack/react-query";
|
|
6
|
+
import { useTranslations } from "next-intl";
|
|
6
7
|
import { toast } from "sonner";
|
|
7
8
|
import { Toast } from "../../ui/feedback/Toast";
|
|
8
9
|
import { changePasswordSchema } from "../../../utils/validators/account";
|
|
9
10
|
import { changePasswordAction } from "../../../modules/accounts/actions/account-management.action";
|
|
10
11
|
function useChangePasswordForm({ onSuccess } = {}) {
|
|
12
|
+
const translate = useTranslations();
|
|
11
13
|
const form = useForm({
|
|
12
14
|
resolver: zodResolver(changePasswordSchema),
|
|
13
15
|
mode: "onChange",
|
|
@@ -20,15 +22,36 @@ function useChangePasswordForm({ onSuccess } = {}) {
|
|
|
20
22
|
mutationFn: changePasswordAction,
|
|
21
23
|
onSuccess: (result) => {
|
|
22
24
|
if (!result.success) {
|
|
23
|
-
toast.custom((
|
|
25
|
+
toast.custom((toastId) => /* @__PURE__ */ jsx(
|
|
26
|
+
Toast,
|
|
27
|
+
{
|
|
28
|
+
variant: "error",
|
|
29
|
+
message: result.error ?? translate("common.account.changePassword.changeError"),
|
|
30
|
+
toastId
|
|
31
|
+
}
|
|
32
|
+
));
|
|
24
33
|
return;
|
|
25
34
|
}
|
|
26
|
-
toast.custom((
|
|
35
|
+
toast.custom((toastId) => /* @__PURE__ */ jsx(
|
|
36
|
+
Toast,
|
|
37
|
+
{
|
|
38
|
+
variant: "success",
|
|
39
|
+
message: translate("common.account.changePassword.changedSuccess"),
|
|
40
|
+
toastId
|
|
41
|
+
}
|
|
42
|
+
));
|
|
27
43
|
form.reset();
|
|
28
44
|
onSuccess?.();
|
|
29
45
|
},
|
|
30
46
|
onError: () => {
|
|
31
|
-
toast.custom((
|
|
47
|
+
toast.custom((toastId) => /* @__PURE__ */ jsx(
|
|
48
|
+
Toast,
|
|
49
|
+
{
|
|
50
|
+
variant: "error",
|
|
51
|
+
message: translate("common.account.changePassword.genericError"),
|
|
52
|
+
toastId
|
|
53
|
+
}
|
|
54
|
+
));
|
|
32
55
|
}
|
|
33
56
|
});
|
|
34
57
|
const onSubmit = (data) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/account/hooks/useChangePasswordForm.tsx"],"sourcesContent":["'use client';\r\n\r\nimport { useForm } from 'react-hook-form';\r\nimport { zodResolver } from '@hookform/resolvers/zod';\r\nimport { useMutation } from '@tanstack/react-query';\r\nimport { toast } from 'sonner';\r\nimport { Toast } from '../../ui/feedback/Toast';\r\nimport { changePasswordSchema, type ChangePasswordFormData } from '../../../utils/validators/account';\r\nimport { changePasswordAction } from '../../../modules/accounts/actions/account-management.action';\r\n\r\ninterface UseChangePasswordFormProps {\r\n onSuccess?: () => void;\r\n}\r\n\r\nexport default function useChangePasswordForm({ onSuccess }: UseChangePasswordFormProps = {}) {\r\n const form = useForm<ChangePasswordFormData>({\r\n resolver: zodResolver(changePasswordSchema),\r\n mode: 'onChange',\r\n defaultValues: {\r\n currentPassword: '',\r\n newPassword: '',\r\n },\r\n });\r\n\r\n const mutation = useMutation({\r\n mutationFn: changePasswordAction,\r\n onSuccess: (result) => {\r\n if (!result.success) {\r\n toast.custom((
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/account/hooks/useChangePasswordForm.tsx"],"sourcesContent":["'use client';\r\n\r\nimport { useForm } from 'react-hook-form';\r\nimport { zodResolver } from '@hookform/resolvers/zod';\r\nimport { useMutation } from '@tanstack/react-query';\r\nimport { useTranslations } from 'next-intl';\r\nimport { toast } from 'sonner';\r\nimport { Toast } from '../../ui/feedback/Toast';\r\nimport { changePasswordSchema, type ChangePasswordFormData } from '../../../utils/validators/account';\r\nimport { changePasswordAction } from '../../../modules/accounts/actions/account-management.action';\r\n\r\ninterface UseChangePasswordFormProps {\r\n onSuccess?: () => void;\r\n}\r\n\r\nexport default function useChangePasswordForm({ onSuccess }: UseChangePasswordFormProps = {}) {\r\n const translate = useTranslations();\r\n const form = useForm<ChangePasswordFormData>({\r\n resolver: zodResolver(changePasswordSchema),\r\n mode: 'onChange',\r\n defaultValues: {\r\n currentPassword: '',\r\n newPassword: '',\r\n },\r\n });\r\n\r\n const mutation = useMutation({\r\n mutationFn: changePasswordAction,\r\n onSuccess: (result) => {\r\n if (!result.success) {\r\n toast.custom((toastId) => (\r\n <Toast\r\n variant=\"error\"\r\n message={result.error ?? translate('common.account.changePassword.changeError')}\r\n toastId={toastId}\r\n />\r\n ));\r\n return;\r\n }\r\n\r\n toast.custom((toastId) => (\r\n <Toast\r\n variant=\"success\"\r\n message={translate('common.account.changePassword.changedSuccess')}\r\n toastId={toastId}\r\n />\r\n ));\r\n\r\n form.reset();\r\n onSuccess?.();\r\n },\r\n onError: () => {\r\n toast.custom((toastId) => (\r\n <Toast\r\n variant=\"error\"\r\n message={translate('common.account.changePassword.genericError')}\r\n toastId={toastId}\r\n />\r\n ));\r\n },\r\n });\r\n\r\n const onSubmit = (data: ChangePasswordFormData) => {\r\n mutation.mutate(data);\r\n };\r\n\r\n return {\r\n register: form.register,\r\n handleSubmit: form.handleSubmit(onSubmit),\r\n errors: form.formState.errors,\r\n isLoading: mutation.isPending,\r\n };\r\n}\r\n"],"mappings":";AA+BU;AA7BV,SAAS,eAAe;AACxB,SAAS,mBAAmB;AAC5B,SAAS,mBAAmB;AAC5B,SAAS,uBAAuB;AAChC,SAAS,aAAa;AACtB,SAAS,aAAa;AACtB,SAAS,4BAAyD;AAClE,SAAS,4BAA4B;AAMtB,SAAR,sBAAuC,EAAE,UAAU,IAAgC,CAAC,GAAG;AAC5F,QAAM,YAAY,gBAAgB;AAClC,QAAM,OAAO,QAAgC;AAAA,IAC3C,UAAU,YAAY,oBAAoB;AAAA,IAC1C,MAAM;AAAA,IACN,eAAe;AAAA,MACb,iBAAiB;AAAA,MACjB,aAAa;AAAA,IACf;AAAA,EACF,CAAC;AAED,QAAM,WAAW,YAAY;AAAA,IAC3B,YAAY;AAAA,IACZ,WAAW,CAAC,WAAW;AACrB,UAAI,CAAC,OAAO,SAAS;AACnB,cAAM,OAAO,CAAC,YACZ;AAAA,UAAC;AAAA;AAAA,YACC,SAAQ;AAAA,YACR,SAAS,OAAO,SAAS,UAAU,2CAA2C;AAAA,YAC9E;AAAA;AAAA,QACF,CACD;AACD;AAAA,MACF;AAEA,YAAM,OAAO,CAAC,YACZ;AAAA,QAAC;AAAA;AAAA,UACC,SAAQ;AAAA,UACR,SAAS,UAAU,8CAA8C;AAAA,UACjE;AAAA;AAAA,MACF,CACD;AAED,WAAK,MAAM;AACX,kBAAY;AAAA,IACd;AAAA,IACA,SAAS,MAAM;AACb,YAAM,OAAO,CAAC,YACZ;AAAA,QAAC;AAAA;AAAA,UACC,SAAQ;AAAA,UACR,SAAS,UAAU,4CAA4C;AAAA,UAC/D;AAAA;AAAA,MACF,CACD;AAAA,IACH;AAAA,EACF,CAAC;AAED,QAAM,WAAW,CAAC,SAAiC;AACjD,aAAS,OAAO,IAAI;AAAA,EACtB;AAEA,SAAO;AAAA,IACL,UAAU,KAAK;AAAA,IACf,cAAc,KAAK,aAAa,QAAQ;AAAA,IACxC,QAAQ,KAAK,UAAU;AAAA,IACvB,WAAW,SAAS;AAAA,EACtB;AACF;","names":[]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
3
|
import { useState, useCallback } from "react";
|
|
4
|
+
import { useTranslations } from "next-intl";
|
|
4
5
|
import { toast } from "sonner";
|
|
5
6
|
import { Toast } from "../../ui/feedback/Toast";
|
|
6
7
|
import { requestPhoneChangeAction, updateUserAction } from "../../../modules/accounts/actions/account-management.action";
|
|
@@ -11,6 +12,7 @@ function splitPhoneValue(fullValue) {
|
|
|
11
12
|
return { ddi: trimmed.slice(0, spaceIdx), local: trimmed.slice(spaceIdx + 1) };
|
|
12
13
|
}
|
|
13
14
|
function useChangePhoneForm({ hasExistingPhone, onDirectUpdateSuccess }) {
|
|
15
|
+
const translate = useTranslations();
|
|
14
16
|
const [showVerification, setShowVerification] = useState(false);
|
|
15
17
|
const [phoneValue, setPhoneValue] = useState("");
|
|
16
18
|
const [phoneError, setPhoneError] = useState("");
|
|
@@ -24,7 +26,7 @@ function useChangePhoneForm({ hasExistingPhone, onDirectUpdateSuccess }) {
|
|
|
24
26
|
e.preventDefault();
|
|
25
27
|
const { ddi, local } = splitPhoneValue(phoneValue);
|
|
26
28
|
if (!local || local.replace(/\D/g, "").length < 8) {
|
|
27
|
-
setPhoneError("
|
|
29
|
+
setPhoneError(translate("common.account.changePhone.invalidNumber"));
|
|
28
30
|
return;
|
|
29
31
|
}
|
|
30
32
|
setIsSubmitting(true);
|
|
@@ -32,28 +34,35 @@ function useChangePhoneForm({ hasExistingPhone, onDirectUpdateSuccess }) {
|
|
|
32
34
|
if (!hasExistingPhone) {
|
|
33
35
|
const result2 = await updateUserAction({ phone: local, ddi });
|
|
34
36
|
if (!result2.success) {
|
|
35
|
-
toast.custom((
|
|
37
|
+
toast.custom((toastId) => /* @__PURE__ */ jsx(
|
|
36
38
|
Toast,
|
|
37
39
|
{
|
|
38
40
|
variant: "error",
|
|
39
|
-
message: result2.error ?? "
|
|
40
|
-
toastId
|
|
41
|
+
message: result2.error ?? translate("common.account.changePhone.saveError"),
|
|
42
|
+
toastId
|
|
41
43
|
}
|
|
42
44
|
));
|
|
43
45
|
return;
|
|
44
46
|
}
|
|
45
|
-
toast.custom((
|
|
47
|
+
toast.custom((toastId) => /* @__PURE__ */ jsx(
|
|
48
|
+
Toast,
|
|
49
|
+
{
|
|
50
|
+
variant: "success",
|
|
51
|
+
message: translate("common.account.changePhone.phoneAdded"),
|
|
52
|
+
toastId
|
|
53
|
+
}
|
|
54
|
+
));
|
|
46
55
|
onDirectUpdateSuccess?.();
|
|
47
56
|
return;
|
|
48
57
|
}
|
|
49
58
|
const result = await requestPhoneChangeAction(local, ddi);
|
|
50
59
|
if (!result.success) {
|
|
51
|
-
toast.custom((
|
|
60
|
+
toast.custom((toastId) => /* @__PURE__ */ jsx(
|
|
52
61
|
Toast,
|
|
53
62
|
{
|
|
54
63
|
variant: "error",
|
|
55
|
-
message: result.error ?? "
|
|
56
|
-
toastId
|
|
64
|
+
message: result.error ?? translate("common.account.changePhone.numberExistsError"),
|
|
65
|
+
toastId
|
|
57
66
|
}
|
|
58
67
|
));
|
|
59
68
|
return;
|
|
@@ -63,7 +72,7 @@ function useChangePhoneForm({ hasExistingPhone, onDirectUpdateSuccess }) {
|
|
|
63
72
|
} finally {
|
|
64
73
|
setIsSubmitting(false);
|
|
65
74
|
}
|
|
66
|
-
}, [phoneValue, hasExistingPhone, onDirectUpdateSuccess]);
|
|
75
|
+
}, [phoneValue, hasExistingPhone, onDirectUpdateSuccess, translate]);
|
|
67
76
|
const handleBack = useCallback(() => {
|
|
68
77
|
setShowVerification(false);
|
|
69
78
|
}, []);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/account/hooks/useChangePhoneForm.tsx"],"sourcesContent":["'use client';\n\nimport { useState, useCallback } from 'react';\nimport { toast } from 'sonner';\nimport { Toast } from '../../ui/feedback/Toast';\nimport { requestPhoneChangeAction, updateUserAction } from '../../../modules/accounts/actions/account-management.action';\n\nfunction splitPhoneValue(fullValue: string): { ddi: string; local: string } {\n const trimmed = fullValue.trim();\n const spaceIdx = trimmed.indexOf(' ');\n if (spaceIdx === -1) return { ddi: '+55', local: trimmed };\n return { ddi: trimmed.slice(0, spaceIdx), local: trimmed.slice(spaceIdx + 1) };\n}\n\ninterface UseChangePhoneFormOptions {\n hasExistingPhone: boolean;\n onDirectUpdateSuccess?: () => void;\n}\n\nexport default function useChangePhoneForm({ hasExistingPhone, onDirectUpdateSuccess }: UseChangePhoneFormOptions) {\n const [showVerification, setShowVerification] = useState(false);\n const [phoneValue, setPhoneValue] = useState('');\n const [phoneError, setPhoneError] = useState('');\n const [isSubmitting, setIsSubmitting] = useState(false);\n const [submittedPhone, setSubmittedPhone] = useState({ ddi: '+55', local: '' });\n\n const handlePhoneChange = useCallback((value: string) => {\n setPhoneValue(value);\n if (phoneError) setPhoneError('');\n }, [phoneError]);\n\n const handleContinue = useCallback(async (e: React.FormEvent) => {\n e.preventDefault();\n\n const { ddi, local } = splitPhoneValue(phoneValue);\n\n if (!local || local.replace(/\\D/g, '').length < 8) {\n setPhoneError('
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/account/hooks/useChangePhoneForm.tsx"],"sourcesContent":["'use client';\n\nimport { useState, useCallback } from 'react';\nimport { useTranslations } from 'next-intl';\nimport { toast } from 'sonner';\nimport { Toast } from '../../ui/feedback/Toast';\nimport { requestPhoneChangeAction, updateUserAction } from '../../../modules/accounts/actions/account-management.action';\n\nfunction splitPhoneValue(fullValue: string): { ddi: string; local: string } {\n const trimmed = fullValue.trim();\n const spaceIdx = trimmed.indexOf(' ');\n if (spaceIdx === -1) return { ddi: '+55', local: trimmed };\n return { ddi: trimmed.slice(0, spaceIdx), local: trimmed.slice(spaceIdx + 1) };\n}\n\ninterface UseChangePhoneFormOptions {\n hasExistingPhone: boolean;\n onDirectUpdateSuccess?: () => void;\n}\n\nexport default function useChangePhoneForm({ hasExistingPhone, onDirectUpdateSuccess }: UseChangePhoneFormOptions) {\n const translate = useTranslations();\n const [showVerification, setShowVerification] = useState(false);\n const [phoneValue, setPhoneValue] = useState('');\n const [phoneError, setPhoneError] = useState('');\n const [isSubmitting, setIsSubmitting] = useState(false);\n const [submittedPhone, setSubmittedPhone] = useState({ ddi: '+55', local: '' });\n\n const handlePhoneChange = useCallback((value: string) => {\n setPhoneValue(value);\n if (phoneError) setPhoneError('');\n }, [phoneError]);\n\n const handleContinue = useCallback(async (e: React.FormEvent) => {\n e.preventDefault();\n\n const { ddi, local } = splitPhoneValue(phoneValue);\n\n if (!local || local.replace(/\\D/g, '').length < 8) {\n setPhoneError(translate('common.account.changePhone.invalidNumber'));\n return;\n }\n\n setIsSubmitting(true);\n try {\n if (!hasExistingPhone) {\n const result = await updateUserAction({ phone: local, ddi });\n\n if (!result.success) {\n toast.custom((toastId) => (\n <Toast\n variant=\"error\"\n message={result.error ?? translate('common.account.changePhone.saveError')}\n toastId={toastId}\n />\n ));\n return;\n }\n\n toast.custom((toastId) => (\n <Toast\n variant=\"success\"\n message={translate('common.account.changePhone.phoneAdded')}\n toastId={toastId}\n />\n ));\n onDirectUpdateSuccess?.();\n return;\n }\n\n const result = await requestPhoneChangeAction(local, ddi);\n\n if (!result.success) {\n toast.custom((toastId) => (\n <Toast\n variant=\"error\"\n message={result.error ?? translate('common.account.changePhone.numberExistsError')}\n toastId={toastId}\n />\n ));\n return;\n }\n\n setSubmittedPhone({ ddi, local });\n setShowVerification(true);\n } finally {\n setIsSubmitting(false);\n }\n }, [phoneValue, hasExistingPhone, onDirectUpdateSuccess, translate]);\n\n const handleBack = useCallback(() => {\n setShowVerification(false);\n }, []);\n\n const resetForm = useCallback(() => {\n setPhoneValue('');\n setPhoneError('');\n setSubmittedPhone({ ddi: '+55', local: '' });\n setShowVerification(false);\n }, []);\n\n return {\n showVerification,\n phoneValue,\n phoneError,\n isSubmitting,\n submittedPhone,\n handlePhoneChange,\n handleContinue,\n handleBack,\n resetForm,\n };\n}\n"],"mappings":";AAkDY;AAhDZ,SAAS,UAAU,mBAAmB;AACtC,SAAS,uBAAuB;AAChC,SAAS,aAAa;AACtB,SAAS,aAAa;AACtB,SAAS,0BAA0B,wBAAwB;AAE3D,SAAS,gBAAgB,WAAmD;AAC1E,QAAM,UAAU,UAAU,KAAK;AAC/B,QAAM,WAAW,QAAQ,QAAQ,GAAG;AACpC,MAAI,aAAa,GAAI,QAAO,EAAE,KAAK,OAAO,OAAO,QAAQ;AACzD,SAAO,EAAE,KAAK,QAAQ,MAAM,GAAG,QAAQ,GAAG,OAAO,QAAQ,MAAM,WAAW,CAAC,EAAE;AAC/E;AAOe,SAAR,mBAAoC,EAAE,kBAAkB,sBAAsB,GAA8B;AACjH,QAAM,YAAY,gBAAgB;AAClC,QAAM,CAAC,kBAAkB,mBAAmB,IAAI,SAAS,KAAK;AAC9D,QAAM,CAAC,YAAY,aAAa,IAAI,SAAS,EAAE;AAC/C,QAAM,CAAC,YAAY,aAAa,IAAI,SAAS,EAAE;AAC/C,QAAM,CAAC,cAAc,eAAe,IAAI,SAAS,KAAK;AACtD,QAAM,CAAC,gBAAgB,iBAAiB,IAAI,SAAS,EAAE,KAAK,OAAO,OAAO,GAAG,CAAC;AAE9E,QAAM,oBAAoB,YAAY,CAAC,UAAkB;AACvD,kBAAc,KAAK;AACnB,QAAI,WAAY,eAAc,EAAE;AAAA,EAClC,GAAG,CAAC,UAAU,CAAC;AAEf,QAAM,iBAAiB,YAAY,OAAO,MAAuB;AAC/D,MAAE,eAAe;AAEjB,UAAM,EAAE,KAAK,MAAM,IAAI,gBAAgB,UAAU;AAEjD,QAAI,CAAC,SAAS,MAAM,QAAQ,OAAO,EAAE,EAAE,SAAS,GAAG;AACjD,oBAAc,UA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AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":["result"]}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
3
|
import { useState, useCallback } from "react";
|
|
4
4
|
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
5
|
+
import { useTranslations } from "next-intl";
|
|
5
6
|
import { toast } from "sonner";
|
|
6
7
|
import { Toast } from "../../ui/feedback/Toast";
|
|
7
8
|
import { USER_QUERY_KEY } from "../../../modules/auth/hooks/useUserQuery";
|
|
@@ -11,6 +12,7 @@ function useDisableTwoFactorAuthForm({
|
|
|
11
12
|
onClose,
|
|
12
13
|
onSuccess
|
|
13
14
|
}) {
|
|
15
|
+
const translate = useTranslations();
|
|
14
16
|
const [code, setCode] = useState("");
|
|
15
17
|
const queryClient = useQueryClient();
|
|
16
18
|
const userKey = useWlQueryKey([...USER_QUERY_KEY]);
|
|
@@ -20,17 +22,38 @@ function useDisableTwoFactorAuthForm({
|
|
|
20
22
|
onSuccess: (result) => {
|
|
21
23
|
if (!result.success) {
|
|
22
24
|
setCode("");
|
|
23
|
-
toast.custom((
|
|
25
|
+
toast.custom((toastId) => /* @__PURE__ */ jsx(
|
|
26
|
+
Toast,
|
|
27
|
+
{
|
|
28
|
+
variant: "error",
|
|
29
|
+
message: result.error ?? translate("common.account.twoFactor.invalidCode"),
|
|
30
|
+
toastId
|
|
31
|
+
}
|
|
32
|
+
));
|
|
24
33
|
return;
|
|
25
34
|
}
|
|
26
35
|
queryClient.invalidateQueries({ queryKey: userKey });
|
|
27
|
-
toast.custom((
|
|
36
|
+
toast.custom((toastId) => /* @__PURE__ */ jsx(
|
|
37
|
+
Toast,
|
|
38
|
+
{
|
|
39
|
+
variant: "success",
|
|
40
|
+
message: translate("common.account.twoFactor.disabledSuccess"),
|
|
41
|
+
toastId
|
|
42
|
+
}
|
|
43
|
+
));
|
|
28
44
|
setCode("");
|
|
29
45
|
onSuccess?.();
|
|
30
46
|
},
|
|
31
47
|
onError: () => {
|
|
32
48
|
setCode("");
|
|
33
|
-
toast.custom((
|
|
49
|
+
toast.custom((toastId) => /* @__PURE__ */ jsx(
|
|
50
|
+
Toast,
|
|
51
|
+
{
|
|
52
|
+
variant: "error",
|
|
53
|
+
message: translate("common.account.twoFactor.disableError"),
|
|
54
|
+
toastId
|
|
55
|
+
}
|
|
56
|
+
));
|
|
34
57
|
}
|
|
35
58
|
});
|
|
36
59
|
const { mutate, reset } = mutation;
|