@greatapps/common 1.1.345 → 1.1.347
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/sections/PreferencesSection.mjs +3 -4
- package/dist/components/account/sections/PreferencesSection.mjs.map +1 -1
- package/dist/components/account/sections/SecuritySection.mjs +11 -126
- package/dist/components/account/sections/SecuritySection.mjs.map +1 -1
- package/package.json +1 -1
- package/src/components/account/sections/PreferencesSection.tsx +3 -5
- package/src/components/account/sections/SecuritySection.tsx +14 -126
|
@@ -112,8 +112,8 @@ function PreferencesSection({ onClose }) {
|
|
|
112
112
|
setPendingSubmit(null);
|
|
113
113
|
};
|
|
114
114
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
115
|
-
/* @__PURE__ */ jsxs("form", { onSubmit: handleSubmit(onSubmit), className: "flex flex-col", children: [
|
|
116
|
-
/* @__PURE__ */ jsxs("div", { className: "overflow-y-auto overscroll-contain px-4 pb-4 lg:p-5 flex flex-col gap-5 lg:gap-6", children: [
|
|
115
|
+
/* @__PURE__ */ jsxs("form", { onSubmit: handleSubmit(onSubmit), className: "flex flex-col h-full", children: [
|
|
116
|
+
/* @__PURE__ */ jsxs("div", { className: "overflow-y-auto overscroll-contain px-4 pb-4 lg:p-5 flex flex-col gap-5 lg:gap-6 flex-1", children: [
|
|
117
117
|
/* @__PURE__ */ jsx("span", { className: "paragraph-medium-semibold text-gray-950", children: "Prefer\xEAncias" }),
|
|
118
118
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-8", children: [
|
|
119
119
|
/* @__PURE__ */ jsx("div", { className: "flex flex-col lg:flex-row items-center gap-3", children: /* @__PURE__ */ jsx(
|
|
@@ -127,7 +127,6 @@ function PreferencesSection({ onClose }) {
|
|
|
127
127
|
disabled: !canEditPreferences
|
|
128
128
|
}
|
|
129
129
|
) }),
|
|
130
|
-
/* @__PURE__ */ jsx(Separator, {}),
|
|
131
130
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col lg:flex-row items-center gap-3", children: [
|
|
132
131
|
/* @__PURE__ */ jsx(
|
|
133
132
|
ComboboxField,
|
|
@@ -192,7 +191,7 @@ function PreferencesSection({ onClose }) {
|
|
|
192
191
|
] })
|
|
193
192
|
] })
|
|
194
193
|
] }),
|
|
195
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center h-20 px-4 lg:px-5 border-t border-gray-200 justify-between bg-white", children: [
|
|
194
|
+
/* @__PURE__ */ jsxs("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", children: [
|
|
196
195
|
/* @__PURE__ */ jsx(
|
|
197
196
|
Button,
|
|
198
197
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/account/sections/PreferencesSection.tsx"],"sourcesContent":["'use client';\n\nimport { useState, useEffect } from 'react';\nimport { useForm } from 'react-hook-form';\nimport { toast } from 'sonner';\nimport { IconLock } from '@tabler/icons-react';\nimport { Button } from '../../ui/buttons/Button';\nimport { Separator } from '../../ui/data-display/Separator';\nimport { Toast } from '../../ui/feedback/Toast';\nimport { FormField } from '../../ui/form/FormField';\nimport { ComboboxField } from '../../ui/form/ComboboxField';\nimport { SelectField } from '../../ui/form/SelectField';\nimport ConfirmGlobalPreferencesModal from '../ConfirmGlobalPreferencesModal';\nimport { useAuth } from '../../../providers/auth.provider';\nimport { UserProfile } from '../../../modules/users/schema';\nimport type { UpdateAccountRequest } from '../../../modules/accounts/types';\nimport {\n useUpdateAccountUser,\n useUpdateAccount,\n} from '../../../modules/accounts/hooks/useAccountManagement';\nimport {\n LANGUAGE_OPTIONS,\n TIME_FORMAT_OPTIONS,\n} from '../constants';\nimport { useTimezones } from '../../../modules/accounts/hooks/useTimezones';\nimport { useCurrencies } from '../../../modules/accounts/hooks/useCurrencies';\n\ninterface PreferencesFormValues {\n companyName: string;\n language: string;\n currency: string;\n timezone: string;\n timeFormat: string;\n receive_sms: boolean;\n receive_email: boolean;\n}\n\ninterface PreferencesSectionProps {\n onClose: () => void;\n}\n\nexport function PreferencesSection({ onClose }: PreferencesSectionProps) {\n const { data: timezones = [] } = useTimezones();\n const { data: currencies = [] } = useCurrencies();\n const { user, account } = useAuth();\n const canEditPreferences =\n user?.profile === UserProfile.owner || user?.profile === UserProfile.admin;\n const updateAccountUser = useUpdateAccountUser();\n const updateAccount = useUpdateAccount();\n const [confirmGlobalOpen, setConfirmGlobalOpen] = useState(false);\n const [pendingSubmit, setPendingSubmit] = useState<{\n data: PreferencesFormValues;\n accountFields: UpdateAccountRequest;\n } | null>(null);\n const [isSaving, setIsSaving] = useState(false);\n\n const { watch, setValue, handleSubmit, reset, formState: { dirtyFields } } =\n useForm<PreferencesFormValues>({\n defaultValues: {\n companyName: '',\n language: '',\n currency: '',\n timezone: '',\n timeFormat: '24h',\n receive_sms: false,\n receive_email: false,\n },\n });\n\n useEffect(() => {\n if (!user || !account) return;\n reset({\n companyName: account.name ?? '',\n language: LANGUAGE_OPTIONS.find(\n (o) => o.apiValue === user.language?.toLowerCase()\n )?.value ?? 'pt-BR',\n currency: account.currency,\n timezone: account.timezone,\n timeFormat: '24h',\n receive_sms: user.receive_sms ?? false,\n receive_email: user.receive_email ?? false,\n });\n }, [user, account, reset]);\n\n const doSave = async (data: PreferencesFormValues, accountFields: UpdateAccountRequest) => {\n setIsSaving(true);\n try {\n const apiLanguage = LANGUAGE_OPTIONS.find((o) => o.value === data.language)?.apiValue ?? data.language.toLowerCase();\n await updateAccountUser.mutateAsync({\n language: apiLanguage,\n receive_sms: data.receive_sms,\n receive_email: data.receive_email,\n });\n\n if (canEditPreferences && Object.keys(accountFields).length > 0) {\n await updateAccount.mutateAsync(accountFields);\n }\n\n reset(data);\n toast.custom((t) => (\n <Toast variant=\"success\" message=\"Preferências salvas com sucesso\" toastId={t} />\n ));\n onClose();\n } catch (error) {\n toast.custom((t) => (\n <Toast\n variant=\"error\"\n message={error instanceof Error ? error.message : 'Erro ao salvar preferências'}\n toastId={t}\n />\n ));\n } finally {\n setIsSaving(false);\n }\n };\n\n const onSubmit = (data: PreferencesFormValues) => {\n const accountFields: UpdateAccountRequest = {\n ...(canEditPreferences && dirtyFields.companyName && { name: data.companyName }),\n ...(canEditPreferences && dirtyFields.currency && { currency: data.currency }),\n ...(canEditPreferences && dirtyFields.timezone && { timezone: data.timezone }),\n };\n const globalFieldChanged = Object.keys(accountFields).length > 0;\n\n if (globalFieldChanged) {\n setPendingSubmit({ data, accountFields });\n setConfirmGlobalOpen(true);\n } else {\n doSave(data, accountFields);\n }\n };\n\n const handleConfirmGlobal = () => {\n setConfirmGlobalOpen(false);\n if (pendingSubmit) {\n doSave(pendingSubmit.data, pendingSubmit.accountFields);\n setPendingSubmit(null);\n }\n };\n\n const handleCancelGlobal = () => {\n setConfirmGlobalOpen(false);\n setPendingSubmit(null);\n };\n\n return (\n <>\n <form onSubmit={handleSubmit(onSubmit)} className=\"flex flex-col\">\n <div className=\"overflow-y-auto overscroll-contain px-4 pb-4 lg:p-5 flex flex-col gap-5 lg:gap-6\">\n <span className=\"paragraph-medium-semibold text-gray-950\">Preferências</span>\n <div className=\"flex flex-col gap-8\">\n <div className=\"flex flex-col lg:flex-row items-center gap-3\">\n <FormField\n label=\"Nome da empresa\"\n placeholder=\"Digite o nome da empresa\"\n classnameContainer=\"w-full\"\n value={watch('companyName')}\n onChange={(e) => setValue('companyName', e.target.value, { shouldDirty: true })}\n disabled={!canEditPreferences}\n />\n </div>\n\n <Separator />\n\n <div className=\"flex flex-col lg:flex-row items-center gap-3\">\n <ComboboxField\n label=\"Idioma\"\n placeholder=\"Selecione o idioma\"\n searchPlaceholder=\"Buscar idioma...\"\n containerClassName=\"w-full\"\n options={LANGUAGE_OPTIONS}\n value={watch('language')}\n onChange={(value) => setValue('language', value, { shouldDirty: true })}\n />\n <ComboboxField\n label=\"Moeda\"\n placeholder=\"Selecione a moeda\"\n searchPlaceholder=\"Buscar moeda...\"\n containerClassName=\"w-full\"\n options={currencies}\n value={watch('currency')}\n onChange={(value) => setValue('currency', value, { shouldDirty: true })}\n icon={!canEditPreferences ? <IconLock className=\"size-4 text-gray-400\" /> : undefined}\n disabled={!canEditPreferences}\n />\n </div>\n\n <Separator />\n\n <div className=\"flex flex-col gap-4\">\n <span className=\"paragraph-medium-semibold text-gray-950\">Exibição hora</span>\n <div className=\"flex flex-col lg:flex-row items-center gap-3\">\n <ComboboxField\n label=\"Fuso horário\"\n placeholder=\"Selecione o fuso horário\"\n searchPlaceholder=\"Buscar fuso horário...\"\n containerClassName=\"w-full\"\n options={timezones}\n value={watch('timezone')}\n onChange={(value) => setValue('timezone', value, { shouldDirty: true })}\n icon={!canEditPreferences ? <IconLock className=\"size-4 text-gray-400\" /> : undefined}\n disabled={!canEditPreferences}\n />\n <SelectField\n label=\"Formato hora\"\n placeholder=\"Selecione o formato\"\n className=\"h-10!\"\n containerClassName=\"w-full\"\n options={TIME_FORMAT_OPTIONS}\n value={watch('timeFormat')}\n onChange={(value) =>\n setValue('timeFormat', value as string, { shouldDirty: true })\n }\n icon={<IconLock className=\"size-4 text-gray-400\" />}\n disabled\n />\n </div>\n </div>\n\n </div>\n </div>\n\n <div className=\"flex items-center h-20 px-4 lg:px-5 border-t border-gray-200 justify-between bg-white\">\n <Button\n variant=\"secondary\"\n className=\"h-10!\"\n type=\"button\"\n disabled={isSaving}\n onClick={() => {\n reset();\n onClose();\n }}\n >\n Cancelar\n </Button>\n <Button className=\"h-10!\" type=\"submit\" disabled={isSaving}>\n {isSaving ? 'Salvando...' : 'Salvar alterações'}\n </Button>\n </div>\n </form>\n\n <ConfirmGlobalPreferencesModal\n open={confirmGlobalOpen}\n onConfirm={handleConfirmGlobal}\n onCancel={handleCancelGlobal}\n />\n </>\n );\n}\n"],"mappings":";AAoGQ,SA8CJ,UA9CI,KAgEI,YAhEJ;AAlGR,SAAS,UAAU,iBAAiB;AACpC,SAAS,eAAe;AACxB,SAAS,aAAa;AACt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ACV,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';\n\nimport { useState, useEffect } from 'react';\nimport { useForm } from 'react-hook-form';\nimport { toast } from 'sonner';\nimport { IconLock } from '@tabler/icons-react';\nimport { Button } from '../../ui/buttons/Button';\nimport { Separator } from '../../ui/data-display/Separator';\nimport { Toast } from '../../ui/feedback/Toast';\nimport { FormField } from '../../ui/form/FormField';\nimport { ComboboxField } from '../../ui/form/ComboboxField';\nimport { SelectField } from '../../ui/form/SelectField';\nimport ConfirmGlobalPreferencesModal from '../ConfirmGlobalPreferencesModal';\nimport { useAuth } from '../../../providers/auth.provider';\nimport { UserProfile } from '../../../modules/users/schema';\nimport type { UpdateAccountRequest } from '../../../modules/accounts/types';\nimport {\n useUpdateAccountUser,\n useUpdateAccount,\n} from '../../../modules/accounts/hooks/useAccountManagement';\nimport {\n LANGUAGE_OPTIONS,\n TIME_FORMAT_OPTIONS,\n} from '../constants';\nimport { useTimezones } from '../../../modules/accounts/hooks/useTimezones';\nimport { useCurrencies } from '../../../modules/accounts/hooks/useCurrencies';\n\ninterface PreferencesFormValues {\n companyName: string;\n language: string;\n currency: string;\n timezone: string;\n timeFormat: string;\n receive_sms: boolean;\n receive_email: boolean;\n}\n\ninterface PreferencesSectionProps {\n onClose: () => void;\n}\n\nexport function PreferencesSection({ onClose }: PreferencesSectionProps) {\n const { data: timezones = [] } = useTimezones();\n const { data: currencies = [] } = useCurrencies();\n const { user, account } = useAuth();\n const canEditPreferences =\n user?.profile === UserProfile.owner || user?.profile === UserProfile.admin;\n const updateAccountUser = useUpdateAccountUser();\n const updateAccount = useUpdateAccount();\n const [confirmGlobalOpen, setConfirmGlobalOpen] = useState(false);\n const [pendingSubmit, setPendingSubmit] = useState<{\n data: PreferencesFormValues;\n accountFields: UpdateAccountRequest;\n } | null>(null);\n const [isSaving, setIsSaving] = useState(false);\n\n const { watch, setValue, handleSubmit, reset, formState: { dirtyFields } } =\n useForm<PreferencesFormValues>({\n defaultValues: {\n companyName: '',\n language: '',\n currency: '',\n timezone: '',\n timeFormat: '24h',\n receive_sms: false,\n receive_email: false,\n },\n });\n\n useEffect(() => {\n if (!user || !account) return;\n reset({\n companyName: account.name ?? '',\n language: LANGUAGE_OPTIONS.find(\n (o) => o.apiValue === user.language?.toLowerCase()\n )?.value ?? 'pt-BR',\n currency: account.currency,\n timezone: account.timezone,\n timeFormat: '24h',\n receive_sms: user.receive_sms ?? false,\n receive_email: user.receive_email ?? false,\n });\n }, [user, account, reset]);\n\n const doSave = async (data: PreferencesFormValues, accountFields: UpdateAccountRequest) => {\n setIsSaving(true);\n try {\n const apiLanguage = LANGUAGE_OPTIONS.find((o) => o.value === data.language)?.apiValue ?? data.language.toLowerCase();\n await updateAccountUser.mutateAsync({\n language: apiLanguage,\n receive_sms: data.receive_sms,\n receive_email: data.receive_email,\n });\n\n if (canEditPreferences && Object.keys(accountFields).length > 0) {\n await updateAccount.mutateAsync(accountFields);\n }\n\n reset(data);\n toast.custom((t) => (\n <Toast variant=\"success\" message=\"Preferências salvas com sucesso\" toastId={t} />\n ));\n onClose();\n } catch (error) {\n toast.custom((t) => (\n <Toast\n variant=\"error\"\n message={error instanceof Error ? error.message : 'Erro ao salvar preferências'}\n toastId={t}\n />\n ));\n } finally {\n setIsSaving(false);\n }\n };\n\n const onSubmit = (data: PreferencesFormValues) => {\n const accountFields: UpdateAccountRequest = {\n ...(canEditPreferences && dirtyFields.companyName && { name: data.companyName }),\n ...(canEditPreferences && dirtyFields.currency && { currency: data.currency }),\n ...(canEditPreferences && dirtyFields.timezone && { timezone: data.timezone }),\n };\n const globalFieldChanged = Object.keys(accountFields).length > 0;\n\n if (globalFieldChanged) {\n setPendingSubmit({ data, accountFields });\n setConfirmGlobalOpen(true);\n } else {\n doSave(data, accountFields);\n }\n };\n\n const handleConfirmGlobal = () => {\n setConfirmGlobalOpen(false);\n if (pendingSubmit) {\n doSave(pendingSubmit.data, pendingSubmit.accountFields);\n setPendingSubmit(null);\n }\n };\n\n const handleCancelGlobal = () => {\n setConfirmGlobalOpen(false);\n setPendingSubmit(null);\n };\n\n return (\n <>\n <form onSubmit={handleSubmit(onSubmit)} className=\"flex flex-col h-full\">\n <div className=\"overflow-y-auto overscroll-contain px-4 pb-4 lg:p-5 flex flex-col gap-5 lg:gap-6 flex-1\">\n <span className=\"paragraph-medium-semibold text-gray-950\">Preferências</span>\n <div className=\"flex flex-col gap-8\">\n <div className=\"flex flex-col lg:flex-row items-center gap-3\">\n <FormField\n label=\"Nome da empresa\"\n placeholder=\"Digite o nome da empresa\"\n classnameContainer=\"w-full\"\n value={watch('companyName')}\n onChange={(e) => setValue('companyName', e.target.value, { shouldDirty: true })}\n disabled={!canEditPreferences}\n />\n </div>\n\n <div className=\"flex flex-col lg:flex-row items-center gap-3\">\n <ComboboxField\n label=\"Idioma\"\n placeholder=\"Selecione o idioma\"\n searchPlaceholder=\"Buscar idioma...\"\n containerClassName=\"w-full\"\n options={LANGUAGE_OPTIONS}\n value={watch('language')}\n onChange={(value) => setValue('language', value, { shouldDirty: true })}\n />\n <ComboboxField\n label=\"Moeda\"\n placeholder=\"Selecione a moeda\"\n searchPlaceholder=\"Buscar moeda...\"\n containerClassName=\"w-full\"\n options={currencies}\n value={watch('currency')}\n onChange={(value) => setValue('currency', value, { shouldDirty: true })}\n icon={!canEditPreferences ? <IconLock className=\"size-4 text-gray-400\" /> : undefined}\n disabled={!canEditPreferences}\n />\n </div>\n\n <Separator />\n\n <div className=\"flex flex-col gap-4\">\n <span className=\"paragraph-medium-semibold text-gray-950\">Exibição hora</span>\n <div className=\"flex flex-col lg:flex-row items-center gap-3\">\n <ComboboxField\n label=\"Fuso horário\"\n placeholder=\"Selecione o fuso horário\"\n searchPlaceholder=\"Buscar fuso horário...\"\n containerClassName=\"w-full\"\n options={timezones}\n value={watch('timezone')}\n onChange={(value) => setValue('timezone', value, { shouldDirty: true })}\n icon={!canEditPreferences ? <IconLock className=\"size-4 text-gray-400\" /> : undefined}\n disabled={!canEditPreferences}\n />\n <SelectField\n label=\"Formato hora\"\n placeholder=\"Selecione o formato\"\n className=\"h-10!\"\n containerClassName=\"w-full\"\n options={TIME_FORMAT_OPTIONS}\n value={watch('timeFormat')}\n onChange={(value) =>\n setValue('timeFormat', value as string, { shouldDirty: true })\n }\n icon={<IconLock className=\"size-4 text-gray-400\" />}\n disabled\n />\n </div>\n </div>\n\n </div>\n </div>\n\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\">\n <Button\n variant=\"secondary\"\n className=\"h-10!\"\n type=\"button\"\n disabled={isSaving}\n onClick={() => {\n reset();\n onClose();\n }}\n >\n Cancelar\n </Button>\n <Button className=\"h-10!\" type=\"submit\" disabled={isSaving}>\n {isSaving ? 'Salvando...' : 'Salvar alterações'}\n </Button>\n </div>\n </form>\n\n <ConfirmGlobalPreferencesModal\n open={confirmGlobalOpen}\n onConfirm={handleConfirmGlobal}\n onCancel={handleCancelGlobal}\n />\n </>\n );\n}\n"],"mappings":";AAoGQ,SA8CJ,UA9CI,KA8DI,YA9DJ;AAlGR,SAAS,UAAU,iBAAiB;AACpC,SAAS,eAAe;AACxB,SAAS,aAAa;AACtB,SAAS,gBAAgB;AACzB,SAAS,cAAc;AACvB,SAAS,iBAAiB;AAC1B,SAAS,aAAa;AACtB,SAAS,iBAAiB;AAC1B,SAAS,qBAAqB;AAC9B,SAAS,mBAAmB;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B;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,143 +1,28 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { IconLock, IconTool } from "@tabler/icons-react";
|
|
5
|
-
import { Badge } from "../../ui/data-display/Badge";
|
|
6
|
-
import { Button } from "../../ui/buttons/Button";
|
|
7
|
-
import { useAuth } from "../../../providers/auth.provider";
|
|
8
|
-
import { useQueryClient } from "@tanstack/react-query";
|
|
9
|
-
import { USER_QUERY_KEY } from "../../../modules/auth/hooks/useUserQuery";
|
|
10
|
-
import { AccountSectionType } from "../../../enums/AccountSectionType";
|
|
11
|
-
import TwoFactorAuthModal from "../TwoFactorAuthModal";
|
|
12
|
-
import DisableTwoFactorAuthModal from "../DisableTwoFactorAuthModal";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { IconAlertTriangle } from "@tabler/icons-react";
|
|
13
4
|
function SecuritySection({
|
|
14
|
-
setActiveSection,
|
|
15
5
|
onClose,
|
|
16
6
|
onDeleteAccount
|
|
17
7
|
}) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
setDisableTwoFactorOpen(true);
|
|
26
|
-
} else {
|
|
27
|
-
setTwoFactorOpen(true);
|
|
28
|
-
}
|
|
29
|
-
}, [twoFactorAuth]);
|
|
30
|
-
const handleDisableTwoFactorSuccess = useCallback(() => {
|
|
31
|
-
queryClient.invalidateQueries({ queryKey: USER_QUERY_KEY });
|
|
32
|
-
setDisableTwoFactorOpen(false);
|
|
33
|
-
}, [queryClient]);
|
|
34
|
-
const handleEnableTwoFactorSuccess = useCallback(() => {
|
|
35
|
-
queryClient.invalidateQueries({ queryKey: USER_QUERY_KEY });
|
|
36
|
-
setTwoFactorOpen(false);
|
|
37
|
-
}, [queryClient]);
|
|
38
|
-
const handleDeleteAccount = useCallback(() => {
|
|
39
|
-
onDeleteAccount?.();
|
|
40
|
-
}, [onDeleteAccount]);
|
|
41
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
42
|
-
/* @__PURE__ */ jsxs("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", children: [
|
|
43
|
-
/* @__PURE__ */ jsx("span", { className: "paragraph-medium-semibold text-gray-950 hidden lg:block", children: "Seguran\xE7a" }),
|
|
44
|
-
/* @__PURE__ */ jsxs("div", { className: "border border-gray-200 rounded-lg overflow-hidden", children: [
|
|
45
|
-
/* @__PURE__ */ jsxs(
|
|
46
|
-
"div",
|
|
47
|
-
{
|
|
48
|
-
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",
|
|
49
|
-
onClick: handleToggleTwoFactor,
|
|
50
|
-
children: [
|
|
51
|
-
/* @__PURE__ */ jsxs("div", { className: "flex flex-1 items-start lg:items-center gap-4 lg:gap-5", children: [
|
|
52
|
-
/* @__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" }) }),
|
|
53
|
-
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1.5 flex-1", children: [
|
|
54
|
-
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
55
|
-
/* @__PURE__ */ jsx("span", { className: "paragraph-small-semibold text-gray-950", children: "Autentica\xE7\xE3o de dois fatores" }),
|
|
56
|
-
/* @__PURE__ */ jsx(
|
|
57
|
-
Badge,
|
|
58
|
-
{
|
|
59
|
-
className: `paragraph-xsmall-semibold rounded-lg ${twoFactorAuth ? "text-green-600 bg-green-50" : "text-gray-600 bg-gray-50"}`,
|
|
60
|
-
children: twoFactorAuth ? "Habilitado" : "Desabilitado"
|
|
61
|
-
}
|
|
62
|
-
)
|
|
63
|
-
] }),
|
|
64
|
-
/* @__PURE__ */ jsx("span", { className: "paragraph-small-regular text-gray-600", children: "Envio de c\xF3digo de seguran\xE7a (e-mail ou sms) para o usu\xE1rio acessar o sistema" })
|
|
65
|
-
] })
|
|
66
|
-
] }),
|
|
67
|
-
/* @__PURE__ */ jsx(
|
|
68
|
-
Button,
|
|
69
|
-
{
|
|
70
|
-
variant: "secondary",
|
|
71
|
-
className: "h-10! shrink-0 w-full lg:w-auto",
|
|
72
|
-
onClick: (e) => {
|
|
73
|
-
e.stopPropagation();
|
|
74
|
-
handleToggleTwoFactor();
|
|
75
|
-
},
|
|
76
|
-
children: twoFactorAuth ? "Desabilitar" : "Habilitar"
|
|
77
|
-
}
|
|
78
|
-
)
|
|
79
|
-
]
|
|
80
|
-
}
|
|
81
|
-
),
|
|
82
|
-
/* @__PURE__ */ jsxs(
|
|
83
|
-
"div",
|
|
84
|
-
{
|
|
85
|
-
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",
|
|
86
|
-
onClick: () => setActiveSection(AccountSectionType.CHANGE_PASSWORD),
|
|
87
|
-
children: [
|
|
88
|
-
/* @__PURE__ */ jsxs("div", { className: "flex flex-1 items-start lg:items-center gap-4 lg:gap-5", children: [
|
|
89
|
-
/* @__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" }) }),
|
|
90
|
-
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1.5 flex-1", children: [
|
|
91
|
-
/* @__PURE__ */ jsx("span", { className: "paragraph-small-semibold text-gray-950", children: "Alterar senha de acesso" }),
|
|
92
|
-
/* @__PURE__ */ jsx("span", { className: "paragraph-small-regular text-gray-600", children: "Atualize sua senha sempre que necess\xE1rio para manter sua conta segura." })
|
|
93
|
-
] })
|
|
94
|
-
] }),
|
|
95
|
-
/* @__PURE__ */ jsx(
|
|
96
|
-
Button,
|
|
97
|
-
{
|
|
98
|
-
variant: "secondary",
|
|
99
|
-
className: "h-10! shrink-0 w-full lg:w-auto",
|
|
100
|
-
onClick: (e) => {
|
|
101
|
-
e.stopPropagation();
|
|
102
|
-
setActiveSection(AccountSectionType.CHANGE_PASSWORD);
|
|
103
|
-
},
|
|
104
|
-
children: "Alterar senha"
|
|
105
|
-
}
|
|
106
|
-
)
|
|
107
|
-
]
|
|
108
|
-
}
|
|
109
|
-
)
|
|
8
|
+
return /* @__PURE__ */ jsxs("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", children: [
|
|
9
|
+
/* @__PURE__ */ jsx("span", { className: "paragraph-medium-semibold text-gray-950 hidden lg:block", children: "Seguran\xE7a" }),
|
|
10
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center lg:items-start gap-4", children: [
|
|
11
|
+
/* @__PURE__ */ jsx("div", { className: "size-10 rounded-full bg-red-50 flex items-center justify-center", children: /* @__PURE__ */ jsx(IconAlertTriangle, { size: 20, className: "text-red-500" }) }),
|
|
12
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
13
|
+
/* @__PURE__ */ jsx("span", { className: "paragraph-medium-semibold text-gray-950", children: "Excluir conta" }),
|
|
14
|
+
/* @__PURE__ */ jsx("span", { className: "paragraph-small-regular text-gray-600", children: "Esta a\xE7\xE3o \xE9 permanente e n\xE3o pode ser desfeita. Todos os seus dados, projetos e configura\xE7\xF5es ser\xE3o removidos definitivamente." })
|
|
110
15
|
] }),
|
|
111
16
|
onDeleteAccount && /* @__PURE__ */ jsx(
|
|
112
17
|
"button",
|
|
113
18
|
{
|
|
114
19
|
type: "button",
|
|
115
20
|
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",
|
|
116
|
-
onClick:
|
|
21
|
+
onClick: onDeleteAccount,
|
|
117
22
|
children: "Excluir minha conta"
|
|
118
23
|
}
|
|
119
24
|
)
|
|
120
|
-
] })
|
|
121
|
-
/* @__PURE__ */ jsxs("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", children: [
|
|
122
|
-
/* @__PURE__ */ jsx(Button, { variant: "secondary", className: "h-10!", type: "button", onClick: onClose, children: "Cancelar" }),
|
|
123
|
-
/* @__PURE__ */ jsx(Button, { className: "h-10!", onClick: onClose, children: "Salvar altera\xE7\xF5es" })
|
|
124
|
-
] }),
|
|
125
|
-
/* @__PURE__ */ jsx(
|
|
126
|
-
DisableTwoFactorAuthModal,
|
|
127
|
-
{
|
|
128
|
-
open: disableTwoFactorOpen,
|
|
129
|
-
onClose: () => setDisableTwoFactorOpen(false),
|
|
130
|
-
onSuccess: handleDisableTwoFactorSuccess
|
|
131
|
-
}
|
|
132
|
-
),
|
|
133
|
-
/* @__PURE__ */ jsx(
|
|
134
|
-
TwoFactorAuthModal,
|
|
135
|
-
{
|
|
136
|
-
open: twoFactorOpen,
|
|
137
|
-
onClose: () => setTwoFactorOpen(false),
|
|
138
|
-
onSuccess: handleEnableTwoFactorSuccess
|
|
139
|
-
}
|
|
140
|
-
)
|
|
25
|
+
] })
|
|
141
26
|
] });
|
|
142
27
|
}
|
|
143
28
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/account/sections/SecuritySection.tsx"],"sourcesContent":["'use client';\n\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/account/sections/SecuritySection.tsx"],"sourcesContent":["'use client';\n\nimport { IconAlertTriangle } from '@tabler/icons-react';\nimport { Button } from '../../ui/buttons/Button';\nimport { useAuth } from '../../../providers/auth.provider';\nimport { AccountSectionType } from '../../../enums/AccountSectionType';\n\ninterface SecuritySectionProps {\n setActiveSection: (section: AccountSectionType) => void;\n onClose: () => void;\n onDeleteAccount?: () => void;\n}\n\nexport function SecuritySection({\n onClose,\n onDeleteAccount,\n}: SecuritySectionProps) {\n return (\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\">\n <span className=\"paragraph-medium-semibold text-gray-950 hidden lg:block\">Segurança</span>\n\n <div className=\"flex flex-col items-center lg:items-start gap-4\">\n <div className=\"size-10 rounded-full bg-red-50 flex items-center justify-center\">\n <IconAlertTriangle size={20} className=\"text-red-500\" />\n </div>\n\n <div className=\"flex flex-col gap-2\">\n <span className=\"paragraph-medium-semibold text-gray-950\">Excluir conta</span>\n <span className=\"paragraph-small-regular text-gray-600\">\n Esta ação é permanente e não pode ser desfeita. Todos os seus dados, projetos e configurações serão removidos definitivamente.\n </span>\n </div>\n\n {onDeleteAccount && (\n <button\n type=\"button\"\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\"\n onClick={onDeleteAccount}\n >\n Excluir minha conta\n </button>\n )}\n </div>\n </div>\n );\n}\n"],"mappings":";AAmBM,cAOE,YAPF;AAjBN,SAAS,yBAAyB;AAW3B,SAAS,gBAAgB;AAAA,EAC9B;AAAA,EACA;AACF,GAAyB;AACvB,SACE,qBAAC,SAAI,WAAU,gIACb;AAAA,wBAAC,UAAK,WAAU,2DAA0D,0BAAS;AAAA,IAEnF,qBAAC,SAAI,WAAU,mDACb;AAAA,0BAAC,SAAI,WAAU,mEACb,8BAAC,qBAAkB,MAAM,IAAI,WAAU,gBAAe,GACxD;AAAA,MAEA,qBAAC,SAAI,WAAU,uBACb;AAAA,4BAAC,UAAK,WAAU,2CAA0C,2BAAa;AAAA,QACvE,oBAAC,UAAK,WAAU,yCAAwC,iKAExD;AAAA,SACF;AAAA,MAEC,mBACC;AAAA,QAAC;AAAA;AAAA,UACC,MAAK;AAAA,UACL,WAAU;AAAA,UACV,SAAS;AAAA,UACV;AAAA;AAAA,MAED;AAAA,OAEJ;AAAA,KACF;AAEJ;","names":[]}
|
package/package.json
CHANGED
|
@@ -145,8 +145,8 @@ export function PreferencesSection({ onClose }: PreferencesSectionProps) {
|
|
|
145
145
|
|
|
146
146
|
return (
|
|
147
147
|
<>
|
|
148
|
-
<form onSubmit={handleSubmit(onSubmit)} className="flex flex-col">
|
|
149
|
-
<div className="overflow-y-auto overscroll-contain px-4 pb-4 lg:p-5 flex flex-col gap-5 lg:gap-6">
|
|
148
|
+
<form onSubmit={handleSubmit(onSubmit)} className="flex flex-col h-full">
|
|
149
|
+
<div className="overflow-y-auto overscroll-contain px-4 pb-4 lg:p-5 flex flex-col gap-5 lg:gap-6 flex-1">
|
|
150
150
|
<span className="paragraph-medium-semibold text-gray-950">Preferências</span>
|
|
151
151
|
<div className="flex flex-col gap-8">
|
|
152
152
|
<div className="flex flex-col lg:flex-row items-center gap-3">
|
|
@@ -160,8 +160,6 @@ export function PreferencesSection({ onClose }: PreferencesSectionProps) {
|
|
|
160
160
|
/>
|
|
161
161
|
</div>
|
|
162
162
|
|
|
163
|
-
<Separator />
|
|
164
|
-
|
|
165
163
|
<div className="flex flex-col lg:flex-row items-center gap-3">
|
|
166
164
|
<ComboboxField
|
|
167
165
|
label="Idioma"
|
|
@@ -220,7 +218,7 @@ export function PreferencesSection({ onClose }: PreferencesSectionProps) {
|
|
|
220
218
|
</div>
|
|
221
219
|
</div>
|
|
222
220
|
|
|
223
|
-
<div className="flex items-center h-20 px-4 lg:px-5 border-t border-gray-200 justify-between bg-white">
|
|
221
|
+
<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">
|
|
224
222
|
<Button
|
|
225
223
|
variant="secondary"
|
|
226
224
|
className="h-10!"
|
|
@@ -1,15 +1,9 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import { IconLock, IconTool } from '@tabler/icons-react';
|
|
5
|
-
import { Badge } from '../../ui/data-display/Badge';
|
|
3
|
+
import { IconAlertTriangle } from '@tabler/icons-react';
|
|
6
4
|
import { Button } from '../../ui/buttons/Button';
|
|
7
5
|
import { useAuth } from '../../../providers/auth.provider';
|
|
8
|
-
import { useQueryClient } from '@tanstack/react-query';
|
|
9
|
-
import { USER_QUERY_KEY } from '../../../modules/auth/hooks/useUserQuery';
|
|
10
6
|
import { AccountSectionType } from '../../../enums/AccountSectionType';
|
|
11
|
-
import TwoFactorAuthModal from '../TwoFactorAuthModal';
|
|
12
|
-
import DisableTwoFactorAuthModal from '../DisableTwoFactorAuthModal';
|
|
13
7
|
|
|
14
8
|
interface SecuritySectionProps {
|
|
15
9
|
setActiveSection: (section: AccountSectionType) => void;
|
|
@@ -18,141 +12,35 @@ interface SecuritySectionProps {
|
|
|
18
12
|
}
|
|
19
13
|
|
|
20
14
|
export function SecuritySection({
|
|
21
|
-
setActiveSection,
|
|
22
15
|
onClose,
|
|
23
16
|
onDeleteAccount,
|
|
24
17
|
}: SecuritySectionProps) {
|
|
25
|
-
const { user } = useAuth();
|
|
26
|
-
const queryClient = useQueryClient();
|
|
27
|
-
|
|
28
|
-
const twoFactorAuth = user?.two_factor_authentication ?? false;
|
|
29
|
-
const [twoFactorOpen, setTwoFactorOpen] = useState(false);
|
|
30
|
-
const [disableTwoFactorOpen, setDisableTwoFactorOpen] = useState(false);
|
|
31
|
-
|
|
32
|
-
const handleToggleTwoFactor = useCallback(() => {
|
|
33
|
-
if (twoFactorAuth) {
|
|
34
|
-
setDisableTwoFactorOpen(true);
|
|
35
|
-
} else {
|
|
36
|
-
setTwoFactorOpen(true);
|
|
37
|
-
}
|
|
38
|
-
}, [twoFactorAuth]);
|
|
39
|
-
|
|
40
|
-
const handleDisableTwoFactorSuccess = useCallback(() => {
|
|
41
|
-
queryClient.invalidateQueries({ queryKey: USER_QUERY_KEY });
|
|
42
|
-
setDisableTwoFactorOpen(false);
|
|
43
|
-
}, [queryClient]);
|
|
44
|
-
|
|
45
|
-
const handleEnableTwoFactorSuccess = useCallback(() => {
|
|
46
|
-
queryClient.invalidateQueries({ queryKey: USER_QUERY_KEY });
|
|
47
|
-
setTwoFactorOpen(false);
|
|
48
|
-
}, [queryClient]);
|
|
49
|
-
|
|
50
|
-
const handleDeleteAccount = useCallback(() => {
|
|
51
|
-
onDeleteAccount?.();
|
|
52
|
-
}, [onDeleteAccount]);
|
|
53
|
-
|
|
54
18
|
return (
|
|
55
|
-
|
|
56
|
-
<
|
|
57
|
-
<span className="paragraph-medium-semibold text-gray-950 hidden lg:block">Segurança</span>
|
|
19
|
+
<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">
|
|
20
|
+
<span className="paragraph-medium-semibold text-gray-950 hidden lg:block">Segurança</span>
|
|
58
21
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
>
|
|
64
|
-
<div className="flex flex-1 items-start lg:items-center gap-4 lg:gap-5">
|
|
65
|
-
<div className="size-10 rounded-lg bg-gray-50 flex items-center justify-center shrink-0">
|
|
66
|
-
<IconTool size={20} className="text-gray-950" />
|
|
67
|
-
</div>
|
|
68
|
-
<div className="flex flex-col gap-1.5 flex-1">
|
|
69
|
-
<div className="flex flex-wrap items-center gap-2">
|
|
70
|
-
<span className="paragraph-small-semibold text-gray-950">
|
|
71
|
-
Autenticação de dois fatores
|
|
72
|
-
</span>
|
|
73
|
-
<Badge
|
|
74
|
-
className={`paragraph-xsmall-semibold rounded-lg ${twoFactorAuth ? 'text-green-600 bg-green-50' : 'text-gray-600 bg-gray-50'}`}
|
|
75
|
-
>
|
|
76
|
-
{twoFactorAuth ? 'Habilitado' : 'Desabilitado'}
|
|
77
|
-
</Badge>
|
|
78
|
-
</div>
|
|
79
|
-
<span className="paragraph-small-regular text-gray-600">
|
|
80
|
-
Envio de código de segurança (e-mail ou sms) para o usuário acessar o sistema
|
|
81
|
-
</span>
|
|
82
|
-
</div>
|
|
83
|
-
</div>
|
|
84
|
-
<Button
|
|
85
|
-
variant="secondary"
|
|
86
|
-
className="h-10! shrink-0 w-full lg:w-auto"
|
|
87
|
-
onClick={(e) => {
|
|
88
|
-
e.stopPropagation();
|
|
89
|
-
handleToggleTwoFactor();
|
|
90
|
-
}}
|
|
91
|
-
>
|
|
92
|
-
{twoFactorAuth ? 'Desabilitar' : 'Habilitar'}
|
|
93
|
-
</Button>
|
|
94
|
-
</div>
|
|
22
|
+
<div className="flex flex-col items-center lg:items-start gap-4">
|
|
23
|
+
<div className="size-10 rounded-full bg-red-50 flex items-center justify-center">
|
|
24
|
+
<IconAlertTriangle size={20} className="text-red-500" />
|
|
25
|
+
</div>
|
|
95
26
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
<div className="size-10 rounded-lg bg-gray-50 flex items-center justify-center shrink-0">
|
|
102
|
-
<IconLock size={20} className="text-gray-950" />
|
|
103
|
-
</div>
|
|
104
|
-
<div className="flex flex-col gap-1.5 flex-1">
|
|
105
|
-
<span className="paragraph-small-semibold text-gray-950">
|
|
106
|
-
Alterar senha de acesso
|
|
107
|
-
</span>
|
|
108
|
-
<span className="paragraph-small-regular text-gray-600">
|
|
109
|
-
Atualize sua senha sempre que necessário para manter sua conta segura.
|
|
110
|
-
</span>
|
|
111
|
-
</div>
|
|
112
|
-
</div>
|
|
113
|
-
<Button
|
|
114
|
-
variant="secondary"
|
|
115
|
-
className="h-10! shrink-0 w-full lg:w-auto"
|
|
116
|
-
onClick={(e) => {
|
|
117
|
-
e.stopPropagation();
|
|
118
|
-
setActiveSection(AccountSectionType.CHANGE_PASSWORD);
|
|
119
|
-
}}
|
|
120
|
-
>
|
|
121
|
-
Alterar senha
|
|
122
|
-
</Button>
|
|
123
|
-
</div>
|
|
27
|
+
<div className="flex flex-col gap-2">
|
|
28
|
+
<span className="paragraph-medium-semibold text-gray-950">Excluir conta</span>
|
|
29
|
+
<span className="paragraph-small-regular text-gray-600">
|
|
30
|
+
Esta ação é permanente e não pode ser desfeita. Todos os seus dados, projetos e configurações serão removidos definitivamente.
|
|
31
|
+
</span>
|
|
124
32
|
</div>
|
|
125
33
|
|
|
126
34
|
{onDeleteAccount && (
|
|
127
35
|
<button
|
|
128
36
|
type="button"
|
|
129
37
|
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"
|
|
130
|
-
onClick={
|
|
38
|
+
onClick={onDeleteAccount}
|
|
131
39
|
>
|
|
132
40
|
Excluir minha conta
|
|
133
41
|
</button>
|
|
134
42
|
)}
|
|
135
43
|
</div>
|
|
136
|
-
|
|
137
|
-
<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">
|
|
138
|
-
<Button variant="secondary" className="h-10!" type="button" onClick={onClose}>
|
|
139
|
-
Cancelar
|
|
140
|
-
</Button>
|
|
141
|
-
<Button className="h-10!" onClick={onClose}>
|
|
142
|
-
Salvar alterações
|
|
143
|
-
</Button>
|
|
144
|
-
</div>
|
|
145
|
-
|
|
146
|
-
<DisableTwoFactorAuthModal
|
|
147
|
-
open={disableTwoFactorOpen}
|
|
148
|
-
onClose={() => setDisableTwoFactorOpen(false)}
|
|
149
|
-
onSuccess={handleDisableTwoFactorSuccess}
|
|
150
|
-
/>
|
|
151
|
-
<TwoFactorAuthModal
|
|
152
|
-
open={twoFactorOpen}
|
|
153
|
-
onClose={() => setTwoFactorOpen(false)}
|
|
154
|
-
onSuccess={handleEnableTwoFactorSuccess}
|
|
155
|
-
/>
|
|
156
|
-
</>
|
|
44
|
+
</div>
|
|
157
45
|
);
|
|
158
46
|
}
|