@greatapps/common 1.1.609 → 1.1.611
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/modals/cards/AddCardModal.mjs +4 -7
- package/dist/components/modals/cards/AddCardModal.mjs.map +1 -1
- package/dist/components/navigation/CancelledSubscriptionBanner.mjs +2 -3
- package/dist/components/navigation/CancelledSubscriptionBanner.mjs.map +1 -1
- package/dist/components/navigation/SubscriptionBanner.mjs +2 -3
- package/dist/components/navigation/SubscriptionBanner.mjs.map +1 -1
- package/dist/index.mjs +5 -1
- package/dist/index.mjs.map +1 -1
- package/dist/infra/utils/date.mjs +38 -6
- package/dist/infra/utils/date.mjs.map +1 -1
- package/dist/modules/charges/types/charge.type.mjs +3 -2
- package/dist/modules/charges/types/charge.type.mjs.map +1 -1
- package/dist/modules/subscriptions/constants/subscription.constants.mjs +5 -0
- package/dist/modules/subscriptions/constants/subscription.constants.mjs.map +1 -0
- package/dist/modules/subscriptions/types/subscription.type.mjs +5 -4
- package/dist/modules/subscriptions/types/subscription.type.mjs.map +1 -1
- package/dist/modules/subscriptions/utils/has-subscription-expired.mjs +3 -3
- package/dist/modules/subscriptions/utils/has-subscription-expired.mjs.map +1 -1
- package/package.json +1 -1
- package/src/components/modals/cards/AddCardModal.tsx +7 -4
- package/src/components/navigation/CancelledSubscriptionBanner.tsx +2 -3
- package/src/components/navigation/SubscriptionBanner.tsx +2 -3
- package/src/index.ts +2 -1
- package/src/infra/utils/date.ts +39 -5
- package/src/modules/charges/types/charge.type.ts +3 -2
- package/src/modules/subscriptions/constants/subscription.constants.ts +1 -0
- package/src/modules/subscriptions/types/subscription.type.ts +5 -4
- package/src/modules/subscriptions/utils/has-subscription-expired.ts +3 -3
|
@@ -10,7 +10,7 @@ import { useCreateSetupIntent } from "../../../modules/cards/hooks/create-setup-
|
|
|
10
10
|
import { useUpdateAccount } from "../../../modules/accounts/hooks/useAccountManagement";
|
|
11
11
|
import { useExternalContracting } from "../../../providers/whitelabel.provider";
|
|
12
12
|
import { CardFormFields, BillingFormFields, cardFormSchema } from "./CardFormFields";
|
|
13
|
-
import {
|
|
13
|
+
import { IconX, IconCreditCard, IconCheck, IconChevronRight } from "@tabler/icons-react";
|
|
14
14
|
import { cn } from "../../../infra/utils/clsx";
|
|
15
15
|
import { useForm } from "react-hook-form";
|
|
16
16
|
import { zodResolver } from "@hookform/resolvers/zod";
|
|
@@ -36,7 +36,7 @@ function CardStepper({ currentStep }) {
|
|
|
36
36
|
{
|
|
37
37
|
className: cn(
|
|
38
38
|
"flex items-center justify-center size-6 rounded-full paragraph-xsmall-semibold",
|
|
39
|
-
isCompleted && "bg-green-
|
|
39
|
+
isCompleted && "bg-green-50 text-green-600 border border-green-200",
|
|
40
40
|
isCurrent && "bg-primary text-zinc-950",
|
|
41
41
|
isPending && "border border-zinc-200 text-zinc-400"
|
|
42
42
|
),
|
|
@@ -302,17 +302,14 @@ function AddCardModal() {
|
|
|
302
302
|
)
|
|
303
303
|
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
304
304
|
/* @__PURE__ */ jsx(Button, { variant: "secondary", type: "button", onClick: handleBack, className: "h-10!", children: "Voltar" }),
|
|
305
|
-
/* @__PURE__ */
|
|
305
|
+
/* @__PURE__ */ jsx(
|
|
306
306
|
Button,
|
|
307
307
|
{
|
|
308
308
|
type: "submit",
|
|
309
309
|
className: "h-10!",
|
|
310
310
|
disabled: isSubmitting || isAuthenticating || !isCardValid,
|
|
311
311
|
loading: isAuthenticating || isSubmitting,
|
|
312
|
-
children:
|
|
313
|
-
isAuthenticating && /* @__PURE__ */ jsx(IconLoader2, { className: "size-4 animate-spin" }),
|
|
314
|
-
isAuthenticating ? "Autenticando..." : isSubmitting ? "Adicionando cart\xE3o..." : "Adicionar cart\xE3o"
|
|
315
|
-
]
|
|
312
|
+
children: isAuthenticating ? "Autenticando..." : isSubmitting ? "Adicionando cart\xE3o..." : "Adicionar cart\xE3o"
|
|
316
313
|
}
|
|
317
314
|
)
|
|
318
315
|
] }) })
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/modals/cards/AddCardModal.tsx"],"sourcesContent":["'use client';\n\nimport { useCallback, useState } from 'react';\nimport { Dialog, DialogContent, DialogHeader, DialogTitle } from '../../ui/overlay/Dialog';\nimport { Button } from '../../ui/buttons/Button';\nimport { Toast } from '../../ui/feedback/Toast';\nimport { useModalManager } from '../../../store/useModalManager';\nimport { useCreateCard } from '../../../modules/cards/hooks/create-card.hook';\nimport { useCreateSetupIntent } from '../../../modules/cards/hooks/create-setup-intent.hook';\nimport { useUpdateAccount } from '../../../modules/accounts/hooks/useAccountManagement';\nimport { useExternalContracting } from '../../../providers/whitelabel.provider';\nimport { CardFormFields, BillingFormFields, cardFormSchema } from './CardFormFields';\nimport type { CardFormData, StripeElementsStatus } from './CardFormFields';\nimport { IconLoader2, IconX, IconCreditCard, IconCheck, IconChevronRight } from '@tabler/icons-react';\nimport { cn } from '../../../infra/utils/clsx';\nimport { useForm } from 'react-hook-form';\nimport { zodResolver } from '@hookform/resolvers/zod';\nimport { CardNumberElement, useElements, useStripe } from '@stripe/react-stripe-js';\nimport { toast } from 'sonner';\n\nconst INITIAL_STRIPE_STATUS: StripeElementsStatus = {\n cardNumber: false,\n cardExpiry: false,\n cardCvc: false,\n};\n\nconst STEPS = [\n { number: 1, label: 'Cobrança' },\n { number: 2, label: 'Cartão' },\n] as const;\n\nfunction CardStepper({ currentStep }: { readonly currentStep: number }) {\n return (\n <div className=\"flex items-center justify-start gap-2 px-4 py-3 bg-zinc-50 border-b border-zinc-200 lg:border-b-0\">\n {STEPS.map((step, idx) => {\n const isCompleted = currentStep > step.number;\n const isCurrent = currentStep === step.number;\n const isPending = !isCompleted && !isCurrent;\n return (\n <div key={step.number} className=\"flex items-center gap-2\">\n <div\n className={cn(\n 'flex items-center justify-center size-6 rounded-full paragraph-xsmall-semibold',\n isCompleted && 'bg-green-500 text-zinc-950',\n isCurrent && 'bg-primary text-zinc-950',\n isPending && 'border border-zinc-200 text-zinc-400',\n )}\n >\n {isCompleted ? <IconCheck size={14} stroke={3} /> : step.number}\n </div>\n <span\n className={cn(\n 'paragraph-xsmall-semibold',\n (isCompleted || isCurrent) && 'text-zinc-950',\n isPending && 'text-zinc-400',\n )}\n >\n {step.label}\n </span>\n {idx < STEPS.length - 1 && (\n <IconChevronRight size={16} className=\"text-zinc-300 ml-1\" />\n )}\n </div>\n );\n })}\n </div>\n );\n}\n\nexport default function AddCardModal() {\n const { activeModal, modalData, closeModal } = useModalManager();\n const isOpen = activeModal === 'addCardModal';\n const { isExternalContracting, redirectToExternal } = useExternalContracting();\n const [currentStep, setCurrentStep] = useState(1);\n const [stripeStatus, setStripeStatus] = useState<StripeElementsStatus>(INITIAL_STRIPE_STATUS);\n const [stripeErrors, setStripeErrors] = useState<Record<string, string | undefined>>({});\n const [isAuthenticating, setIsAuthenticating] = useState(false);\n\n const onCardAdded = modalData.onCardAdded as ((cardId: string) => void) | undefined;\n\n const createSetupIntentMutation = useCreateSetupIntent();\n const createCardMutation = useCreateCard();\n const updateAccountMutation = useUpdateAccount();\n const elements = useElements();\n const stripe = useStripe();\n\n const form = useForm<CardFormData>({\n resolver: zodResolver(cardFormSchema),\n mode: 'onSubmit',\n reValidateMode: 'onChange',\n defaultValues: {\n country: 'BR',\n personType: 'pf',\n },\n });\n\n const handleClose = useCallback(() => {\n form.reset();\n setCurrentStep(1);\n setStripeStatus(INITIAL_STRIPE_STATUS);\n setStripeErrors({});\n setIsAuthenticating(false);\n closeModal();\n }, [form, closeModal]);\n\n const handleStripeChange = useCallback(\n (field: keyof StripeElementsStatus, complete: boolean) => {\n setStripeStatus((prev) => ({ ...prev, [field]: complete }));\n if (complete) {\n setStripeErrors((prev) => ({ ...prev, [field]: undefined }));\n }\n },\n []\n );\n\n const handleContinue = useCallback(async () => {\n const isValid = await form.trigger([\n 'fullName',\n 'cep',\n 'street',\n 'streetNumber',\n 'neighborhood',\n 'city',\n 'state',\n ]);\n if (!isValid) return;\n setCurrentStep(2);\n }, [form]);\n\n const handleBack = useCallback(() => {\n setCurrentStep(1);\n }, []);\n\n async function handleSubmit(data: CardFormData) {\n const newStripeErrors: Record<string, string | undefined> = {};\n if (!stripeStatus.cardNumber) newStripeErrors.cardNumber = 'Número do cartão é obrigatório';\n if (!stripeStatus.cardExpiry) newStripeErrors.cardExpiry = 'Data de validade é obrigatória';\n if (!stripeStatus.cardCvc) newStripeErrors.cardCvc = 'Código de segurança é obrigatório';\n setStripeErrors(newStripeErrors);\n\n const stripeValid =\n stripeStatus.cardNumber && stripeStatus.cardExpiry && stripeStatus.cardCvc;\n if (!stripeValid) return;\n if (!stripe || !elements) return;\n\n const cardElement = elements.getElement(CardNumberElement);\n if (!cardElement) return;\n\n setIsAuthenticating(true);\n try {\n const intentResult = await createSetupIntentMutation.mutateAsync();\n const intent = intentResult?.data;\n if (!intent?.client_secret || !intent?.setup_intent_id) {\n toast.custom(\n (t) => (\n <Toast\n variant=\"error\"\n message=\"Não foi possível iniciar a autenticação do cartão, tente novamente.\"\n toastId={t}\n />\n ),\n { duration: 5000 }\n );\n return;\n }\n\n const { setupIntent, error } = await stripe.confirmCardSetup(intent.client_secret, {\n payment_method: {\n card: cardElement,\n billing_details: { name: data.name },\n },\n });\n\n if (error) {\n toast.custom(\n (t) => (\n <Toast\n variant=\"error\"\n message={error.message || 'Falha na autenticação do cartão.'}\n toastId={t}\n />\n ),\n { duration: 5000 }\n );\n return;\n }\n\n if (setupIntent?.status !== 'succeeded') {\n toast.custom(\n (t) => (\n <Toast\n variant=\"error\"\n message={`Autenticação não concluída (status: ${setupIntent?.status ?? 'desconhecido'}).`}\n toastId={t}\n />\n ),\n { duration: 5000 }\n );\n return;\n }\n\n const [cardResult] = await Promise.all([\n createCardMutation.mutateAsync({\n setup_intent_id: intent.setup_intent_id,\n name: data.name,\n set_default: true,\n }),\n updateAccountMutation.mutateAsync({\n financial_document_type: data.personType === 'pf' ? 1 : 2,\n financial_document: data.personType === 'pf' ? data.cpf : data.cnpj,\n financial_name: data.fullName,\n zipcode: data.cep,\n address: data.street,\n address_number: data.streetNumber,\n address_complement: data.complement || '',\n neighborhood: data.neighborhood,\n city: data.city,\n state: data.state,\n }),\n ]);\n\n if (cardResult.success && cardResult.data?.id != null) {\n onCardAdded?.(cardResult.data.id.toString());\n }\n\n toast.custom(\n (t) => <Toast variant=\"success\" message=\"Cartão adicionado com sucesso.\" toastId={t} />,\n { duration: 5000 }\n );\n handleClose();\n } catch {\n toast.custom(\n (t) => (\n <Toast\n variant=\"error\"\n message=\"Não foi possível salvar o seu novo cartão, tente novamente.\"\n toastId={t}\n />\n ),\n { duration: 5000 }\n );\n } finally {\n setIsAuthenticating(false);\n }\n }\n\n const isSubmitting =\n createCardMutation.isPending ||\n updateAccountMutation.isPending ||\n form.formState.isSubmitting;\n\n const watchedValues = form.watch(['name', 'country', 'personType', 'cpf', 'cnpj', 'fullName', 'cep', 'street', 'streetNumber', 'neighborhood', 'city', 'state']);\n const [name, country, personType, cpf, cnpj, fullName, cep, street, streetNumber, neighborhood, city, state] = watchedValues;\n const isBillingValid =\n !!fullName &&\n !!cep && cep.length >= 9 &&\n !!street &&\n !!streetNumber &&\n !!neighborhood &&\n !!city &&\n !!state;\n const isCardValid =\n !!name &&\n !!country &&\n !!personType &&\n (personType === 'pf' ? !!cpf && cpf.length >= 14 : !!cnpj && cnpj.length >= 18) &&\n stripeStatus.cardNumber &&\n stripeStatus.cardExpiry &&\n stripeStatus.cardCvc;\n\n if (isExternalContracting) {\n return (\n <Dialog open={isOpen} onOpenChange={handleClose}>\n <DialogContent className=\"flex flex-col p-0 gap-0 w-full md:w-[410px] lg:w-[410px]\">\n <DialogHeader className=\"gap-3 text-left p-5\">\n <div className=\"flex items-center justify-center w-10 h-10 bg-zinc-50 rounded-lg\">\n <IconCreditCard size={24} className=\"text-zinc-950\" />\n </div>\n <div className=\"flex flex-col gap-2\">\n <DialogTitle className=\"paragraph-medium-semibold text-zinc-950\">\n Gerenciamento de cartões indisponível\n </DialogTitle>\n <span className=\"paragraph-small-regular text-zinc-600\">\n Acesse sua área de assinatura para gerenciar formas de pagamento.\n </span>\n </div>\n </DialogHeader>\n <div className=\"flex items-center gap-2 p-5 border-t border-zinc-200\">\n <Button\n className=\"w-fit h-10!\"\n onClick={() => {\n handleClose();\n redirectToExternal('contracting');\n }}\n >\n Acessar área de assinatura\n </Button>\n </div>\n </DialogContent>\n </Dialog>\n );\n }\n\n return (\n <Dialog open={isOpen} onOpenChange={handleClose}>\n <DialogContent\n showCloseButton={false}\n className=\"flex flex-col p-0 gap-0 max-w-full sm:max-w-full border-0 rounded-t-2xl rounded-b-none h-dvh top-0 bottom-0 left-0 right-0 translate-x-0 translate-y-0 lg:max-w-[502px] lg:h-auto lg:max-h-[90vh] lg:rounded-lg lg:border lg:top-[50%] lg:left-[50%] lg:right-auto lg:bottom-auto lg:translate-x-[-50%] lg:translate-y-[-50%] overflow-y-auto\"\n >\n <DialogHeader className=\"p-0\">\n <div className=\"flex items-center justify-center px-4 py-3 relative border-b border-zinc-200 lg:border-b-0\">\n <DialogTitle className=\"paragraph-medium-semibold text-zinc-950 text-center\">\n Adicionar cartão\n </DialogTitle>\n <Button\n type=\"button\"\n variant=\"ghost\"\n className=\"size-8! p-0 absolute right-4\"\n onClick={handleClose}\n >\n <IconX size={18} />\n </Button>\n </div>\n </DialogHeader>\n\n <CardStepper currentStep={currentStep} />\n\n <form\n onSubmit={form.handleSubmit(handleSubmit)}\n className=\"flex flex-col flex-1 lg:flex-none\"\n >\n <div className={`flex flex-col gap-6 lg:gap-8 p-4 lg:p-5 flex-1 lg:flex-none ${currentStep !== 1 ? 'hidden' : ''}`}>\n <h2 className=\"font-[family-name:var(--font-outfit)] text-[18px] leading-tight font-semibold text-zinc-950\">\n Adicione suas informações de cobrança\n </h2>\n <BillingFormFields form={form} />\n </div>\n <div className={`flex flex-col gap-6 lg:gap-8 p-4 lg:p-5 flex-1 lg:flex-none ${currentStep !== 2 ? 'hidden' : ''}`}>\n <h2 className=\"font-[family-name:var(--font-outfit)] text-[18px] leading-tight font-semibold text-zinc-950\">\n Adicione informações do seu cartão\n </h2>\n <CardFormFields\n form={form}\n onStripeChange={handleStripeChange}\n stripeErrors={stripeErrors}\n />\n </div>\n\n <div className=\"flex justify-between items-center p-4 lg:p-5 border-t border-zinc-200 gap-2 mt-auto lg:mt-0\">\n {currentStep === 1 ? (\n <>\n <Button variant=\"secondary\" type=\"button\" onClick={handleClose} className=\"h-10!\">\n Cancelar\n </Button>\n <Button\n type=\"button\"\n className=\"h-10!\"\n onClick={handleContinue}\n disabled={!isBillingValid}\n >\n Continuar\n </Button>\n </>\n ) : (\n <>\n <Button variant=\"secondary\" type=\"button\" onClick={handleBack} className=\"h-10!\">\n Voltar\n </Button>\n <Button\n type=\"submit\"\n className=\"h-10!\"\n disabled={isSubmitting || isAuthenticating || !isCardValid}\n loading={isAuthenticating || isSubmitting}\n >\n {isAuthenticating && <IconLoader2 className=\"size-4 animate-spin\" />}\n {isAuthenticating\n ? 'Autenticando...'\n : isSubmitting\n ? 'Adicionando cartão...'\n : 'Adicionar cartão'}\n </Button>\n </>\n )}\n </div>\n </form>\n </DialogContent>\n </Dialog>\n );\n}\n"],"mappings":";AAuCU,SAuTI,UA9Se,KATnB;AArCV,SAAS,aAAa,gBAAgB;AACtC,SAAS,QAAQ,eAAe,cAAc,mBAAmB;AACjE,SAAS,cAAc;AACvB,SAAS,aAAa;AACtB,SAAS,uBAAuB;AAChC,SAAS,qBAAqB;AAC9B,SAAS,4BAA4B;AACrC,SAAS,wBAAwB;AACjC,SAAS,8BAA8B;AACvC,SAAS,gBAAgB,mBAAmB,sBAAsB;AAElE,SAAS,aAAa,OAAO,gBAAgB,WAAW,wBAAwB;AAChF,SAAS,UAAU;AACnB,SAAS,eAAe;AACxB,SAAS,mBAAmB;AAC5B,SAAS,mBAAmB,aAAa,iBAAiB;AAC1D,SAAS,aAAa;AAEtB,MAAM,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G,oBACA,eACE,6BACA;AAAA;AAAA;AAAA,gBACR;AAAA,iBACF,GAEJ;AAAA;AAAA;AAAA,QACF;AAAA;AAAA;AAAA,EACF,GACF;AAEJ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/modals/cards/AddCardModal.tsx"],"sourcesContent":["'use client';\n\nimport { useCallback, useState } from 'react';\nimport { Dialog, DialogContent, DialogHeader, DialogTitle } from '../../ui/overlay/Dialog';\nimport { Button } from '../../ui/buttons/Button';\nimport { Toast } from '../../ui/feedback/Toast';\nimport { useModalManager } from '../../../store/useModalManager';\nimport { useCreateCard } from '../../../modules/cards/hooks/create-card.hook';\nimport { useCreateSetupIntent } from '../../../modules/cards/hooks/create-setup-intent.hook';\nimport { useUpdateAccount } from '../../../modules/accounts/hooks/useAccountManagement';\nimport { useExternalContracting } from '../../../providers/whitelabel.provider';\nimport { CardFormFields, BillingFormFields, cardFormSchema } from './CardFormFields';\nimport type { CardFormData, StripeElementsStatus } from './CardFormFields';\nimport { IconX, IconCreditCard, IconCheck, IconChevronRight } from '@tabler/icons-react';\nimport { cn } from '../../../infra/utils/clsx';\nimport { useForm } from 'react-hook-form';\nimport { zodResolver } from '@hookform/resolvers/zod';\nimport { CardNumberElement, useElements, useStripe } from '@stripe/react-stripe-js';\nimport { toast } from 'sonner';\n\nconst INITIAL_STRIPE_STATUS: StripeElementsStatus = {\n cardNumber: false,\n cardExpiry: false,\n cardCvc: false,\n};\n\nconst STEPS = [\n { number: 1, label: 'Cobrança' },\n { number: 2, label: 'Cartão' },\n] as const;\n\nfunction CardStepper({ currentStep }: { readonly currentStep: number }) {\n return (\n <div className=\"flex items-center justify-start gap-2 px-4 py-3 bg-zinc-50 border-b border-zinc-200 lg:border-b-0\">\n {STEPS.map((step, idx) => {\n const isCompleted = currentStep > step.number;\n const isCurrent = currentStep === step.number;\n const isPending = !isCompleted && !isCurrent;\n return (\n <div key={step.number} className=\"flex items-center gap-2\">\n <div\n className={cn(\n 'flex items-center justify-center size-6 rounded-full paragraph-xsmall-semibold',\n isCompleted && 'bg-green-50 text-green-600 border border-green-200',\n isCurrent && 'bg-primary text-zinc-950',\n isPending && 'border border-zinc-200 text-zinc-400',\n )}\n >\n {isCompleted ? (\n <IconCheck size={14} stroke={3} />\n ) : (\n step.number\n )}\n </div>\n <span\n className={cn(\n 'paragraph-xsmall-semibold',\n (isCompleted || isCurrent) && 'text-zinc-950',\n isPending && 'text-zinc-400',\n )}\n >\n {step.label}\n </span>\n {idx < STEPS.length - 1 && (\n <IconChevronRight size={16} className=\"text-zinc-300 ml-1\" />\n )}\n </div>\n );\n })}\n </div>\n );\n}\n\nexport default function AddCardModal() {\n const { activeModal, modalData, closeModal } = useModalManager();\n const isOpen = activeModal === 'addCardModal';\n const { isExternalContracting, redirectToExternal } = useExternalContracting();\n const [currentStep, setCurrentStep] = useState(1);\n const [stripeStatus, setStripeStatus] = useState<StripeElementsStatus>(INITIAL_STRIPE_STATUS);\n const [stripeErrors, setStripeErrors] = useState<Record<string, string | undefined>>({});\n const [isAuthenticating, setIsAuthenticating] = useState(false);\n\n const onCardAdded = modalData.onCardAdded as ((cardId: string) => void) | undefined;\n\n const createSetupIntentMutation = useCreateSetupIntent();\n const createCardMutation = useCreateCard();\n const updateAccountMutation = useUpdateAccount();\n const elements = useElements();\n const stripe = useStripe();\n\n const form = useForm<CardFormData>({\n resolver: zodResolver(cardFormSchema),\n mode: 'onSubmit',\n reValidateMode: 'onChange',\n defaultValues: {\n country: 'BR',\n personType: 'pf',\n },\n });\n\n const handleClose = useCallback(() => {\n form.reset();\n setCurrentStep(1);\n setStripeStatus(INITIAL_STRIPE_STATUS);\n setStripeErrors({});\n setIsAuthenticating(false);\n closeModal();\n }, [form, closeModal]);\n\n const handleStripeChange = useCallback(\n (field: keyof StripeElementsStatus, complete: boolean) => {\n setStripeStatus((prev) => ({ ...prev, [field]: complete }));\n if (complete) {\n setStripeErrors((prev) => ({ ...prev, [field]: undefined }));\n }\n },\n []\n );\n\n const handleContinue = useCallback(async () => {\n const isValid = await form.trigger([\n 'fullName',\n 'cep',\n 'street',\n 'streetNumber',\n 'neighborhood',\n 'city',\n 'state',\n ]);\n if (!isValid) return;\n setCurrentStep(2);\n }, [form]);\n\n const handleBack = useCallback(() => {\n setCurrentStep(1);\n }, []);\n\n async function handleSubmit(data: CardFormData) {\n const newStripeErrors: Record<string, string | undefined> = {};\n if (!stripeStatus.cardNumber) newStripeErrors.cardNumber = 'Número do cartão é obrigatório';\n if (!stripeStatus.cardExpiry) newStripeErrors.cardExpiry = 'Data de validade é obrigatória';\n if (!stripeStatus.cardCvc) newStripeErrors.cardCvc = 'Código de segurança é obrigatório';\n setStripeErrors(newStripeErrors);\n\n const stripeValid =\n stripeStatus.cardNumber && stripeStatus.cardExpiry && stripeStatus.cardCvc;\n if (!stripeValid) return;\n if (!stripe || !elements) return;\n\n const cardElement = elements.getElement(CardNumberElement);\n if (!cardElement) return;\n\n setIsAuthenticating(true);\n try {\n const intentResult = await createSetupIntentMutation.mutateAsync();\n const intent = intentResult?.data;\n if (!intent?.client_secret || !intent?.setup_intent_id) {\n toast.custom(\n (t) => (\n <Toast\n variant=\"error\"\n message=\"Não foi possível iniciar a autenticação do cartão, tente novamente.\"\n toastId={t}\n />\n ),\n { duration: 5000 }\n );\n return;\n }\n\n const { setupIntent, error } = await stripe.confirmCardSetup(intent.client_secret, {\n payment_method: {\n card: cardElement,\n billing_details: { name: data.name },\n },\n });\n\n if (error) {\n toast.custom(\n (t) => (\n <Toast\n variant=\"error\"\n message={error.message || 'Falha na autenticação do cartão.'}\n toastId={t}\n />\n ),\n { duration: 5000 }\n );\n return;\n }\n\n if (setupIntent?.status !== 'succeeded') {\n toast.custom(\n (t) => (\n <Toast\n variant=\"error\"\n message={`Autenticação não concluída (status: ${setupIntent?.status ?? 'desconhecido'}).`}\n toastId={t}\n />\n ),\n { duration: 5000 }\n );\n return;\n }\n\n const [cardResult] = await Promise.all([\n createCardMutation.mutateAsync({\n setup_intent_id: intent.setup_intent_id,\n name: data.name,\n set_default: true,\n }),\n updateAccountMutation.mutateAsync({\n financial_document_type: data.personType === 'pf' ? 1 : 2,\n financial_document: data.personType === 'pf' ? data.cpf : data.cnpj,\n financial_name: data.fullName,\n zipcode: data.cep,\n address: data.street,\n address_number: data.streetNumber,\n address_complement: data.complement || '',\n neighborhood: data.neighborhood,\n city: data.city,\n state: data.state,\n }),\n ]);\n\n if (cardResult.success && cardResult.data?.id != null) {\n onCardAdded?.(cardResult.data.id.toString());\n }\n\n toast.custom(\n (t) => <Toast variant=\"success\" message=\"Cartão adicionado com sucesso.\" toastId={t} />,\n { duration: 5000 }\n );\n handleClose();\n } catch {\n toast.custom(\n (t) => (\n <Toast\n variant=\"error\"\n message=\"Não foi possível salvar o seu novo cartão, tente novamente.\"\n toastId={t}\n />\n ),\n { duration: 5000 }\n );\n } finally {\n setIsAuthenticating(false);\n }\n }\n\n const isSubmitting =\n createCardMutation.isPending ||\n updateAccountMutation.isPending ||\n form.formState.isSubmitting;\n\n const watchedValues = form.watch(['name', 'country', 'personType', 'cpf', 'cnpj', 'fullName', 'cep', 'street', 'streetNumber', 'neighborhood', 'city', 'state']);\n const [name, country, personType, cpf, cnpj, fullName, cep, street, streetNumber, neighborhood, city, state] = watchedValues;\n const isBillingValid =\n !!fullName &&\n !!cep && cep.length >= 9 &&\n !!street &&\n !!streetNumber &&\n !!neighborhood &&\n !!city &&\n !!state;\n const isCardValid =\n !!name &&\n !!country &&\n !!personType &&\n (personType === 'pf' ? !!cpf && cpf.length >= 14 : !!cnpj && cnpj.length >= 18) &&\n stripeStatus.cardNumber &&\n stripeStatus.cardExpiry &&\n stripeStatus.cardCvc;\n\n if (isExternalContracting) {\n return (\n <Dialog open={isOpen} onOpenChange={handleClose}>\n <DialogContent className=\"flex flex-col p-0 gap-0 w-full md:w-[410px] lg:w-[410px]\">\n <DialogHeader className=\"gap-3 text-left p-5\">\n <div className=\"flex items-center justify-center w-10 h-10 bg-zinc-50 rounded-lg\">\n <IconCreditCard size={24} className=\"text-zinc-950\" />\n </div>\n <div className=\"flex flex-col gap-2\">\n <DialogTitle className=\"paragraph-medium-semibold text-zinc-950\">\n Gerenciamento de cartões indisponível\n </DialogTitle>\n <span className=\"paragraph-small-regular text-zinc-600\">\n Acesse sua área de assinatura para gerenciar formas de pagamento.\n </span>\n </div>\n </DialogHeader>\n <div className=\"flex items-center gap-2 p-5 border-t border-zinc-200\">\n <Button\n className=\"w-fit h-10!\"\n onClick={() => {\n handleClose();\n redirectToExternal('contracting');\n }}\n >\n Acessar área de assinatura\n </Button>\n </div>\n </DialogContent>\n </Dialog>\n );\n }\n\n return (\n <Dialog open={isOpen} onOpenChange={handleClose}>\n <DialogContent\n showCloseButton={false}\n className=\"flex flex-col p-0 gap-0 max-w-full sm:max-w-full border-0 rounded-t-2xl rounded-b-none h-dvh top-0 bottom-0 left-0 right-0 translate-x-0 translate-y-0 lg:max-w-[502px] lg:h-auto lg:max-h-[90vh] lg:rounded-lg lg:border lg:top-[50%] lg:left-[50%] lg:right-auto lg:bottom-auto lg:translate-x-[-50%] lg:translate-y-[-50%] overflow-y-auto\"\n >\n <DialogHeader className=\"p-0\">\n <div className=\"flex items-center justify-center px-4 py-3 relative border-b border-zinc-200 lg:border-b-0\">\n <DialogTitle className=\"paragraph-medium-semibold text-zinc-950 text-center\">\n Adicionar cartão\n </DialogTitle>\n <Button\n type=\"button\"\n variant=\"ghost\"\n className=\"size-8! p-0 absolute right-4\"\n onClick={handleClose}\n >\n <IconX size={18} />\n </Button>\n </div>\n </DialogHeader>\n\n <CardStepper currentStep={currentStep} />\n\n <form\n onSubmit={form.handleSubmit(handleSubmit)}\n className=\"flex flex-col flex-1 lg:flex-none\"\n >\n <div className={`flex flex-col gap-6 lg:gap-8 p-4 lg:p-5 flex-1 lg:flex-none ${currentStep !== 1 ? 'hidden' : ''}`}>\n <h2 className=\"font-[family-name:var(--font-outfit)] text-[18px] leading-tight font-semibold text-zinc-950\">\n Adicione suas informações de cobrança\n </h2>\n <BillingFormFields form={form} />\n </div>\n <div className={`flex flex-col gap-6 lg:gap-8 p-4 lg:p-5 flex-1 lg:flex-none ${currentStep !== 2 ? 'hidden' : ''}`}>\n <h2 className=\"font-[family-name:var(--font-outfit)] text-[18px] leading-tight font-semibold text-zinc-950\">\n Adicione informações do seu cartão\n </h2>\n <CardFormFields\n form={form}\n onStripeChange={handleStripeChange}\n stripeErrors={stripeErrors}\n />\n </div>\n\n <div className=\"flex justify-between items-center p-4 lg:p-5 border-t border-zinc-200 gap-2 mt-auto lg:mt-0\">\n {currentStep === 1 ? (\n <>\n <Button variant=\"secondary\" type=\"button\" onClick={handleClose} className=\"h-10!\">\n Cancelar\n </Button>\n <Button\n type=\"button\"\n className=\"h-10!\"\n onClick={handleContinue}\n disabled={!isBillingValid}\n >\n Continuar\n </Button>\n </>\n ) : (\n <>\n <Button variant=\"secondary\" type=\"button\" onClick={handleBack} className=\"h-10!\">\n Voltar\n </Button>\n <Button\n type=\"submit\"\n className=\"h-10!\"\n disabled={isSubmitting || isAuthenticating || !isCardValid}\n loading={isAuthenticating || isSubmitting}\n >\n {isAuthenticating\n ? 'Autenticando...'\n : isSubmitting\n ? 'Adicionando cartão...'\n : 'Adicionar cartão'}\n </Button>\n </>\n )}\n </div>\n </form>\n </DialogContent>\n </Dialog>\n );\n}\n"],"mappings":";AAuCU,SA2TI,UAjTE,KAVN;AArCV,SAAS,aAAa,gBAAgB;AACtC,SAAS,QAAQ,eAAe,cAAc,mBAAmB;AACjE,SAAS,cAAc;AACvB,SAAS,aAAa;AACtB,SAAS,uBAAuB;AAChC,SAAS,qBAAqB;AAC9B,SAAS,4BAA4B;AACrC,SAAS,wBAAwB;AACjC,SAAS,8BAA8B;AACvC,SAAS,gBAAgB,mBAAmB,sBAAsB;AAElE,SAAS,OAAO,gBAAgB,WAAW,wBAAwB;AACnE,SAAS,UAAU;AACnB,SAAS,eAAe;AACxB,SAAS,mBAAmB;AAC5B,SAAS,mBAAmB,aAAa,iBAA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AAAA;AAAA,gBACR;AAAA,iBACF,GAEJ;AAAA;AAAA;AAAA,QACF;AAAA;AAAA;AAAA,EACF,GACF;AAEJ;","names":[]}
|
|
@@ -18,9 +18,8 @@ function CancelledSubscriptionBanner({ onReactivate }) {
|
|
|
18
18
|
if (subscription.type === "free" || subscription.type === "trial") return null;
|
|
19
19
|
const dueDate = new Date(subscription.date_due);
|
|
20
20
|
const today = /* @__PURE__ */ new Date();
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
const isPastDue = todayCalendar > dueCalendar;
|
|
21
|
+
const todayCalendar = new Date(today.getFullYear(), today.getMonth(), today.getDate()).getTime();
|
|
22
|
+
const isPastDue = todayCalendar > dueDate.getTime();
|
|
24
23
|
const formattedDate = formatShortDate(dueDate);
|
|
25
24
|
if (!subscription.date_cancellation && !isPastDue) return null;
|
|
26
25
|
return /* @__PURE__ */ jsx("div", { className: "fixed top-[80px] md:top-0 left-0 right-0 z-[60] flex justify-center pointer-events-none px-4 lg:px-0", children: /* @__PURE__ */ jsxs(
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/navigation/CancelledSubscriptionBanner.tsx"],"sourcesContent":["'use client';\n\nimport { useState, useEffect, useCallback } from 'react';\nimport { IconAlertOctagon, IconX } from '@tabler/icons-react';\nimport { formatShortDate } from '../../infra/utils/date';\nimport { useActiveSubscription } from '../../modules/subscriptions/hooks/find-active-subscription.hook';\n\ninterface CancelledSubscriptionBannerProps {\n onReactivate?: () => void;\n}\n\nexport function CancelledSubscriptionBanner({ onReactivate }: CancelledSubscriptionBannerProps) {\n const { data: { data: [subscription] = [] } = {} } = useActiveSubscription();\n const [visible, setVisible] = useState(true);\n const [animated, setAnimated] = useState(false);\n\n useEffect(() => {\n const timer = setTimeout(() => setAnimated(true), 50);\n return () => clearTimeout(timer);\n }, []);\n\n const dismiss = useCallback(() => setVisible(false), []);\n\n if (!visible) return null;\n if (!subscription?.date_due) return null;\n if (subscription.type === 'free' || subscription.type === 'trial') return null;\n\n const dueDate = new Date(subscription.date_due);\n const today = new Date();\n const
|
|
1
|
+
{"version":3,"sources":["../../../src/components/navigation/CancelledSubscriptionBanner.tsx"],"sourcesContent":["'use client';\n\nimport { useState, useEffect, useCallback } from 'react';\nimport { IconAlertOctagon, IconX } from '@tabler/icons-react';\nimport { formatShortDate } from '../../infra/utils/date';\nimport { useActiveSubscription } from '../../modules/subscriptions/hooks/find-active-subscription.hook';\n\ninterface CancelledSubscriptionBannerProps {\n onReactivate?: () => void;\n}\n\nexport function CancelledSubscriptionBanner({ onReactivate }: CancelledSubscriptionBannerProps) {\n const { data: { data: [subscription] = [] } = {} } = useActiveSubscription();\n const [visible, setVisible] = useState(true);\n const [animated, setAnimated] = useState(false);\n\n useEffect(() => {\n const timer = setTimeout(() => setAnimated(true), 50);\n return () => clearTimeout(timer);\n }, []);\n\n const dismiss = useCallback(() => setVisible(false), []);\n\n if (!visible) return null;\n if (!subscription?.date_due) return null;\n if (subscription.type === 'free' || subscription.type === 'trial') return null;\n\n const dueDate = new Date(subscription.date_due);\n const today = new Date();\n const todayCalendar = new Date(today.getFullYear(), today.getMonth(), today.getDate()).getTime();\n const isPastDue = todayCalendar > dueDate.getTime();\n const formattedDate = formatShortDate(dueDate);\n\n if (!subscription.date_cancellation && !isPastDue) return null;\n\n return (\n <div className=\"fixed top-[80px] md:top-0 left-0 right-0 z-[60] flex justify-center pointer-events-none px-4 lg:px-0\">\n <div\n className={`flex flex-col sm:flex-row items-start sm:items-center justify-between bg-red-500 rounded-lg px-3 py-2 sm:py-1 w-full lg:w-[805px] max-w-full pointer-events-auto transition-transform duration-500 ease-out gap-2 sm:gap-0 ${animated ? 'translate-y-0 md:translate-y-9' : '-translate-y-full'}`}\n >\n <div className=\"flex items-center gap-2 flex-1 w-full sm:w-auto\">\n <IconAlertOctagon size={16} className=\"text-white shrink-0\" />\n <span className=\"paragraph-xsmall-semibold text-white\">\n {isPastDue\n ? 'Sua assinatura foi cancelada e suas páginas foram retiradas do ar.'\n : `Assinatura cancelada! Suas páginas serão retiradas do ar no dia ${formattedDate}!`}\n </span>\n </div>\n <div className=\"flex items-center gap-1.5 w-full sm:w-auto justify-between sm:justify-start\">\n <button\n type=\"button\"\n className=\"flex items-center justify-center p-1.5 cursor-pointer\"\n onClick={onReactivate}\n >\n <span className=\"paragraph-xsmall-semibold text-white underline\">\n Escolher um novo plano\n </span>\n </button>\n <button type=\"button\" className=\"cursor-pointer shrink-0\" onClick={dismiss}>\n <IconX size={18} className=\"text-red-200\" />\n </button>\n </div>\n </div>\n </div>\n );\n}\n"],"mappings":";AAwCQ,SACE,KADF;AAtCR,SAAS,UAAU,WAAW,mBAAmB;AACjD,SAAS,kBAAkB,aAAa;AACxC,SAAS,uBAAuB;AAChC,SAAS,6BAA6B;AAM/B,SAAS,4BAA4B,EAAE,aAAa,GAAqC;AAC9F,QAAM,EAAE,MAAM,EAAE,MAAM,CAAC,YAAY,IAAI,CAAC,EAAE,IAAI,CAAC,EAAE,IAAI,sBAAsB;AAC3E,QAAM,CAAC,SAAS,UAAU,IAAI,SAAS,IAAI;AAC3C,QAAM,CAAC,UAAU,WAAW,IAAI,SAAS,KAAK;AAE9C,YAAU,MAAM;AACd,UAAM,QAAQ,WAAW,MAAM,YAAY,IAAI,GAAG,EAAE;AACpD,WAAO,MAAM,aAAa,KAAK;AAAA,EACjC,GAAG,CAAC,CAAC;AAEL,QAAM,UAAU,YAAY,MAAM,WAAW,KAAK,GAAG,CAAC,CAAC;AAEvD,MAAI,CAAC,QAAS,QAAO;AACrB,MAAI,CAAC,cAAc,SAAU,QAAO;AACpC,MAAI,aAAa,SAAS,UAAU,aAAa,SAAS,QAAS,QAAO;AAE1E,QAAM,UAAU,IAAI,KAAK,aAAa,QAAQ;AAC9C,QAAM,QAAQ,oBAAI,KAAK;AACvB,QAAM,gBAAgB,IAAI,KAAK,MAAM,YAAY,GAAG,MAAM,SAAS,GAAG,MAAM,QAAQ,CAAC,EAAE,QAAQ;AAC/F,QAAM,YAAY,gBAAgB,QAAQ,QAAQ;AAClD,QAAM,gBAAgB,gBAAgB,OAAO;AAE7C,MAAI,CAAC,aAAa,qBAAqB,CAAC,UAAW,QAAO;AAE1D,SACE,oBAAC,SAAI,WAAU,wGACb;AAAA,IAAC;AAAA;AAAA,MACC,WAAW,8NAA8N,WAAW,mCAAmC,mBAAmB;AAAA,MAE1S;AAAA,6BAAC,SAAI,WAAU,mDACb;AAAA,8BAAC,oBAAiB,MAAM,IAAI,WAAU,uBAAsB;AAAA,UAC5D,oBAAC,UAAK,WAAU,wCACb,sBACG,0EACA,yEAAmE,aAAa,KACtF;AAAA,WACF;AAAA,QACA,qBAAC,SAAI,WAAU,+EACb;AAAA;AAAA,YAAC;AAAA;AAAA,cACC,MAAK;AAAA,cACL,WAAU;AAAA,cACV,SAAS;AAAA,cAET,8BAAC,UAAK,WAAU,kDAAiD,oCAEjE;AAAA;AAAA,UACF;AAAA,UACA,oBAAC,YAAO,MAAK,UAAS,WAAU,2BAA0B,SAAS,SACjE,8BAAC,SAAM,MAAM,IAAI,WAAU,gBAAe,GAC5C;AAAA,WACF;AAAA;AAAA;AAAA,EACF,GACF;AAEJ;","names":[]}
|
|
@@ -16,9 +16,8 @@ function SubscriptionBanner({
|
|
|
16
16
|
if (!isCancellable) return null;
|
|
17
17
|
const dueDate = new Date(subscription.date_due);
|
|
18
18
|
const today = /* @__PURE__ */ new Date();
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
const isPastDue = todayCalendar > dueCalendar;
|
|
19
|
+
const todayCalendar = new Date(today.getFullYear(), today.getMonth(), today.getDate()).getTime();
|
|
20
|
+
const isPastDue = todayCalendar > dueDate.getTime();
|
|
22
21
|
if (!subscription.date_cancellation && !isPastDue) return null;
|
|
23
22
|
return /* @__PURE__ */ jsx(CancelledSubscriptionBanner, { onReactivate });
|
|
24
23
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/navigation/SubscriptionBanner.tsx"],"sourcesContent":["'use client';\n\nimport { useActiveSubscription } from '../../modules/subscriptions/hooks/find-active-subscription.hook';\nimport { OverdueInvoiceBanner } from './OverdueInvoiceBanner';\nimport { CancelledSubscriptionBanner } from './CancelledSubscriptionBanner';\n\ninterface OverdueInfo {\n dueDate: Date | null | undefined;\n}\n\ninterface SubscriptionBannerProps {\n onReactivate?: () => void;\n onOverdueDetails?: () => void;\n overdue?: OverdueInfo | null;\n}\n\nexport function SubscriptionBanner({\n onReactivate,\n onOverdueDetails,\n overdue,\n}: SubscriptionBannerProps) {\n const { data: { data: [subscription] = [] } = {} } = useActiveSubscription();\n\n if (overdue) {\n return <OverdueInvoiceBanner dueDate={overdue.dueDate} onDetails={onOverdueDetails} />;\n }\n\n const isCancellable =\n subscription?.date_due &&\n subscription.type !== 'free' &&\n subscription.type !== 'trial';\n\n if (!isCancellable) return null;\n\n const dueDate = new Date(subscription.date_due!);\n const today = new Date();\n const
|
|
1
|
+
{"version":3,"sources":["../../../src/components/navigation/SubscriptionBanner.tsx"],"sourcesContent":["'use client';\n\nimport { useActiveSubscription } from '../../modules/subscriptions/hooks/find-active-subscription.hook';\nimport { OverdueInvoiceBanner } from './OverdueInvoiceBanner';\nimport { CancelledSubscriptionBanner } from './CancelledSubscriptionBanner';\n\ninterface OverdueInfo {\n dueDate: Date | null | undefined;\n}\n\ninterface SubscriptionBannerProps {\n onReactivate?: () => void;\n onOverdueDetails?: () => void;\n overdue?: OverdueInfo | null;\n}\n\nexport function SubscriptionBanner({\n onReactivate,\n onOverdueDetails,\n overdue,\n}: SubscriptionBannerProps) {\n const { data: { data: [subscription] = [] } = {} } = useActiveSubscription();\n\n if (overdue) {\n return <OverdueInvoiceBanner dueDate={overdue.dueDate} onDetails={onOverdueDetails} />;\n }\n\n const isCancellable =\n subscription?.date_due &&\n subscription.type !== 'free' &&\n subscription.type !== 'trial';\n\n if (!isCancellable) return null;\n\n const dueDate = new Date(subscription.date_due!);\n const today = new Date();\n const todayCalendar = new Date(today.getFullYear(), today.getMonth(), today.getDate()).getTime();\n const isPastDue = todayCalendar > dueDate.getTime();\n\n if (!subscription.date_cancellation && !isPastDue) return null;\n\n return <CancelledSubscriptionBanner onReactivate={onReactivate} />;\n}\n"],"mappings":";AAwBW;AAtBX,SAAS,6BAA6B;AACtC,SAAS,4BAA4B;AACrC,SAAS,mCAAmC;AAYrC,SAAS,mBAAmB;AAAA,EACjC;AAAA,EACA;AAAA,EACA;AACF,GAA4B;AAC1B,QAAM,EAAE,MAAM,EAAE,MAAM,CAAC,YAAY,IAAI,CAAC,EAAE,IAAI,CAAC,EAAE,IAAI,sBAAsB;AAE3E,MAAI,SAAS;AACX,WAAO,oBAAC,wBAAqB,SAAS,QAAQ,SAAS,WAAW,kBAAkB;AAAA,EACtF;AAEA,QAAM,gBACJ,cAAc,YACd,aAAa,SAAS,UACtB,aAAa,SAAS;AAExB,MAAI,CAAC,cAAe,QAAO;AAE3B,QAAM,UAAU,IAAI,KAAK,aAAa,QAAS;AAC/C,QAAM,QAAQ,oBAAI,KAAK;AACvB,QAAM,gBAAgB,IAAI,KAAK,MAAM,YAAY,GAAG,MAAM,SAAS,GAAG,MAAM,QAAQ,CAAC,EAAE,QAAQ;AAC/F,QAAM,YAAY,gBAAgB,QAAQ,QAAQ;AAElD,MAAI,CAAC,aAAa,qBAAqB,CAAC,UAAW,QAAO;AAE1D,SAAO,oBAAC,+BAA4B,cAA4B;AAClE;","names":[]}
|
package/dist/index.mjs
CHANGED
|
@@ -95,6 +95,7 @@ import {
|
|
|
95
95
|
} from "./modules/charges/types/charge.type";
|
|
96
96
|
import { buildPlanExtras } from "./modules/subscriptions/utils/build-plan-extras";
|
|
97
97
|
import { hasSubscriptionExpired } from "./modules/subscriptions/utils/has-subscription-expired";
|
|
98
|
+
import { SUBSCRIPTION_GRACE_PERIOD_DAYS } from "./modules/subscriptions/constants/subscription.constants";
|
|
98
99
|
import {
|
|
99
100
|
useCountPages,
|
|
100
101
|
COUNT_PAGES_QUERY_KEY
|
|
@@ -127,7 +128,7 @@ import { createAuthMiddleware } from "./middlewares/create-auth-middleware";
|
|
|
127
128
|
import { createMiddlewareChain } from "./middlewares/chain";
|
|
128
129
|
import { continueChain, stopChain } from "./middlewares/types";
|
|
129
130
|
import { cn } from "./infra/utils/clsx";
|
|
130
|
-
import { formatShortDate, formatDateTime } from "./infra/utils/date";
|
|
131
|
+
import { formatShortDate, formatDateTime, calendarDateSchema, toCalendarDate } from "./infra/utils/date";
|
|
131
132
|
import { buildQueryParams } from "./infra/utils/params";
|
|
132
133
|
import { parseSchema, parseResult } from "./infra/utils/parser";
|
|
133
134
|
import { withAction } from "./utils/withAction";
|
|
@@ -534,6 +535,7 @@ export {
|
|
|
534
535
|
RadioGroup,
|
|
535
536
|
RadioGroupItem,
|
|
536
537
|
SUBSCRIPTIONS_QUERY_KEY,
|
|
538
|
+
SUBSCRIPTION_GRACE_PERIOD_DAYS,
|
|
537
539
|
ScrollArea,
|
|
538
540
|
ScrollBar,
|
|
539
541
|
SecuritySection,
|
|
@@ -596,6 +598,7 @@ export {
|
|
|
596
598
|
buildPlanExtras,
|
|
597
599
|
buildQueryParams,
|
|
598
600
|
buttonVariants,
|
|
601
|
+
calendarDateSchema,
|
|
599
602
|
cardFormSchema,
|
|
600
603
|
cn,
|
|
601
604
|
compressImage,
|
|
@@ -627,6 +630,7 @@ export {
|
|
|
627
630
|
readFromClipboard,
|
|
628
631
|
showCrisp,
|
|
629
632
|
stopChain,
|
|
633
|
+
toCalendarDate,
|
|
630
634
|
toastIconContainerVariants,
|
|
631
635
|
toastVariants,
|
|
632
636
|
updateCrispUser,
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["// Types\nexport * from \"./modules/auth/schema\";\nexport * from \"./modules/users/schema\";\nexport * from \"./modules/whitelabel/schema\";\n// Style types now come from whitelabel schema directly\nexport * from \"./infra/api/types\";\n\n// Contexts\nexport * from \"./providers/query.provider\";\nexport * from \"./providers/auth.provider\";\nexport * from \"./providers/whitelabel.provider\";\n\n// Hooks\nexport {\n useListProjectUsers,\n LIST_PROJECT_USERS_QUERY_KEY,\n LIST_PROJECT_USERS_BASE_KEY,\n} from \"./modules/projects/hooks/list-project-users.hook\";\nexport {\n useListAvailableUsers,\n LIST_AVAILABLE_USERS_QUERY_KEY,\n LIST_AVAILABLE_USERS_BASE_KEY,\n} from \"./modules/projects/hooks/list-available-users.hook\";\nexport {\n useListAllAccountUsers,\n LIST_ALL_ACCOUNT_USERS_QUERY_KEY,\n LIST_ALL_ACCOUNT_USERS_BASE_KEY,\n} from \"./modules/projects/hooks/list-all-account-users.hook\";\nexport {\n useProjects,\n PROJECTS_BASE_KEY,\n PROJECTS_QUERY_KEY,\n} from \"./modules/projects/hooks/list-projects.hook\";\nexport {\n useInfiniteProjects,\n INFINITE_PROJECTS_QUERY_KEY,\n} from \"./modules/projects/hooks/list-infinite-projects.hook\";\nexport { useProject } from \"./modules/projects/hooks/find-project.hook\";\nexport { useCreateProject } from \"./modules/projects/hooks/create-project.hook\";\nexport { useUpdateProject } from \"./modules/projects/hooks/update-project.hook\";\nexport { useDeleteProject } from \"./modules/projects/hooks/delete-project.hook\";\nexport type {\n Project,\n ProjectsPage,\n CreateProjectRequest,\n UpdateProjectRequest,\n ProjectUser,\n AccountUser,\n AddRemoveProjectUsersParams,\n ListUsersParams,\n UsersPage,\n} from \"./modules/projects/types\";\nexport { ProjectSchema } from \"./modules/projects/types\";\nexport type { ListProjectsActionParams } from \"./modules/projects/actions/list-projects.action\";\nexport {\n useUserQuery,\n useUserValidateSession,\n useInvalidateUser,\n useSetUserData,\n useTwoFactorVerify,\n USER_QUERY_KEY,\n} from \"./modules/auth/hooks/useUserQuery\";\nexport { useManagementPermissions } from \"./modules/auth/hooks/useManagementPermissions\";\nexport type { ManagementPermission } from \"./modules/auth/types/management-permission.type\";\nexport { useSubscriptions } from \"./modules/subscriptions/hooks/list-subscriptions.hook\";\nexport {\n SUBSCRIPTIONS_QUERY_KEY,\n CHARGES_QUERY_KEY,\n} from \"./modules/subscriptions/constants/query-keys.constants\";\nexport { useActiveSubscription } from \"./modules/subscriptions/hooks/find-active-subscription.hook\";\nexport { useCancelledSubscriptionGuard } from \"./modules/subscriptions/hooks/use-cancelled-subscription-guard\";\nexport { usePlanById } from \"./modules/plans/hooks/use-plan-by-id.hook\";\nexport { useHasPlanAddon } from \"./modules/plans/hooks/use-has-plan-addon.hook\";\nexport { useCalculateSubscription } from \"./modules/subscriptions/hooks/calculate-subscription.hook\";\nexport { useUpdateSubscriptionPlan } from \"./modules/subscriptions/hooks/update-subscription-plan.hook\";\nexport { useUpdateSubscriptionPayment } from \"./modules/subscriptions/hooks/update-subscription-payment.hook\";\nexport { useCards, CARDS_QUERY_KEY } from \"./modules/cards/hooks/cards.hook\";\nexport { useCardById } from \"./modules/cards/hooks/card-by-id.hook\";\nexport { useCreateCard } from \"./modules/cards/hooks/create-card.hook\";\nexport { useCreateSetupIntent } from \"./modules/cards/hooks/create-setup-intent.hook\";\nexport { useSetDefaultCard } from \"./modules/cards/hooks/set-default-card.hook\";\nexport { useDeleteCard } from \"./modules/cards/hooks/delete-card.hook\";\nexport { useDeleteConfirmation } from \"./modules/cards/hooks/delete-confirmation.hook\";\nexport type { DeleteConfirmationFormData } from \"./modules/cards/hooks/delete-confirmation.hook\";\nexport { useHandleDeleteCard } from \"./modules/cards/hooks/handle-delete-card.hook\";\nexport { useCharges } from \"./modules/charges/hooks/charges.hook\";\nexport { useChargeById } from \"./modules/charges/hooks/charge-by-id.hook\";\nexport { useChargeAction } from \"./modules/charges/hooks/charge-action.hook\";\nexport { useIaCredits } from \"./modules/ia-credits/hooks/ia-credits.hook\";\nexport type {\n IaCreditsSummary,\n IaCreditOperation,\n} from \"./modules/ia-credits/types\";\nexport type {\n Subscription,\n SubscriptionItem,\n FindSubscriptionsParams,\n} from \"./modules/subscriptions/types/subscription.type\";\nexport {\n SubscriptionSchema,\n SubscriptionItemSchema,\n} from \"./modules/subscriptions/types/subscription.type\";\nexport {\n ADDON_IDS,\n AI_CREDIT_OPTIONS,\n AI_CREDIT_VALUES,\n} from \"./modules/subscriptions/constants/addons.constants\";\nexport type {\n AddonKindEnum,\n AiCreditOption,\n} from \"./modules/subscriptions/constants/addons.constants\";\nexport type {\n Plan,\n PlanItem,\n UiPlan,\n PlanFeature,\n PlanMainFeatures,\n PlanPricingByPeriod,\n PlanTooltips,\n} from \"./modules/plans/types/plan.type\";\nexport { PlanSchema, PlanItemSchema } from \"./modules/plans/types/plan.type\";\nexport { mapApiPlanToUiPlan } from \"./modules/plans/utils/map-api-plan-to-ui\";\nexport type { PlanBillingPeriod } from \"./modules/plans/utils/map-api-plan-to-ui\";\nexport {\n usePlans,\n PLANS_QUERY_KEY,\n} from \"./modules/plans/hooks/list-plans.hook\";\nexport type { BillingPeriod } from \"./modules/subscriptions/types/billing-period.type\";\nexport type {\n CalculateSubscriptionRequest,\n CalculateSubscriptionResponse,\n UpdateSubscriptionPlanRequest,\n} from \"./modules/subscriptions/types/calculate-subscription.type\";\nexport type {\n Card as PaymentCard,\n CreateCardRequest,\n FindCardsParams,\n SetupIntent,\n} from \"./modules/cards/types\";\nexport {\n CardSchema as PaymentCardSchema,\n CreateCardRequestSchema,\n FindCardsParamsSchema,\n SetupIntentSchema,\n} from \"./modules/cards/types\";\nexport type {\n Charge,\n FindChargesParams,\n PayChargeInput,\n} from \"./modules/charges/types/charge.type\";\nexport {\n ChargeSchema,\n FindChargesParamsSchema,\n PayChargeInputSchema,\n} from \"./modules/charges/types/charge.type\";\nexport { buildPlanExtras } from \"./modules/subscriptions/utils/build-plan-extras\";\nexport { hasSubscriptionExpired } from \"./modules/subscriptions/utils/has-subscription-expired\";\nexport {\n useCountPages,\n COUNT_PAGES_QUERY_KEY,\n} from \"./modules/pages/hooks/count-pages.hook\";\nexport { PAGES_QUERY_KEY } from \"./modules/pages/constants/query-keys.constants\";\nexport {\n getPriceFromCalculatedData,\n getOriginalPriceFromCalculatedData,\n periodicityToBillingPeriod,\n} from \"./modules/subscriptions/utils/periodicity\";\nexport { useBuyCreditsModal } from \"./store/useBuyCreditsModal\";\nexport { useCreditsDisabledModal } from \"./store/useCreditsDisabledModal\";\nexport { usePaidPlanRequiredModal } from \"./store/usePaidPlanRequiredModal\";\nexport { default as BuyCreditsModal } from \"./components/modals/BuyCreditsModal\";\nexport { default as CreditsDisabledModal } from \"./components/modals/CreditsDisabledModal\";\nexport { default as PaidPlanRequiredModal } from \"./components/modals/PaidPlanRequiredModal\";\nexport { default as AddCardModal } from \"./components/modals/cards/AddCardModal\";\nexport { DeleteCardModal } from \"./components/modals/cards/DeleteCardModal\";\nexport { CannotDeleteCardModal } from \"./components/modals/cards/CannotDeleteCardModal\";\nexport {\n CardFormFields,\n cardFormSchema,\n} from \"./components/modals/cards/CardFormFields\";\nexport type { CardFormData } from \"./components/modals/cards/CardFormFields\";\nexport { Skeleton } from \"./components/ui/feedback/Skeleton\";\nexport { PaymentInfoCard } from \"./components/ui/data-display/PaymentInfoCard\";\nexport { CardBrandIcon } from \"./components/ui/data-display/CardBrandIcons\";\nexport { CardItem } from \"./components/ui/data-display/CardItem\";\n\n// Providers\nexport { QueryProvider } from \"./providers/query.provider\";\n\n// Middleware\nexport { createAuthMiddleware } from \"./middlewares/create-auth-middleware\";\nexport { createMiddlewareChain } from \"./middlewares/chain\";\nexport { continueChain, stopChain } from \"./middlewares/types\";\nexport type {\n MiddlewareFunction,\n MiddlewareConfig,\n MiddlewareResult,\n} from \"./middlewares/types\";\n\n// Utils\nexport { cn } from \"./infra/utils/clsx\";\nexport { formatShortDate, formatDateTime } from \"./infra/utils/date\";\nexport { buildQueryParams } from \"./infra/utils/params\";\nexport { parseSchema, parseResult } from \"./infra/utils/parser\";\nexport { withAction } from \"./utils/withAction\";\n\n// Layout\nexport {\n MainLayout,\n MainLayoutContent,\n MainLayoutSpacer,\n MainLayoutMain,\n} from \"./components/layouts/MainLayout\";\nexport { NavBar } from \"./components/layouts/NavBar\";\nexport type { NavBarProps } from \"./components/layouts/NavBar\";\nexport { AppNavBar } from \"./components/layouts/AppNavBar\";\nexport type { AppNavBarProps } from \"./components/layouts/AppNavBar\";\nexport { AppMobileNavBar } from \"./components/layouts/AppMobileNavBar\";\nexport type { AppMobileNavBarProps } from \"./components/layouts/AppMobileNavBar\";\nexport { SideBarNavigation } from \"./components/layouts/SideBarNavigation\";\nexport { MdSideBarNavigation } from \"./components/layouts/MdSideBarNavigation\";\nexport { default as NotificationCard } from \"./components/widgets/notifications/NotificationCard\";\nexport type { NotificationCardProps } from \"./components/widgets/notifications/NotificationCard\";\nexport { NotificationsPopover } from \"./components/layouts/NotificationsPopover\";\nexport type { NotificationsPopoverProps } from \"./components/layouts/NotificationsPopover\";\nexport { NotificationPageContent } from \"./components/pages/notifications/Notifications\";\nexport { NotFoundPage } from \"./components/pages/NotFoundPage\";\nexport { UsersSelectorPopover } from \"./components/layouts/UsersSelectorPopover\";\nexport type { UsersSelectorPopoverProps } from \"./components/layouts/UsersSelectorPopover\";\nexport { ProfilePopover } from \"./components/layouts/ProfilePopover\";\nexport type {\n ProfilePopoverProps,\n ProfileMenuItem,\n} from \"./components/layouts/ProfilePopover\";\nexport { default as WhitelabelCodes } from \"./components/layouts/WhitelabelCodes\";\nexport { NavBarItem } from \"./components/layouts/NavBarItem\";\nexport type { NavBarItemProps } from \"./components/layouts/NavBarItem\";\n\n// Navigation\nexport { AppNavigation } from \"./components/navigation/AppNavigation\";\nexport { CancelledSubscriptionBanner } from \"./components/navigation/CancelledSubscriptionBanner\";\nexport { SubscriptionBanner } from \"./components/navigation/SubscriptionBanner\";\nexport { OverdueInvoiceBanner } from \"./components/navigation/OverdueInvoiceBanner\";\nexport type { NavItemConfig } from \"./components/navigation/subcomponents/NavItems\";\nexport { useMobileNavbarSheet } from \"./store/useMobileNavbarSheet\";\n\n// Auth Query Key Utilities\nexport {\n useAuthQueryKey,\n useWlQueryKey,\n useWlId,\n} from \"./hooks/useAuthQueryKey\";\n\n// Hooks\nexport { default as useCopyToClipboard } from \"./hooks/copy-to-clipboard.hook\";\n\n// UI - Buttons\nexport { Button, buttonVariants } from \"./components/ui/buttons/Button\";\nexport { CopyButton } from \"./components/ui/buttons/CopyButton\";\nexport { default as CancelButton } from \"./components/ui/buttons/CancelButton\";\n\n// UI - Data Display\nexport {\n Accordion,\n AccordionItem,\n AccordionTrigger,\n AccordionContent,\n} from \"./components/ui/data-display/Accordion\";\nexport { Badge, badgeVariants } from \"./components/ui/data-display/Badge\";\nexport {\n Card,\n CardHeader,\n CardFooter,\n CardTitle,\n CardAction,\n CardDescription,\n CardContent,\n} from \"./components/ui/data-display/Card\";\nexport {\n Pagination,\n PaginationContent,\n PaginationLink,\n PaginationItem,\n PaginationPrevious,\n PaginationNext,\n PaginationEllipsis,\n} from \"./components/ui/data-display/Pagination\";\nexport { ScrollArea, ScrollBar } from \"./components/ui/data-display/ScrollArea\";\nexport { Separator } from \"./components/ui/data-display/Separator\";\nexport {\n Table,\n TableHeader,\n TableBody,\n TableFooter,\n TableHead,\n TableRow,\n TableCell,\n TableCaption,\n} from \"./components/ui/data-display/Table\";\nexport {\n Tabs,\n TabsList,\n TabsTrigger,\n TabsContent,\n} from \"./components/ui/data-display/Tabs\";\nexport { UserAvatar } from \"./components/ui/data-display/UserAvatar\";\nexport type { UserAvatarProps } from \"./components/ui/data-display/UserAvatar\";\n\n// UI - Feedback\nexport { default as CircularProgress } from \"./components/ui/feedback/CircularProgress\";\nexport { default as DefaultCircularProgress } from \"./components/ui/feedback/DefaultCircularProgress\";\nexport { Progress } from \"./components/ui/feedback/Progress\";\nexport { LoadingOverlay } from \"./components/ui/feedback/LoadingOverlay\";\nexport {\n Toast,\n toastVariants,\n toastIconContainerVariants,\n} from \"./components/ui/feedback/Toast\";\nexport type { ToastProps } from \"./components/ui/feedback/Toast\";\n\n// UI - Form\nexport { Calendar, CalendarDayButton } from \"./components/ui/form/Calendar\";\nexport { Checkbox } from \"./components/ui/form/Checkbox\";\nexport { DatePicker } from \"./components/ui/form/DatePicker\";\nexport { DateRangePicker } from \"./components/ui/form/DateRangePicker\";\nexport { Input } from \"./components/ui/form/Input\";\nexport {\n InputOTP,\n InputOTPGroup,\n InputOTPSlot,\n InputOTPSeparator,\n} from \"./components/ui/form/InputOtp\";\nexport { RadioGroup, RadioGroupItem } from \"./components/ui/form/RadioGroup\";\nexport {\n Select,\n SelectContent,\n SelectGroup,\n SelectItem,\n SelectLabel,\n SelectScrollDownButton,\n SelectScrollUpButton,\n SelectSeparator,\n SelectTrigger,\n SelectValue,\n} from \"./components/ui/form/Select\";\nexport { Switch } from \"./components/ui/form/Switch\";\nexport { Textarea } from \"./components/ui/form/Textarea\";\n\n// UI - Overlay\nexport {\n Command,\n CommandDialog,\n CommandInput,\n CommandList,\n CommandEmpty,\n CommandGroup,\n CommandItem,\n CommandShortcut,\n CommandSeparator,\n} from \"./components/ui/overlay/Command\";\nexport {\n Dialog,\n DialogClose,\n DialogContent,\n DialogDescription,\n DialogFooter,\n DialogHeader,\n DialogOverlay,\n DialogPortal,\n DialogTitle,\n DialogTrigger,\n} from \"./components/ui/overlay/Dialog\";\nexport {\n Popover,\n PopoverTrigger,\n PopoverContent,\n PopoverAnchor,\n} from \"./components/ui/overlay/Popover\";\nexport {\n Sheet,\n SheetTrigger,\n SheetClose,\n SheetContent,\n SheetHeader,\n SheetFooter,\n SheetTitle,\n SheetDescription,\n} from \"./components/ui/overlay/Sheet\";\nexport {\n Tooltip,\n TooltipTrigger,\n TooltipContent,\n TooltipProvider,\n} from \"./components/ui/overlay/Tooltip\";\n\n// Embeds\nexport { FrillEmbed } from \"./components/embeds/FrillEmbed\";\nexport {\n CrispEmbed,\n openCrispHelpdesk,\n hideCrisp,\n showCrisp,\n updateCrispUser,\n} from \"./components/embeds/CrispEmbed\";\nexport { EmbedWidgets } from \"./components/embeds/EmbedWidgets\";\nexport { ClarityEmbed } from \"./components/embeds/ClarityEmbed\";\n\n// Store\nexport { useMdSidebarStore } from \"./store/useMdSidebarStore\";\nexport { useDesktopSidebarStore } from \"./store/useDesktopSidebarStore\";\nexport { useModalManager } from \"./store/useModalManager\";\nexport type { ModalData } from \"./store/useModalManager\";\n\n// Enums\nexport { AccountSectionType } from \"./enums/AccountSectionType\";\n\n// Hooks\nexport { default as usePasswordVisibility } from \"./hooks/usePasswordVisibility\";\nexport { default as useCountdownTimer } from \"./hooks/useCountdownTimer\";\nexport { default as useIsMobile } from \"./hooks/useIsMobile\";\nexport { useDebounce } from \"./hooks/useDebounce\";\nexport { useDebouncedEffect } from \"./hooks/useDebouncedEffect\";\nexport { useDebounceState } from \"./hooks/useDebounceState\";\n\n// Utils\nexport {\n formatPhone,\n formatTimer,\n formatFullName,\n formatCPF,\n formatCNPJ,\n formatCardNumber,\n} from \"./utils/format/masks\";\nexport { formatCurrencyNumber } from \"./utils/format/currency\";\nexport { BR_STATE_OPTIONS } from \"./utils/constants/br-states\";\nexport type { TimezoneOption } from \"./modules/accounts/services/timezone.service\";\nexport {\n buildLocaleOptions,\n LANGUAGE_OPTIONS as LOCALE_LANGUAGE_OPTIONS,\n} from \"./utils/intl/locales\";\nexport type { LocaleOption } from \"./utils/intl/locales\";\nexport { copyToClipboard, readFromClipboard } from \"./utils/browser/clipboard\";\n\n// UI - Form (new widgets)\nexport { FormField } from \"./components/ui/form/FormField\";\nexport { SelectField } from \"./components/ui/form/SelectField\";\nexport { ComboboxField } from \"./components/ui/form/ComboboxField\";\nexport type { ComboboxOption } from \"./components/ui/form/ComboboxField\";\nexport { default as PhoneInput } from \"./components/ui/form/PhoneInput\";\nexport { default as SwitchOptionFieldWithIcon } from \"./components/ui/form/SwitchOptionFieldWithIcon\";\nexport { TextAreaField } from \"./components/ui/form/TextAreaField\";\n\n// Account Module - Hooks\nexport {\n useCurrentAccount,\n ACCOUNT_QUERY_KEY,\n} from \"./modules/accounts/hooks/current-account.hook\";\nexport {\n useUpdateAccount,\n useUpdateAccountUser,\n useUpdateAccountUserById,\n useDeleteAccountUser,\n useDeleteAccount,\n ACCOUNT_USERS_QUERY_KEY,\n} from \"./modules/accounts/hooks/useAccountManagement\";\nexport { useViaCep } from \"./modules/accounts/hooks/useViaCep\";\nexport { useAccountToken } from \"./modules/accounts/hooks/use-account-token.hook\";\n\n// Account Types\nexport type {\n UpdateAccountRequest,\n UpdateAccountUserRequest,\n ChangePasswordRequest,\n DeleteAccountActionResult,\n DeleteUserActionResult,\n UpdateAccountActionResult,\n UpdateUserActionResult,\n TwoFactorGenerateResult,\n TwoFactorActionResult,\n ContactResetResult,\n} from \"./modules/accounts/types\";\n\nexport { default as AccountModals } from \"./components/account/AccountModals\";\nexport { useAccountModals } from \"./store/useAccountModals\";\nexport type { AccountModalsConfig } from \"./store/useAccountModals\";\n\nexport { ModalManager } from \"./components/modals/ModalManager\";\nexport { Modals } from \"./components/modals/Modals\";\n\nexport { default as TwoFactorAuthModal } from \"./components/account/TwoFactorAuthModal\";\nexport { default as DisableTwoFactorAuthModal } from \"./components/account/DisableTwoFactorAuthModal\";\nexport { default as ConfirmGlobalPreferencesModal } from \"./components/account/ConfirmGlobalPreferencesModal\";\nexport { MyProfileSection } from \"./components/account/sections/MyProfileSection\";\nexport { PreferencesSection } from \"./components/account/sections/PreferencesSection\";\nexport { SecuritySection } from \"./components/account/sections/SecuritySection\";\nexport { ChangePasswordSection } from \"./components/account/sections/ChangePasswordSection\";\nexport { ChangeEmailModal } from \"./components/account/sections/ChangeEmailModal\";\nexport { ChangePhoneModal } from \"./components/account/sections/ChangePhoneModal\";\n\n// Account Constants\nexport {\n GENDER_OPTIONS,\n CURRENCY_OPTIONS,\n TIME_FORMAT_OPTIONS,\n NOTIFICATION_TYPES,\n LANGUAGE_OPTIONS,\n} from \"./components/account/constants\";\n\n// Image Upload\nexport {\n ImageUpload,\n ImageCropModal,\n ImageTooSmallModal,\n} from \"./components/widgets/ImageUpload\";\nexport {\n useImageUpload,\n type ImageTooSmallError,\n} from \"./modules/images/hooks/use-image-upload.hook\";\nexport {\n ACCEPTED_IMAGE_FORMATS,\n ACCEPTED_IMAGE_FORMATS_STRING,\n MAX_FILE_SIZE_MB,\n} from \"./modules/images/constants/image.constants\";\nexport type {\n ImageConfig,\n CropArea,\n ProcessedImage,\n CompressImageOptions,\n} from \"./modules/images/types/image.type\";\nexport { compressImage } from \"./modules/images/utils/compress-image\";\nexport { cropImageToCanvas } from \"./modules/images/utils/crop-image\";\nexport { base64ToFile, fileToBase64 } from \"./modules/images/utils/base64\";\nexport {\n validateImage,\n validateImageFormat,\n validateImageSize,\n getImageDimensions,\n} from \"./modules/images/utils/validate-image\";\n"],"mappings":"AACA,cAAc;AACd,cAAc;AACd,cAAc;AAEd,cAAc;AAGd,cAAc;AACd,cAAc;AACd,cAAc;AAGd;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,kBAAkB;AAC3B,SAAS,wBAAwB;AACjC,SAAS,wBAAwB;AACjC,SAAS,wBAAwB;AAYjC,SAAS,qBAAqB;AAE9B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,gCAAgC;AAEzC,SAAS,wBAAwB;AACjC;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,6BAA6B;AACtC,SAAS,qCAAqC;AAC9C,SAAS,mBAAmB;AAC5B,SAAS,uBAAuB;AAChC,SAAS,gCAAgC;AACzC,SAAS,iCAAiC;AAC1C,SAAS,oCAAoC;AAC7C,SAAS,UAAU,uBAAuB;AAC1C,SAAS,mBAAmB;AAC5B,SAAS,qBAAqB;AAC9B,SAAS,4BAA4B;AACrC,SAAS,yBAA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BAAwB;AAEjC;AAAA,EACE;AAAA,EACoB;AAAA,OACf;AAEP,SAAS,iBAAiB,yBAAyB;AAGnD,SAAS,iBAAiB;AAC1B,SAAS,mBAAmB;AAC5B,SAAS,qBAAqB;AAE9B,SAAoB,WAAXA,iBAA6B;AACtC,SAAoB,WAAXA,iBAA4C;AACrD,SAAS,qBAAqB;AAG9B;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,iBAAiB;AAC1B,SAAS,uBAAuB;AAgBhC,SAAoB,WAAXA,iBAAgC;AACzC,SAAS,wBAAwB;AAGjC,SAAS,oBAAoB;AAC7B,SAAS,cAAc;AAEvB,SAAoB,WAAXA,iBAAqC;AAC9C,SAAoB,WAAXA,iBAA4C;AACrD,SAAoB,WAAXA,iBAAgD;AACzD,SAAS,wBAAwB;AACjC,SAAS,0BAA0B;AACnC,SAAS,uBAAuB;AAChC,SAAS,6BAA6B;AACtC,SAAS,wBAAwB;AACjC,SAAS,wBAAwB;AAGjC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,oBAAAC;AAAA,OACK;AAGP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,OAEK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAOP,SAAS,qBAAqB;AAC9B,SAAS,yBAAyB;AAClC,SAAS,cAAc,oBAAoB;AAC3C;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;","names":["default","LANGUAGE_OPTIONS"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["// Types\nexport * from \"./modules/auth/schema\";\nexport * from \"./modules/users/schema\";\nexport * from \"./modules/whitelabel/schema\";\n// Style types now come from whitelabel schema directly\nexport * from \"./infra/api/types\";\n\n// Contexts\nexport * from \"./providers/query.provider\";\nexport * from \"./providers/auth.provider\";\nexport * from \"./providers/whitelabel.provider\";\n\n// Hooks\nexport {\n useListProjectUsers,\n LIST_PROJECT_USERS_QUERY_KEY,\n LIST_PROJECT_USERS_BASE_KEY,\n} from \"./modules/projects/hooks/list-project-users.hook\";\nexport {\n useListAvailableUsers,\n LIST_AVAILABLE_USERS_QUERY_KEY,\n LIST_AVAILABLE_USERS_BASE_KEY,\n} from \"./modules/projects/hooks/list-available-users.hook\";\nexport {\n useListAllAccountUsers,\n LIST_ALL_ACCOUNT_USERS_QUERY_KEY,\n LIST_ALL_ACCOUNT_USERS_BASE_KEY,\n} from \"./modules/projects/hooks/list-all-account-users.hook\";\nexport {\n useProjects,\n PROJECTS_BASE_KEY,\n PROJECTS_QUERY_KEY,\n} from \"./modules/projects/hooks/list-projects.hook\";\nexport {\n useInfiniteProjects,\n INFINITE_PROJECTS_QUERY_KEY,\n} from \"./modules/projects/hooks/list-infinite-projects.hook\";\nexport { useProject } from \"./modules/projects/hooks/find-project.hook\";\nexport { useCreateProject } from \"./modules/projects/hooks/create-project.hook\";\nexport { useUpdateProject } from \"./modules/projects/hooks/update-project.hook\";\nexport { useDeleteProject } from \"./modules/projects/hooks/delete-project.hook\";\nexport type {\n Project,\n ProjectsPage,\n CreateProjectRequest,\n UpdateProjectRequest,\n ProjectUser,\n AccountUser,\n AddRemoveProjectUsersParams,\n ListUsersParams,\n UsersPage,\n} from \"./modules/projects/types\";\nexport { ProjectSchema } from \"./modules/projects/types\";\nexport type { ListProjectsActionParams } from \"./modules/projects/actions/list-projects.action\";\nexport {\n useUserQuery,\n useUserValidateSession,\n useInvalidateUser,\n useSetUserData,\n useTwoFactorVerify,\n USER_QUERY_KEY,\n} from \"./modules/auth/hooks/useUserQuery\";\nexport { useManagementPermissions } from \"./modules/auth/hooks/useManagementPermissions\";\nexport type { ManagementPermission } from \"./modules/auth/types/management-permission.type\";\nexport { useSubscriptions } from \"./modules/subscriptions/hooks/list-subscriptions.hook\";\nexport {\n SUBSCRIPTIONS_QUERY_KEY,\n CHARGES_QUERY_KEY,\n} from \"./modules/subscriptions/constants/query-keys.constants\";\nexport { useActiveSubscription } from \"./modules/subscriptions/hooks/find-active-subscription.hook\";\nexport { useCancelledSubscriptionGuard } from \"./modules/subscriptions/hooks/use-cancelled-subscription-guard\";\nexport { usePlanById } from \"./modules/plans/hooks/use-plan-by-id.hook\";\nexport { useHasPlanAddon } from \"./modules/plans/hooks/use-has-plan-addon.hook\";\nexport { useCalculateSubscription } from \"./modules/subscriptions/hooks/calculate-subscription.hook\";\nexport { useUpdateSubscriptionPlan } from \"./modules/subscriptions/hooks/update-subscription-plan.hook\";\nexport { useUpdateSubscriptionPayment } from \"./modules/subscriptions/hooks/update-subscription-payment.hook\";\nexport { useCards, CARDS_QUERY_KEY } from \"./modules/cards/hooks/cards.hook\";\nexport { useCardById } from \"./modules/cards/hooks/card-by-id.hook\";\nexport { useCreateCard } from \"./modules/cards/hooks/create-card.hook\";\nexport { useCreateSetupIntent } from \"./modules/cards/hooks/create-setup-intent.hook\";\nexport { useSetDefaultCard } from \"./modules/cards/hooks/set-default-card.hook\";\nexport { useDeleteCard } from \"./modules/cards/hooks/delete-card.hook\";\nexport { useDeleteConfirmation } from \"./modules/cards/hooks/delete-confirmation.hook\";\nexport type { DeleteConfirmationFormData } from \"./modules/cards/hooks/delete-confirmation.hook\";\nexport { useHandleDeleteCard } from \"./modules/cards/hooks/handle-delete-card.hook\";\nexport { useCharges } from \"./modules/charges/hooks/charges.hook\";\nexport { useChargeById } from \"./modules/charges/hooks/charge-by-id.hook\";\nexport { useChargeAction } from \"./modules/charges/hooks/charge-action.hook\";\nexport { useIaCredits } from \"./modules/ia-credits/hooks/ia-credits.hook\";\nexport type {\n IaCreditsSummary,\n IaCreditOperation,\n} from \"./modules/ia-credits/types\";\nexport type {\n Subscription,\n SubscriptionItem,\n FindSubscriptionsParams,\n} from \"./modules/subscriptions/types/subscription.type\";\nexport {\n SubscriptionSchema,\n SubscriptionItemSchema,\n} from \"./modules/subscriptions/types/subscription.type\";\nexport {\n ADDON_IDS,\n AI_CREDIT_OPTIONS,\n AI_CREDIT_VALUES,\n} from \"./modules/subscriptions/constants/addons.constants\";\nexport type {\n AddonKindEnum,\n AiCreditOption,\n} from \"./modules/subscriptions/constants/addons.constants\";\nexport type {\n Plan,\n PlanItem,\n UiPlan,\n PlanFeature,\n PlanMainFeatures,\n PlanPricingByPeriod,\n PlanTooltips,\n} from \"./modules/plans/types/plan.type\";\nexport { PlanSchema, PlanItemSchema } from \"./modules/plans/types/plan.type\";\nexport { mapApiPlanToUiPlan } from \"./modules/plans/utils/map-api-plan-to-ui\";\nexport type { PlanBillingPeriod } from \"./modules/plans/utils/map-api-plan-to-ui\";\nexport {\n usePlans,\n PLANS_QUERY_KEY,\n} from \"./modules/plans/hooks/list-plans.hook\";\nexport type { BillingPeriod } from \"./modules/subscriptions/types/billing-period.type\";\nexport type {\n CalculateSubscriptionRequest,\n CalculateSubscriptionResponse,\n UpdateSubscriptionPlanRequest,\n} from \"./modules/subscriptions/types/calculate-subscription.type\";\nexport type {\n Card as PaymentCard,\n CreateCardRequest,\n FindCardsParams,\n SetupIntent,\n} from \"./modules/cards/types\";\nexport {\n CardSchema as PaymentCardSchema,\n CreateCardRequestSchema,\n FindCardsParamsSchema,\n SetupIntentSchema,\n} from \"./modules/cards/types\";\nexport type {\n Charge,\n FindChargesParams,\n PayChargeInput,\n} from \"./modules/charges/types/charge.type\";\nexport {\n ChargeSchema,\n FindChargesParamsSchema,\n PayChargeInputSchema,\n} from \"./modules/charges/types/charge.type\";\nexport { buildPlanExtras } from \"./modules/subscriptions/utils/build-plan-extras\";\nexport { hasSubscriptionExpired } from \"./modules/subscriptions/utils/has-subscription-expired\";\nexport { SUBSCRIPTION_GRACE_PERIOD_DAYS } from \"./modules/subscriptions/constants/subscription.constants\";\nexport {\n useCountPages,\n COUNT_PAGES_QUERY_KEY,\n} from \"./modules/pages/hooks/count-pages.hook\";\nexport { PAGES_QUERY_KEY } from \"./modules/pages/constants/query-keys.constants\";\nexport {\n getPriceFromCalculatedData,\n getOriginalPriceFromCalculatedData,\n periodicityToBillingPeriod,\n} from \"./modules/subscriptions/utils/periodicity\";\nexport { useBuyCreditsModal } from \"./store/useBuyCreditsModal\";\nexport { useCreditsDisabledModal } from \"./store/useCreditsDisabledModal\";\nexport { usePaidPlanRequiredModal } from \"./store/usePaidPlanRequiredModal\";\nexport { default as BuyCreditsModal } from \"./components/modals/BuyCreditsModal\";\nexport { default as CreditsDisabledModal } from \"./components/modals/CreditsDisabledModal\";\nexport { default as PaidPlanRequiredModal } from \"./components/modals/PaidPlanRequiredModal\";\nexport { default as AddCardModal } from \"./components/modals/cards/AddCardModal\";\nexport { DeleteCardModal } from \"./components/modals/cards/DeleteCardModal\";\nexport { CannotDeleteCardModal } from \"./components/modals/cards/CannotDeleteCardModal\";\nexport {\n CardFormFields,\n cardFormSchema,\n} from \"./components/modals/cards/CardFormFields\";\nexport type { CardFormData } from \"./components/modals/cards/CardFormFields\";\nexport { Skeleton } from \"./components/ui/feedback/Skeleton\";\nexport { PaymentInfoCard } from \"./components/ui/data-display/PaymentInfoCard\";\nexport { CardBrandIcon } from \"./components/ui/data-display/CardBrandIcons\";\nexport { CardItem } from \"./components/ui/data-display/CardItem\";\n\n// Providers\nexport { QueryProvider } from \"./providers/query.provider\";\n\n// Middleware\nexport { createAuthMiddleware } from \"./middlewares/create-auth-middleware\";\nexport { createMiddlewareChain } from \"./middlewares/chain\";\nexport { continueChain, stopChain } from \"./middlewares/types\";\nexport type {\n MiddlewareFunction,\n MiddlewareConfig,\n MiddlewareResult,\n} from \"./middlewares/types\";\n\n// Utils\nexport { cn } from \"./infra/utils/clsx\";\nexport { formatShortDate, formatDateTime, calendarDateSchema, toCalendarDate } from \"./infra/utils/date\";\nexport { buildQueryParams } from \"./infra/utils/params\";\nexport { parseSchema, parseResult } from \"./infra/utils/parser\";\nexport { withAction } from \"./utils/withAction\";\n\n// Layout\nexport {\n MainLayout,\n MainLayoutContent,\n MainLayoutSpacer,\n MainLayoutMain,\n} from \"./components/layouts/MainLayout\";\nexport { NavBar } from \"./components/layouts/NavBar\";\nexport type { NavBarProps } from \"./components/layouts/NavBar\";\nexport { AppNavBar } from \"./components/layouts/AppNavBar\";\nexport type { AppNavBarProps } from \"./components/layouts/AppNavBar\";\nexport { AppMobileNavBar } from \"./components/layouts/AppMobileNavBar\";\nexport type { AppMobileNavBarProps } from \"./components/layouts/AppMobileNavBar\";\nexport { SideBarNavigation } from \"./components/layouts/SideBarNavigation\";\nexport { MdSideBarNavigation } from \"./components/layouts/MdSideBarNavigation\";\nexport { default as NotificationCard } from \"./components/widgets/notifications/NotificationCard\";\nexport type { NotificationCardProps } from \"./components/widgets/notifications/NotificationCard\";\nexport { NotificationsPopover } from \"./components/layouts/NotificationsPopover\";\nexport type { NotificationsPopoverProps } from \"./components/layouts/NotificationsPopover\";\nexport { NotificationPageContent } from \"./components/pages/notifications/Notifications\";\nexport { NotFoundPage } from \"./components/pages/NotFoundPage\";\nexport { UsersSelectorPopover } from \"./components/layouts/UsersSelectorPopover\";\nexport type { UsersSelectorPopoverProps } from \"./components/layouts/UsersSelectorPopover\";\nexport { ProfilePopover } from \"./components/layouts/ProfilePopover\";\nexport type {\n ProfilePopoverProps,\n ProfileMenuItem,\n} from \"./components/layouts/ProfilePopover\";\nexport { default as WhitelabelCodes } from \"./components/layouts/WhitelabelCodes\";\nexport { NavBarItem } from \"./components/layouts/NavBarItem\";\nexport type { NavBarItemProps } from \"./components/layouts/NavBarItem\";\n\n// Navigation\nexport { AppNavigation } from \"./components/navigation/AppNavigation\";\nexport { CancelledSubscriptionBanner } from \"./components/navigation/CancelledSubscriptionBanner\";\nexport { SubscriptionBanner } from \"./components/navigation/SubscriptionBanner\";\nexport { OverdueInvoiceBanner } from \"./components/navigation/OverdueInvoiceBanner\";\nexport type { NavItemConfig } from \"./components/navigation/subcomponents/NavItems\";\nexport { useMobileNavbarSheet } from \"./store/useMobileNavbarSheet\";\n\n// Auth Query Key Utilities\nexport {\n useAuthQueryKey,\n useWlQueryKey,\n useWlId,\n} from \"./hooks/useAuthQueryKey\";\n\n// Hooks\nexport { default as useCopyToClipboard } from \"./hooks/copy-to-clipboard.hook\";\n\n// UI - Buttons\nexport { Button, buttonVariants } from \"./components/ui/buttons/Button\";\nexport { CopyButton } from \"./components/ui/buttons/CopyButton\";\nexport { default as CancelButton } from \"./components/ui/buttons/CancelButton\";\n\n// UI - Data Display\nexport {\n Accordion,\n AccordionItem,\n AccordionTrigger,\n AccordionContent,\n} from \"./components/ui/data-display/Accordion\";\nexport { Badge, badgeVariants } from \"./components/ui/data-display/Badge\";\nexport {\n Card,\n CardHeader,\n CardFooter,\n CardTitle,\n CardAction,\n CardDescription,\n CardContent,\n} from \"./components/ui/data-display/Card\";\nexport {\n Pagination,\n PaginationContent,\n PaginationLink,\n PaginationItem,\n PaginationPrevious,\n PaginationNext,\n PaginationEllipsis,\n} from \"./components/ui/data-display/Pagination\";\nexport { ScrollArea, ScrollBar } from \"./components/ui/data-display/ScrollArea\";\nexport { Separator } from \"./components/ui/data-display/Separator\";\nexport {\n Table,\n TableHeader,\n TableBody,\n TableFooter,\n TableHead,\n TableRow,\n TableCell,\n TableCaption,\n} from \"./components/ui/data-display/Table\";\nexport {\n Tabs,\n TabsList,\n TabsTrigger,\n TabsContent,\n} from \"./components/ui/data-display/Tabs\";\nexport { UserAvatar } from \"./components/ui/data-display/UserAvatar\";\nexport type { UserAvatarProps } from \"./components/ui/data-display/UserAvatar\";\n\n// UI - Feedback\nexport { default as CircularProgress } from \"./components/ui/feedback/CircularProgress\";\nexport { default as DefaultCircularProgress } from \"./components/ui/feedback/DefaultCircularProgress\";\nexport { Progress } from \"./components/ui/feedback/Progress\";\nexport { LoadingOverlay } from \"./components/ui/feedback/LoadingOverlay\";\nexport {\n Toast,\n toastVariants,\n toastIconContainerVariants,\n} from \"./components/ui/feedback/Toast\";\nexport type { ToastProps } from \"./components/ui/feedback/Toast\";\n\n// UI - Form\nexport { Calendar, CalendarDayButton } from \"./components/ui/form/Calendar\";\nexport { Checkbox } from \"./components/ui/form/Checkbox\";\nexport { DatePicker } from \"./components/ui/form/DatePicker\";\nexport { DateRangePicker } from \"./components/ui/form/DateRangePicker\";\nexport { Input } from \"./components/ui/form/Input\";\nexport {\n InputOTP,\n InputOTPGroup,\n InputOTPSlot,\n InputOTPSeparator,\n} from \"./components/ui/form/InputOtp\";\nexport { RadioGroup, RadioGroupItem } from \"./components/ui/form/RadioGroup\";\nexport {\n Select,\n SelectContent,\n SelectGroup,\n SelectItem,\n SelectLabel,\n SelectScrollDownButton,\n SelectScrollUpButton,\n SelectSeparator,\n SelectTrigger,\n SelectValue,\n} from \"./components/ui/form/Select\";\nexport { Switch } from \"./components/ui/form/Switch\";\nexport { Textarea } from \"./components/ui/form/Textarea\";\n\n// UI - Overlay\nexport {\n Command,\n CommandDialog,\n CommandInput,\n CommandList,\n CommandEmpty,\n CommandGroup,\n CommandItem,\n CommandShortcut,\n CommandSeparator,\n} from \"./components/ui/overlay/Command\";\nexport {\n Dialog,\n DialogClose,\n DialogContent,\n DialogDescription,\n DialogFooter,\n DialogHeader,\n DialogOverlay,\n DialogPortal,\n DialogTitle,\n DialogTrigger,\n} from \"./components/ui/overlay/Dialog\";\nexport {\n Popover,\n PopoverTrigger,\n PopoverContent,\n PopoverAnchor,\n} from \"./components/ui/overlay/Popover\";\nexport {\n Sheet,\n SheetTrigger,\n SheetClose,\n SheetContent,\n SheetHeader,\n SheetFooter,\n SheetTitle,\n SheetDescription,\n} from \"./components/ui/overlay/Sheet\";\nexport {\n Tooltip,\n TooltipTrigger,\n TooltipContent,\n TooltipProvider,\n} from \"./components/ui/overlay/Tooltip\";\n\n// Embeds\nexport { FrillEmbed } from \"./components/embeds/FrillEmbed\";\nexport {\n CrispEmbed,\n openCrispHelpdesk,\n hideCrisp,\n showCrisp,\n updateCrispUser,\n} from \"./components/embeds/CrispEmbed\";\nexport { EmbedWidgets } from \"./components/embeds/EmbedWidgets\";\nexport { ClarityEmbed } from \"./components/embeds/ClarityEmbed\";\n\n// Store\nexport { useMdSidebarStore } from \"./store/useMdSidebarStore\";\nexport { useDesktopSidebarStore } from \"./store/useDesktopSidebarStore\";\nexport { useModalManager } from \"./store/useModalManager\";\nexport type { ModalData } from \"./store/useModalManager\";\n\n// Enums\nexport { AccountSectionType } from \"./enums/AccountSectionType\";\n\n// Hooks\nexport { default as usePasswordVisibility } from \"./hooks/usePasswordVisibility\";\nexport { default as useCountdownTimer } from \"./hooks/useCountdownTimer\";\nexport { default as useIsMobile } from \"./hooks/useIsMobile\";\nexport { useDebounce } from \"./hooks/useDebounce\";\nexport { useDebouncedEffect } from \"./hooks/useDebouncedEffect\";\nexport { useDebounceState } from \"./hooks/useDebounceState\";\n\n// Utils\nexport {\n formatPhone,\n formatTimer,\n formatFullName,\n formatCPF,\n formatCNPJ,\n formatCardNumber,\n} from \"./utils/format/masks\";\nexport { formatCurrencyNumber } from \"./utils/format/currency\";\nexport { BR_STATE_OPTIONS } from \"./utils/constants/br-states\";\nexport type { TimezoneOption } from \"./modules/accounts/services/timezone.service\";\nexport {\n buildLocaleOptions,\n LANGUAGE_OPTIONS as LOCALE_LANGUAGE_OPTIONS,\n} from \"./utils/intl/locales\";\nexport type { LocaleOption } from \"./utils/intl/locales\";\nexport { copyToClipboard, readFromClipboard } from \"./utils/browser/clipboard\";\n\n// UI - Form (new widgets)\nexport { FormField } from \"./components/ui/form/FormField\";\nexport { SelectField } from \"./components/ui/form/SelectField\";\nexport { ComboboxField } from \"./components/ui/form/ComboboxField\";\nexport type { ComboboxOption } from \"./components/ui/form/ComboboxField\";\nexport { default as PhoneInput } from \"./components/ui/form/PhoneInput\";\nexport { default as SwitchOptionFieldWithIcon } from \"./components/ui/form/SwitchOptionFieldWithIcon\";\nexport { TextAreaField } from \"./components/ui/form/TextAreaField\";\n\n// Account Module - Hooks\nexport {\n useCurrentAccount,\n ACCOUNT_QUERY_KEY,\n} from \"./modules/accounts/hooks/current-account.hook\";\nexport {\n useUpdateAccount,\n useUpdateAccountUser,\n useUpdateAccountUserById,\n useDeleteAccountUser,\n useDeleteAccount,\n ACCOUNT_USERS_QUERY_KEY,\n} from \"./modules/accounts/hooks/useAccountManagement\";\nexport { useViaCep } from \"./modules/accounts/hooks/useViaCep\";\nexport { useAccountToken } from \"./modules/accounts/hooks/use-account-token.hook\";\n\n// Account Types\nexport type {\n UpdateAccountRequest,\n UpdateAccountUserRequest,\n ChangePasswordRequest,\n DeleteAccountActionResult,\n DeleteUserActionResult,\n UpdateAccountActionResult,\n UpdateUserActionResult,\n TwoFactorGenerateResult,\n TwoFactorActionResult,\n ContactResetResult,\n} from \"./modules/accounts/types\";\n\nexport { default as AccountModals } from \"./components/account/AccountModals\";\nexport { useAccountModals } from \"./store/useAccountModals\";\nexport type { AccountModalsConfig } from \"./store/useAccountModals\";\n\nexport { ModalManager } from \"./components/modals/ModalManager\";\nexport { Modals } from \"./components/modals/Modals\";\n\nexport { default as TwoFactorAuthModal } from \"./components/account/TwoFactorAuthModal\";\nexport { default as DisableTwoFactorAuthModal } from \"./components/account/DisableTwoFactorAuthModal\";\nexport { default as ConfirmGlobalPreferencesModal } from \"./components/account/ConfirmGlobalPreferencesModal\";\nexport { MyProfileSection } from \"./components/account/sections/MyProfileSection\";\nexport { PreferencesSection } from \"./components/account/sections/PreferencesSection\";\nexport { SecuritySection } from \"./components/account/sections/SecuritySection\";\nexport { ChangePasswordSection } from \"./components/account/sections/ChangePasswordSection\";\nexport { ChangeEmailModal } from \"./components/account/sections/ChangeEmailModal\";\nexport { ChangePhoneModal } from \"./components/account/sections/ChangePhoneModal\";\n\n// Account Constants\nexport {\n GENDER_OPTIONS,\n CURRENCY_OPTIONS,\n TIME_FORMAT_OPTIONS,\n NOTIFICATION_TYPES,\n LANGUAGE_OPTIONS,\n} from \"./components/account/constants\";\n\n// Image Upload\nexport {\n ImageUpload,\n ImageCropModal,\n ImageTooSmallModal,\n} from \"./components/widgets/ImageUpload\";\nexport {\n useImageUpload,\n type ImageTooSmallError,\n} from \"./modules/images/hooks/use-image-upload.hook\";\nexport {\n ACCEPTED_IMAGE_FORMATS,\n ACCEPTED_IMAGE_FORMATS_STRING,\n MAX_FILE_SIZE_MB,\n} from \"./modules/images/constants/image.constants\";\nexport type {\n ImageConfig,\n CropArea,\n ProcessedImage,\n CompressImageOptions,\n} from \"./modules/images/types/image.type\";\nexport { compressImage } from \"./modules/images/utils/compress-image\";\nexport { cropImageToCanvas } from \"./modules/images/utils/crop-image\";\nexport { base64ToFile, fileToBase64 } from \"./modules/images/utils/base64\";\nexport {\n validateImage,\n validateImageFormat,\n validateImageSize,\n getImageDimensions,\n} from \"./modules/images/utils/validate-image\";\n"],"mappings":"AACA,cAAc;AACd,cAAc;AACd,cAAc;AAEd,cAAc;AAGd,cAAc;AACd,cAAc;AACd,cAAc;AAGd;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,kBAAkB;AAC3B,SAAS,wBAAwB;AACjC,SAAS,wBAAwB;AACjC,SAAS,wBAAwB;AAYjC,SAAS,qBAAqB;AAE9B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,gCAAgC;AAEzC,SAAS,wBAAwB;AACjC;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,6BAA6B;AACtC,SAAS,qCAAqC;AAC9C,SAAS,mBAAmB;AAC5B,SAAS,uBAAuB;AAChC,SAAS,gCAAgC;AACzC,SAAS,iCAAiC;AAC1C,SAAS,oCAAoC;AAC7C,SAAS,UAAU,u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2
|
+
function parseCalendarDate(val) {
|
|
3
|
+
if (val == null) return val;
|
|
4
|
+
if (val instanceof Date) return val;
|
|
5
|
+
if (typeof val === "string") {
|
|
6
|
+
const dateOnly = val.match(/^(\d{4})-(\d{2})-(\d{2})$/);
|
|
7
|
+
if (dateOnly) {
|
|
8
|
+
return new Date(Number(dateOnly[1]), Number(dateOnly[2]) - 1, Number(dateOnly[3]));
|
|
9
|
+
}
|
|
10
|
+
const noTz = val.match(/^(\d{4})-(\d{2})-(\d{2})[T ](\d{2}):(\d{2})(?::(\d{2}))?$/);
|
|
11
|
+
if (noTz) {
|
|
12
|
+
return new Date(
|
|
13
|
+
Number(noTz[1]),
|
|
14
|
+
Number(noTz[2]) - 1,
|
|
15
|
+
Number(noTz[3]),
|
|
16
|
+
Number(noTz[4]),
|
|
17
|
+
Number(noTz[5]),
|
|
18
|
+
Number(noTz[6] ?? 0)
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
return new Date(val);
|
|
22
|
+
}
|
|
23
|
+
return val;
|
|
24
|
+
}
|
|
25
|
+
const calendarDateSchema = () => z.preprocess(parseCalendarDate, z.date());
|
|
26
|
+
function toCalendarDate(date) {
|
|
27
|
+
if (!date) return null;
|
|
28
|
+
const parsed = parseCalendarDate(date);
|
|
29
|
+
return parsed instanceof Date ? parsed : null;
|
|
30
|
+
}
|
|
1
31
|
function formatShortDate(date) {
|
|
2
32
|
if (!date) return "--";
|
|
3
|
-
const d = new Date(date);
|
|
4
|
-
const day = String(d.
|
|
5
|
-
const month = String(d.
|
|
6
|
-
if (d.
|
|
7
|
-
return `${day}/${month}/${d.
|
|
33
|
+
const d = toCalendarDate(date) ?? new Date(date);
|
|
34
|
+
const day = String(d.getDate()).padStart(2, "0");
|
|
35
|
+
const month = String(d.getMonth() + 1).padStart(2, "0");
|
|
36
|
+
if (d.getFullYear() !== (/* @__PURE__ */ new Date()).getFullYear()) {
|
|
37
|
+
return `${day}/${month}/${d.getFullYear()}`;
|
|
8
38
|
}
|
|
9
39
|
return `${day}/${month}`;
|
|
10
40
|
}
|
|
@@ -19,7 +49,9 @@ function formatDateTime(date) {
|
|
|
19
49
|
});
|
|
20
50
|
}
|
|
21
51
|
export {
|
|
52
|
+
calendarDateSchema,
|
|
22
53
|
formatDateTime,
|
|
23
|
-
formatShortDate
|
|
54
|
+
formatShortDate,
|
|
55
|
+
toCalendarDate
|
|
24
56
|
};
|
|
25
57
|
//# sourceMappingURL=date.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/infra/utils/date.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../../src/infra/utils/date.ts"],"sourcesContent":["import z from 'zod';\n\nfunction parseCalendarDate(val: unknown): Date | unknown {\n if (val == null) return val;\n if (val instanceof Date) return val;\n if (typeof val === 'string') {\n const dateOnly = val.match(/^(\\d{4})-(\\d{2})-(\\d{2})$/);\n if (dateOnly) {\n return new Date(Number(dateOnly[1]), Number(dateOnly[2]) - 1, Number(dateOnly[3]));\n }\n const noTz = val.match(/^(\\d{4})-(\\d{2})-(\\d{2})[T ](\\d{2}):(\\d{2})(?::(\\d{2}))?$/);\n if (noTz) {\n return new Date(\n Number(noTz[1]),\n Number(noTz[2]) - 1,\n Number(noTz[3]),\n Number(noTz[4]),\n Number(noTz[5]),\n Number(noTz[6] ?? 0)\n );\n }\n return new Date(val);\n }\n return val;\n}\n\nexport const calendarDateSchema = () => z.preprocess(parseCalendarDate, z.date());\n\nexport function toCalendarDate(date: Date | string | null | undefined): Date | null {\n if (!date) return null;\n const parsed = parseCalendarDate(date);\n return parsed instanceof Date ? parsed : null;\n}\n\nexport function formatShortDate(date: Date | string | null | undefined): string {\n if (!date) return '--';\n const d = toCalendarDate(date) ?? new Date(date);\n const day = String(d.getDate()).padStart(2, '0');\n const month = String(d.getMonth() + 1).padStart(2, '0');\n if (d.getFullYear() !== new Date().getFullYear()) {\n return `${day}/${month}/${d.getFullYear()}`;\n }\n return `${day}/${month}`;\n}\n\nexport function formatDateTime(date: Date | string | null | undefined): string | null {\n if (!date) return null;\n return new Date(date).toLocaleString('pt-BR', {\n day: '2-digit',\n month: '2-digit',\n year: 'numeric',\n hour: '2-digit',\n minute: '2-digit',\n });\n}\n"],"mappings":"AAAA,OAAO,OAAO;AAEd,SAAS,kBAAkB,KAA8B;AACvD,MAAI,OAAO,KAAM,QAAO;AACxB,MAAI,eAAe,KAAM,QAAO;AAChC,MAAI,OAAO,QAAQ,UAAU;AAC3B,UAAM,WAAW,IAAI,MAAM,2BAA2B;AACtD,QAAI,UAAU;AACZ,aAAO,IAAI,KAAK,OAAO,SAAS,CAAC,CAAC,GAAG,OAAO,SAAS,CAAC,CAAC,IAAI,GAAG,OAAO,SAAS,CAAC,CAAC,CAAC;AAAA,IACnF;AACA,UAAM,OAAO,IAAI,MAAM,2DAA2D;AAClF,QAAI,MAAM;AACR,aAAO,IAAI;AAAA,QACT,OAAO,KAAK,CAAC,CAAC;AAAA,QACd,OAAO,KAAK,CAAC,CAAC,IAAI;AAAA,QAClB,OAAO,KAAK,CAAC,CAAC;AAAA,QACd,OAAO,KAAK,CAAC,CAAC;AAAA,QACd,OAAO,KAAK,CAAC,CAAC;AAAA,QACd,OAAO,KAAK,CAAC,KAAK,CAAC;AAAA,MACrB;AAAA,IACF;AACA,WAAO,IAAI,KAAK,GAAG;AAAA,EACrB;AACA,SAAO;AACT;AAEO,MAAM,qBAAqB,MAAM,EAAE,WAAW,mBAAmB,EAAE,KAAK,CAAC;AAEzE,SAAS,eAAe,MAAqD;AAClF,MAAI,CAAC,KAAM,QAAO;AAClB,QAAM,SAAS,kBAAkB,IAAI;AACrC,SAAO,kBAAkB,OAAO,SAAS;AAC3C;AAEO,SAAS,gBAAgB,MAAgD;AAC9E,MAAI,CAAC,KAAM,QAAO;AAClB,QAAM,IAAI,eAAe,IAAI,KAAK,IAAI,KAAK,IAAI;AAC/C,QAAM,MAAM,OAAO,EAAE,QAAQ,CAAC,EAAE,SAAS,GAAG,GAAG;AAC/C,QAAM,QAAQ,OAAO,EAAE,SAAS,IAAI,CAAC,EAAE,SAAS,GAAG,GAAG;AACtD,MAAI,EAAE,YAAY,OAAM,oBAAI,KAAK,GAAE,YAAY,GAAG;AAChD,WAAO,GAAG,GAAG,IAAI,KAAK,IAAI,EAAE,YAAY,CAAC;AAAA,EAC3C;AACA,SAAO,GAAG,GAAG,IAAI,KAAK;AACxB;AAEO,SAAS,eAAe,MAAuD;AACpF,MAAI,CAAC,KAAM,QAAO;AAClB,SAAO,IAAI,KAAK,IAAI,EAAE,eAAe,SAAS;AAAA,IAC5C,KAAK;AAAA,IACL,OAAO;AAAA,IACP,MAAM;AAAA,IACN,MAAM;AAAA,IACN,QAAQ;AAAA,EACV,CAAC;AACH;","names":[]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { PaginationParamsSchema, SearchParamsSchema, SortParamsSchema } from "../../../infra/api/types";
|
|
2
|
+
import { calendarDateSchema } from "../../../infra/utils/date";
|
|
2
3
|
import z from "zod";
|
|
3
4
|
const BoletoPaymentDetailsSchema = z.object({
|
|
4
5
|
type: z.literal("boleto"),
|
|
@@ -17,8 +18,8 @@ const ChargeSchema = z.object({
|
|
|
17
18
|
id_account: z.coerce.number(),
|
|
18
19
|
status: z.coerce.number().nullable().optional().transform((val) => val ?? 0),
|
|
19
20
|
description: z.string().nullable().optional(),
|
|
20
|
-
date_due:
|
|
21
|
-
date_payment:
|
|
21
|
+
date_due: calendarDateSchema().nullable().optional(),
|
|
22
|
+
date_payment: calendarDateSchema().nullable().optional(),
|
|
22
23
|
payment_method: z.number().nullable().optional(),
|
|
23
24
|
value: z.coerce.number().nullable().optional().transform((val) => val ?? 0),
|
|
24
25
|
type: z.number().nullable().optional(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/modules/charges/types/charge.type.ts"],"sourcesContent":["import { PaginationParamsSchema, SearchParamsSchema, SortParamsSchema } from '../../../infra/api/types';\nimport z from 'zod';\n\nconst BoletoPaymentDetailsSchema = z.object({\n type: z.literal('boleto'),\n barcode: z.string().nullable().optional(),\n expiration_date: z.number().nullable().optional(),\n hosted_voucher_url: z.string().nullable().optional(),\n pdf: z.string().nullable().optional(),\n});\n\nconst PaymentDetailsSchema = z.union([BoletoPaymentDetailsSchema, z.record(z.string(), z.unknown())]).nullable().optional();\n\nexport const ChargeSchema = z.object({\n id: z.union([z.number(), z.string()]),\n id_wl: z.number(),\n id_product: z.number().nullable().optional(),\n title: z.string().nullable().optional(),\n id_subscription: z.union([z.number(), z.string()]).nullable().optional(),\n id_account: z.coerce.number(),\n status: z.coerce.number().nullable().optional().transform((val) => val ?? 0),\n description: z.string().nullable().optional(),\n date_due:
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/charges/types/charge.type.ts"],"sourcesContent":["import { PaginationParamsSchema, SearchParamsSchema, SortParamsSchema } from '../../../infra/api/types';\nimport { calendarDateSchema } from '../../../infra/utils/date';\nimport z from 'zod';\n\nconst BoletoPaymentDetailsSchema = z.object({\n type: z.literal('boleto'),\n barcode: z.string().nullable().optional(),\n expiration_date: z.number().nullable().optional(),\n hosted_voucher_url: z.string().nullable().optional(),\n pdf: z.string().nullable().optional(),\n});\n\nconst PaymentDetailsSchema = z.union([BoletoPaymentDetailsSchema, z.record(z.string(), z.unknown())]).nullable().optional();\n\nexport const ChargeSchema = z.object({\n id: z.union([z.number(), z.string()]),\n id_wl: z.number(),\n id_product: z.number().nullable().optional(),\n title: z.string().nullable().optional(),\n id_subscription: z.union([z.number(), z.string()]).nullable().optional(),\n id_account: z.coerce.number(),\n status: z.coerce.number().nullable().optional().transform((val) => val ?? 0),\n description: z.string().nullable().optional(),\n date_due: calendarDateSchema().nullable().optional(),\n date_payment: calendarDateSchema().nullable().optional(),\n payment_method: z.number().nullable().optional(),\n value: z.coerce.number().nullable().optional().transform((val) => val ?? 0),\n type: z.number().nullable().optional(),\n periodicity: z.number().nullable().optional(),\n id_gateway: z.number().nullable().optional(),\n gateway_invoice: z.string().nullable().optional(),\n gateway_billet: z.string().nullable().optional(),\n invoice_id: z.string().nullable().optional(),\n invoice_service: z.string().nullable().optional(),\n invoice_url: z.string().nullable().optional(),\n invoice_pdf: z.string().nullable().optional(),\n date_created: z.coerce.date().nullable().optional(),\n deleted: z.coerce.number().nullable().optional().transform((val) => val === 1),\n datetime_alt: z.coerce.date().nullable().optional(),\n datetime_del: z.coerce.date().nullable().optional(),\n datetime_add: z.coerce.date().nullable().optional(),\n line_descriptions: z.array(z.string()).nullable().optional().transform((val) => val ?? []),\n payment_details: PaymentDetailsSchema,\n});\n\nexport type Charge = z.infer<typeof ChargeSchema>;\n\nexport const FindChargesParamsSchema = z\n .object({\n date_start: z.date(),\n date_end: z.date(),\n date_payment_start: z.date(),\n date_payment_end: z.date(),\n status: z.array(z.number()).optional(),\n })\n .extend(PaginationParamsSchema.shape)\n .extend(SortParamsSchema.shape)\n .extend(SearchParamsSchema.shape);\n\nexport const PayChargeInputSchema = z.object({\n chargeId: z.union([z.number(), z.string()]),\n paymentMethod: z.number(),\n paymentMethodId: z.string().optional(),\n});\n\nexport type PayChargeInput = z.infer<typeof PayChargeInputSchema>;\n\nexport type FindChargesParams = z.infer<typeof FindChargesParamsSchema>;\n"],"mappings":"AAAA,SAAS,wBAAwB,oBAAoB,wBAAwB;AAC7E,SAAS,0BAA0B;AACnC,OAAO,OAAO;AAEd,MAAM,6BAA6B,EAAE,OAAO;AAAA,EAC1C,MAAM,EAAE,QAAQ,QAAQ;AAAA,EACxB,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS;AAAA,EACxC,iBAAiB,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS;AAAA,EAChD,oBAAoB,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS;AAAA,EACnD,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS;AACtC,CAAC;AAED,MAAM,uBAAuB,EAAE,MAAM,CAAC,4BAA4B,EAAE,OAAO,EAAE,OAA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"sourcesContent":["export const SUBSCRIPTION_GRACE_PERIOD_DAYS = 15;\n"],"mappings":"AAAO,MAAM,iCAAiC;","names":[]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import z from "zod";
|
|
2
|
+
import { calendarDateSchema } from "../../../infra/utils/date";
|
|
2
3
|
const SubscriptionItemSchema = z.object({
|
|
3
4
|
id: z.union([z.number(), z.string()]),
|
|
4
5
|
deleted: z.number(),
|
|
@@ -36,10 +37,10 @@ const SubscriptionSchema = z.object({
|
|
|
36
37
|
plan_name: z.string().nullable().optional(),
|
|
37
38
|
id_gateway: z.union([z.number(), z.string()]).nullable(),
|
|
38
39
|
gateway_account: z.string().nullable(),
|
|
39
|
-
date_hiring:
|
|
40
|
-
date_due:
|
|
41
|
-
date_cancellation:
|
|
42
|
-
date_verification:
|
|
40
|
+
date_hiring: calendarDateSchema().nullable(),
|
|
41
|
+
date_due: calendarDateSchema().nullable(),
|
|
42
|
+
date_cancellation: calendarDateSchema().nullable(),
|
|
43
|
+
date_verification: calendarDateSchema().nullable(),
|
|
43
44
|
cancellation_reason: z.string().nullable(),
|
|
44
45
|
cancellation_description: z.string().nullable(),
|
|
45
46
|
active: z.boolean(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/modules/subscriptions/types/subscription.type.ts"],"sourcesContent":["import z from 'zod';\r\n\r\nexport const SubscriptionItemSchema = z.object({\r\n id: z.union([z.number(), z.string()]),\r\n deleted: z.number(),\r\n datetime_alt: z.coerce.date().nullable().optional(),\r\n datetime_del: z.coerce.date().nullable().optional(),\r\n datetime_add: z.coerce.date(),\r\n id_wl: z.number(),\r\n id_subscription: z.union([z.number(), z.string()]),\r\n id_addon: z.number().nullable(),\r\n addon_name: z.string().optional(),\r\n value: z.number().nullable(),\r\n currency: z.string(),\r\n quantity: z.number(),\r\n payment_status: z.number().nullable(),\r\n id_charge: z.union([z.number(), z.string()]).nullable(),\r\n trial: z.boolean().nullable(),\r\n trial_ends_at: z.coerce.date().nullable().optional(),\r\n});\r\n\r\nexport type SubscriptionItem = z.infer<typeof SubscriptionItemSchema>;\r\n\r\nexport const SubscriptionSchema = z.object({\r\n id: z.union([z.number(), z.string()]),\r\n deleted: z.number(),\r\n datetime_alt: z.coerce.date().nullable().optional(),\r\n datetime_del: z.coerce.date().nullable().optional(),\r\n datetime_add: z.coerce.date(),\r\n id_wl: z.number(),\r\n id_account: z.union([z.number(), z.string()]),\r\n id_card: z.union([z.number(), z.string()]).nullable(),\r\n id_coupon: z.union([z.number(), z.string()]).nullable(),\r\n type: z.string(),\r\n payment_method: z.number().nullable(),\r\n periodicity: z.coerce.number().nullable(),\r\n value: z.number().nullable(),\r\n id_product: z.number(),\r\n id_plan: z.number().nullable(),\r\n plan_name: z.string().nullable().optional(),\r\n id_gateway: z.union([z.number(), z.string()]).nullable(),\r\n gateway_account: z.string().nullable(),\r\n date_hiring:
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/subscriptions/types/subscription.type.ts"],"sourcesContent":["import z from 'zod';\r\nimport { calendarDateSchema } from '../../../infra/utils/date';\r\n\r\nexport const SubscriptionItemSchema = z.object({\r\n id: z.union([z.number(), z.string()]),\r\n deleted: z.number(),\r\n datetime_alt: z.coerce.date().nullable().optional(),\r\n datetime_del: z.coerce.date().nullable().optional(),\r\n datetime_add: z.coerce.date(),\r\n id_wl: z.number(),\r\n id_subscription: z.union([z.number(), z.string()]),\r\n id_addon: z.number().nullable(),\r\n addon_name: z.string().optional(),\r\n value: z.number().nullable(),\r\n currency: z.string(),\r\n quantity: z.number(),\r\n payment_status: z.number().nullable(),\r\n id_charge: z.union([z.number(), z.string()]).nullable(),\r\n trial: z.boolean().nullable(),\r\n trial_ends_at: z.coerce.date().nullable().optional(),\r\n});\r\n\r\nexport type SubscriptionItem = z.infer<typeof SubscriptionItemSchema>;\r\n\r\nexport const SubscriptionSchema = z.object({\r\n id: z.union([z.number(), z.string()]),\r\n deleted: z.number(),\r\n datetime_alt: z.coerce.date().nullable().optional(),\r\n datetime_del: z.coerce.date().nullable().optional(),\r\n datetime_add: z.coerce.date(),\r\n id_wl: z.number(),\r\n id_account: z.union([z.number(), z.string()]),\r\n id_card: z.union([z.number(), z.string()]).nullable(),\r\n id_coupon: z.union([z.number(), z.string()]).nullable(),\r\n type: z.string(),\r\n payment_method: z.number().nullable(),\r\n periodicity: z.coerce.number().nullable(),\r\n value: z.number().nullable(),\r\n id_product: z.number(),\r\n id_plan: z.number().nullable(),\r\n plan_name: z.string().nullable().optional(),\r\n id_gateway: z.union([z.number(), z.string()]).nullable(),\r\n gateway_account: z.string().nullable(),\r\n date_hiring: calendarDateSchema().nullable(),\r\n date_due: calendarDateSchema().nullable(),\r\n date_cancellation: calendarDateSchema().nullable(),\r\n date_verification: calendarDateSchema().nullable(),\r\n cancellation_reason: z.string().nullable(),\r\n cancellation_description: z.string().nullable(),\r\n active: z.boolean(),\r\n charged: z.boolean(),\r\n datetime_last_update_periodicity: z.coerce.date().nullable().optional(),\r\n card_name: z.string().nullable().optional(),\r\n card_brand: z.string().nullable().optional(),\r\n card_number: z.string().nullable().optional(),\r\n card: z.record(z.string(), z.unknown()).nullable().optional(),\r\n items: z.array(SubscriptionItemSchema),\r\n pending_change: z.object({\r\n schedule_id: z.string(),\r\n schedule_status: z.string(),\r\n kind: z.string(),\r\n takes_effect_at: z.number(),\r\n takes_effect_at_iso: z.string(),\r\n new_plan: z.object({\r\n id: z.number(),\r\n name: z.string(),\r\n periodicity: z.number(),\r\n value: z.number(),\r\n value_gross: z.number(),\r\n }),\r\n new_items: z.array(z.object({\r\n price_id: z.string(),\r\n id_addon: z.number().nullable(),\r\n addon_name: z.string(),\r\n quantity: z.number(),\r\n unit_value: z.number(),\r\n value: z.number(),\r\n is_plan_base: z.boolean(),\r\n is_ai_credit: z.boolean(),\r\n })),\r\n new_discounts: z.array(z.unknown()),\r\n changes: z.array(z.object({\r\n type: z.string(),\r\n from: z.unknown(),\r\n to: z.unknown(),\r\n })),\r\n }).nullable().optional(),\r\n});\r\n\r\nexport type Subscription = z.infer<typeof SubscriptionSchema>;\r\n\r\nexport interface FindSubscriptionsParams {\r\n active?: boolean;\r\n trial?: boolean;\r\n date_start?: string;\r\n date_end?: string;\r\n date_hiring_start?: string;\r\n date_hiring_end?: string;\r\n limit?: number;\r\n}\r\n"],"mappings":"AAAA,OAAO,OAAO;AACd,SAAS,0BAA0B;AAE5B,MAAM,yBAAyB,EAAE,OAAO;AAAA,EAC7C,IAAI,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC,CAAC;AAAA,EACpC,SAAS,EAAE,OAAO;AAAA,EAClB,cAAc,EAAE,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS;AAAA,EAClD,cAAc,EAAE,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS;AAAA,EAClD,cAAc,EAAE,OAAO,KAAK;AAAA,EAC5B,OAAO,EAAE,OAAO;AAAA,EAChB,iBAAiB,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC,CAAC;AAAA,EACjD,UAAU,EAAE,OAAO,EAAE,SAAS;AAAA,EAC9B,YAAY,EAAE,OAAO,EAAE,SAAS;AAAA,EAChC,OAAO,EAAE,OAAO,EAAE,SAAS;AAAA,EAC3B,UAAU,EAAE,OAAO;AAAA,EACnB,UAAU,EAAE,OAAO;AAAA,EACnB,gBAAgB,EAAE,OAAO,EAAE,SAAS;AAAA,EACpC,WAAW,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC,CAAC,EAAE,SAAS;AAAA,EACtD,OAAO,EAAE,QAAQ,EAAE,SAAS;AAAA,EAC5B,eAAe,EAAE,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS;AACrD,CAAC;AAIM,MAAM,qBAAqB,EAAE,OAAO;AAAA,EACzC,IAAI,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC,CAAC;AAAA,EACpC,SAAS,EAAE,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AC,CAAC;AAAA,EACJ,CAAC,EAAE,SAAS,EAAE,SAAS;AACzB,CAAC;","names":[]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import { SUBSCRIPTION_GRACE_PERIOD_DAYS } from "../constants/subscription.constants";
|
|
2
2
|
function hasSubscriptionExpired(dateDue) {
|
|
3
3
|
if (!dateDue) return false;
|
|
4
4
|
const dueDate = new Date(dateDue);
|
|
5
|
-
dueDate.
|
|
6
|
-
dueDate.
|
|
5
|
+
dueDate.setDate(dueDate.getDate() + SUBSCRIPTION_GRACE_PERIOD_DAYS);
|
|
6
|
+
dueDate.setHours(23, 59, 59, 999);
|
|
7
7
|
return Date.now() > dueDate.getTime();
|
|
8
8
|
}
|
|
9
9
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/modules/subscriptions/utils/has-subscription-expired.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/subscriptions/utils/has-subscription-expired.ts"],"sourcesContent":["import { SUBSCRIPTION_GRACE_PERIOD_DAYS } from '../constants/subscription.constants';\n\nexport function hasSubscriptionExpired(dateDue: Date | null | undefined) {\n if (!dateDue) return false;\n\n const dueDate = new Date(dateDue);\n dueDate.setDate(dueDate.getDate() + SUBSCRIPTION_GRACE_PERIOD_DAYS);\n dueDate.setHours(23, 59, 59, 999);\n\n return Date.now() > dueDate.getTime();\n}\n"],"mappings":"AAAA,SAAS,sCAAsC;AAExC,SAAS,uBAAuB,SAAkC;AACvE,MAAI,CAAC,QAAS,QAAO;AAErB,QAAM,UAAU,IAAI,KAAK,OAAO;AAChC,UAAQ,QAAQ,QAAQ,QAAQ,IAAI,8BAA8B;AAClE,UAAQ,SAAS,IAAI,IAAI,IAAI,GAAG;AAEhC,SAAO,KAAK,IAAI,IAAI,QAAQ,QAAQ;AACtC;","names":[]}
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@ import { useUpdateAccount } from '../../../modules/accounts/hooks/useAccountMana
|
|
|
11
11
|
import { useExternalContracting } from '../../../providers/whitelabel.provider';
|
|
12
12
|
import { CardFormFields, BillingFormFields, cardFormSchema } from './CardFormFields';
|
|
13
13
|
import type { CardFormData, StripeElementsStatus } from './CardFormFields';
|
|
14
|
-
import {
|
|
14
|
+
import { IconX, IconCreditCard, IconCheck, IconChevronRight } from '@tabler/icons-react';
|
|
15
15
|
import { cn } from '../../../infra/utils/clsx';
|
|
16
16
|
import { useForm } from 'react-hook-form';
|
|
17
17
|
import { zodResolver } from '@hookform/resolvers/zod';
|
|
@@ -41,12 +41,16 @@ function CardStepper({ currentStep }: { readonly currentStep: number }) {
|
|
|
41
41
|
<div
|
|
42
42
|
className={cn(
|
|
43
43
|
'flex items-center justify-center size-6 rounded-full paragraph-xsmall-semibold',
|
|
44
|
-
isCompleted && 'bg-green-
|
|
44
|
+
isCompleted && 'bg-green-50 text-green-600 border border-green-200',
|
|
45
45
|
isCurrent && 'bg-primary text-zinc-950',
|
|
46
46
|
isPending && 'border border-zinc-200 text-zinc-400',
|
|
47
47
|
)}
|
|
48
48
|
>
|
|
49
|
-
{isCompleted ?
|
|
49
|
+
{isCompleted ? (
|
|
50
|
+
<IconCheck size={14} stroke={3} />
|
|
51
|
+
) : (
|
|
52
|
+
step.number
|
|
53
|
+
)}
|
|
50
54
|
</div>
|
|
51
55
|
<span
|
|
52
56
|
className={cn(
|
|
@@ -372,7 +376,6 @@ export default function AddCardModal() {
|
|
|
372
376
|
disabled={isSubmitting || isAuthenticating || !isCardValid}
|
|
373
377
|
loading={isAuthenticating || isSubmitting}
|
|
374
378
|
>
|
|
375
|
-
{isAuthenticating && <IconLoader2 className="size-4 animate-spin" />}
|
|
376
379
|
{isAuthenticating
|
|
377
380
|
? 'Autenticando...'
|
|
378
381
|
: isSubmitting
|
|
@@ -27,9 +27,8 @@ export function CancelledSubscriptionBanner({ onReactivate }: CancelledSubscript
|
|
|
27
27
|
|
|
28
28
|
const dueDate = new Date(subscription.date_due);
|
|
29
29
|
const today = new Date();
|
|
30
|
-
const
|
|
31
|
-
const
|
|
32
|
-
const isPastDue = todayCalendar > dueCalendar;
|
|
30
|
+
const todayCalendar = new Date(today.getFullYear(), today.getMonth(), today.getDate()).getTime();
|
|
31
|
+
const isPastDue = todayCalendar > dueDate.getTime();
|
|
33
32
|
const formattedDate = formatShortDate(dueDate);
|
|
34
33
|
|
|
35
34
|
if (!subscription.date_cancellation && !isPastDue) return null;
|
|
@@ -34,9 +34,8 @@ export function SubscriptionBanner({
|
|
|
34
34
|
|
|
35
35
|
const dueDate = new Date(subscription.date_due!);
|
|
36
36
|
const today = new Date();
|
|
37
|
-
const
|
|
38
|
-
const
|
|
39
|
-
const isPastDue = todayCalendar > dueCalendar;
|
|
37
|
+
const todayCalendar = new Date(today.getFullYear(), today.getMonth(), today.getDate()).getTime();
|
|
38
|
+
const isPastDue = todayCalendar > dueDate.getTime();
|
|
40
39
|
|
|
41
40
|
if (!subscription.date_cancellation && !isPastDue) return null;
|
|
42
41
|
|
package/src/index.ts
CHANGED
|
@@ -155,6 +155,7 @@ export {
|
|
|
155
155
|
} from "./modules/charges/types/charge.type";
|
|
156
156
|
export { buildPlanExtras } from "./modules/subscriptions/utils/build-plan-extras";
|
|
157
157
|
export { hasSubscriptionExpired } from "./modules/subscriptions/utils/has-subscription-expired";
|
|
158
|
+
export { SUBSCRIPTION_GRACE_PERIOD_DAYS } from "./modules/subscriptions/constants/subscription.constants";
|
|
158
159
|
export {
|
|
159
160
|
useCountPages,
|
|
160
161
|
COUNT_PAGES_QUERY_KEY,
|
|
@@ -199,7 +200,7 @@ export type {
|
|
|
199
200
|
|
|
200
201
|
// Utils
|
|
201
202
|
export { cn } from "./infra/utils/clsx";
|
|
202
|
-
export { formatShortDate, formatDateTime } from "./infra/utils/date";
|
|
203
|
+
export { formatShortDate, formatDateTime, calendarDateSchema, toCalendarDate } from "./infra/utils/date";
|
|
203
204
|
export { buildQueryParams } from "./infra/utils/params";
|
|
204
205
|
export { parseSchema, parseResult } from "./infra/utils/parser";
|
|
205
206
|
export { withAction } from "./utils/withAction";
|
package/src/infra/utils/date.ts
CHANGED
|
@@ -1,10 +1,44 @@
|
|
|
1
|
+
import z from 'zod';
|
|
2
|
+
|
|
3
|
+
function parseCalendarDate(val: unknown): Date | unknown {
|
|
4
|
+
if (val == null) return val;
|
|
5
|
+
if (val instanceof Date) return val;
|
|
6
|
+
if (typeof val === 'string') {
|
|
7
|
+
const dateOnly = val.match(/^(\d{4})-(\d{2})-(\d{2})$/);
|
|
8
|
+
if (dateOnly) {
|
|
9
|
+
return new Date(Number(dateOnly[1]), Number(dateOnly[2]) - 1, Number(dateOnly[3]));
|
|
10
|
+
}
|
|
11
|
+
const noTz = val.match(/^(\d{4})-(\d{2})-(\d{2})[T ](\d{2}):(\d{2})(?::(\d{2}))?$/);
|
|
12
|
+
if (noTz) {
|
|
13
|
+
return new Date(
|
|
14
|
+
Number(noTz[1]),
|
|
15
|
+
Number(noTz[2]) - 1,
|
|
16
|
+
Number(noTz[3]),
|
|
17
|
+
Number(noTz[4]),
|
|
18
|
+
Number(noTz[5]),
|
|
19
|
+
Number(noTz[6] ?? 0)
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
return new Date(val);
|
|
23
|
+
}
|
|
24
|
+
return val;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const calendarDateSchema = () => z.preprocess(parseCalendarDate, z.date());
|
|
28
|
+
|
|
29
|
+
export function toCalendarDate(date: Date | string | null | undefined): Date | null {
|
|
30
|
+
if (!date) return null;
|
|
31
|
+
const parsed = parseCalendarDate(date);
|
|
32
|
+
return parsed instanceof Date ? parsed : null;
|
|
33
|
+
}
|
|
34
|
+
|
|
1
35
|
export function formatShortDate(date: Date | string | null | undefined): string {
|
|
2
36
|
if (!date) return '--';
|
|
3
|
-
const d = new Date(date);
|
|
4
|
-
const day = String(d.
|
|
5
|
-
const month = String(d.
|
|
6
|
-
if (d.
|
|
7
|
-
return `${day}/${month}/${d.
|
|
37
|
+
const d = toCalendarDate(date) ?? new Date(date);
|
|
38
|
+
const day = String(d.getDate()).padStart(2, '0');
|
|
39
|
+
const month = String(d.getMonth() + 1).padStart(2, '0');
|
|
40
|
+
if (d.getFullYear() !== new Date().getFullYear()) {
|
|
41
|
+
return `${day}/${month}/${d.getFullYear()}`;
|
|
8
42
|
}
|
|
9
43
|
return `${day}/${month}`;
|
|
10
44
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { PaginationParamsSchema, SearchParamsSchema, SortParamsSchema } from '../../../infra/api/types';
|
|
2
|
+
import { calendarDateSchema } from '../../../infra/utils/date';
|
|
2
3
|
import z from 'zod';
|
|
3
4
|
|
|
4
5
|
const BoletoPaymentDetailsSchema = z.object({
|
|
@@ -20,8 +21,8 @@ export const ChargeSchema = z.object({
|
|
|
20
21
|
id_account: z.coerce.number(),
|
|
21
22
|
status: z.coerce.number().nullable().optional().transform((val) => val ?? 0),
|
|
22
23
|
description: z.string().nullable().optional(),
|
|
23
|
-
date_due:
|
|
24
|
-
date_payment:
|
|
24
|
+
date_due: calendarDateSchema().nullable().optional(),
|
|
25
|
+
date_payment: calendarDateSchema().nullable().optional(),
|
|
25
26
|
payment_method: z.number().nullable().optional(),
|
|
26
27
|
value: z.coerce.number().nullable().optional().transform((val) => val ?? 0),
|
|
27
28
|
type: z.number().nullable().optional(),
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const SUBSCRIPTION_GRACE_PERIOD_DAYS = 15;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import z from 'zod';
|
|
2
|
+
import { calendarDateSchema } from '../../../infra/utils/date';
|
|
2
3
|
|
|
3
4
|
export const SubscriptionItemSchema = z.object({
|
|
4
5
|
id: z.union([z.number(), z.string()]),
|
|
@@ -40,10 +41,10 @@ export const SubscriptionSchema = z.object({
|
|
|
40
41
|
plan_name: z.string().nullable().optional(),
|
|
41
42
|
id_gateway: z.union([z.number(), z.string()]).nullable(),
|
|
42
43
|
gateway_account: z.string().nullable(),
|
|
43
|
-
date_hiring:
|
|
44
|
-
date_due:
|
|
45
|
-
date_cancellation:
|
|
46
|
-
date_verification:
|
|
44
|
+
date_hiring: calendarDateSchema().nullable(),
|
|
45
|
+
date_due: calendarDateSchema().nullable(),
|
|
46
|
+
date_cancellation: calendarDateSchema().nullable(),
|
|
47
|
+
date_verification: calendarDateSchema().nullable(),
|
|
47
48
|
cancellation_reason: z.string().nullable(),
|
|
48
49
|
cancellation_description: z.string().nullable(),
|
|
49
50
|
active: z.boolean(),
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
import { SUBSCRIPTION_GRACE_PERIOD_DAYS } from '../constants/subscription.constants';
|
|
2
2
|
|
|
3
3
|
export function hasSubscriptionExpired(dateDue: Date | null | undefined) {
|
|
4
4
|
if (!dateDue) return false;
|
|
5
5
|
|
|
6
6
|
const dueDate = new Date(dateDue);
|
|
7
|
-
dueDate.
|
|
8
|
-
dueDate.
|
|
7
|
+
dueDate.setDate(dueDate.getDate() + SUBSCRIPTION_GRACE_PERIOD_DAYS);
|
|
8
|
+
dueDate.setHours(23, 59, 59, 999);
|
|
9
9
|
|
|
10
10
|
return Date.now() > dueDate.getTime();
|
|
11
11
|
}
|