@greatapps/common 1.1.39 → 1.1.41
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 +5 -1
- 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/modules/accounts/actions/list-currencies.action.mjs +9 -0
- package/dist/modules/accounts/actions/list-currencies.action.mjs.map +1 -0
- package/dist/modules/accounts/actions/list-timezones.action.mjs +9 -0
- package/dist/modules/accounts/actions/list-timezones.action.mjs.map +1 -0
- package/dist/modules/accounts/hooks/useCurrencies.mjs +16 -0
- package/dist/modules/accounts/hooks/useCurrencies.mjs.map +1 -0
- package/dist/modules/accounts/hooks/useTimezones.mjs +16 -0
- package/dist/modules/accounts/hooks/useTimezones.mjs.map +1 -0
- package/dist/store/useAccountModals.mjs.map +1 -1
- package/dist/utils/intl/currencies.mjs +21 -0
- package/dist/utils/intl/currencies.mjs.map +1 -0
- package/package.json +1 -1
- package/src/components/account/ConfigurationsMyAccountModal.tsx +2 -2
- package/src/components/account/sections/PreferencesSection.tsx +6 -5
- package/src/components/modals/Modals.tsx +3 -8
- package/src/components/ui/overlay/Dialog.tsx +1 -1
- package/src/components/ui/overlay/Sheet.tsx +1 -1
- package/src/modules/accounts/actions/list-currencies.action.ts +7 -0
- package/src/modules/accounts/actions/list-timezones.action.ts +7 -0
- package/src/modules/accounts/hooks/useCurrencies.ts +14 -0
- package/src/modules/accounts/hooks/useTimezones.ts +14 -0
- package/src/store/useAccountModals.ts +0 -4
- package/src/utils/intl/currencies.ts +34 -0
|
@@ -22,7 +22,7 @@ function ConfigurationsMyAccountModal() {
|
|
|
22
22
|
close
|
|
23
23
|
} = useAccountModals();
|
|
24
24
|
const open = activeModal === "configurations";
|
|
25
|
-
const { hasActiveSubscription
|
|
25
|
+
const { hasActiveSubscription } = 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
|
|
120
|
+
/* @__PURE__ */ jsx(TabsContent, { value: AccountSectionType.PREFERENCES, className: "h-full! relative overflow-hidden", children: /* @__PURE__ */ jsx(PreferencesSection, { onClose: close }) })
|
|
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
|
|
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 } = 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} />\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,sBAAsB,IAAI;AAElC,QAAM,WAAW,YAAY;AAC7B,QAAM,EAAE,eAAe,iBAAiB,IAAI,uBAAuB;AAAA,IACjE,QAAQ;AAAA,IACR;AAAA,EACF,CAAC;AAED,QAAM,sBAAsB,MAAM;AAChC,UAAM;AACN,QAAI,uBAAuB;AACzB,6BAAuB;AAAA,IACzB,OAAO;AACL,wBAAkB;AAAA,IACpB;AAAA,EACF;AAEA,QAAM,oBAAoB;AAAA,IACxB;AAAA,IAEA;AAAA,IACA;AAAA,IACA;AAAA,IAEA;AAAA,IACA;AAAA,IACA;AAAA,IAEA;AAAA,IACA;AAAA,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AC,UAAK,WAAU,0BAAyB,0BAAS;AAAA,yBACpD;AAAA,uBACF;AAAA;AAAA;AAAA,cACF;AAAA,cAEA,qBAAC,SAAI,WAAU,gFACb;AAAA,oCAAC,eAAY,OAAO,mBAAmB,YAAY,WAAU,oCAC3D,8BAAC,oBAAiB,SAAS,OAAO,GACpC;AAAA,gBAEA,oBAAC,eAAY,OAAO,mBAAmB,UAAU,WAAU,oCACzD;AAAA,kBAAC;AAAA;AAAA,oBACC;AAAA,oBACA,SAAS;AAAA,oBACT;AAAA,oBACA,iBAAiB;AAAA;AAAA,gBACnB,GACF;AAAA,gBAEA,oBAAC,eAAY,OAAO,mBAAmB,iBAAiB,WAAU,oCAChE,8BAAC,yBAAsB,QAAQ,MAAM,iBAAiB,mBAAmB,QAAQ,GAAG,GACtF;AAAA,gBAEA,oBAAC,eAAY,OAAO,mBAAmB,aAAa,WAAU,oCAC5D,8BAAC,sBAAmB,SAAS,OAAO,GACtC;AAAA,iBACF;AAAA;AAAA;AAAA,QACF;AAAA;AAAA;AAAA,EACF,GACF;AAEJ;","names":[]}
|
|
@@ -22,7 +22,11 @@ import {
|
|
|
22
22
|
TIME_FORMAT_OPTIONS,
|
|
23
23
|
NOTIFICATION_TYPES
|
|
24
24
|
} from "../constants";
|
|
25
|
-
|
|
25
|
+
import { useTimezones } from "../../../modules/accounts/hooks/useTimezones";
|
|
26
|
+
import { useCurrencies } from "../../../modules/accounts/hooks/useCurrencies";
|
|
27
|
+
function PreferencesSection({ onClose }) {
|
|
28
|
+
const { data: timezones = [] } = useTimezones();
|
|
29
|
+
const { data: currencies = [] } = useCurrencies();
|
|
26
30
|
const { user, account } = useAuth();
|
|
27
31
|
const canEditPreferences = user?.profile === UserProfile.owner || user?.profile === UserProfile.admin;
|
|
28
32
|
const updateAccountUser = useUpdateAccountUser();
|
|
@@ -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 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;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAkBA,SAAS,mBAAmB,EAAE,SAAS,aAAa,CAAC,GAAG,YAAY,CAAC,EAAE,GAA4B;AACxG,QAAM,EAAE,MAAM,QAAQ,I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AFrD,IAGV,CACD,GACH;AAAA,iBACF;AAAA,eACF;AAAA,aACF;AAAA,WACF;AAAA,SACF;AAAA,MAEA,qBAAC,SAAI,WAAU,sIACb;AAAA;AAAA,UAAC;AAAA;AAAA,YACC,SAAQ;AAAA,YACR,WAAU;AAAA,YACV,MAAK;AAAA,YACL,UAAU;AAAA,YACV,SAAS,MAAM;AACb,oBAAM;AACN,sBAAQ;AAAA,YACV;AAAA,YACD;AAAA;AAAA,QAED;AAAA,QACA,oBAAC,UAAO,WAAU,SAAQ,MAAK,UAAS,UAAU,UAC/C,qBAAW,gBAAgB,2BAC9B;AAAA,SACF;AAAA,OACF;AAAA,IAEA;AAAA,MAAC;AAAA;AAAA,QACC,MAAM;AAAA,QACN,WAAW;AAAA,QACX,UAAU;AAAA;AAAA,IACZ;AAAA,KACF;AAEJ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/account/sections/PreferencesSection.tsx"],"sourcesContent":["'use client';\r\n\r\nimport { useState, useEffect } from 'react';\r\nimport { useForm } from 'react-hook-form';\r\nimport { toast } from 'sonner';\r\nimport { Lock, Mail, MessageCircle } from 'lucide-react';\r\nimport { Button } from '../../ui/buttons/Button';\r\nimport { Separator } from '../../ui/data-display/Separator';\r\nimport { Toast } from '../../ui/feedback/Toast';\r\nimport { ComboboxField } from '../../ui/form/ComboboxField';\r\nimport { SelectField } from '../../ui/form/SelectField';\r\nimport SwitchOptionFieldWithIcon from '../../ui/form/SwitchOptionFieldWithIcon';\r\nimport ConfirmGlobalPreferencesModal from '../ConfirmGlobalPreferencesModal';\r\nimport { useAuth } from '../../../providers/auth.provider';\r\nimport { UserProfile } from '../../../modules/users/schema';\r\nimport type { UpdateAccountRequest } from '../../../modules/accounts/types';\r\nimport {\r\n useUpdateAccountUser,\r\n useUpdateAccount,\r\n} from '../../../modules/accounts/hooks/useAccountManagement';\r\nimport {\r\n LANGUAGE_OPTIONS,\r\n TIME_FORMAT_OPTIONS,\r\n NOTIFICATION_TYPES,\r\n} from '../constants';\r\nimport { useTimezones } from '../../../modules/accounts/hooks/useTimezones';\r\nimport { useCurrencies } from '../../../modules/accounts/hooks/useCurrencies';\r\n\r\ninterface PreferencesFormValues {\r\n language: string;\r\n currency: string;\r\n timezone: string;\r\n timeFormat: string;\r\n receive_sms: boolean;\r\n receive_email: boolean;\r\n}\r\n\r\ninterface PreferencesSectionProps {\r\n onClose: () => void;\r\n}\r\n\r\nexport function PreferencesSection({ onClose }: PreferencesSectionProps) {\r\n const { data: timezones = [] } = useTimezones();\r\n const { data: currencies = [] } = useCurrencies();\r\n const { user, account } = useAuth();\r\n const canEditPreferences =\r\n user?.profile === UserProfile.owner || user?.profile === UserProfile.admin;\r\n const updateAccountUser = useUpdateAccountUser();\r\n const updateAccount = useUpdateAccount();\r\n const [confirmGlobalOpen, setConfirmGlobalOpen] = useState(false);\r\n const [pendingSubmit, setPendingSubmit] = useState<{\r\n data: PreferencesFormValues;\r\n accountFields: UpdateAccountRequest;\r\n } | null>(null);\r\n const [isSaving, setIsSaving] = useState(false);\r\n\r\n const { watch, setValue, handleSubmit, reset, formState: { dirtyFields } } =\r\n useForm<PreferencesFormValues>({\r\n defaultValues: {\r\n language: '',\r\n currency: '',\r\n timezone: '',\r\n timeFormat: '24h',\r\n receive_sms: false,\r\n receive_email: false,\r\n },\r\n });\r\n\r\n useEffect(() => {\r\n if (!user || !account) return;\r\n reset({\r\n language: LANGUAGE_OPTIONS.find(\r\n (o) => o.apiValue === user.language?.toLowerCase()\r\n )?.value ?? 'pt-BR',\r\n currency: account.currency,\r\n timezone: account.timezone,\r\n timeFormat: '24h',\r\n receive_sms: user.receive_sms ?? false,\r\n receive_email: user.receive_email ?? false,\r\n });\r\n }, [user, account, reset]);\r\n\r\n const receiveSms = watch('receive_sms');\r\n const receiveEmail = watch('receive_email');\r\n\r\n const doSave = async (data: PreferencesFormValues, accountFields: UpdateAccountRequest) => {\r\n setIsSaving(true);\r\n try {\r\n const apiLanguage = LANGUAGE_OPTIONS.find((o) => o.value === data.language)?.apiValue ?? data.language.toLowerCase();\r\n 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\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ACX,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,
|
|
7
|
+
function Modals({ registry, hasActiveSubscription, onGoToSubscription }) {
|
|
8
8
|
const { updateConfig } = useAccountModals();
|
|
9
9
|
useEffect(() => {
|
|
10
|
-
updateConfig({ hasActiveSubscription,
|
|
11
|
-
}, [hasActiveSubscription,
|
|
10
|
+
updateConfig({ hasActiveSubscription, onGoToSubscription });
|
|
11
|
+
}, [hasActiveSubscription, 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';\
|
|
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';\ninterface ModalsProps {\n registry: Record<string, ComponentType>;\n hasActiveSubscription?: boolean;\n onGoToSubscription?: () => void;\n}\n\nexport function Modals({ registry, hasActiveSubscription, onGoToSubscription }: ModalsProps) {\n const { updateConfig } = useAccountModals();\n\n useEffect(() => {\n updateConfig({ hasActiveSubscription, onGoToSubscription });\n }, [hasActiveSubscription, onGoToSubscription, updateConfig]);\n\n return (\n <>\n <AccountModals />\n <ModalManager registry={registry} />\n </>\n );\n}\n"],"mappings":";AAoBI,mBACE,KADF;AAlBJ,SAAwB,iBAAiB;AACzC,OAAO,mBAAmB;AAC1B,SAAS,oBAAoB;AAC7B,SAAS,wBAAwB;AAO1B,SAAS,OAAO,EAAE,UAAU,uBAAuB,mBAAmB,GAAgB;AAC3F,QAAM,EAAE,aAAa,IAAI,iBAAiB;AAE1C,YAAU,MAAM;AACd,iBAAa,EAAE,uBAAuB,mBAAmB,CAAC;AAAA,EAC5D,GAAG,CAAC,uBAAuB,oBAAoB,YAAY,CAAC;AAE5D,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;AAAA,EACd,GAAG;AACL,GAAsD;AACpD,SAAO,oBAAC,gBAAgB,MAAhB,EAAqB,aAAU,UAAU,GAAG,OAAO;AAC7D;AAEA,SAAS,cAAc;AAAA,EACrB,GAAG;AACL,GAAyD;AACvD,SAAO,oBAAC,gB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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 Sheet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-currencies.action.ts"],"sourcesContent":["'use server';\r\n\r\nimport { fetchCurrencyOptions } from '../../../utils/intl/currencies';\r\n\r\nexport async function listCurrenciesAction() {\r\n return fetchCurrencyOptions();\r\n}\r\n"],"mappings":";AAEA,SAAS,4BAA4B;AAErC,eAAsB,uBAAuB;AAC3C,SAAO,qBAAqB;AAC9B;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/accounts/actions/list-timezones.action.ts"],"sourcesContent":["'use server';\r\n\r\nimport { fetchTimezoneOptions } from '../../../utils/intl/timezones';\r\n\r\nexport async function listTimezonesAction() {\r\n return fetchTimezoneOptions();\r\n}\r\n"],"mappings":";AAEA,SAAS,4BAA4B;AAErC,eAAsB,sBAAsB;AAC1C,SAAO,qBAAqB;AAC9B;","names":[]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useQuery } from "@tanstack/react-query";
|
|
3
|
+
import { listCurrenciesAction } from "../actions/list-currencies.action";
|
|
4
|
+
const CURRENCIES_QUERY_KEY = ["currencies"];
|
|
5
|
+
function useCurrencies() {
|
|
6
|
+
return useQuery({
|
|
7
|
+
queryKey: CURRENCIES_QUERY_KEY,
|
|
8
|
+
queryFn: listCurrenciesAction,
|
|
9
|
+
staleTime: Infinity
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
CURRENCIES_QUERY_KEY,
|
|
14
|
+
useCurrencies
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=useCurrencies.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/accounts/hooks/useCurrencies.ts"],"sourcesContent":["'use client';\r\n\r\nimport { useQuery } from '@tanstack/react-query';\r\nimport { listCurrenciesAction } from '../actions/list-currencies.action';\r\n\r\nexport const CURRENCIES_QUERY_KEY = ['currencies'];\r\n\r\nexport function useCurrencies() {\r\n return useQuery({\r\n queryKey: CURRENCIES_QUERY_KEY,\r\n queryFn: listCurrenciesAction,\r\n staleTime: Infinity,\r\n });\r\n}\r\n"],"mappings":";AAEA,SAAS,gBAAgB;AACzB,SAAS,4BAA4B;AAE9B,MAAM,uBAAuB,CAAC,YAAY;AAE1C,SAAS,gBAAgB;AAC9B,SAAO,SAAS;AAAA,IACd,UAAU;AAAA,IACV,SAAS;AAAA,IACT,WAAW;AAAA,EACb,CAAC;AACH;","names":[]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useQuery } from "@tanstack/react-query";
|
|
3
|
+
import { listTimezonesAction } from "../actions/list-timezones.action";
|
|
4
|
+
const TIMEZONES_QUERY_KEY = ["timezones"];
|
|
5
|
+
function useTimezones() {
|
|
6
|
+
return useQuery({
|
|
7
|
+
queryKey: TIMEZONES_QUERY_KEY,
|
|
8
|
+
queryFn: listTimezonesAction,
|
|
9
|
+
staleTime: Infinity
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
TIMEZONES_QUERY_KEY,
|
|
14
|
+
useTimezones
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=useTimezones.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/accounts/hooks/useTimezones.ts"],"sourcesContent":["'use client';\r\n\r\nimport { useQuery } from '@tanstack/react-query';\r\nimport { listTimezonesAction } from '../actions/list-timezones.action';\r\n\r\nexport const TIMEZONES_QUERY_KEY = ['timezones'];\r\n\r\nexport function useTimezones() {\r\n return useQuery({\r\n queryKey: TIMEZONES_QUERY_KEY,\r\n queryFn: listTimezonesAction,\r\n staleTime: Infinity,\r\n });\r\n}\r\n"],"mappings":";AAEA,SAAS,gBAAgB;AACzB,SAAS,2BAA2B;AAE7B,MAAM,sBAAsB,CAAC,WAAW;AAExC,SAAS,eAAe;AAC7B,SAAO,SAAS;AAAA,IACd,UAAU;AAAA,IACV,SAAS;AAAA,IACT,WAAW;AAAA,EACb,CAAC;AACH;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/store/useAccountModals.ts"],"sourcesContent":["'use client';\n\nimport { create } from 'zustand';\nimport type {
|
|
1
|
+
{"version":3,"sources":["../../src/store/useAccountModals.ts"],"sourcesContent":["'use client';\n\nimport { create } from 'zustand';\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 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;AA8BhB,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":[]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { api } from "../../infra/api/client";
|
|
2
|
+
const FALLBACK_CURRENCIES = [
|
|
3
|
+
{ value: "BRL", label: "Real (R$)" },
|
|
4
|
+
{ value: "USD", label: "D\xF3lar Americano (US$)" },
|
|
5
|
+
{ value: "EUR", label: "Euro (\u20AC)" }
|
|
6
|
+
];
|
|
7
|
+
async function fetchCurrencyOptions() {
|
|
8
|
+
try {
|
|
9
|
+
const response = await api.apps.get("/accounts/action/currencies");
|
|
10
|
+
return response.data.map((item) => ({
|
|
11
|
+
value: item.value,
|
|
12
|
+
label: item.title["pt-br"] || item.title["en-us"] || item.value
|
|
13
|
+
}));
|
|
14
|
+
} catch {
|
|
15
|
+
return FALLBACK_CURRENCIES;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export {
|
|
19
|
+
fetchCurrencyOptions
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=currencies.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/intl/currencies.ts"],"sourcesContent":["import { api } from '../../infra/api/client';\r\nimport type { ComboboxOption } from '../../components/ui/form/ComboboxField';\r\n\r\ntype CurrencyApiItem = {\r\n value: string;\r\n icon: string;\r\n title: { 'pt-br': string; 'en-us': string };\r\n description: string;\r\n};\r\n\r\ntype CurrencyApiResponse = {\r\n status: number;\r\n message: string;\r\n data: CurrencyApiItem[];\r\n};\r\n\r\nconst FALLBACK_CURRENCIES: ComboboxOption[] = [\r\n { value: 'BRL', label: 'Real (R$)' },\r\n { value: 'USD', label: 'Dólar Americano (US$)' },\r\n { value: 'EUR', label: 'Euro (€)' },\r\n];\r\n\r\nexport async function fetchCurrencyOptions(): Promise<ComboboxOption[]> {\r\n try {\r\n const response = await api.apps.get<CurrencyApiResponse>('/accounts/action/currencies');\r\n\r\n return response.data.map((item) => ({\r\n value: item.value,\r\n label: item.title['pt-br'] || item.title['en-us'] || item.value,\r\n }));\r\n } catch {\r\n return FALLBACK_CURRENCIES;\r\n }\r\n}\r\n"],"mappings":"AAAA,SAAS,WAAW;AAgBpB,MAAM,sBAAwC;AAAA,EAC5C,EAAE,OAAO,OAAO,OAAO,YAAY;AAAA,EACnC,EAAE,OAAO,OAAO,OAAO,2BAAwB;AAAA,EAC/C,EAAE,OAAO,OAAO,OAAO,gBAAW;AACpC;AAEA,eAAsB,uBAAkD;AACtE,MAAI;AACF,UAAM,WAAW,MAAM,IAAI,KAAK,IAAyB,6BAA6B;AAEtF,WAAO,SAAS,KAAK,IAAI,CAAC,UAAU;AAAA,MAClC,OAAO,KAAK;AAAA,MACZ,OAAO,KAAK,MAAM,OAAO,KAAK,KAAK,MAAM,OAAO,KAAK,KAAK;AAAA,IAC5D,EAAE;AAAA,EACJ,QAAQ;AACN,WAAO;AAAA,EACT;AACF;","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
|
|
28
|
+
const { hasActiveSubscription } = 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}
|
|
143
|
+
<PreferencesSection onClose={close} />
|
|
144
144
|
</TabsContent>
|
|
145
145
|
</div>
|
|
146
146
|
</Tabs>
|
|
@@ -7,7 +7,7 @@ import { Lock, Mail, MessageCircle } from 'lucide-react';
|
|
|
7
7
|
import { Button } from '../../ui/buttons/Button';
|
|
8
8
|
import { Separator } from '../../ui/data-display/Separator';
|
|
9
9
|
import { Toast } from '../../ui/feedback/Toast';
|
|
10
|
-
import { ComboboxField
|
|
10
|
+
import { ComboboxField } from '../../ui/form/ComboboxField';
|
|
11
11
|
import { SelectField } from '../../ui/form/SelectField';
|
|
12
12
|
import SwitchOptionFieldWithIcon from '../../ui/form/SwitchOptionFieldWithIcon';
|
|
13
13
|
import ConfirmGlobalPreferencesModal from '../ConfirmGlobalPreferencesModal';
|
|
@@ -23,7 +23,8 @@ import {
|
|
|
23
23
|
TIME_FORMAT_OPTIONS,
|
|
24
24
|
NOTIFICATION_TYPES,
|
|
25
25
|
} from '../constants';
|
|
26
|
-
import
|
|
26
|
+
import { useTimezones } from '../../../modules/accounts/hooks/useTimezones';
|
|
27
|
+
import { useCurrencies } from '../../../modules/accounts/hooks/useCurrencies';
|
|
27
28
|
|
|
28
29
|
interface PreferencesFormValues {
|
|
29
30
|
language: string;
|
|
@@ -36,11 +37,11 @@ interface PreferencesFormValues {
|
|
|
36
37
|
|
|
37
38
|
interface PreferencesSectionProps {
|
|
38
39
|
onClose: () => void;
|
|
39
|
-
currencies?: ComboboxOption[];
|
|
40
|
-
timezones?: TimezoneOption[];
|
|
41
40
|
}
|
|
42
41
|
|
|
43
|
-
export function PreferencesSection({ onClose
|
|
42
|
+
export function PreferencesSection({ onClose }: PreferencesSectionProps) {
|
|
43
|
+
const { data: timezones = [] } = useTimezones();
|
|
44
|
+
const { data: currencies = [] } = useCurrencies();
|
|
44
45
|
const { user, account } = useAuth();
|
|
45
46
|
const canEditPreferences =
|
|
46
47
|
user?.profile === UserProfile.owner || user?.profile === UserProfile.admin;
|
|
@@ -4,23 +4,18 @@ import { ComponentType, useEffect } from 'react';
|
|
|
4
4
|
import AccountModals from '../account/AccountModals';
|
|
5
5
|
import { ModalManager } from './ModalManager';
|
|
6
6
|
import { useAccountModals } from '../../store/useAccountModals';
|
|
7
|
-
import type { ComboboxOption } from '../ui/form/ComboboxField';
|
|
8
|
-
import type { TimezoneOption } from '../../utils/intl/timezones';
|
|
9
|
-
|
|
10
7
|
interface ModalsProps {
|
|
11
8
|
registry: Record<string, ComponentType>;
|
|
12
9
|
hasActiveSubscription?: boolean;
|
|
13
|
-
currencies?: ComboboxOption[];
|
|
14
|
-
timezones?: TimezoneOption[];
|
|
15
10
|
onGoToSubscription?: () => void;
|
|
16
11
|
}
|
|
17
12
|
|
|
18
|
-
export function Modals({ registry, hasActiveSubscription,
|
|
13
|
+
export function Modals({ registry, hasActiveSubscription, onGoToSubscription }: ModalsProps) {
|
|
19
14
|
const { updateConfig } = useAccountModals();
|
|
20
15
|
|
|
21
16
|
useEffect(() => {
|
|
22
|
-
updateConfig({ hasActiveSubscription,
|
|
23
|
-
}, [hasActiveSubscription,
|
|
17
|
+
updateConfig({ hasActiveSubscription, onGoToSubscription });
|
|
18
|
+
}, [hasActiveSubscription, onGoToSubscription, updateConfig]);
|
|
24
19
|
|
|
25
20
|
return (
|
|
26
21
|
<>
|
|
@@ -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 &&
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useQuery } from '@tanstack/react-query';
|
|
4
|
+
import { listCurrenciesAction } from '../actions/list-currencies.action';
|
|
5
|
+
|
|
6
|
+
export const CURRENCIES_QUERY_KEY = ['currencies'];
|
|
7
|
+
|
|
8
|
+
export function useCurrencies() {
|
|
9
|
+
return useQuery({
|
|
10
|
+
queryKey: CURRENCIES_QUERY_KEY,
|
|
11
|
+
queryFn: listCurrenciesAction,
|
|
12
|
+
staleTime: Infinity,
|
|
13
|
+
});
|
|
14
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useQuery } from '@tanstack/react-query';
|
|
4
|
+
import { listTimezonesAction } from '../actions/list-timezones.action';
|
|
5
|
+
|
|
6
|
+
export const TIMEZONES_QUERY_KEY = ['timezones'];
|
|
7
|
+
|
|
8
|
+
export function useTimezones() {
|
|
9
|
+
return useQuery({
|
|
10
|
+
queryKey: TIMEZONES_QUERY_KEY,
|
|
11
|
+
queryFn: listTimezonesAction,
|
|
12
|
+
staleTime: Infinity,
|
|
13
|
+
});
|
|
14
|
+
}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import { create } from 'zustand';
|
|
4
|
-
import type { ComboboxOption } from '../components/ui/form/ComboboxField';
|
|
5
4
|
import type { AccountSectionType } from '../enums/AccountSectionType';
|
|
6
|
-
import type { TimezoneOption } from '../utils/intl/timezones';
|
|
7
5
|
|
|
8
6
|
type AccountModalType =
|
|
9
7
|
| 'configurations'
|
|
@@ -13,8 +11,6 @@ type AccountModalType =
|
|
|
13
11
|
|
|
14
12
|
export interface AccountModalsConfig {
|
|
15
13
|
hasActiveSubscription?: boolean;
|
|
16
|
-
currencies?: ComboboxOption[];
|
|
17
|
-
timezones?: TimezoneOption[];
|
|
18
14
|
onGoToSubscription?: () => void;
|
|
19
15
|
}
|
|
20
16
|
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { api } from '../../infra/api/client';
|
|
2
|
+
import type { ComboboxOption } from '../../components/ui/form/ComboboxField';
|
|
3
|
+
|
|
4
|
+
type CurrencyApiItem = {
|
|
5
|
+
value: string;
|
|
6
|
+
icon: string;
|
|
7
|
+
title: { 'pt-br': string; 'en-us': string };
|
|
8
|
+
description: string;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
type CurrencyApiResponse = {
|
|
12
|
+
status: number;
|
|
13
|
+
message: string;
|
|
14
|
+
data: CurrencyApiItem[];
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const FALLBACK_CURRENCIES: ComboboxOption[] = [
|
|
18
|
+
{ value: 'BRL', label: 'Real (R$)' },
|
|
19
|
+
{ value: 'USD', label: 'Dólar Americano (US$)' },
|
|
20
|
+
{ value: 'EUR', label: 'Euro (€)' },
|
|
21
|
+
];
|
|
22
|
+
|
|
23
|
+
export async function fetchCurrencyOptions(): Promise<ComboboxOption[]> {
|
|
24
|
+
try {
|
|
25
|
+
const response = await api.apps.get<CurrencyApiResponse>('/accounts/action/currencies');
|
|
26
|
+
|
|
27
|
+
return response.data.map((item) => ({
|
|
28
|
+
value: item.value,
|
|
29
|
+
label: item.title['pt-br'] || item.title['en-us'] || item.value,
|
|
30
|
+
}));
|
|
31
|
+
} catch {
|
|
32
|
+
return FALLBACK_CURRENCIES;
|
|
33
|
+
}
|
|
34
|
+
}
|