@greatapps/common 1.1.38 → 1.1.40
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 +2 -2
- package/dist/components/account/ConfigurationsMyAccountModal.mjs.map +1 -1
- package/dist/components/account/sections/PreferencesSection.mjs +2 -3
- package/dist/components/account/sections/PreferencesSection.mjs.map +1 -1
- package/dist/components/modals/Modals.mjs +3 -3
- package/dist/components/modals/Modals.mjs.map +1 -1
- package/dist/components/ui/overlay/Dialog.mjs +1 -1
- package/dist/components/ui/overlay/Dialog.mjs.map +1 -1
- package/dist/components/ui/overlay/Sheet.mjs +1 -1
- package/dist/components/ui/overlay/Sheet.mjs.map +1 -1
- package/dist/store/useAccountModals.mjs.map +1 -1
- package/package.json +1 -1
- package/src/components/account/ConfigurationsMyAccountModal.tsx +2 -2
- package/src/components/account/sections/PreferencesSection.tsx +4 -3
- package/src/components/modals/Modals.tsx +5 -3
- package/src/components/ui/overlay/Dialog.tsx +1 -1
- package/src/components/ui/overlay/Sheet.tsx +1 -1
- package/src/store/useAccountModals.ts +2 -0
|
@@ -22,7 +22,7 @@ function ConfigurationsMyAccountModal() {
|
|
|
22
22
|
close
|
|
23
23
|
} = useAccountModals();
|
|
24
24
|
const open = activeModal === "configurations";
|
|
25
|
-
const { hasActiveSubscription, currencies = [] } = config;
|
|
25
|
+
const { hasActiveSubscription, currencies = [], timezones = [] } = config;
|
|
26
26
|
const isMobile = useIsMobile();
|
|
27
27
|
const { activeSection, setActiveSection } = useConfigurationsModal({
|
|
28
28
|
isOpen: open,
|
|
@@ -117,7 +117,7 @@ function ConfigurationsMyAccountModal() {
|
|
|
117
117
|
}
|
|
118
118
|
) }),
|
|
119
119
|
/* @__PURE__ */ jsx(TabsContent, { value: AccountSectionType.CHANGE_PASSWORD, className: "h-full! relative overflow-hidden", children: /* @__PURE__ */ jsx(ChangePasswordSection, { onBack: () => setActiveSection(AccountSectionType.SECURITY) }) }),
|
|
120
|
-
/* @__PURE__ */ jsx(TabsContent, { value: AccountSectionType.PREFERENCES, className: "h-full! relative overflow-hidden", children: /* @__PURE__ */ jsx(PreferencesSection, { onClose: close, currencies }) })
|
|
120
|
+
/* @__PURE__ */ jsx(TabsContent, { value: AccountSectionType.PREFERENCES, className: "h-full! relative overflow-hidden", children: /* @__PURE__ */ jsx(PreferencesSection, { onClose: close, currencies, timezones }) })
|
|
121
121
|
] })
|
|
122
122
|
]
|
|
123
123
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/account/ConfigurationsMyAccountModal.tsx"],"sourcesContent":["'use client';\r\n\r\nimport { Lock, Settings2, User, X } from 'lucide-react';\r\nimport { Dialog, DialogContent, DialogHeader, DialogTitle } from '../ui/overlay/Dialog';\r\nimport { Tabs, TabsList, TabsTrigger, TabsContent } from '../ui/data-display/Tabs';\r\nimport { Button } from '../ui/buttons/Button';\r\nimport { cn } from '../../infra/utils/clsx';\r\nimport { AccountSectionType } from '../../enums/AccountSectionType';\r\nimport { MyProfileSection } from './sections/MyProfileSection';\r\nimport { PreferencesSection } from './sections/PreferencesSection';\r\nimport { ChangePasswordSection } from './sections/ChangePasswordSection';\r\nimport { SecuritySection } from './sections/SecuritySection';\r\nimport useConfigurationsModal from './hooks/useConfigurationsModal';\r\nimport useIsMobile from '../../hooks/useIsMobile';\r\nimport { useAccountModals } from '../../store/useAccountModals';\r\n\r\nexport default function ConfigurationsMyAccountModal() {\r\n const {\r\n activeModal,\r\n config,\r\n initialSection,\r\n openDeleteAccount,\r\n openIsntPossibleDelete,\r\n close,\r\n } = useAccountModals();\r\n\r\n const open = activeModal === 'configurations';\r\n const { hasActiveSubscription, currencies = [] } = config;\r\n\r\n const isMobile = useIsMobile();\r\n const { activeSection, setActiveSection } = useConfigurationsModal({\r\n isOpen: open,\r\n initialSection,\r\n });\r\n\r\n const handleDeleteAccount = () => {\r\n close();\r\n if (hasActiveSubscription) {\r\n openIsntPossibleDelete();\r\n } else {\r\n openDeleteAccount();\r\n }\r\n };\r\n\r\n const tabTriggerClasses = cn(\r\n 'border-0! px-0 py-0',\r\n\r\n 'lg:rounded-md lg:flex lg:items-center lg:gap-2 lg:p-3 lg:justify-start lg:w-full',\r\n 'lg:bg-white lg:hover:bg-gray-100 lg:active:bg-gray-50 lg:border-0',\r\n 'lg:data-[state=active]:bg-gray-50',\r\n\r\n 'flex items-center gap-1.5 px-3 py-3 justify-center whitespace-nowrap',\r\n 'border-b-2 border-transparent',\r\n 'data-[state=active]:bg-gray-50 rounded-lg',\r\n\r\n 'text-gray-500 data-[state=active]:text-gray-950',\r\n 'hover:text-gray-900 transition-colors'\r\n );\r\n\r\n return (\r\n <Dialog open={open} onOpenChange={close}>\r\n <DialogContent\r\n showCloseButton={!isMobile}\r\n overlayClassName=\"bg-black/20 lg:bg-black/50\"\r\n className=\"\r\n flex flex-col p-0 gap-0 max-w-full! overflow-x-hidden border-0\r\n rounded-t-2xl rounded-b-none h-[100dvh] top-0! bottom-0! left-0! right-0! translate-x-0! translate-y-0!\r\n lg:flex-row lg:w-[892px]! lg:max-w-[892px]! lg:h-[626px]! lg:rounded-lg lg:border\r\n lg:top-[50%]! lg:bottom-auto! lg:left-[50%]! lg:right-auto! lg:translate-x-[-50%]! lg:translate-y-[-50%]!\"\r\n >\r\n <DialogHeader className=\"sr-only\">\r\n <DialogTitle>Configurações</DialogTitle>\r\n </DialogHeader>\r\n <div className=\"md:hidden flex items-center justify-between px-5 py-3 border-b border-gray-200\">\r\n <span className=\"text-gray-950 paragraph-medium-semibold\">Configurações</span>\r\n <button\r\n type=\"button\"\r\n className=\"size-8 flex items-center justify-center text-gray-500 cursor-pointer\"\r\n onClick={close}\r\n >\r\n <X size={18} />\r\n </button>\r\n </div>\r\n <Tabs\r\n value={activeSection}\r\n onValueChange={(value) => setActiveSection(value as AccountSectionType)}\r\n orientation=\"vertical\"\r\n className=\"flex lg:flex-row flex-col w-full h-full flex-1 lg:h-full lg:pt-0 lg:gap-0\"\r\n >\r\n <TabsList\r\n className={cn(\r\n 'flex gap-0 bg-transparent border-b-0',\r\n\r\n 'lg:flex-col lg:items-stretch lg:justify-start lg:w-auto lg:min-w-60',\r\n 'lg:border-r lg:border-gray-200 lg:pl-5 lg:pr-5 lg:pt-5 lg:gap-5 lg:overflow-x-visible lg:self-stretch',\r\n\r\n 'flex-row items-center justify-start w-full overflow-x-auto scrollbar-hide shrink-0',\r\n 'px-4 py-3',\r\n '[mask-image:linear-gradient(to_right,transparent,black_16px,black_calc(100%-24px),transparent)] lg:[mask-image:none]'\r\n )}\r\n >\r\n <span className=\"hidden lg:block paragraph-medium-semibold text-gray-950 mb-0\">\r\n Configurações\r\n </span>\r\n\r\n <div className=\"lg:flex lg:flex-col flex flex-row lg:gap-0 gap-0 lg:w-full\">\r\n <TabsTrigger value={AccountSectionType.MY_PROFILE} className={tabTriggerClasses}>\r\n <User size={20} className=\"shrink-0\" />\r\n <span className=\"paragraph-small-medium\">Meu perfil</span>\r\n </TabsTrigger>\r\n\r\n <TabsTrigger value={AccountSectionType.PREFERENCES} className={tabTriggerClasses}>\r\n <Settings2 size={20} className=\"shrink-0\" />\r\n <span className=\"paragraph-small-medium\">Preferências</span>\r\n </TabsTrigger>\r\n\r\n <TabsTrigger value={AccountSectionType.SECURITY} className={tabTriggerClasses}>\r\n <Lock size={20} className=\"shrink-0\" />\r\n <span className=\"paragraph-small-medium\">Segurança</span>\r\n </TabsTrigger>\r\n </div>\r\n </TabsList>\r\n\r\n <div className=\"w-full flex-1 min-h-0 lg:h-full overflow-hidden lg:overflow-visible relative\">\r\n <TabsContent value={AccountSectionType.MY_PROFILE} className=\"h-full! relative overflow-hidden\">\r\n <MyProfileSection onClose={close} />\r\n </TabsContent>\r\n\r\n <TabsContent value={AccountSectionType.SECURITY} className=\"h-full! relative overflow-hidden\">\r\n <SecuritySection\r\n setActiveSection={setActiveSection}\r\n onClose={close}\r\n hasActiveSubscription={hasActiveSubscription}\r\n onDeleteAccount={handleDeleteAccount}\r\n />\r\n </TabsContent>\r\n\r\n <TabsContent value={AccountSectionType.CHANGE_PASSWORD} className=\"h-full! relative overflow-hidden\">\r\n <ChangePasswordSection onBack={() => setActiveSection(AccountSectionType.SECURITY)} />\r\n </TabsContent>\r\n\r\n <TabsContent value={AccountSectionType.PREFERENCES} className=\"h-full! relative overflow-hidden\">\r\n <PreferencesSection onClose={close} currencies={currencies} />\r\n </TabsContent>\r\n </div>\r\n </Tabs>\r\n </DialogContent>\r\n </Dialog>\r\n );\r\n}\r\n"],"mappings":";AAuEU,cAEF,YAFE;AArEV,SAAS,MAAM,WAAW,MAAM,SAAS;AACzC,SAAS,QAAQ,eAAe,cAAc,mBAAmB;AACjE,SAAS,MAAM,UAAU,aAAa,mBAAmB;AAEzD,SAAS,UAAU;AACnB,SAAS,0BAA0B;AACnC,SAAS,wBAAwB;AACjC,SAAS,0BAA0B;AACnC,SAAS,6BAA6B;AACtC,SAAS,uBAAuB;AAChC,OAAO,4BAA4B;AACnC,OAAO,iBAAiB;AACxB,SAAS,wBAAwB;AAElB,SAAR,+BAAgD;AACrD,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI,iBAAiB;AAErB,QAAM,OAAO,gBAAgB;AAC7B,QAAM,EAAE,uBAAuB,aAAa,CAAC,EAAE,IAAI;
|
|
1
|
+
{"version":3,"sources":["../../../src/components/account/ConfigurationsMyAccountModal.tsx"],"sourcesContent":["'use client';\r\n\r\nimport { Lock, Settings2, User, X } from 'lucide-react';\r\nimport { Dialog, DialogContent, DialogHeader, DialogTitle } from '../ui/overlay/Dialog';\r\nimport { Tabs, TabsList, TabsTrigger, TabsContent } from '../ui/data-display/Tabs';\r\nimport { Button } from '../ui/buttons/Button';\r\nimport { cn } from '../../infra/utils/clsx';\r\nimport { AccountSectionType } from '../../enums/AccountSectionType';\r\nimport { MyProfileSection } from './sections/MyProfileSection';\r\nimport { PreferencesSection } from './sections/PreferencesSection';\r\nimport { ChangePasswordSection } from './sections/ChangePasswordSection';\r\nimport { SecuritySection } from './sections/SecuritySection';\r\nimport useConfigurationsModal from './hooks/useConfigurationsModal';\r\nimport useIsMobile from '../../hooks/useIsMobile';\r\nimport { useAccountModals } from '../../store/useAccountModals';\r\n\r\nexport default function ConfigurationsMyAccountModal() {\r\n const {\r\n activeModal,\r\n config,\r\n initialSection,\r\n openDeleteAccount,\r\n openIsntPossibleDelete,\r\n close,\r\n } = useAccountModals();\r\n\r\n const open = activeModal === 'configurations';\r\n const { hasActiveSubscription, currencies = [], timezones = [] } = config;\r\n\r\n const isMobile = useIsMobile();\r\n const { activeSection, setActiveSection } = useConfigurationsModal({\r\n isOpen: open,\r\n initialSection,\r\n });\r\n\r\n const handleDeleteAccount = () => {\r\n close();\r\n if (hasActiveSubscription) {\r\n openIsntPossibleDelete();\r\n } else {\r\n openDeleteAccount();\r\n }\r\n };\r\n\r\n const tabTriggerClasses = cn(\r\n 'border-0! px-0 py-0',\r\n\r\n 'lg:rounded-md lg:flex lg:items-center lg:gap-2 lg:p-3 lg:justify-start lg:w-full',\r\n 'lg:bg-white lg:hover:bg-gray-100 lg:active:bg-gray-50 lg:border-0',\r\n 'lg:data-[state=active]:bg-gray-50',\r\n\r\n 'flex items-center gap-1.5 px-3 py-3 justify-center whitespace-nowrap',\r\n 'border-b-2 border-transparent',\r\n 'data-[state=active]:bg-gray-50 rounded-lg',\r\n\r\n 'text-gray-500 data-[state=active]:text-gray-950',\r\n 'hover:text-gray-900 transition-colors'\r\n );\r\n\r\n return (\r\n <Dialog open={open} onOpenChange={close}>\r\n <DialogContent\r\n showCloseButton={!isMobile}\r\n overlayClassName=\"bg-black/20 lg:bg-black/50\"\r\n className=\"\r\n flex flex-col p-0 gap-0 max-w-full! overflow-x-hidden border-0\r\n rounded-t-2xl rounded-b-none h-[100dvh] top-0! bottom-0! left-0! right-0! translate-x-0! translate-y-0!\r\n lg:flex-row lg:w-[892px]! lg:max-w-[892px]! lg:h-[626px]! lg:rounded-lg lg:border\r\n lg:top-[50%]! lg:bottom-auto! lg:left-[50%]! lg:right-auto! lg:translate-x-[-50%]! lg:translate-y-[-50%]!\"\r\n >\r\n <DialogHeader className=\"sr-only\">\r\n <DialogTitle>Configurações</DialogTitle>\r\n </DialogHeader>\r\n <div className=\"md:hidden flex items-center justify-between px-5 py-3 border-b border-gray-200\">\r\n <span className=\"text-gray-950 paragraph-medium-semibold\">Configurações</span>\r\n <button\r\n type=\"button\"\r\n className=\"size-8 flex items-center justify-center text-gray-500 cursor-pointer\"\r\n onClick={close}\r\n >\r\n <X size={18} />\r\n </button>\r\n </div>\r\n <Tabs\r\n value={activeSection}\r\n onValueChange={(value) => setActiveSection(value as AccountSectionType)}\r\n orientation=\"vertical\"\r\n className=\"flex lg:flex-row flex-col w-full h-full flex-1 lg:h-full lg:pt-0 lg:gap-0\"\r\n >\r\n <TabsList\r\n className={cn(\r\n 'flex gap-0 bg-transparent border-b-0',\r\n\r\n 'lg:flex-col lg:items-stretch lg:justify-start lg:w-auto lg:min-w-60',\r\n 'lg:border-r lg:border-gray-200 lg:pl-5 lg:pr-5 lg:pt-5 lg:gap-5 lg:overflow-x-visible lg:self-stretch',\r\n\r\n 'flex-row items-center justify-start w-full overflow-x-auto scrollbar-hide shrink-0',\r\n 'px-4 py-3',\r\n '[mask-image:linear-gradient(to_right,transparent,black_16px,black_calc(100%-24px),transparent)] lg:[mask-image:none]'\r\n )}\r\n >\r\n <span className=\"hidden lg:block paragraph-medium-semibold text-gray-950 mb-0\">\r\n Configurações\r\n </span>\r\n\r\n <div className=\"lg:flex lg:flex-col flex flex-row lg:gap-0 gap-0 lg:w-full\">\r\n <TabsTrigger value={AccountSectionType.MY_PROFILE} className={tabTriggerClasses}>\r\n <User size={20} className=\"shrink-0\" />\r\n <span className=\"paragraph-small-medium\">Meu perfil</span>\r\n </TabsTrigger>\r\n\r\n <TabsTrigger value={AccountSectionType.PREFERENCES} className={tabTriggerClasses}>\r\n <Settings2 size={20} className=\"shrink-0\" />\r\n <span className=\"paragraph-small-medium\">Preferências</span>\r\n </TabsTrigger>\r\n\r\n <TabsTrigger value={AccountSectionType.SECURITY} className={tabTriggerClasses}>\r\n <Lock size={20} className=\"shrink-0\" />\r\n <span className=\"paragraph-small-medium\">Segurança</span>\r\n </TabsTrigger>\r\n </div>\r\n </TabsList>\r\n\r\n <div className=\"w-full flex-1 min-h-0 lg:h-full overflow-hidden lg:overflow-visible relative\">\r\n <TabsContent value={AccountSectionType.MY_PROFILE} className=\"h-full! relative overflow-hidden\">\r\n <MyProfileSection onClose={close} />\r\n </TabsContent>\r\n\r\n <TabsContent value={AccountSectionType.SECURITY} className=\"h-full! relative overflow-hidden\">\r\n <SecuritySection\r\n setActiveSection={setActiveSection}\r\n onClose={close}\r\n hasActiveSubscription={hasActiveSubscription}\r\n onDeleteAccount={handleDeleteAccount}\r\n />\r\n </TabsContent>\r\n\r\n <TabsContent value={AccountSectionType.CHANGE_PASSWORD} className=\"h-full! relative overflow-hidden\">\r\n <ChangePasswordSection onBack={() => setActiveSection(AccountSectionType.SECURITY)} />\r\n </TabsContent>\r\n\r\n <TabsContent value={AccountSectionType.PREFERENCES} className=\"h-full! relative overflow-hidden\">\r\n <PreferencesSection onClose={close} currencies={currencies} timezones={timezones} />\r\n </TabsContent>\r\n </div>\r\n </Tabs>\r\n </DialogContent>\r\n </Dialog>\r\n );\r\n}\r\n"],"mappings":";AAuEU,cAEF,YAFE;AArEV,SAAS,MAAM,WAAW,MAAM,SAAS;AACzC,SAAS,QAAQ,eAAe,cAAc,mBAAmB;AACjE,SAAS,MAAM,UAAU,aAAa,mBAAmB;AAEzD,SAAS,UAAU;AACnB,SAAS,0BAA0B;AACnC,SAAS,wBAAwB;AACjC,SAAS,0BAA0B;AACnC,SAAS,6BAA6B;AACtC,SAAS,uBAAuB;AAChC,OAAO,4BAA4B;AACnC,OAAO,iBAAiB;AACxB,SAAS,wBAAwB;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QACF;AAAA;AAAA;AAAA,EACF,GACF;AAEJ;","names":[]}
|
|
@@ -19,11 +19,10 @@ import {
|
|
|
19
19
|
} from "../../../modules/accounts/hooks/useAccountManagement";
|
|
20
20
|
import {
|
|
21
21
|
LANGUAGE_OPTIONS,
|
|
22
|
-
TIMEZONE_OPTIONS,
|
|
23
22
|
TIME_FORMAT_OPTIONS,
|
|
24
23
|
NOTIFICATION_TYPES
|
|
25
24
|
} from "../constants";
|
|
26
|
-
function PreferencesSection({ onClose, currencies = [] }) {
|
|
25
|
+
function PreferencesSection({ onClose, currencies = [], timezones = [] }) {
|
|
27
26
|
const { user, account } = useAuth();
|
|
28
27
|
const canEditPreferences = user?.profile === UserProfile.owner || user?.profile === UserProfile.admin;
|
|
29
28
|
const updateAccountUser = useUpdateAccountUser();
|
|
@@ -151,7 +150,7 @@ function PreferencesSection({ onClose, currencies = [] }) {
|
|
|
151
150
|
placeholder: "Selecione o fuso hor\xE1rio",
|
|
152
151
|
searchPlaceholder: "Buscar fuso hor\xE1rio...",
|
|
153
152
|
containerClassName: "w-full",
|
|
154
|
-
options:
|
|
153
|
+
options: timezones,
|
|
155
154
|
value: watch("timezone"),
|
|
156
155
|
onChange: (value) => setValue("timezone", value, { shouldDirty: true }),
|
|
157
156
|
icon: !canEditPreferences ? /* @__PURE__ */ jsx(Lock, { className: "size-4 text-gray-400" }) : void 0,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/account/sections/PreferencesSection.tsx"],"sourcesContent":["'use client';\r\n\r\nimport { useState, useEffect } from 'react';\r\nimport { useForm } from 'react-hook-form';\r\nimport { toast } from 'sonner';\r\nimport { Lock, Mail, MessageCircle } from 'lucide-react';\r\nimport { Button } from '../../ui/buttons/Button';\r\nimport { Separator } from '../../ui/data-display/Separator';\r\nimport { Toast } from '../../ui/feedback/Toast';\r\nimport { ComboboxField, type ComboboxOption } from '../../ui/form/ComboboxField';\r\nimport { SelectField } from '../../ui/form/SelectField';\r\nimport SwitchOptionFieldWithIcon from '../../ui/form/SwitchOptionFieldWithIcon';\r\nimport ConfirmGlobalPreferencesModal from '../ConfirmGlobalPreferencesModal';\r\nimport { useAuth } from '../../../providers/auth.provider';\r\nimport { UserProfile } from '../../../modules/users/schema';\r\nimport type { UpdateAccountRequest } from '../../../modules/accounts/types';\r\nimport {\r\n useUpdateAccountUser,\r\n useUpdateAccount,\r\n} from '../../../modules/accounts/hooks/useAccountManagement';\r\nimport {\r\n LANGUAGE_OPTIONS,\r\n TIMEZONE_OPTIONS,\r\n TIME_FORMAT_OPTIONS,\r\n NOTIFICATION_TYPES,\r\n} from '../constants';\r\n\r\ninterface PreferencesFormValues {\r\n language: string;\r\n currency: string;\r\n timezone: string;\r\n timeFormat: string;\r\n receive_sms: boolean;\r\n receive_email: boolean;\r\n}\r\n\r\ninterface PreferencesSectionProps {\r\n onClose: () => void;\r\n currencies?: ComboboxOption[];\r\n}\r\n\r\nexport function PreferencesSection({ onClose, currencies = [] }: PreferencesSectionProps) {\r\n const { user, account } = useAuth();\r\n const canEditPreferences =\r\n user?.profile === UserProfile.owner || user?.profile === UserProfile.admin;\r\n const updateAccountUser = useUpdateAccountUser();\r\n const updateAccount = useUpdateAccount();\r\n const [confirmGlobalOpen, setConfirmGlobalOpen] = useState(false);\r\n const [pendingSubmit, setPendingSubmit] = useState<{\r\n data: PreferencesFormValues;\r\n accountFields: UpdateAccountRequest;\r\n } | null>(null);\r\n const [isSaving, setIsSaving] = useState(false);\r\n\r\n const { watch, setValue, handleSubmit, reset, formState: { dirtyFields } } =\r\n useForm<PreferencesFormValues>({\r\n defaultValues: {\r\n language: '',\r\n currency: '',\r\n timezone: '',\r\n timeFormat: '24h',\r\n receive_sms: false,\r\n receive_email: false,\r\n },\r\n });\r\n\r\n useEffect(() => {\r\n if (!user || !account) return;\r\n reset({\r\n language: LANGUAGE_OPTIONS.find(\r\n (o) => o.apiValue === user.language?.toLowerCase()\r\n )?.value ?? 'pt-BR',\r\n currency: account.currency,\r\n timezone: account.timezone,\r\n timeFormat: '24h',\r\n receive_sms: user.receive_sms ?? false,\r\n receive_email: user.receive_email ?? false,\r\n });\r\n }, [user, account, reset]);\r\n\r\n const receiveSms = watch('receive_sms');\r\n const receiveEmail = watch('receive_email');\r\n\r\n const doSave = async (data: PreferencesFormValues, accountFields: UpdateAccountRequest) => {\r\n setIsSaving(true);\r\n try {\r\n const apiLanguage = LANGUAGE_OPTIONS.find((o) => o.value === data.language)?.apiValue ?? data.language.toLowerCase();\r\n const userResult = await updateAccountUser.mutateAsync({\r\n language: apiLanguage,\r\n receive_sms: data.receive_sms,\r\n receive_email: data.receive_email,\r\n });\r\n\r\n if (!userResult.success) {\r\n toast.custom((t) => (\r\n <Toast variant=\"error\" message={userResult.error ?? 'Erro ao salvar preferências'} toastId={t} />\r\n ));\r\n return;\r\n }\r\n\r\n if (canEditPreferences && Object.keys(accountFields).length > 0) {\r\n const accountResult = await updateAccount.mutateAsync(accountFields);\r\n\r\n if (!accountResult.success) {\r\n toast.custom((t) => (\r\n <Toast variant=\"error\" message={accountResult.error ?? 'Erro ao salvar preferências da conta'} toastId={t} />\r\n ));\r\n return;\r\n }\r\n }\r\n\r\n reset(data);\r\n toast.custom((t) => (\r\n <Toast variant=\"success\" message=\"Preferências salvas com sucesso\" toastId={t} />\r\n ));\r\n onClose();\r\n } finally {\r\n setIsSaving(false);\r\n }\r\n };\r\n\r\n const onSubmit = (data: PreferencesFormValues) => {\r\n const accountFields: UpdateAccountRequest = {\r\n ...(canEditPreferences && dirtyFields.currency && { currency: data.currency }),\r\n ...(canEditPreferences && dirtyFields.timezone && { timezone: data.timezone }),\r\n };\r\n const globalFieldChanged = Object.keys(accountFields).length > 0;\r\n\r\n if (globalFieldChanged) {\r\n setPendingSubmit({ data, accountFields });\r\n setConfirmGlobalOpen(true);\r\n } else {\r\n doSave(data, accountFields);\r\n }\r\n };\r\n\r\n const handleConfirmGlobal = () => {\r\n setConfirmGlobalOpen(false);\r\n if (pendingSubmit) {\r\n doSave(pendingSubmit.data, pendingSubmit.accountFields);\r\n setPendingSubmit(null);\r\n }\r\n };\r\n\r\n const handleCancelGlobal = () => {\r\n setConfirmGlobalOpen(false);\r\n setPendingSubmit(null);\r\n };\r\n\r\n return (\r\n <>\r\n <form onSubmit={handleSubmit(onSubmit)} className=\"lg:h-full lg:flex lg:flex-col\">\r\n <div className=\"absolute inset-0 overflow-y-auto overscroll-contain px-4 pb-36 lg:p-5 lg:static lg:flex-1 lg:min-h-0 lg:overscroll-auto flex flex-col gap-5 lg:gap-6\">\r\n <span className=\"paragraph-medium-semibold text-gray-950\">Preferências</span>\r\n <div className=\"flex flex-col gap-8\">\r\n <div className=\"flex flex-col lg:flex-row items-center gap-3\">\r\n <ComboboxField\r\n label=\"Idioma\"\r\n placeholder=\"Selecione o idioma\"\r\n searchPlaceholder=\"Buscar idioma...\"\r\n containerClassName=\"w-full\"\r\n options={LANGUAGE_OPTIONS}\r\n value={watch('language')}\r\n onChange={(value) => setValue('language', value, { shouldDirty: true })}\r\n />\r\n <ComboboxField\r\n label=\"Moeda\"\r\n placeholder=\"Selecione a moeda\"\r\n searchPlaceholder=\"Buscar moeda...\"\r\n containerClassName=\"w-full\"\r\n options={currencies}\r\n value={watch('currency')}\r\n onChange={(value) => setValue('currency', value, { shouldDirty: true })}\r\n icon={!canEditPreferences ? <Lock className=\"size-4 text-gray-400\" /> : undefined}\r\n disabled={!canEditPreferences}\r\n />\r\n </div>\r\n\r\n <Separator />\r\n\r\n <div className=\"flex flex-col gap-4\">\r\n <span className=\"paragraph-medium-semibold text-gray-600\">Exibição hora</span>\r\n <div className=\"flex flex-col lg:flex-row items-center gap-3\">\r\n <ComboboxField\r\n label=\"Fuso horário\"\r\n placeholder=\"Selecione o fuso horário\"\r\n searchPlaceholder=\"Buscar fuso horário...\"\r\n containerClassName=\"w-full\"\r\n options={TIMEZONE_OPTIONS}\r\n value={watch('timezone')}\r\n onChange={(value) => setValue('timezone', value, { shouldDirty: true })}\r\n icon={!canEditPreferences ? <Lock className=\"size-4 text-gray-400\" /> : undefined}\r\n disabled={!canEditPreferences}\r\n />\r\n <SelectField\r\n label=\"Formato hora\"\r\n placeholder=\"Selecione o formato\"\r\n className=\"h-10!\"\r\n containerClassName=\"w-full\"\r\n options={TIME_FORMAT_OPTIONS}\r\n value={watch('timeFormat')}\r\n onChange={(value) =>\r\n setValue('timeFormat', value as string, { shouldDirty: true })\r\n }\r\n icon={<Lock className=\"size-4 text-gray-400\" />}\r\n disabled\r\n />\r\n </div>\r\n </div>\r\n\r\n <Separator />\r\n\r\n <div className=\"flex flex-col gap-4\">\r\n <span className=\"paragraph-medium-semibold text-gray-600\">Notificações</span>\r\n <div className=\"flex flex-col gap-3\">\r\n <div className=\"flex flex-col border border-gray-200 rounded-lg\">\r\n <SwitchOptionFieldWithIcon\r\n icon={MessageCircle}\r\n label=\"WhatsApp\"\r\n description=\"Receber notificações importantes por WhatsApp\"\r\n checked={receiveSms}\r\n onCheckedChange={(val: boolean) => setValue('receive_sms', val, { shouldDirty: true })}\r\n />\r\n <SwitchOptionFieldWithIcon\r\n icon={Mail}\r\n label=\"E-mail\"\r\n description=\"Receber notificações e atualizações por email\"\r\n checked={receiveEmail}\r\n onCheckedChange={(val: boolean) => setValue('receive_email', val, { shouldDirty: true })}\r\n hideBorderBottom={true}\r\n />\r\n </div>\r\n <div className=\"flex flex-col gap-4 p-5 pb-6 rounded-lg bg-gray-50\">\r\n <span className=\"paragraph-small-semibold text-gray-950\">\r\n Tipos de notificações incluem:\r\n </span>\r\n <div className=\"flex flex-col\">\r\n {NOTIFICATION_TYPES.map((type) => (\r\n <div key={type} className=\"flex items-center gap-2\">\r\n <div className=\"size-1 rounded-full bg-gray-600\" />\r\n <span className=\"paragraph-small-medium text-gray-600\">{type}</span>\r\n </div>\r\n ))}\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n\r\n <div className=\"fixed bottom-0 left-0 right-0 lg:static flex items-center h-20 px-4 lg:px-5 border-t border-gray-200 justify-between bg-white z-10\">\r\n <Button\r\n variant=\"secondary\"\r\n className=\"h-10!\"\r\n type=\"button\"\r\n disabled={isSaving}\r\n onClick={() => {\r\n reset();\r\n onClose();\r\n }}\r\n >\r\n Cancelar\r\n </Button>\r\n <Button className=\"h-10!\" type=\"submit\" disabled={isSaving}>\r\n {isSaving ? 'Salvando...' : 'Salvar alterações'}\r\n </Button>\r\n </div>\r\n </form>\r\n\r\n <ConfirmGlobalPreferencesModal\r\n open={confirmGlobalOpen}\r\n onConfirm={handleConfirmGlobal}\r\n onCancel={handleCancelGlobal}\r\n />\r\n </>\r\n );\r\n}\r\n"],"mappings":";AA+FU,SAuDN,UAvDM,KA4DE,YA5DF;AA7FV,SAAS,UAAU,iBAAiB;AACpC,SAAS,eAAe;AACxB,SAAS,aAAa;AACtB,SAAS,MAAM,MAAM,qBAAqB;AAC1C,SAAS,cAAc;AACvB,SAAS,iBAAiB;AAC1B,SAAS,aAAa;AACtB,SAAS,qBAA0C;AACnD,SAAS,mBAAmB;AAC5B,OAAO,+BAA+B;AACtC,OAAO,mCAAmC;AAC1C,SAAS,eAAe;AACxB,SAAS,mBAAmB;AAE5B;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAgBA,SAAS,mBAAmB,EAAE,SAAS,aAAa,CAAC,EAAE,GAA4B;AACxF,QAAM,EAAE,MAAM,QAAQ,IAAI,QAAQ;AAClC,QAAM,qBACJ,MAAM,YAAY,YAAY,SAAS,MAAM,YAAY,YAAY;AACvE,QAAM,oBAAoB,qBAAqB;AAC/C,QAAM,gBAAgB,iBAAiB;AACvC,QAAM,CAAC,mBAAmB,oBAAoB,IAAI,SAAS,KAAK;AAChE,QAAM,CAAC,eAAe,gBAAgB,IAAI,SAGhC,IAAI;AACd,QAAM,CAAC,UAAU,WAAW,IAAI,SAAS,KAAK;AAE9C,QAAM,EAAE,OAAO,U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,UAAO,WAAU,SAAQ,MAAK,UAAS,UAAU,UAC/C,qBAAW,gBAAgB,2BAC9B;AAAA,SACF;AAAA,OACF;AAAA,IAEA;AAAA,MAAC;AAAA;AAAA,QACC,MAAM;AAAA,QACN,WAAW;AAAA,QACX,UAAU;AAAA;AAAA,IACZ;AAAA,KACF;AAEJ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/account/sections/PreferencesSection.tsx"],"sourcesContent":["'use client';\r\n\r\nimport { useState, useEffect } from 'react';\r\nimport { useForm } from 'react-hook-form';\r\nimport { toast } from 'sonner';\r\nimport { Lock, Mail, MessageCircle } from 'lucide-react';\r\nimport { Button } from '../../ui/buttons/Button';\r\nimport { Separator } from '../../ui/data-display/Separator';\r\nimport { Toast } from '../../ui/feedback/Toast';\r\nimport { ComboboxField, type ComboboxOption } from '../../ui/form/ComboboxField';\r\nimport { SelectField } from '../../ui/form/SelectField';\r\nimport SwitchOptionFieldWithIcon from '../../ui/form/SwitchOptionFieldWithIcon';\r\nimport ConfirmGlobalPreferencesModal from '../ConfirmGlobalPreferencesModal';\r\nimport { useAuth } from '../../../providers/auth.provider';\r\nimport { UserProfile } from '../../../modules/users/schema';\r\nimport type { UpdateAccountRequest } from '../../../modules/accounts/types';\r\nimport {\r\n useUpdateAccountUser,\r\n useUpdateAccount,\r\n} from '../../../modules/accounts/hooks/useAccountManagement';\r\nimport {\r\n LANGUAGE_OPTIONS,\r\n TIME_FORMAT_OPTIONS,\r\n NOTIFICATION_TYPES,\r\n} from '../constants';\r\nimport type { TimezoneOption } from '../../../utils/intl/timezones';\r\n\r\ninterface PreferencesFormValues {\r\n language: string;\r\n currency: string;\r\n timezone: string;\r\n timeFormat: string;\r\n receive_sms: boolean;\r\n receive_email: boolean;\r\n}\r\n\r\ninterface PreferencesSectionProps {\r\n onClose: () => void;\r\n currencies?: ComboboxOption[];\r\n timezones?: TimezoneOption[];\r\n}\r\n\r\nexport function PreferencesSection({ onClose, currencies = [], timezones = [] }: PreferencesSectionProps) {\r\n const { user, account } = useAuth();\r\n const canEditPreferences =\r\n user?.profile === UserProfile.owner || user?.profile === UserProfile.admin;\r\n const updateAccountUser = useUpdateAccountUser();\r\n const updateAccount = useUpdateAccount();\r\n const [confirmGlobalOpen, setConfirmGlobalOpen] = useState(false);\r\n const [pendingSubmit, setPendingSubmit] = useState<{\r\n data: PreferencesFormValues;\r\n accountFields: UpdateAccountRequest;\r\n } | null>(null);\r\n const [isSaving, setIsSaving] = useState(false);\r\n\r\n const { watch, setValue, handleSubmit, reset, formState: { dirtyFields } } =\r\n useForm<PreferencesFormValues>({\r\n defaultValues: {\r\n language: '',\r\n currency: '',\r\n timezone: '',\r\n timeFormat: '24h',\r\n receive_sms: false,\r\n receive_email: false,\r\n },\r\n });\r\n\r\n useEffect(() => {\r\n if (!user || !account) return;\r\n reset({\r\n language: LANGUAGE_OPTIONS.find(\r\n (o) => o.apiValue === user.language?.toLowerCase()\r\n )?.value ?? 'pt-BR',\r\n currency: account.currency,\r\n timezone: account.timezone,\r\n timeFormat: '24h',\r\n receive_sms: user.receive_sms ?? false,\r\n receive_email: user.receive_email ?? false,\r\n });\r\n }, [user, account, reset]);\r\n\r\n const receiveSms = watch('receive_sms');\r\n const receiveEmail = watch('receive_email');\r\n\r\n const doSave = async (data: PreferencesFormValues, accountFields: UpdateAccountRequest) => {\r\n setIsSaving(true);\r\n try {\r\n const apiLanguage = LANGUAGE_OPTIONS.find((o) => o.value === data.language)?.apiValue ?? data.language.toLowerCase();\r\n const userResult = await updateAccountUser.mutateAsync({\r\n language: apiLanguage,\r\n receive_sms: data.receive_sms,\r\n receive_email: data.receive_email,\r\n });\r\n\r\n if (!userResult.success) {\r\n toast.custom((t) => (\r\n <Toast variant=\"error\" message={userResult.error ?? 'Erro ao salvar preferências'} toastId={t} />\r\n ));\r\n return;\r\n }\r\n\r\n if (canEditPreferences && Object.keys(accountFields).length > 0) {\r\n const accountResult = await updateAccount.mutateAsync(accountFields);\r\n\r\n if (!accountResult.success) {\r\n toast.custom((t) => (\r\n <Toast variant=\"error\" message={accountResult.error ?? 'Erro ao salvar preferências da conta'} toastId={t} />\r\n ));\r\n return;\r\n }\r\n }\r\n\r\n reset(data);\r\n toast.custom((t) => (\r\n <Toast variant=\"success\" message=\"Preferências salvas com sucesso\" toastId={t} />\r\n ));\r\n onClose();\r\n } finally {\r\n setIsSaving(false);\r\n }\r\n };\r\n\r\n const onSubmit = (data: PreferencesFormValues) => {\r\n const accountFields: UpdateAccountRequest = {\r\n ...(canEditPreferences && dirtyFields.currency && { currency: data.currency }),\r\n ...(canEditPreferences && dirtyFields.timezone && { timezone: data.timezone }),\r\n };\r\n const globalFieldChanged = Object.keys(accountFields).length > 0;\r\n\r\n if (globalFieldChanged) {\r\n setPendingSubmit({ data, accountFields });\r\n setConfirmGlobalOpen(true);\r\n } else {\r\n doSave(data, accountFields);\r\n }\r\n };\r\n\r\n const handleConfirmGlobal = () => {\r\n setConfirmGlobalOpen(false);\r\n if (pendingSubmit) {\r\n doSave(pendingSubmit.data, pendingSubmit.accountFields);\r\n setPendingSubmit(null);\r\n }\r\n };\r\n\r\n const handleCancelGlobal = () => {\r\n setConfirmGlobalOpen(false);\r\n setPendingSubmit(null);\r\n };\r\n\r\n return (\r\n <>\r\n <form onSubmit={handleSubmit(onSubmit)} className=\"lg:h-full lg:flex lg:flex-col\">\r\n <div className=\"absolute inset-0 overflow-y-auto overscroll-contain px-4 pb-36 lg:p-5 lg:static lg:flex-1 lg:min-h-0 lg:overscroll-auto flex flex-col gap-5 lg:gap-6\">\r\n <span className=\"paragraph-medium-semibold text-gray-950\">Preferências</span>\r\n <div className=\"flex flex-col gap-8\">\r\n <div className=\"flex flex-col lg:flex-row items-center gap-3\">\r\n <ComboboxField\r\n label=\"Idioma\"\r\n placeholder=\"Selecione o idioma\"\r\n searchPlaceholder=\"Buscar idioma...\"\r\n containerClassName=\"w-full\"\r\n options={LANGUAGE_OPTIONS}\r\n value={watch('language')}\r\n onChange={(value) => setValue('language', value, { shouldDirty: true })}\r\n />\r\n <ComboboxField\r\n label=\"Moeda\"\r\n placeholder=\"Selecione a moeda\"\r\n searchPlaceholder=\"Buscar moeda...\"\r\n containerClassName=\"w-full\"\r\n options={currencies}\r\n value={watch('currency')}\r\n onChange={(value) => setValue('currency', value, { shouldDirty: true })}\r\n icon={!canEditPreferences ? <Lock className=\"size-4 text-gray-400\" /> : undefined}\r\n disabled={!canEditPreferences}\r\n />\r\n </div>\r\n\r\n <Separator />\r\n\r\n <div className=\"flex flex-col gap-4\">\r\n <span className=\"paragraph-medium-semibold text-gray-600\">Exibição hora</span>\r\n <div className=\"flex flex-col lg:flex-row items-center gap-3\">\r\n <ComboboxField\r\n label=\"Fuso horário\"\r\n placeholder=\"Selecione o fuso horário\"\r\n searchPlaceholder=\"Buscar fuso horário...\"\r\n containerClassName=\"w-full\"\r\n options={timezones}\r\n value={watch('timezone')}\r\n onChange={(value) => setValue('timezone', value, { shouldDirty: true })}\r\n icon={!canEditPreferences ? <Lock className=\"size-4 text-gray-400\" /> : undefined}\r\n disabled={!canEditPreferences}\r\n />\r\n <SelectField\r\n label=\"Formato hora\"\r\n placeholder=\"Selecione o formato\"\r\n className=\"h-10!\"\r\n containerClassName=\"w-full\"\r\n options={TIME_FORMAT_OPTIONS}\r\n value={watch('timeFormat')}\r\n onChange={(value) =>\r\n setValue('timeFormat', value as string, { shouldDirty: true })\r\n }\r\n icon={<Lock className=\"size-4 text-gray-400\" />}\r\n disabled\r\n />\r\n </div>\r\n </div>\r\n\r\n <Separator />\r\n\r\n <div className=\"flex flex-col gap-4\">\r\n <span className=\"paragraph-medium-semibold text-gray-600\">Notificações</span>\r\n <div className=\"flex flex-col gap-3\">\r\n <div className=\"flex flex-col border border-gray-200 rounded-lg\">\r\n <SwitchOptionFieldWithIcon\r\n icon={MessageCircle}\r\n label=\"WhatsApp\"\r\n description=\"Receber notificações importantes por WhatsApp\"\r\n checked={receiveSms}\r\n onCheckedChange={(val: boolean) => setValue('receive_sms', val, { shouldDirty: true })}\r\n />\r\n <SwitchOptionFieldWithIcon\r\n icon={Mail}\r\n label=\"E-mail\"\r\n description=\"Receber notificações e atualizações por email\"\r\n checked={receiveEmail}\r\n onCheckedChange={(val: boolean) => setValue('receive_email', val, { shouldDirty: true })}\r\n hideBorderBottom={true}\r\n />\r\n </div>\r\n <div className=\"flex flex-col gap-4 p-5 pb-6 rounded-lg bg-gray-50\">\r\n <span className=\"paragraph-small-semibold text-gray-950\">\r\n Tipos de notificações incluem:\r\n </span>\r\n <div className=\"flex flex-col\">\r\n {NOTIFICATION_TYPES.map((type) => (\r\n <div key={type} className=\"flex items-center gap-2\">\r\n <div className=\"size-1 rounded-full bg-gray-600\" />\r\n <span className=\"paragraph-small-medium text-gray-600\">{type}</span>\r\n </div>\r\n ))}\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n\r\n <div className=\"fixed bottom-0 left-0 right-0 lg:static flex items-center h-20 px-4 lg:px-5 border-t border-gray-200 justify-between bg-white z-10\">\r\n <Button\r\n variant=\"secondary\"\r\n className=\"h-10!\"\r\n type=\"button\"\r\n disabled={isSaving}\r\n onClick={() => {\r\n reset();\r\n onClose();\r\n }}\r\n >\r\n Cancelar\r\n </Button>\r\n <Button className=\"h-10!\" type=\"submit\" disabled={isSaving}>\r\n {isSaving ? 'Salvando...' : 'Salvar alterações'}\r\n </Button>\r\n </div>\r\n </form>\r\n\r\n <ConfirmGlobalPreferencesModal\r\n open={confirmGlobalOpen}\r\n onConfirm={handleConfirmGlobal}\r\n onCancel={handleCancelGlobal}\r\n />\r\n </>\r\n );\r\n}\r\n"],"mappings":";AAgGU,SAuDN,UAvDM,KA4DE,YA5DF;AA9FV,SAAS,UAAU,iBAAiB;AACpC,SAAS,eAAe;AACxB,SAAS,aAAa;AACtB,SAAS,MAAM,MAAM,qBAAqB;AAC1C,SAAS,cAAc;AACvB,SAAS,iBAAiB;AAC1B,SAAS,aAAa;AACtB,SAAS,qBAA0C;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kBAAkB;AAAA;AAAA,gBACpB;AAAA,iBACF;AAAA,cACA,qBAAC,SAAI,WAAU,sDACb;AAAA,oCAAC,UAAK,WAAU,0CAAyC,kDAEzD;AAAA,gBACA,oBAAC,SAAI,WAAU,iBACZ,6BAAmB,IAAI,CAAC,SACvB,qBAAC,SAAe,WAAU,2BACxB;AAAA,sCAAC,SAAI,WAAU,mCAAkC;AAAA,kBACjD,oBAAC,UAAK,WAAU,wCAAwC,gBAAK;AAAA,qBAFrD,IAGV,CACD,GACH;AAAA,iBACF;AAAA,eACF;AAAA,aACF;AAAA,WACF;AAAA,SACF;AAAA,MAEA,qBAAC,SAAI,WAAU,sIACb;AAAA;AAAA,UAAC;AAAA;AAAA,YACC,SAAQ;AAAA,YACR,WAAU;AAAA,YACV,MAAK;AAAA,YACL,UAAU;AAAA,YACV,SAAS,MAAM;AACb,oBAAM;AACN,sBAAQ;AAAA,YACV;AAAA,YACD;AAAA;AAAA,QAED;AAAA,QACA,oBAAC,UAAO,WAAU,SAAQ,MAAK,UAAS,UAAU,UAC/C,qBAAW,gBAAgB,2BAC9B;AAAA,SACF;AAAA,OACF;AAAA,IAEA;AAAA,MAAC;AAAA;AAAA,QACC,MAAM;AAAA,QACN,WAAW;AAAA,QACX,UAAU;AAAA;AAAA,IACZ;AAAA,KACF;AAEJ;","names":[]}
|
|
@@ -4,11 +4,11 @@ import { useEffect } from "react";
|
|
|
4
4
|
import AccountModals from "../account/AccountModals";
|
|
5
5
|
import { ModalManager } from "./ModalManager";
|
|
6
6
|
import { useAccountModals } from "../../store/useAccountModals";
|
|
7
|
-
function Modals({ registry, hasActiveSubscription, currencies, onGoToSubscription }) {
|
|
7
|
+
function Modals({ registry, hasActiveSubscription, currencies, timezones, onGoToSubscription }) {
|
|
8
8
|
const { updateConfig } = useAccountModals();
|
|
9
9
|
useEffect(() => {
|
|
10
|
-
updateConfig({ hasActiveSubscription, currencies, onGoToSubscription });
|
|
11
|
-
}, [hasActiveSubscription, currencies, onGoToSubscription, updateConfig]);
|
|
10
|
+
updateConfig({ hasActiveSubscription, currencies, timezones, onGoToSubscription });
|
|
11
|
+
}, [hasActiveSubscription, currencies, timezones, onGoToSubscription, updateConfig]);
|
|
12
12
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
13
13
|
/* @__PURE__ */ jsx(AccountModals, {}),
|
|
14
14
|
/* @__PURE__ */ jsx(ModalManager, { registry })
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/modals/Modals.tsx"],"sourcesContent":["'use client';\n\nimport { ComponentType, useEffect } from 'react';\nimport AccountModals from '../account/AccountModals';\nimport { ModalManager } from './ModalManager';\nimport { useAccountModals } from '../../store/useAccountModals';\nimport type { ComboboxOption } from '../ui/form/ComboboxField';\n\ninterface ModalsProps {\n registry: Record<string, ComponentType>;\n hasActiveSubscription?: boolean;\n currencies?: ComboboxOption[];\n onGoToSubscription?: () => void;\n}\n\nexport function Modals({ registry, hasActiveSubscription, currencies, onGoToSubscription }: ModalsProps) {\n const { updateConfig } = useAccountModals();\n\n useEffect(() => {\n updateConfig({ hasActiveSubscription, currencies, onGoToSubscription });\n }, [hasActiveSubscription, currencies, onGoToSubscription, updateConfig]);\n\n return (\n <>\n <AccountModals />\n <ModalManager registry={registry} />\n </>\n );\n}\n"],"mappings":";
|
|
1
|
+
{"version":3,"sources":["../../../src/components/modals/Modals.tsx"],"sourcesContent":["'use client';\n\nimport { ComponentType, useEffect } from 'react';\nimport AccountModals from '../account/AccountModals';\nimport { ModalManager } from './ModalManager';\nimport { useAccountModals } from '../../store/useAccountModals';\nimport type { ComboboxOption } from '../ui/form/ComboboxField';\nimport type { TimezoneOption } from '../../utils/intl/timezones';\n\ninterface ModalsProps {\n registry: Record<string, ComponentType>;\n hasActiveSubscription?: boolean;\n currencies?: ComboboxOption[];\n timezones?: TimezoneOption[];\n onGoToSubscription?: () => void;\n}\n\nexport function Modals({ registry, hasActiveSubscription, currencies, timezones, onGoToSubscription }: ModalsProps) {\n const { updateConfig } = useAccountModals();\n\n useEffect(() => {\n updateConfig({ hasActiveSubscription, currencies, timezones, onGoToSubscription });\n }, [hasActiveSubscription, currencies, timezones, onGoToSubscription, updateConfig]);\n\n return (\n <>\n <AccountModals />\n <ModalManager registry={registry} />\n </>\n );\n}\n"],"mappings":";AAyBI,mBACE,KADF;AAvBJ,SAAwB,iBAAiB;AACzC,OAAO,mBAAmB;AAC1B,SAAS,oBAAoB;AAC7B,SAAS,wBAAwB;AAY1B,SAAS,OAAO,EAAE,UAAU,uBAAuB,YAAY,WAAW,mBAAmB,GAAgB;AAClH,QAAM,EAAE,aAAa,IAAI,iBAAiB;AAE1C,YAAU,MAAM;AACd,iBAAa,EAAE,uBAAuB,YAAY,WAAW,mBAAmB,CAAC;AAAA,EACnF,GAAG,CAAC,uBAAuB,YAAY,WAAW,oBAAoB,YAAY,CAAC;AAEnF,SACE,iCACE;AAAA,wBAAC,iBAAc;AAAA,IACf,oBAAC,gBAAa,UAAoB;AAAA,KACpC;AAEJ;","names":[]}
|
|
@@ -53,7 +53,7 @@ function DialogContent({
|
|
|
53
53
|
{
|
|
54
54
|
"data-slot": "dialog-content",
|
|
55
55
|
className: cn(
|
|
56
|
-
"bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-[
|
|
56
|
+
"bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-[1001] grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",
|
|
57
57
|
className
|
|
58
58
|
),
|
|
59
59
|
...props,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/ui/overlay/Dialog.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport * as DialogPrimitive from \"@radix-ui/react-dialog\";\nimport { XIcon } from \"lucide-react\";\nimport { cn } from \"../../../infra/utils/clsx\";\n\nfunction Dialog({\n ...props\n}: React.ComponentProps<typeof DialogPrimitive.Root>) {\n return <DialogPrimitive.Root data-slot=\"dialog\" {...props} />;\n}\n\nfunction DialogTrigger({\n ...props\n}: React.ComponentProps<typeof DialogPrimitive.Trigger>) {\n return <DialogPrimitive.Trigger data-slot=\"dialog-trigger\" {...props} />;\n}\n\nfunction DialogPortal({\n ...props\n}: React.ComponentProps<typeof DialogPrimitive.Portal>) {\n return <DialogPrimitive.Portal data-slot=\"dialog-portal\" {...props} />;\n}\n\nfunction DialogClose({\n ...props\n}: React.ComponentProps<typeof DialogPrimitive.Close>) {\n return <DialogPrimitive.Close data-slot=\"dialog-close\" {...props} />;\n}\n\nfunction DialogOverlay({\n className,\n ...props\n}: React.ComponentProps<typeof DialogPrimitive.Overlay>) {\n return (\n <DialogPrimitive.Overlay\n data-slot=\"dialog-overlay\"\n className={cn(\n \"data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-[1000] bg-black/50\",\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction DialogContent({\n className,\n children,\n showCloseButton = true,\n overlayClassName,\n ...props\n}: React.ComponentProps<typeof DialogPrimitive.Content> & {\n showCloseButton?: boolean;\n overlayClassName?: string;\n}) {\n return (\n <DialogPortal data-slot=\"dialog-portal\">\n <DialogOverlay className={overlayClassName} />\n <DialogPrimitive.Content\n data-slot=\"dialog-content\"\n className={cn(\n \"bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-[
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/ui/overlay/Dialog.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport * as DialogPrimitive from \"@radix-ui/react-dialog\";\nimport { XIcon } from \"lucide-react\";\nimport { cn } from \"../../../infra/utils/clsx\";\n\nfunction Dialog({\n ...props\n}: React.ComponentProps<typeof DialogPrimitive.Root>) {\n return <DialogPrimitive.Root data-slot=\"dialog\" {...props} />;\n}\n\nfunction DialogTrigger({\n ...props\n}: React.ComponentProps<typeof DialogPrimitive.Trigger>) {\n return <DialogPrimitive.Trigger data-slot=\"dialog-trigger\" {...props} />;\n}\n\nfunction DialogPortal({\n ...props\n}: React.ComponentProps<typeof DialogPrimitive.Portal>) {\n return <DialogPrimitive.Portal data-slot=\"dialog-portal\" {...props} />;\n}\n\nfunction DialogClose({\n ...props\n}: React.ComponentProps<typeof DialogPrimitive.Close>) {\n return <DialogPrimitive.Close data-slot=\"dialog-close\" {...props} />;\n}\n\nfunction DialogOverlay({\n className,\n ...props\n}: React.ComponentProps<typeof DialogPrimitive.Overlay>) {\n return (\n <DialogPrimitive.Overlay\n data-slot=\"dialog-overlay\"\n className={cn(\n \"data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-[1000] bg-black/50\",\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction DialogContent({\n className,\n children,\n showCloseButton = true,\n overlayClassName,\n ...props\n}: React.ComponentProps<typeof DialogPrimitive.Content> & {\n showCloseButton?: boolean;\n overlayClassName?: string;\n}) {\n return (\n <DialogPortal data-slot=\"dialog-portal\">\n <DialogOverlay className={overlayClassName} />\n <DialogPrimitive.Content\n data-slot=\"dialog-content\"\n className={cn(\n \"bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-[1001] grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg\",\n className,\n )}\n {...props}\n >\n {children}\n {showCloseButton && (\n <div className=\"absolute top-0.5 right-0\">\n <div className=\"p-4\">\n <DialogPrimitive.Close\n data-slot=\"dialog-close\"\n className=\"hover:cursor-pointer flex size-8 items-center justify-center rounded-lg p-2 text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-950 focus:outline-none\"\n >\n <XIcon className=\"size-[18px]\" />\n <span className=\"sr-only\">Close</span>\n </DialogPrimitive.Close>\n </div>\n </div>\n )}\n </DialogPrimitive.Content>\n </DialogPortal>\n );\n}\n\nfunction DialogHeader({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"dialog-header\"\n className={cn(\n \"p-5 flex flex-col gap-2 text-center sm:text-left\",\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction DialogFooter({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"dialog-footer\"\n className={cn(\n \"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end\",\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction DialogTitle({\n className,\n ...props\n}: React.ComponentProps<typeof DialogPrimitive.Title>) {\n return (\n <DialogPrimitive.Title\n data-slot=\"dialog-title\"\n className={cn(\"text-lg leading-none font-semibold\", className)}\n {...props}\n />\n );\n}\n\nfunction DialogDescription({\n className,\n ...props\n}: React.ComponentProps<typeof DialogPrimitive.Description>) {\n return (\n <DialogPrimitive.Description\n data-slot=\"dialog-description\"\n className={cn(\"text-muted-foreground text-sm\", className)}\n {...props}\n />\n );\n}\n\nexport {\n Dialog,\n DialogClose,\n DialogContent,\n DialogDescription,\n DialogFooter,\n DialogHeader,\n DialogOverlay,\n DialogPortal,\n DialogTitle,\n DialogTrigger,\n};\n"],"mappings":";AAUS,cA8DK,YA9DL;AAPT,YAAY,qBAAqB;AACjC,SAAS,aAAa;AACtB,SAAS,UAAU;AAEnB,SAAS,OAAO;A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AA;AAAA,UACjC,GACF,GACF;AAAA;AAAA;AAAA,IAEJ;AAAA,KACF;AAEJ;AAEA,SAAS,aAAa,EAAE,WAAW,GAAG,MAAM,GAAgC;AAC1E,SACE;AAAA,IAAC;AAAA;AAAA,MACC,aAAU;AAAA,MACV,WAAW;AAAA,QACT;AAAA,QACA;AAAA,MACF;AAAA,MACC,GAAG;AAAA;AAAA,EACN;AAEJ;AAEA,SAAS,aAAa,EAAE,WAAW,GAAG,MAAM,GAAgC;AAC1E,SACE;AAAA,IAAC;AAAA;AAAA,MACC,aAAU;AAAA,MACV,WAAW;AAAA,QACT;AAAA,QACA;AAAA,MACF;AAAA,MACC,GAAG;AAAA;AAAA,EACN;AAEJ;AAEA,SAAS,YAAY;AAAA,EACnB;AAAA,EACA,GAAG;AACL,GAAuD;AACrD,SACE;AAAA,IAAC,gBAAgB;AAAA,IAAhB;AAAA,MACC,aAAU;AAAA,MACV,WAAW,GAAG,sCAAsC,SAAS;AAAA,MAC5D,GAAG;AAAA;AAAA,EACN;AAEJ;AAEA,SAAS,kBAAkB;AAAA,EACzB;AAAA,EACA,GAAG;AACL,GAA6D;AAC3D,SACE;AAAA,IAAC,gBAAgB;AAAA,IAAhB;AAAA,MACC,aAAU;AAAA,MACV,WAAW,GAAG,iCAAiC,SAAS;AAAA,MACvD,GAAG;AAAA;AAAA,EACN;AAEJ;","names":[]}
|
|
@@ -52,7 +52,7 @@ function SheetContent({
|
|
|
52
52
|
{
|
|
53
53
|
"data-slot": "sheet-content",
|
|
54
54
|
className: cn(
|
|
55
|
-
"bg-background fixed z-
|
|
55
|
+
"bg-background fixed z-[1001] flex flex-col gap-4 shadow-lg",
|
|
56
56
|
!noAnimation && "data-[state=open]:animate-in data-[state=closed]:animate-out transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500",
|
|
57
57
|
!noAnimation && side === "right" && "data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right",
|
|
58
58
|
!noAnimation && side === "left" && "data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/ui/overlay/Sheet.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport * as SheetPrimitive from \"@radix-ui/react-dialog\";\nimport { XIcon } from \"lucide-react\";\nimport { cn } from \"../../../infra/utils/clsx\";\n\nfunction Sheet({ ...props }: React.ComponentProps<typeof SheetPrimitive.Root>) {\n return <SheetPrimitive.Root data-slot=\"sheet\" {...props} />;\n}\n\nfunction SheetTrigger({\n ...props\n}: React.ComponentProps<typeof SheetPrimitive.Trigger>) {\n return <SheetPrimitive.Trigger data-slot=\"sheet-trigger\" {...props} />;\n}\n\nfunction SheetClose({\n ...props\n}: React.ComponentProps<typeof SheetPrimitive.Close>) {\n return <SheetPrimitive.Close data-slot=\"sheet-close\" {...props} />;\n}\n\nfunction SheetPortal({\n ...props\n}: React.ComponentProps<typeof SheetPrimitive.Portal>) {\n return <SheetPrimitive.Portal data-slot=\"sheet-portal\" {...props} />;\n}\n\nfunction SheetOverlay({\n className,\n ...props\n}: React.ComponentProps<typeof SheetPrimitive.Overlay>) {\n return (\n <SheetPrimitive.Overlay\n data-slot=\"sheet-overlay\"\n className={cn(\n \"data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-[1000] bg-black/50\",\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction SheetContent({\n className,\n children,\n side = \"right\",\n showCloseButton = true,\n noAnimation = false,\n ...props\n}: React.ComponentProps<typeof SheetPrimitive.Content> & {\n side?: \"top\" | \"right\" | \"bottom\" | \"left\";\n showCloseButton?: boolean;\n noAnimation?: boolean;\n}) {\n return (\n <SheetPortal>\n <SheetOverlay className={noAnimation ? \"!animate-none\" : undefined} />\n <SheetPrimitive.Content\n data-slot=\"sheet-content\"\n className={cn(\n \"bg-background fixed z-
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/ui/overlay/Sheet.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport * as SheetPrimitive from \"@radix-ui/react-dialog\";\nimport { XIcon } from \"lucide-react\";\nimport { cn } from \"../../../infra/utils/clsx\";\n\nfunction Sheet({ ...props }: React.ComponentProps<typeof SheetPrimitive.Root>) {\n return <SheetPrimitive.Root data-slot=\"sheet\" {...props} />;\n}\n\nfunction SheetTrigger({\n ...props\n}: React.ComponentProps<typeof SheetPrimitive.Trigger>) {\n return <SheetPrimitive.Trigger data-slot=\"sheet-trigger\" {...props} />;\n}\n\nfunction SheetClose({\n ...props\n}: React.ComponentProps<typeof SheetPrimitive.Close>) {\n return <SheetPrimitive.Close data-slot=\"sheet-close\" {...props} />;\n}\n\nfunction SheetPortal({\n ...props\n}: React.ComponentProps<typeof SheetPrimitive.Portal>) {\n return <SheetPrimitive.Portal data-slot=\"sheet-portal\" {...props} />;\n}\n\nfunction SheetOverlay({\n className,\n ...props\n}: React.ComponentProps<typeof SheetPrimitive.Overlay>) {\n return (\n <SheetPrimitive.Overlay\n data-slot=\"sheet-overlay\"\n className={cn(\n \"data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-[1000] bg-black/50\",\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction SheetContent({\n className,\n children,\n side = \"right\",\n showCloseButton = true,\n noAnimation = false,\n ...props\n}: React.ComponentProps<typeof SheetPrimitive.Content> & {\n side?: \"top\" | \"right\" | \"bottom\" | \"left\";\n showCloseButton?: boolean;\n noAnimation?: boolean;\n}) {\n return (\n <SheetPortal>\n <SheetOverlay className={noAnimation ? \"!animate-none\" : undefined} />\n <SheetPrimitive.Content\n data-slot=\"sheet-content\"\n className={cn(\n \"bg-background fixed z-[1001] flex flex-col gap-4 shadow-lg\",\n !noAnimation &&\n \"data-[state=open]:animate-in data-[state=closed]:animate-out transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500\",\n !noAnimation &&\n side === \"right\" &&\n \"data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right\",\n !noAnimation &&\n side === \"left\" &&\n \"data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left\",\n !noAnimation &&\n side === \"top\" &&\n \"data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top\",\n !noAnimation &&\n side === \"bottom\" &&\n \"data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom\",\n side === \"right\" &&\n \"inset-y-0 right-0 h-full w-3/4 border-l sm:max-w-sm\",\n side === \"left\" &&\n \"inset-y-0 left-0 h-full w-3/4 border-r sm:max-w-sm\",\n side === \"top\" && \"inset-x-0 top-0 h-auto border-b\",\n side === \"bottom\" && \"inset-x-0 bottom-0 h-auto border-t\",\n className,\n )}\n {...props}\n >\n {children}\n {showCloseButton && (\n <SheetPrimitive.Close\n data-slot=\"sheet-close\"\n className=\"absolute top-3 right-3 hover:cursor-pointer flex size-8 items-center justify-center rounded-lg p-2 text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-950 focus:outline-none\"\n >\n <XIcon className=\"size-[18px]\" />\n <span className=\"sr-only\">Close</span>\n </SheetPrimitive.Close>\n )}\n </SheetPrimitive.Content>\n </SheetPortal>\n );\n}\n\nfunction SheetHeader({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"sheet-header\"\n className={cn(\"flex flex-col gap-1.5 p-4\", className)}\n {...props}\n />\n );\n}\n\nfunction SheetFooter({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"sheet-footer\"\n className={cn(\"mt-auto flex flex-col gap-2 p-4\", className)}\n {...props}\n />\n );\n}\n\nfunction SheetTitle({\n className,\n ...props\n}: React.ComponentProps<typeof SheetPrimitive.Title>) {\n return (\n <SheetPrimitive.Title\n data-slot=\"sheet-title\"\n className={cn(\"text-foreground font-semibold\", className)}\n {...props}\n />\n );\n}\n\nfunction SheetDescription({\n className,\n ...props\n}: React.ComponentProps<typeof SheetPrimitive.Description>) {\n return (\n <SheetPrimitive.Description\n data-slot=\"sheet-description\"\n className={cn(\"text-muted-foreground text-sm\", className)}\n {...props}\n />\n );\n}\n\nexport {\n Sheet,\n SheetTrigger,\n SheetClose,\n SheetContent,\n SheetHeader,\n SheetFooter,\n SheetTitle,\n SheetDescription,\n};\n"],"mappings":";AAQS,cAkFC,YAlFD;AALT,YAAY,oBAAoB;AAChC,SAAS,aAAa;AACtB,SAAS,UAAU;AAEnB,SAAS,MAAM,EAAE,GAAG,MAAM,GAAqD;AAC7E,SAAO,oBAAC,eAAe,MAAf,EAAoB,aAAU,SAAS,GAAG,OAAO;AAC3D;AAEA,SAAS,aAAa;AAAA,EACpB,GAAG;AACL,GAAwD;AACtD,SAAO,oBAAC,eAAe,SAAf,EAAuB,aAAU,iBAAiB,GAAG,OAAO;AACtE;AAEA,SAAS,WAAW;AAAA,EAClB,GAAG;AACL,GAAsD;AACpD,SAAO,oBAAC,eAAe,OAAf,EAAqB,aAAU,eAAe,GAAG,OAAO;AAClE;AAEA,SAAS,YAAY;AAAA,EACnB,GAAG;AACL,GAAuD;AACrD,SAAO,oBAAC,eAAe,QAAf,EAAsB,aAAU,gBAAgB,GAAG,OAAO;AACpE;AAEA,SAAS,aAAa;AAAA,EACpB;AAAA,EACA,GAAG;AACL,GAAwD;AACtD,SACE;AAAA,IAAC,eAAe;AAAA,IAAf;AAAA,MACC,aAAU;AAAA,MACV,WAAW;AAAA,QACT;AAAA,QACA;AAAA,MACF;AAAA,MACC,GAAG;AAAA;AAAA,EACN;AAEJ;AAEA,SAAS,aAAa;AAAA,EACpB;AAAA,EACA;AAAA,EACA,OAAO;AAAA,EACP,kBAAkB;AAAA,EAClB,cAAc;AAAA,EACd,GAAG;AACL,GAIG;AACD,SACE,qBAAC,eACC;AAAA,wBAAC,gBAAa,WAAW,cAAc,kBAAkB,QAAW;AAAA,IACpE;AAAA,MAAC,eAAe;AAAA,MAAf;AA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A,MACC,aAAU;AAAA,MACV,WAAW,GAAG,iCAAiC,SAAS;AAAA,MACvD,GAAG;AAAA;AAAA,EACN;AAEJ;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/store/useAccountModals.ts"],"sourcesContent":["'use client';\n\nimport { create } from 'zustand';\nimport type { ComboboxOption } from '../components/ui/form/ComboboxField';\nimport type { AccountSectionType } from '../enums/AccountSectionType';\n\ntype AccountModalType =\n | 'configurations'\n | 'deleteAccount'\n | 'isntPossibleDelete'\n | 'confirmDelete';\n\nexport interface AccountModalsConfig {\n hasActiveSubscription?: boolean;\n currencies?: ComboboxOption[];\n onGoToSubscription?: () => void;\n}\n\ninterface AccountModalsState {\n activeModal: AccountModalType | null;\n config: AccountModalsConfig;\n initialSection?: AccountSectionType;\n pagesCount: number;\n\n /** Called by <AccountModals> to keep app-level config in sync */\n updateConfig: (config: AccountModalsConfig) => void;\n\n openConfigurations: (initialSection?: AccountSectionType) => void;\n openDeleteAccount: (pagesCount?: number) => void;\n openIsntPossibleDelete: () => void;\n openConfirmDelete: (pagesCount?: number) => void;\n close: () => void;\n}\n\nexport const useAccountModals = create<AccountModalsState>((set) => ({\n activeModal: null,\n config: {},\n initialSection: undefined,\n pagesCount: 0,\n\n updateConfig: (config) => set({ config }),\n\n openConfigurations: (initialSection) =>\n set({ activeModal: 'configurations', initialSection }),\n\n openDeleteAccount: (pagesCount = 0) =>\n set({ activeModal: 'deleteAccount', pagesCount }),\n\n openIsntPossibleDelete: () =>\n set({ activeModal: 'isntPossibleDelete' }),\n\n openConfirmDelete: (pagesCount = 0) =>\n set({ activeModal: 'confirmDelete', pagesCount }),\n\n close: () =>\n set({ activeModal: null, initialSection: undefined }),\n}));\n"],"mappings":";AAEA,SAAS,cAAc;
|
|
1
|
+
{"version":3,"sources":["../../src/store/useAccountModals.ts"],"sourcesContent":["'use client';\n\nimport { create } from 'zustand';\nimport type { ComboboxOption } from '../components/ui/form/ComboboxField';\nimport type { AccountSectionType } from '../enums/AccountSectionType';\nimport type { TimezoneOption } from '../utils/intl/timezones';\n\ntype AccountModalType =\n | 'configurations'\n | 'deleteAccount'\n | 'isntPossibleDelete'\n | 'confirmDelete';\n\nexport interface AccountModalsConfig {\n hasActiveSubscription?: boolean;\n currencies?: ComboboxOption[];\n timezones?: TimezoneOption[];\n onGoToSubscription?: () => void;\n}\n\ninterface AccountModalsState {\n activeModal: AccountModalType | null;\n config: AccountModalsConfig;\n initialSection?: AccountSectionType;\n pagesCount: number;\n\n /** Called by <AccountModals> to keep app-level config in sync */\n updateConfig: (config: AccountModalsConfig) => void;\n\n openConfigurations: (initialSection?: AccountSectionType) => void;\n openDeleteAccount: (pagesCount?: number) => void;\n openIsntPossibleDelete: () => void;\n openConfirmDelete: (pagesCount?: number) => void;\n close: () => void;\n}\n\nexport const useAccountModals = create<AccountModalsState>((set) => ({\n activeModal: null,\n config: {},\n initialSection: undefined,\n pagesCount: 0,\n\n updateConfig: (config) => set({ config }),\n\n openConfigurations: (initialSection) =>\n set({ activeModal: 'configurations', initialSection }),\n\n openDeleteAccount: (pagesCount = 0) =>\n set({ activeModal: 'deleteAccount', pagesCount }),\n\n openIsntPossibleDelete: () =>\n set({ activeModal: 'isntPossibleDelete' }),\n\n openConfirmDelete: (pagesCount = 0) =>\n set({ activeModal: 'confirmDelete', pagesCount }),\n\n close: () =>\n set({ activeModal: null, initialSection: undefined }),\n}));\n"],"mappings":";AAEA,SAAS,cAAc;AAkChB,MAAM,mBAAmB,OAA2B,CAAC,SAAS;AAAA,EACnE,aAAa;AAAA,EACb,QAAQ,CAAC;AAAA,EACT,gBAAgB;AAAA,EAChB,YAAY;AAAA,EAEZ,cAAc,CAAC,WAAW,IAAI,EAAE,OAAO,CAAC;AAAA,EAExC,oBAAoB,CAAC,mBACnB,IAAI,EAAE,aAAa,kBAAkB,eAAe,CAAC;AAAA,EAEvD,mBAAmB,CAAC,aAAa,MAC/B,IAAI,EAAE,aAAa,iBAAiB,WAAW,CAAC;AAAA,EAElD,wBAAwB,MACtB,IAAI,EAAE,aAAa,qBAAqB,CAAC;AAAA,EAE3C,mBAAmB,CAAC,aAAa,MAC/B,IAAI,EAAE,aAAa,iBAAiB,WAAW,CAAC;AAAA,EAElD,OAAO,MACL,IAAI,EAAE,aAAa,MAAM,gBAAgB,OAAU,CAAC;AACxD,EAAE;","names":[]}
|
package/package.json
CHANGED
|
@@ -25,7 +25,7 @@ export default function ConfigurationsMyAccountModal() {
|
|
|
25
25
|
} = useAccountModals();
|
|
26
26
|
|
|
27
27
|
const open = activeModal === 'configurations';
|
|
28
|
-
const { hasActiveSubscription, currencies = [] } = config;
|
|
28
|
+
const { hasActiveSubscription, currencies = [], timezones = [] } = config;
|
|
29
29
|
|
|
30
30
|
const isMobile = useIsMobile();
|
|
31
31
|
const { activeSection, setActiveSection } = useConfigurationsModal({
|
|
@@ -140,7 +140,7 @@ export default function ConfigurationsMyAccountModal() {
|
|
|
140
140
|
</TabsContent>
|
|
141
141
|
|
|
142
142
|
<TabsContent value={AccountSectionType.PREFERENCES} className="h-full! relative overflow-hidden">
|
|
143
|
-
<PreferencesSection onClose={close} currencies={currencies} />
|
|
143
|
+
<PreferencesSection onClose={close} currencies={currencies} timezones={timezones} />
|
|
144
144
|
</TabsContent>
|
|
145
145
|
</div>
|
|
146
146
|
</Tabs>
|
|
@@ -20,10 +20,10 @@ import {
|
|
|
20
20
|
} from '../../../modules/accounts/hooks/useAccountManagement';
|
|
21
21
|
import {
|
|
22
22
|
LANGUAGE_OPTIONS,
|
|
23
|
-
TIMEZONE_OPTIONS,
|
|
24
23
|
TIME_FORMAT_OPTIONS,
|
|
25
24
|
NOTIFICATION_TYPES,
|
|
26
25
|
} from '../constants';
|
|
26
|
+
import type { TimezoneOption } from '../../../utils/intl/timezones';
|
|
27
27
|
|
|
28
28
|
interface PreferencesFormValues {
|
|
29
29
|
language: string;
|
|
@@ -37,9 +37,10 @@ interface PreferencesFormValues {
|
|
|
37
37
|
interface PreferencesSectionProps {
|
|
38
38
|
onClose: () => void;
|
|
39
39
|
currencies?: ComboboxOption[];
|
|
40
|
+
timezones?: TimezoneOption[];
|
|
40
41
|
}
|
|
41
42
|
|
|
42
|
-
export function PreferencesSection({ onClose, currencies = [] }: PreferencesSectionProps) {
|
|
43
|
+
export function PreferencesSection({ onClose, currencies = [], timezones = [] }: PreferencesSectionProps) {
|
|
43
44
|
const { user, account } = useAuth();
|
|
44
45
|
const canEditPreferences =
|
|
45
46
|
user?.profile === UserProfile.owner || user?.profile === UserProfile.admin;
|
|
@@ -186,7 +187,7 @@ export function PreferencesSection({ onClose, currencies = [] }: PreferencesSect
|
|
|
186
187
|
placeholder="Selecione o fuso horário"
|
|
187
188
|
searchPlaceholder="Buscar fuso horário..."
|
|
188
189
|
containerClassName="w-full"
|
|
189
|
-
options={
|
|
190
|
+
options={timezones}
|
|
190
191
|
value={watch('timezone')}
|
|
191
192
|
onChange={(value) => setValue('timezone', value, { shouldDirty: true })}
|
|
192
193
|
icon={!canEditPreferences ? <Lock className="size-4 text-gray-400" /> : undefined}
|
|
@@ -5,20 +5,22 @@ import AccountModals from '../account/AccountModals';
|
|
|
5
5
|
import { ModalManager } from './ModalManager';
|
|
6
6
|
import { useAccountModals } from '../../store/useAccountModals';
|
|
7
7
|
import type { ComboboxOption } from '../ui/form/ComboboxField';
|
|
8
|
+
import type { TimezoneOption } from '../../utils/intl/timezones';
|
|
8
9
|
|
|
9
10
|
interface ModalsProps {
|
|
10
11
|
registry: Record<string, ComponentType>;
|
|
11
12
|
hasActiveSubscription?: boolean;
|
|
12
13
|
currencies?: ComboboxOption[];
|
|
14
|
+
timezones?: TimezoneOption[];
|
|
13
15
|
onGoToSubscription?: () => void;
|
|
14
16
|
}
|
|
15
17
|
|
|
16
|
-
export function Modals({ registry, hasActiveSubscription, currencies, onGoToSubscription }: ModalsProps) {
|
|
18
|
+
export function Modals({ registry, hasActiveSubscription, currencies, timezones, onGoToSubscription }: ModalsProps) {
|
|
17
19
|
const { updateConfig } = useAccountModals();
|
|
18
20
|
|
|
19
21
|
useEffect(() => {
|
|
20
|
-
updateConfig({ hasActiveSubscription, currencies, onGoToSubscription });
|
|
21
|
-
}, [hasActiveSubscription, currencies, onGoToSubscription, updateConfig]);
|
|
22
|
+
updateConfig({ hasActiveSubscription, currencies, timezones, onGoToSubscription });
|
|
23
|
+
}, [hasActiveSubscription, currencies, timezones, onGoToSubscription, updateConfig]);
|
|
22
24
|
|
|
23
25
|
return (
|
|
24
26
|
<>
|
|
@@ -61,7 +61,7 @@ function DialogContent({
|
|
|
61
61
|
<DialogPrimitive.Content
|
|
62
62
|
data-slot="dialog-content"
|
|
63
63
|
className={cn(
|
|
64
|
-
"bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-[
|
|
64
|
+
"bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-[1001] grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",
|
|
65
65
|
className,
|
|
66
66
|
)}
|
|
67
67
|
{...props}
|
|
@@ -61,7 +61,7 @@ function SheetContent({
|
|
|
61
61
|
<SheetPrimitive.Content
|
|
62
62
|
data-slot="sheet-content"
|
|
63
63
|
className={cn(
|
|
64
|
-
"bg-background fixed z-
|
|
64
|
+
"bg-background fixed z-[1001] flex flex-col gap-4 shadow-lg",
|
|
65
65
|
!noAnimation &&
|
|
66
66
|
"data-[state=open]:animate-in data-[state=closed]:animate-out transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500",
|
|
67
67
|
!noAnimation &&
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import { create } from 'zustand';
|
|
4
4
|
import type { ComboboxOption } from '../components/ui/form/ComboboxField';
|
|
5
5
|
import type { AccountSectionType } from '../enums/AccountSectionType';
|
|
6
|
+
import type { TimezoneOption } from '../utils/intl/timezones';
|
|
6
7
|
|
|
7
8
|
type AccountModalType =
|
|
8
9
|
| 'configurations'
|
|
@@ -13,6 +14,7 @@ type AccountModalType =
|
|
|
13
14
|
export interface AccountModalsConfig {
|
|
14
15
|
hasActiveSubscription?: boolean;
|
|
15
16
|
currencies?: ComboboxOption[];
|
|
17
|
+
timezones?: TimezoneOption[];
|
|
16
18
|
onGoToSubscription?: () => void;
|
|
17
19
|
}
|
|
18
20
|
|