@greatapps/common 1.1.37 → 1.1.39
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/store/useAccountModals.mjs.map +1 -1
- package/dist/utils/intl/timezones.mjs +1 -1
- package/dist/utils/intl/timezones.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/store/useAccountModals.ts +2 -0
- package/src/utils/intl/timezones.ts +1 -1
|
@@ -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;AAElB,SAAR,+BAAgD;AACrD,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI,iBAAi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|
|
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,UAAU,cAAc,OAAO,WAAW,EAAE,YAAY,EAAE,IACvE,QAA+B;AAAA,IAC7B,eAAe;AAAA,MACb,UAAU;AAAA,MACV,UAAU;AAAA,MACV,UAA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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;AACnD,SAAS,mBAAmB;AAC5B,OAAO,+BAA+B;AACtC,OAAO,mCAAmC;AAC1C,SAAS,eAAe;AACxB,SAAS,mBAAmB;AAE5B;AAAA,EACE;A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A,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":[]}
|
|
@@ -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":[]}
|
|
@@ -33,7 +33,7 @@ async function fetchTimezoneOptions() {
|
|
|
33
33
|
items.sort((a, b) => a.sort - b.sort || a.label.localeCompare(b.label));
|
|
34
34
|
return items.map(({ value, label, displayValue }) => ({ value, label, displayValue }));
|
|
35
35
|
} catch {
|
|
36
|
-
return
|
|
36
|
+
return FALLBACK_TIMEZONES;
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
function buildTimezoneOptions() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/intl/timezones.ts"],"sourcesContent":["import { api } from '../../infra/api/client';\r\n\r\nexport type TimezoneOption = {\r\n value: string;\r\n label: string;\r\n displayValue: string;\r\n};\r\n\r\ntype TimezoneApiResponse = {\r\n message: string;\r\n data: { value: string; title: string }[];\r\n};\r\n\r\nfunction parseOffsetMinutes(offsetStr: string): number {\r\n const match = offsetStr.match(/GMT([+-])(\\d+)(?::(\\d+))?/);\r\n if (!match) return 0;\r\n const sign = match[1] === '+' ? 1 : -1;\r\n return sign * (parseInt(match[2], 10) * 60 + parseInt(match[3] ?? '0', 10));\r\n}\r\n\r\nconst FALLBACK_TIMEZONES: TimezoneOption[] = [\r\n { value: 'America/Noronha', label: '(GMT-2) America/Noronha', displayValue: '(GMT-2) Noronha' },\r\n { value: 'America/Sao_Paulo', label: '(GMT-3) America/Sao Paulo', displayValue: '(GMT-3) Sao Paulo' },\r\n { value: 'America/Manaus', label: '(GMT-4) America/Manaus', displayValue: '(GMT-4) Manaus' },\r\n { value: 'America/Rio_Branco', label: '(GMT-5) America/Rio Branco', displayValue: '(GMT-5) Rio Branco' },\r\n { value: 'America/New_York', label: '(GMT-5) America/New York', displayValue: '(GMT-5) New York' },\r\n { value: 'America/Los_Angeles', label: '(GMT-8) America/Los Angeles', displayValue: '(GMT-8) Los Angeles' },\r\n { value: 'Europe/London', label: '(GMT+0) Europe/London', displayValue: '(GMT+0) London' },\r\n { value: 'Europe/Paris', label: '(GMT+1) Europe/Paris', displayValue: '(GMT+1) Paris' },\r\n { value: 'Asia/Tokyo', label: '(GMT+9) Asia/Tokyo', displayValue: '(GMT+9) Tokyo' },\r\n];\r\n\r\nexport async function fetchTimezoneOptions(): Promise<TimezoneOption[]> {\r\n try {\r\n const response = await api.apps.get<TimezoneApiResponse>('/accounts/action/timezones');\r\n const now = new Date();\r\n\r\n const items = response.data.map((item) => {\r\n const offsetStr =\r\n new Intl.DateTimeFormat('en', { timeZone: item.value, timeZoneName: 'shortOffset' })\r\n .formatToParts(now)\r\n .find((p) => p.type === 'timeZoneName')?.value ?? 'GMT';\r\n\r\n const city = item.value.split('/').slice(1).join('/').replace(/_/g, ' ') || item.value;\r\n\r\n return {\r\n value: item.value,\r\n label: `(${offsetStr}) ${item.value.replace(/_/g, ' ')}`,\r\n displayValue: `(${offsetStr}) ${city}`,\r\n sort: parseOffsetMinutes(offsetStr),\r\n };\r\n });\r\n\r\n items.sort((a, b) => a.sort - b.sort || a.label.localeCompare(b.label));\r\n\r\n return items.map(({ value, label, displayValue }) => ({ value, label, displayValue }));\r\n } catch {\r\n return
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/intl/timezones.ts"],"sourcesContent":["import { api } from '../../infra/api/client';\r\n\r\nexport type TimezoneOption = {\r\n value: string;\r\n label: string;\r\n displayValue: string;\r\n};\r\n\r\ntype TimezoneApiResponse = {\r\n message: string;\r\n data: { value: string; title: string }[];\r\n};\r\n\r\nfunction parseOffsetMinutes(offsetStr: string): number {\r\n const match = offsetStr.match(/GMT([+-])(\\d+)(?::(\\d+))?/);\r\n if (!match) return 0;\r\n const sign = match[1] === '+' ? 1 : -1;\r\n return sign * (parseInt(match[2], 10) * 60 + parseInt(match[3] ?? '0', 10));\r\n}\r\n\r\nconst FALLBACK_TIMEZONES: TimezoneOption[] = [\r\n { value: 'America/Noronha', label: '(GMT-2) America/Noronha', displayValue: '(GMT-2) Noronha' },\r\n { value: 'America/Sao_Paulo', label: '(GMT-3) America/Sao Paulo', displayValue: '(GMT-3) Sao Paulo' },\r\n { value: 'America/Manaus', label: '(GMT-4) America/Manaus', displayValue: '(GMT-4) Manaus' },\r\n { value: 'America/Rio_Branco', label: '(GMT-5) America/Rio Branco', displayValue: '(GMT-5) Rio Branco' },\r\n { value: 'America/New_York', label: '(GMT-5) America/New York', displayValue: '(GMT-5) New York' },\r\n { value: 'America/Los_Angeles', label: '(GMT-8) America/Los Angeles', displayValue: '(GMT-8) Los Angeles' },\r\n { value: 'Europe/London', label: '(GMT+0) Europe/London', displayValue: '(GMT+0) London' },\r\n { value: 'Europe/Paris', label: '(GMT+1) Europe/Paris', displayValue: '(GMT+1) Paris' },\r\n { value: 'Asia/Tokyo', label: '(GMT+9) Asia/Tokyo', displayValue: '(GMT+9) Tokyo' },\r\n];\r\n\r\nexport async function fetchTimezoneOptions(): Promise<TimezoneOption[]> {\r\n try {\r\n const response = await api.apps.get<TimezoneApiResponse>('/accounts/action/timezones');\r\n const now = new Date();\r\n\r\n const items = response.data.map((item) => {\r\n const offsetStr =\r\n new Intl.DateTimeFormat('en', { timeZone: item.value, timeZoneName: 'shortOffset' })\r\n .formatToParts(now)\r\n .find((p) => p.type === 'timeZoneName')?.value ?? 'GMT';\r\n\r\n const city = item.value.split('/').slice(1).join('/').replace(/_/g, ' ') || item.value;\r\n\r\n return {\r\n value: item.value,\r\n label: `(${offsetStr}) ${item.value.replace(/_/g, ' ')}`,\r\n displayValue: `(${offsetStr}) ${city}`,\r\n sort: parseOffsetMinutes(offsetStr),\r\n };\r\n });\r\n\r\n items.sort((a, b) => a.sort - b.sort || a.label.localeCompare(b.label));\r\n\r\n return items.map(({ value, label, displayValue }) => ({ value, label, displayValue }));\r\n } catch {\r\n return FALLBACK_TIMEZONES;\r\n }\r\n}\r\n\r\nexport function buildTimezoneOptions(): TimezoneOption[] {\r\n try {\r\n const zones = Intl.supportedValuesOf('timeZone');\r\n const now = new Date();\r\n\r\n const items = zones.map((tz) => {\r\n const offsetStr =\r\n new Intl.DateTimeFormat('en', { timeZone: tz, timeZoneName: 'shortOffset' })\r\n .formatToParts(now)\r\n .find((p) => p.type === 'timeZoneName')?.value ?? 'GMT';\r\n\r\n const city = tz.split('/').slice(1).join('/').replace(/_/g, ' ') || tz;\r\n\r\n return {\r\n value: tz,\r\n label: `(${offsetStr}) ${tz.replace(/_/g, ' ')}`,\r\n displayValue: `(${offsetStr}) ${city}`,\r\n sort: parseOffsetMinutes(offsetStr),\r\n };\r\n });\r\n\r\n items.sort((a, b) => a.sort - b.sort || a.label.localeCompare(b.label));\r\n\r\n return items.map(({ value, label, displayValue }) => ({ value, label, displayValue }));\r\n } catch {\r\n return FALLBACK_TIMEZONES;\r\n }\r\n}\r\n"],"mappings":"AAAA,SAAS,WAAW;AAapB,SAAS,mBAAmB,WAA2B;AACrD,QAAM,QAAQ,UAAU,MAAM,2BAA2B;AACzD,MAAI,CAAC,MAAO,QAAO;AACnB,QAAM,OAAO,MAAM,CAAC,M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,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
|
<>
|
|
@@ -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
|
|