@greatapps/common 1.1.484 → 1.1.486
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/ui/data-display/CardItem.mjs +1 -1
- package/dist/components/ui/data-display/CardItem.mjs.map +1 -1
- package/dist/components/ui/data-display/PaymentInfoCard.mjs +1 -1
- package/dist/components/ui/data-display/PaymentInfoCard.mjs.map +1 -1
- package/dist/index.mjs +8 -1
- package/dist/index.mjs.map +1 -1
- package/dist/modules/cards/actions/delete-card.action.mjs +10 -0
- package/dist/modules/cards/actions/delete-card.action.mjs.map +1 -0
- package/dist/modules/cards/actions/find-card-by-id.action.mjs +10 -0
- package/dist/modules/cards/actions/find-card-by-id.action.mjs.map +1 -0
- package/dist/modules/cards/actions/set-default-card.action.mjs +10 -0
- package/dist/modules/cards/actions/set-default-card.action.mjs.map +1 -0
- package/dist/modules/cards/hooks/card-by-id.hook.mjs +22 -0
- package/dist/modules/cards/hooks/card-by-id.hook.mjs.map +1 -0
- package/dist/modules/cards/hooks/cards.hook.mjs +8 -2
- package/dist/modules/cards/hooks/cards.hook.mjs.map +1 -1
- package/dist/modules/cards/hooks/delete-card.hook.mjs +50 -0
- package/dist/modules/cards/hooks/delete-card.hook.mjs.map +1 -0
- package/dist/modules/cards/hooks/set-default-card.hook.mjs +51 -0
- package/dist/modules/cards/hooks/set-default-card.hook.mjs.map +1 -0
- package/dist/modules/cards/services/cards.service.mjs +45 -4
- package/dist/modules/cards/services/cards.service.mjs.map +1 -1
- package/dist/modules/cards/types.mjs +11 -3
- package/dist/modules/cards/types.mjs.map +1 -1
- package/package.json +1 -1
- package/src/components/ui/data-display/CardItem.tsx +1 -1
- package/src/components/ui/data-display/PaymentInfoCard.tsx +1 -1
- package/src/index.ts +5 -2
- package/src/modules/cards/actions/delete-card.action.ts +8 -0
- package/src/modules/cards/actions/find-card-by-id.action.ts +8 -0
- package/src/modules/cards/actions/set-default-card.action.ts +8 -0
- package/src/modules/cards/hooks/card-by-id.hook.ts +21 -0
- package/src/modules/cards/hooks/cards.hook.ts +8 -2
- package/src/modules/cards/hooks/delete-card.hook.ts +54 -0
- package/src/modules/cards/hooks/set-default-card.hook.ts +55 -0
- package/src/modules/cards/services/cards.service.ts +62 -5
- package/src/modules/cards/types.ts +12 -2
|
@@ -24,7 +24,7 @@ function CardItem({
|
|
|
24
24
|
/* @__PURE__ */ jsx("span", { className: "paragraph-small-semibold text-zinc-950 truncate", children: card.name }),
|
|
25
25
|
/* @__PURE__ */ jsxs("span", { className: "paragraph-small-medium text-zinc-950", children: [
|
|
26
26
|
"\u2022\u2022\u2022\u2022 ",
|
|
27
|
-
card.number.replaceAll(/\D/g, "").slice(-4)
|
|
27
|
+
(card.number ?? "").replaceAll(/\D/g, "").slice(-4)
|
|
28
28
|
] })
|
|
29
29
|
] }),
|
|
30
30
|
/* @__PURE__ */ jsx(CardBrandIcon, { brand: card.brand }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/ui/data-display/CardItem.tsx"],"sourcesContent":["'use client';\n\nimport { useState } from 'react';\nimport { IconDotsVertical, IconTrash } from '@tabler/icons-react';\nimport { Popover, PopoverContent, PopoverTrigger } from '../overlay/Popover';\nimport { NavBarItem } from '../../layouts/NavBarItem';\nimport { CardBrandIcon } from './CardBrandIcons';\nimport type { Card } from '../../../modules/cards/types';\n\ntype CardItemProps = {\n card: Card;\n isSelected?: boolean;\n onSelect?: () => void;\n showMenu?: boolean;\n canDelete?: boolean;\n onDelete?: () => void;\n};\n\nexport function CardItem({\n card,\n isSelected,\n onSelect,\n showMenu = false,\n canDelete = true,\n onDelete,\n}: CardItemProps) {\n const [popoverOpen, setPopoverOpen] = useState(false);\n\n return (\n <div\n className={`flex items-center p-4 cursor-pointer transition-colors gap-3 rounded-lg border ${\n isSelected ? 'bg-zinc-50 border-zinc-950' : 'bg-white border-zinc-200 hover:bg-zinc-50'\n }`}\n onClick={onSelect}\n >\n <div className=\"flex flex-col gap-0.5 flex-1 min-w-0\">\n <span className=\"paragraph-small-semibold text-zinc-950 truncate\">\n {card.name}\n </span>\n <span className=\"paragraph-small-medium text-zinc-950\">\n •••• {card.number.replaceAll(/\\D/g, '').slice(-4)}\n </span>\n </div>\n <CardBrandIcon brand={card.brand} />\n {showMenu && (\n <Popover open={popoverOpen} onOpenChange={setPopoverOpen}>\n <PopoverTrigger asChild>\n <button\n className=\"size-10 flex items-center justify-center rounded-lg hover:bg-zinc-100 cursor-pointer\"\n onClick={(e) => e.stopPropagation()}\n >\n <IconDotsVertical className=\"size-5 text-zinc-500\" />\n </button>\n </PopoverTrigger>\n <PopoverContent\n align=\"end\"\n className=\"w-[140px] p-2 bg-white rounded-2xl shadow-md border border-zinc-200\"\n onClick={(e) => e.stopPropagation()}\n >\n {canDelete && (\n <NavBarItem\n icon={<IconTrash size={20} className=\"text-zinc-400\" />}\n label=\"Excluir\"\n onClick={() => {\n setPopoverOpen(false);\n onDelete?.();\n }}\n />\n )}\n </PopoverContent>\n </Popover>\n )}\n </div>\n );\n}\n"],"mappings":";AAoCQ,cAGA,YAHA;AAlCR,SAAS,gBAAgB;AACzB,SAAS,kBAAkB,iBAAiB;AAC5C,SAAS,SAAS,gBAAgB,sBAAsB;AACxD,SAAS,kBAAkB;AAC3B,SAAS,qBAAqB;AAYvB,SAAS,SAAS;AAAA,EACvB;AAAA,EACA;AAAA,EACA;AAAA,EACA,WAAW;AAAA,EACX,YAAY;AAAA,EACZ;AACF,GAAkB;AAChB,QAAM,CAAC,aAAa,cAAc,IAAI,SAAS,KAAK;AAEpD,SACE;AAAA,IAAC;AAAA;AAAA,MACC,WAAW,kFACT,aAAa,+BAA+B,2CAC9C;AAAA,MACA,SAAS;AAAA,MAET;AAAA,6BAAC,SAAI,WAAU,wCACb;AAAA,8BAAC,UAAK,WAAU,mDACb,eAAK,MACR;AAAA,UACA,qBAAC,UAAK,WAAU,wCAAuC;AAAA;AAAA,
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/ui/data-display/CardItem.tsx"],"sourcesContent":["'use client';\n\nimport { useState } from 'react';\nimport { IconDotsVertical, IconTrash } from '@tabler/icons-react';\nimport { Popover, PopoverContent, PopoverTrigger } from '../overlay/Popover';\nimport { NavBarItem } from '../../layouts/NavBarItem';\nimport { CardBrandIcon } from './CardBrandIcons';\nimport type { Card } from '../../../modules/cards/types';\n\ntype CardItemProps = {\n card: Card;\n isSelected?: boolean;\n onSelect?: () => void;\n showMenu?: boolean;\n canDelete?: boolean;\n onDelete?: () => void;\n};\n\nexport function CardItem({\n card,\n isSelected,\n onSelect,\n showMenu = false,\n canDelete = true,\n onDelete,\n}: CardItemProps) {\n const [popoverOpen, setPopoverOpen] = useState(false);\n\n return (\n <div\n className={`flex items-center p-4 cursor-pointer transition-colors gap-3 rounded-lg border ${\n isSelected ? 'bg-zinc-50 border-zinc-950' : 'bg-white border-zinc-200 hover:bg-zinc-50'\n }`}\n onClick={onSelect}\n >\n <div className=\"flex flex-col gap-0.5 flex-1 min-w-0\">\n <span className=\"paragraph-small-semibold text-zinc-950 truncate\">\n {card.name}\n </span>\n <span className=\"paragraph-small-medium text-zinc-950\">\n •••• {(card.number ?? '').replaceAll(/\\D/g, '').slice(-4)}\n </span>\n </div>\n <CardBrandIcon brand={card.brand} />\n {showMenu && (\n <Popover open={popoverOpen} onOpenChange={setPopoverOpen}>\n <PopoverTrigger asChild>\n <button\n className=\"size-10 flex items-center justify-center rounded-lg hover:bg-zinc-100 cursor-pointer\"\n onClick={(e) => e.stopPropagation()}\n >\n <IconDotsVertical className=\"size-5 text-zinc-500\" />\n </button>\n </PopoverTrigger>\n <PopoverContent\n align=\"end\"\n className=\"w-[140px] p-2 bg-white rounded-2xl shadow-md border border-zinc-200\"\n onClick={(e) => e.stopPropagation()}\n >\n {canDelete && (\n <NavBarItem\n icon={<IconTrash size={20} className=\"text-zinc-400\" />}\n label=\"Excluir\"\n onClick={() => {\n setPopoverOpen(false);\n onDelete?.();\n }}\n />\n )}\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b;AAAA;AAAA,cACF;AAAA;AAAA,UAEJ;AAAA,WACF;AAAA;AAAA;AAAA,EAEJ;AAEJ;","names":[]}
|
|
@@ -39,7 +39,7 @@ function PaymentInfoCard({
|
|
|
39
39
|
if (canDeleteCards) {
|
|
40
40
|
openModal("deleteCardModal", {
|
|
41
41
|
cardId: card.id.toString(),
|
|
42
|
-
cardLastDigits: card.number.replaceAll(/\D/g, "").slice(-4),
|
|
42
|
+
cardLastDigits: (card.number ?? "").replaceAll(/\D/g, "").slice(-4),
|
|
43
43
|
onSuccess: () => {
|
|
44
44
|
if (card.id === selectedCardId && cards.length > 1) {
|
|
45
45
|
const remainingCards = cards.filter((c) => c.id !== card.id);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/ui/data-display/PaymentInfoCard.tsx"],"sourcesContent":["'use client';\n\nimport { IconChevronDown, IconPlus } from '@tabler/icons-react';\nimport { CardBrandIcon } from './CardBrandIcons';\nimport { CardItem } from './CardItem';\nimport useIsMobile from '../../../hooks/useIsMobile';\nimport { useCards } from '../../../modules/cards/hooks/cards.hook';\nimport { useCallback, useState } from 'react';\nimport { useModalManager } from '../../../store/useModalManager';\nimport type { Card } from '../../../modules/cards/types';\n\ntype PaymentInfoCardProps = {\n email?: string;\n selectedCardId: string;\n onCardSelect: (cardId: string) => void;\n onManageCards?: () => void;\n onOpenAddCard?: () => void;\n};\n\nexport function PaymentInfoCard({\n email,\n selectedCardId,\n onCardSelect,\n onManageCards,\n onOpenAddCard,\n}: PaymentInfoCardProps) {\n const isMobile = useIsMobile();\n const { openModal } = useModalManager();\n\n const [isExpanded, setIsExpanded] = useState(false);\n\n const { data: cardsData } = useCards();\n const cards = cardsData?.data ?? [];\n\n const selectedCard = cards.find((card) => card.id.toString() === selectedCardId.toString());\n\n const canDeleteCards = cards.length > 1;\n const hasCards = cards.length > 0;\n\n const hasMoreThan3Cards = cards.length > 3;\n const shouldShowManageButton = isMobile && hasMoreThan3Cards;\n const displayedCards = shouldShowManageButton ? cards.slice(0, 3) : cards;\n\n const handleOpenAddCardModal = useCallback(() => {\n if (onOpenAddCard) {\n onOpenAddCard();\n return;\n }\n openModal('addCardModal', {\n onCardAdded: (cardId: string) => onCardSelect(cardId),\n });\n }, [openModal, onOpenAddCard, onCardSelect]);\n\n const handleDeleteCard = useCallback(\n (card: Card) => {\n if (canDeleteCards) {\n openModal('deleteCardModal', {\n cardId: card.id.toString(),\n cardLastDigits: card.number.replaceAll(/\\D/g, '').slice(-4),\n onSuccess: () => {\n if (card.id === selectedCardId && cards.length > 1) {\n const remainingCards = cards.filter((c) => c.id !== card.id);\n if (remainingCards.length > 0) {\n onCardSelect(remainingCards[0].id.toString());\n }\n }\n },\n });\n }\n },\n [canDeleteCards, openModal, selectedCardId, cards, onCardSelect]\n );\n\n const handleSelectCard = useCallback(\n (cardId: string) => {\n onCardSelect(cardId);\n setIsExpanded(false);\n },\n [onCardSelect]\n );\n\n if (!hasCards) {\n return (\n <div className=\"border border-zinc-200 rounded-lg overflow-hidden\">\n {email && (\n <div className=\"flex items-center h-[60px] px-4 border-b border-zinc-200 gap-3\">\n <span className=\"paragraph-small-medium text-zinc-500 w-[100px]\">E-mail</span>\n <span className=\"paragraph-small-medium text-zinc-950 flex-1\">{email}</span>\n </div>\n )}\n <div className=\"flex items-center h-[60px] px-4 gap-3\">\n <span className=\"paragraph-small-medium text-zinc-500 w-[100px]\">Pagamento</span>\n <button\n type=\"button\"\n onClick={handleOpenAddCardModal}\n className=\"flex items-center h-8 px-2 paragraph-small-semibold text-zinc-950 border border-zinc-200 rounded-md hover:border-zinc-400 transition-colors cursor-pointer w-fit\"\n >\n <IconPlus className=\"size-[18px]\" />\n <span className=\"px-1.5\">Adicionar cartão</span>\n </button>\n </div>\n </div>\n );\n }\n\n return (\n <div className=\"flex flex-col gap-3\">\n <div className=\"border border-zinc-200 rounded-lg overflow-hidden\">\n {email && (\n <div className=\"flex items-center h-[60px] px-4 border-b border-zinc-200 gap-3\">\n <span className=\"paragraph-small-medium text-zinc-500 w-[100px]\">E-mail</span>\n <span className=\"paragraph-small-medium text-zinc-950 flex-1\">{email}</span>\n </div>\n )}\n\n <div\n className=\"flex items-center px-4 py-4 cursor-pointer gap-3\"\n onClick={() => setIsExpanded((prev) => !prev)}\n >\n {!isExpanded ? (\n <>\n <span className=\"paragraph-small-medium text-zinc-500 w-[100px]\">Pagamento</span>\n <div className=\"flex flex-col gap-0.5 flex-1 min-w-0\">\n <span className=\"paragraph-small-semibold text-zinc-950 truncate\">{selectedCard?.name}</span>\n <span className=\"paragraph-small-medium text-zinc-950\">\n •••• {selectedCard?.number?.replaceAll(/\\D/g, '')?.slice(-4)}\n </span>\n </div>\n {selectedCard && <CardBrandIcon brand={selectedCard.brand} />}\n <div className=\"size-8 flex items-center justify-center rounded-lg\">\n <IconChevronDown className=\"size-[18px] text-zinc-500\" />\n </div>\n </>\n ) : (\n <>\n <span className=\"paragraph-small-semibold text-zinc-950 flex-1\">\n Selecione a forma de pagamento\n </span>\n <div className=\"size-8 flex items-center justify-center rounded-lg\">\n <IconChevronDown className=\"size-[18px] text-zinc-500 rotate-180\" />\n </div>\n </>\n )}\n </div>\n\n <div\n className={`flex flex-col gap-2 px-4 overflow-hidden transition-all duration-300 ease-in-out ${\n isExpanded ? 'max-h-[500px] pb-4 opacity-100' : 'max-h-0 pb-0 opacity-0'\n }`}\n >\n {displayedCards.map((card) => (\n <CardItem\n key={card.id}\n card={card}\n isSelected={card.id.toString() === selectedCardId.toString()}\n onSelect={() => handleSelectCard(card.id.toString())}\n showMenu\n canDelete={canDeleteCards}\n onDelete={() => handleDeleteCard(card)}\n />\n ))}\n {shouldShowManageButton && onManageCards && (\n <button\n type=\"button\"\n onClick={onManageCards}\n className=\"flex items-center justify-center h-10 px-4 paragraph-small-semibold text-cyan-600 border border-cyan-200 rounded-lg hover:bg-cyan-50 transition-colors cursor-pointer mt-2\"\n >\n Gerenciar cartões\n </button>\n )}\n </div>\n </div>\n\n <button\n type=\"button\"\n onClick={handleOpenAddCardModal}\n className=\"flex items-center h-8 px-2 paragraph-small-semibold text-zinc-950 border border-zinc-200 rounded-md hover:border-zinc-400 transition-colors cursor-pointer w-fit\"\n >\n <IconPlus className=\"size-[18px]\" />\n <span className=\"px-1.5\">\n {isExpanded ? 'Adicionar cartão' : 'Nova forma de pagamento'}\n </span>\n </button>\n </div>\n );\n}\n"],"mappings":";AAqFU,SAmCE,UAlCA,KADF;AAnFV,SAAS,iBAAiB,gBAAgB;AAC1C,SAAS,qBAAqB;AAC9B,SAAS,gBAAgB;AACzB,OAAO,iBAAiB;AACxB,SAAS,gBAAgB;AACzB,SAAS,aAAa,gBAAgB;AACtC,SAAS,uBAAuB;AAWzB,SAAS,gBAAgB;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAyB;AACvB,QAAM,WAAW,YAAY;AAC7B,QAAM,EAAE,UAAU,IAAI,gBAAgB;AAEtC,QAAM,CAAC,YAAY,aAAa,IAAI,SAAS,KAAK;AAElD,QAAM,EAAE,MAAM,UAAU,IAAI,SAAS;AACrC,QAAM,QAAQ,WAAW,QAAQ,CAAC;AAElC,QAAM,eAAe,MAAM,KAAK,CAAC,SAAS,KAAK,GAAG,SAAS,MAAM,eAAe,SAAS,CAAC;AAE1F,QAAM,iBAAiB,MAAM,SAAS;AACtC,QAAM,WAAW,MAAM,SAAS;AAEhC,QAAM,oBAAoB,MAAM,SAAS;AACzC,QAAM,yBAAyB,YAAY;AAC3C,QAAM,iBAAiB,yBAAyB,MAAM,MAAM,GAAG,CAAC,IAAI;AAEpE,QAAM,yBAAyB,YAAY,MAAM;AAC/C,QAAI,eAAe;AACjB,oBAAc;AACd;AAAA,IACF;AACA,cAAU,gBAAgB;AAAA,MACxB,aAAa,CAAC,WAAmB,aAAa,MAAM;AAAA,IACtD,CAAC;AAAA,EACH,GAAG,CAAC,WAAW,eAAe,YAAY,CAAC;AAE3C,QAAM,mBAAmB;AAAA,IACv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A,cAAC;AAAA;AAAA,gBACC,MAAK;AAAA,gBACL,SAAS;AAAA,gBACT,WAAU;AAAA,gBACX;AAAA;AAAA,YAED;AAAA;AAAA;AAAA,MAEJ;AAAA,OACF;AAAA,IAEA;AAAA,MAAC;AAAA;AAAA,QACC,MAAK;AAAA,QACL,SAAS;AAAA,QACT,WAAU;AAAA,QAEV;AAAA,8BAAC,YAAS,WAAU,eAAc;AAAA,UAClC,oBAAC,UAAK,WAAU,UACb,uBAAa,wBAAqB,2BACrC;AAAA;AAAA;AAAA,IACF;AAAA,KACF;AAEJ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/ui/data-display/PaymentInfoCard.tsx"],"sourcesContent":["'use client';\n\nimport { IconChevronDown, IconPlus } from '@tabler/icons-react';\nimport { CardBrandIcon } from './CardBrandIcons';\nimport { CardItem } from './CardItem';\nimport useIsMobile from '../../../hooks/useIsMobile';\nimport { useCards } from '../../../modules/cards/hooks/cards.hook';\nimport { useCallback, useState } from 'react';\nimport { useModalManager } from '../../../store/useModalManager';\nimport type { Card } from '../../../modules/cards/types';\n\ntype PaymentInfoCardProps = {\n email?: string;\n selectedCardId: string;\n onCardSelect: (cardId: string) => void;\n onManageCards?: () => void;\n onOpenAddCard?: () => void;\n};\n\nexport function PaymentInfoCard({\n email,\n selectedCardId,\n onCardSelect,\n onManageCards,\n onOpenAddCard,\n}: PaymentInfoCardProps) {\n const isMobile = useIsMobile();\n const { openModal } = useModalManager();\n\n const [isExpanded, setIsExpanded] = useState(false);\n\n const { data: cardsData } = useCards();\n const cards = cardsData?.data ?? [];\n\n const selectedCard = cards.find((card) => card.id.toString() === selectedCardId.toString());\n\n const canDeleteCards = cards.length > 1;\n const hasCards = cards.length > 0;\n\n const hasMoreThan3Cards = cards.length > 3;\n const shouldShowManageButton = isMobile && hasMoreThan3Cards;\n const displayedCards = shouldShowManageButton ? cards.slice(0, 3) : cards;\n\n const handleOpenAddCardModal = useCallback(() => {\n if (onOpenAddCard) {\n onOpenAddCard();\n return;\n }\n openModal('addCardModal', {\n onCardAdded: (cardId: string) => onCardSelect(cardId),\n });\n }, [openModal, onOpenAddCard, onCardSelect]);\n\n const handleDeleteCard = useCallback(\n (card: Card) => {\n if (canDeleteCards) {\n openModal('deleteCardModal', {\n cardId: card.id.toString(),\n cardLastDigits: (card.number ?? '').replaceAll(/\\D/g, '').slice(-4),\n onSuccess: () => {\n if (card.id === selectedCardId && cards.length > 1) {\n const remainingCards = cards.filter((c) => c.id !== card.id);\n if (remainingCards.length > 0) {\n onCardSelect(remainingCards[0].id.toString());\n }\n }\n },\n });\n }\n },\n [canDeleteCards, openModal, selectedCardId, cards, onCardSelect]\n );\n\n const handleSelectCard = useCallback(\n (cardId: string) => {\n onCardSelect(cardId);\n setIsExpanded(false);\n },\n [onCardSelect]\n );\n\n if (!hasCards) {\n return (\n <div className=\"border border-zinc-200 rounded-lg overflow-hidden\">\n {email && (\n <div className=\"flex items-center h-[60px] px-4 border-b border-zinc-200 gap-3\">\n <span className=\"paragraph-small-medium text-zinc-500 w-[100px]\">E-mail</span>\n <span className=\"paragraph-small-medium text-zinc-950 flex-1\">{email}</span>\n </div>\n )}\n <div className=\"flex items-center h-[60px] px-4 gap-3\">\n <span className=\"paragraph-small-medium text-zinc-500 w-[100px]\">Pagamento</span>\n <button\n type=\"button\"\n onClick={handleOpenAddCardModal}\n className=\"flex items-center h-8 px-2 paragraph-small-semibold text-zinc-950 border border-zinc-200 rounded-md hover:border-zinc-400 transition-colors cursor-pointer w-fit\"\n >\n <IconPlus className=\"size-[18px]\" />\n <span className=\"px-1.5\">Adicionar cartão</span>\n </button>\n </div>\n </div>\n );\n }\n\n return (\n <div className=\"flex flex-col gap-3\">\n <div className=\"border border-zinc-200 rounded-lg overflow-hidden\">\n {email && (\n <div className=\"flex items-center h-[60px] px-4 border-b border-zinc-200 gap-3\">\n <span className=\"paragraph-small-medium text-zinc-500 w-[100px]\">E-mail</span>\n <span className=\"paragraph-small-medium text-zinc-950 flex-1\">{email}</span>\n </div>\n )}\n\n <div\n className=\"flex items-center px-4 py-4 cursor-pointer gap-3\"\n onClick={() => setIsExpanded((prev) => !prev)}\n >\n {!isExpanded ? (\n <>\n <span className=\"paragraph-small-medium text-zinc-500 w-[100px]\">Pagamento</span>\n <div className=\"flex flex-col gap-0.5 flex-1 min-w-0\">\n <span className=\"paragraph-small-semibold text-zinc-950 truncate\">{selectedCard?.name}</span>\n <span className=\"paragraph-small-medium text-zinc-950\">\n •••• {selectedCard?.number?.replaceAll(/\\D/g, '')?.slice(-4)}\n </span>\n </div>\n {selectedCard && <CardBrandIcon brand={selectedCard.brand} />}\n <div className=\"size-8 flex items-center justify-center rounded-lg\">\n <IconChevronDown className=\"size-[18px] text-zinc-500\" />\n </div>\n </>\n ) : (\n <>\n <span className=\"paragraph-small-semibold text-zinc-950 flex-1\">\n Selecione a forma de pagamento\n </span>\n <div className=\"size-8 flex items-center justify-center rounded-lg\">\n <IconChevronDown className=\"size-[18px] text-zinc-500 rotate-180\" />\n </div>\n </>\n )}\n </div>\n\n <div\n className={`flex flex-col gap-2 px-4 overflow-hidden transition-all duration-300 ease-in-out ${\n isExpanded ? 'max-h-[500px] pb-4 opacity-100' : 'max-h-0 pb-0 opacity-0'\n }`}\n >\n {displayedCards.map((card) => (\n <CardItem\n key={card.id}\n card={card}\n isSelected={card.id.toString() === selectedCardId.toString()}\n onSelect={() => handleSelectCard(card.id.toString())}\n showMenu\n canDelete={canDeleteCards}\n onDelete={() => handleDeleteCard(card)}\n />\n ))}\n {shouldShowManageButton && onManageCards && (\n <button\n type=\"button\"\n onClick={onManageCards}\n className=\"flex items-center justify-center h-10 px-4 paragraph-small-semibold text-cyan-600 border border-cyan-200 rounded-lg hover:bg-cyan-50 transition-colors cursor-pointer mt-2\"\n >\n Gerenciar cartões\n </button>\n )}\n </div>\n </div>\n\n <button\n type=\"button\"\n onClick={handleOpenAddCardModal}\n className=\"flex items-center h-8 px-2 paragraph-small-semibold text-zinc-950 border border-zinc-200 rounded-md hover:border-zinc-400 transition-colors cursor-pointer w-fit\"\n >\n <IconPlus className=\"size-[18px]\" />\n <span className=\"px-1.5\">\n {isExpanded ? 'Adicionar cartão' : 'Nova forma de pagamento'}\n </span>\n </button>\n </div>\n );\n}\n"],"mappings":";AAqFU,SAmCE,UAlCA,KADF;AAnFV,SAAS,iBAAiB,gBAAgB;AAC1C,SAAS,qBAAqB;AAC9B,SAAS,gBAAgB;AACzB,OAAO,iBAAiB;AACxB,SAAS,gBAAgB;AACzB,SAAS,aAAa,gBAAgB;AACtC,SAAS,uBAAuB;AAWzB,SAAS,gBAAgB;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAyB;AACvB,QAAM,WAAW,YAAY;AAC7B,QAAM,EAAE,UAAU,IAAI,gBAAgB;AAEtC,QAAM,CAAC,YAAY,aAAa,IAAI,SAAS,KAAK;AAElD,QAAM,EAAE,MAAM,UAAU,IAAI,SAAS;AACrC,QAAM,QAAQ,WAAW,QAAQ,CAAC;AAElC,QAAM,eAAe,MAAM,KAAK,CAAC,SAAS,KAAK,GAAG,SAAS,MAAM,eAAe,SAAS,CAAC;AAE1F,QAAM,iBAAiB,MAAM,SAAS;AACtC,QAAM,WAAW,MAAM,SAAS;AAEhC,QAAM,oBAAoB,MAAM,SAAS;AACzC,QAAM,yBAAyB,YAAY;AAC3C,QAAM,iBAAiB,yBAAyB,MAAM,MAAM,GAAG,CAAC,IAAI;AAEpE,QAAM,yBAAyB,YAAY,MAAM;AAC/C,QAAI,eAAe;AACjB,oBAAc;AACd;AAAA,IACF;AACA,cAAU,gBAAgB;AAAA,MACxB,aAAa,CAAC,WAAmB,aAAa,MAAM;AAAA,IACtD,CAAC;AAAA,EACH,GAAG,CAAC,WAAW,eAAe,YAAY,CAAC;AAE3C,QAAM,mBAAmB;AAAA,IACvB,CAAC,SAAe;AACd,UAAI,gBAAgB;AAClB,kBAAU,mBAAmB;AAAA,UAC3B,QAAQ,KAAK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BACX;AAAA;AAAA,YAED;AAAA;AAAA;AAAA,MAEJ;AAAA,OACF;AAAA,IAEA;AAAA,MAAC;AAAA;AAAA,QACC,MAAK;AAAA,QACL,SAAS;AAAA,QACT,WAAU;AAAA,QAEV;AAAA,8BAAC,YAAS,WAAU,eAAc;AAAA,UAClC,oBAAC,UAAK,WAAU,UACb,uBAAa,wBAAqB,2BACrC;AAAA;AAAA;AAAA,IACF;AAAA,KACF;AAEJ;","names":[]}
|
package/dist/index.mjs
CHANGED
|
@@ -38,7 +38,10 @@ import { useHasPlanAddon } from "./modules/plans/hooks/use-has-plan-addon.hook";
|
|
|
38
38
|
import { useCalculateSubscription } from "./modules/subscriptions/hooks/calculate-subscription.hook";
|
|
39
39
|
import { useUpdateSubscriptionPlan } from "./modules/subscriptions/hooks/update-subscription-plan.hook";
|
|
40
40
|
import { useCards, CARDS_QUERY_KEY } from "./modules/cards/hooks/cards.hook";
|
|
41
|
+
import { useCardById } from "./modules/cards/hooks/card-by-id.hook";
|
|
41
42
|
import { useCreateCard } from "./modules/cards/hooks/create-card.hook";
|
|
43
|
+
import { useSetDefaultCard } from "./modules/cards/hooks/set-default-card.hook";
|
|
44
|
+
import { useDeleteCard } from "./modules/cards/hooks/delete-card.hook";
|
|
42
45
|
import { useIaCredits } from "./modules/ia-credits/hooks/ia-credits.hook";
|
|
43
46
|
import {
|
|
44
47
|
SubscriptionSchema,
|
|
@@ -48,7 +51,7 @@ import { ADDON_IDS, AI_CREDIT_OPTIONS, AI_CREDIT_VALUES } from "./modules/subscr
|
|
|
48
51
|
import { PlanSchema, PlanItemSchema } from "./modules/plans/types/plan.type";
|
|
49
52
|
import { mapApiPlanToUiPlan } from "./modules/plans/utils/map-api-plan-to-ui";
|
|
50
53
|
import { usePlans, PLANS_QUERY_KEY } from "./modules/plans/hooks/list-plans.hook";
|
|
51
|
-
import { CardSchema, CreateCardRequestSchema } from "./modules/cards/types";
|
|
54
|
+
import { CardSchema, CreateCardRequestSchema, FindCardsParamsSchema } from "./modules/cards/types";
|
|
52
55
|
import { buildPlanExtras } from "./modules/subscriptions/utils/build-plan-extras";
|
|
53
56
|
import { hasSubscriptionExpired } from "./modules/subscriptions/utils/has-subscription-expired";
|
|
54
57
|
import { getPriceFromCalculatedData, periodicityToBillingPeriod } from "./modules/subscriptions/utils/periodicity";
|
|
@@ -384,6 +387,7 @@ export {
|
|
|
384
387
|
DialogTrigger,
|
|
385
388
|
default18 as DisableTwoFactorAuthModal,
|
|
386
389
|
EmbedWidgets,
|
|
390
|
+
FindCardsParamsSchema,
|
|
387
391
|
FormField,
|
|
388
392
|
FrillEmbed,
|
|
389
393
|
GENDER_OPTIONS,
|
|
@@ -544,6 +548,7 @@ export {
|
|
|
544
548
|
useBuyCreditsModal,
|
|
545
549
|
useCalculateSubscription,
|
|
546
550
|
useCancelledSubscriptionGuard,
|
|
551
|
+
useCardById,
|
|
547
552
|
useCards,
|
|
548
553
|
default7 as useCopyToClipboard,
|
|
549
554
|
default12 as useCountdownTimer,
|
|
@@ -554,6 +559,7 @@ export {
|
|
|
554
559
|
useDebouncedEffect,
|
|
555
560
|
useDeleteAccount,
|
|
556
561
|
useDeleteAccountUser,
|
|
562
|
+
useDeleteCard,
|
|
557
563
|
useDesktopSidebarStore,
|
|
558
564
|
useHasPlanAddon,
|
|
559
565
|
useIaCredits,
|
|
@@ -571,6 +577,7 @@ export {
|
|
|
571
577
|
default11 as usePasswordVisibility,
|
|
572
578
|
usePlanById,
|
|
573
579
|
usePlans,
|
|
580
|
+
useSetDefaultCard,
|
|
574
581
|
useSetUserData,
|
|
575
582
|
useSubscriptions,
|
|
576
583
|
useTwoFactorVerify,
|
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 type {\n ProjectUser,\n AccountUser,\n AddRemoveProjectUsersParams,\n ListUsersParams,\n UsersPage,\n} from \"./modules/projects/types\";\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 { SUBSCRIPTIONS_QUERY_KEY, CHARGES_QUERY_KEY } 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 { useCards, CARDS_QUERY_KEY } from \"./modules/cards/hooks/cards.hook\";\nexport { useCreateCard } from \"./modules/cards/hooks/create-card.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 { ADDON_IDS, AI_CREDIT_OPTIONS, AI_CREDIT_VALUES } from \"./modules/subscriptions/constants/addons.constants\";\nexport type { AddonKindEnum, AiCreditOption } from \"./modules/subscriptions/constants/addons.constants\";\nexport type { Plan, PlanItem, UiPlan, PlanFeature, PlanMainFeatures, PlanPricingByPeriod, PlanTooltips } 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 { usePlans, PLANS_QUERY_KEY } 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 { Card as PaymentCard, CreateCardRequest } from \"./modules/cards/types\";\nexport { CardSchema as PaymentCardSchema, CreateCardRequestSchema } from \"./modules/cards/types\";\nexport { buildPlanExtras } from \"./modules/subscriptions/utils/build-plan-extras\";\nexport { hasSubscriptionExpired } from \"./modules/subscriptions/utils/has-subscription-expired\";\nexport { getPriceFromCalculatedData, periodicityToBillingPeriod } from \"./modules/subscriptions/utils/periodicity\";\nexport { useBuyCreditsModal } from \"./store/useBuyCreditsModal\";\nexport { usePaidPlanRequiredModal } from \"./store/usePaidPlanRequiredModal\";\nexport { default as BuyCreditsModal } from \"./components/modals/BuyCreditsModal\";\nexport { default as PaidPlanRequiredModal } from \"./components/modals/PaidPlanRequiredModal\";\nexport { default as AddCardModal } from \"./components/modals/cards/AddCardModal\";\nexport { CardFormFields, cardFormSchema } 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 type { NavItemConfig } from './components/navigation/subcomponents/NavItems';\nexport type { NavigationProject } from './components/navigation/types';\nexport { useMobileNavbarSheet } from './store/useMobileNavbarSheet';\n\n// Auth Query Key Utilities\nexport { useAuthQueryKey, useWlQueryKey, useWlId } 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 { CrispEmbed, openCrispHelpdesk, hideCrisp, showCrisp, updateCrispUser } from \"./components/embeds/CrispEmbed\";\nexport { EmbedWidgets } from \"./components/embeds/EmbedWidgets\";\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\";\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,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;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;AAgB1B,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 type {\n ProjectUser,\n AccountUser,\n AddRemoveProjectUsersParams,\n ListUsersParams,\n UsersPage,\n} from \"./modules/projects/types\";\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 { SUBSCRIPTIONS_QUERY_KEY, CHARGES_QUERY_KEY } 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 { 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 { useSetDefaultCard } from \"./modules/cards/hooks/set-default-card.hook\";\nexport { useDeleteCard } from \"./modules/cards/hooks/delete-card.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 { ADDON_IDS, AI_CREDIT_OPTIONS, AI_CREDIT_VALUES } from \"./modules/subscriptions/constants/addons.constants\";\nexport type { AddonKindEnum, AiCreditOption } from \"./modules/subscriptions/constants/addons.constants\";\nexport type { Plan, PlanItem, UiPlan, PlanFeature, PlanMainFeatures, PlanPricingByPeriod, PlanTooltips } 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 { usePlans, PLANS_QUERY_KEY } 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 { Card as PaymentCard, CreateCardRequest, FindCardsParams } from \"./modules/cards/types\";\nexport { CardSchema as PaymentCardSchema, CreateCardRequestSchema, FindCardsParamsSchema } from \"./modules/cards/types\";\nexport { buildPlanExtras } from \"./modules/subscriptions/utils/build-plan-extras\";\nexport { hasSubscriptionExpired } from \"./modules/subscriptions/utils/has-subscription-expired\";\nexport { getPriceFromCalculatedData, periodicityToBillingPeriod } from \"./modules/subscriptions/utils/periodicity\";\nexport { useBuyCreditsModal } from \"./store/useBuyCreditsModal\";\nexport { usePaidPlanRequiredModal } from \"./store/usePaidPlanRequiredModal\";\nexport { default as BuyCreditsModal } from \"./components/modals/BuyCreditsModal\";\nexport { default as PaidPlanRequiredModal } from \"./components/modals/PaidPlanRequiredModal\";\nexport { default as AddCardModal } from \"./components/modals/cards/AddCardModal\";\nexport { CardFormFields, cardFormSchema } 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 type { NavItemConfig } from './components/navigation/subcomponents/NavItems';\nexport type { NavigationProject } from './components/navigation/types';\nexport { useMobileNavbarSheet } from './store/useMobileNavbarSheet';\n\n// Auth Query Key Utilities\nexport { useAuthQueryKey, useWlQueryKey, useWlId } 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 { CrispEmbed, openCrispHelpdesk, hideCrisp, showCrisp, updateCrispUser } from \"./components/embeds/CrispEmbed\";\nexport { EmbedWidgets } from \"./components/embeds/EmbedWidgets\";\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\";\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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AwB;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;AAgB1B,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"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use server";
|
|
2
|
+
import { safeServerAction } from "../../../utils/safeServerAction";
|
|
3
|
+
import { cardsService } from "../services/cards.service";
|
|
4
|
+
async function deleteCardAction(id) {
|
|
5
|
+
return safeServerAction(() => cardsService.deleteCard(id));
|
|
6
|
+
}
|
|
7
|
+
export {
|
|
8
|
+
deleteCardAction
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=delete-card.action.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/cards/actions/delete-card.action.ts"],"sourcesContent":["'use server';\n\nimport { safeServerAction } from '../../../utils/safeServerAction';\nimport { cardsService } from '../services/cards.service';\n\nexport async function deleteCardAction(id: string) {\n return safeServerAction(() => cardsService.deleteCard(id));\n}\n"],"mappings":";AAEA,SAAS,wBAAwB;AACjC,SAAS,oBAAoB;AAE7B,eAAsB,iBAAiB,IAAY;AACjD,SAAO,iBAAiB,MAAM,aAAa,WAAW,EAAE,CAAC;AAC3D;","names":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use server";
|
|
2
|
+
import { safeServerAction } from "../../../utils/safeServerAction";
|
|
3
|
+
import { cardsService } from "../services/cards.service";
|
|
4
|
+
async function findCardByIdAction(id) {
|
|
5
|
+
return safeServerAction(() => cardsService.findCardById(id));
|
|
6
|
+
}
|
|
7
|
+
export {
|
|
8
|
+
findCardByIdAction
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=find-card-by-id.action.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/cards/actions/find-card-by-id.action.ts"],"sourcesContent":["'use server';\n\nimport { safeServerAction } from '../../../utils/safeServerAction';\nimport { cardsService } from '../services/cards.service';\n\nexport async function findCardByIdAction(id: number) {\n return safeServerAction(() => cardsService.findCardById(id));\n}\n"],"mappings":";AAEA,SAAS,wBAAwB;AACjC,SAAS,oBAAoB;AAE7B,eAAsB,mBAAmB,IAAY;AACnD,SAAO,iBAAiB,MAAM,aAAa,aAAa,EAAE,CAAC;AAC7D;","names":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use server";
|
|
2
|
+
import { safeServerAction } from "../../../utils/safeServerAction";
|
|
3
|
+
import { cardsService } from "../services/cards.service";
|
|
4
|
+
async function setDefaultCardAction(cardId) {
|
|
5
|
+
return safeServerAction(() => cardsService.setDefaultCard(cardId));
|
|
6
|
+
}
|
|
7
|
+
export {
|
|
8
|
+
setDefaultCardAction
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=set-default-card.action.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/cards/actions/set-default-card.action.ts"],"sourcesContent":["'use server';\n\nimport { safeServerAction } from '../../../utils/safeServerAction';\nimport { cardsService } from '../services/cards.service';\n\nexport async function setDefaultCardAction(cardId: string) {\n return safeServerAction(() => cardsService.setDefaultCard(cardId));\n}\n"],"mappings":";AAEA,SAAS,wBAAwB;AACjC,SAAS,oBAAoB;AAE7B,eAAsB,qBAAqB,QAAgB;AACzD,SAAO,iBAAiB,MAAM,aAAa,eAAe,MAAM,CAAC;AACnE;","names":[]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useQuery } from "@tanstack/react-query";
|
|
3
|
+
import { withAction } from "../../../utils/withAction";
|
|
4
|
+
import { useAuthQueryKey } from "../../../hooks/useAuthQueryKey";
|
|
5
|
+
import { useAuth } from "../../../providers/auth.provider";
|
|
6
|
+
function useCardById(id) {
|
|
7
|
+
const { account } = useAuth();
|
|
8
|
+
const isVindi = account?.gateway === "vindi";
|
|
9
|
+
const cardKey = useAuthQueryKey(["card", id]);
|
|
10
|
+
return useQuery({
|
|
11
|
+
queryKey: cardKey,
|
|
12
|
+
queryFn: async () => {
|
|
13
|
+
const { findCardByIdAction } = await import("../actions/find-card-by-id.action");
|
|
14
|
+
return withAction(findCardByIdAction)(id);
|
|
15
|
+
},
|
|
16
|
+
enabled: id != null && !isVindi
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
export {
|
|
20
|
+
useCardById
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=card-by-id.hook.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/cards/hooks/card-by-id.hook.ts"],"sourcesContent":["'use client';\n\nimport { useQuery } from '@tanstack/react-query';\nimport { withAction } from '../../../utils/withAction';\nimport { useAuthQueryKey } from '../../../hooks/useAuthQueryKey';\nimport { useAuth } from '../../../providers/auth.provider';\n\nexport function useCardById(id: number | undefined) {\n const { account } = useAuth();\n const isVindi = account?.gateway === 'vindi';\n const cardKey = useAuthQueryKey(['card', id]);\n\n return useQuery({\n queryKey: cardKey,\n queryFn: async () => {\n const { findCardByIdAction } = await import('../actions/find-card-by-id.action');\n return withAction(findCardByIdAction)(id!);\n },\n enabled: id != null && !isVindi,\n });\n}\n"],"mappings":";AAEA,SAAS,gBAAgB;AACzB,SAAS,kBAAkB;AAC3B,SAAS,uBAAuB;AAChC,SAAS,eAAe;AAEjB,SAAS,YAAY,IAAwB;AAClD,QAAM,EAAE,QAAQ,IAAI,QAAQ;AAC5B,QAAM,UAAU,SAAS,YAAY;AACrC,QAAM,UAAU,gBAAgB,CAAC,QAAQ,EAAE,CAAC;AAE5C,SAAO,SAAS;AAAA,IACd,UAAU;AAAA,IACV,SAAS,YAAY;AACnB,YAAM,EAAE,mBAAmB,IAAI,MAAM,OAAO,mCAAmC;AAC/E,aAAO,WAAW,kBAAkB,EAAE,EAAG;AAAA,IAC3C;AAAA,IACA,SAAS,MAAM,QAAQ,CAAC;AAAA,EAC1B,CAAC;AACH;","names":[]}
|
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useQuery } from "@tanstack/react-query";
|
|
3
3
|
import { withAction } from "../../../utils/withAction";
|
|
4
|
-
import { listCardsAction } from "../actions/list-cards.action";
|
|
5
4
|
import { useAuthQueryKey } from "../../../hooks/useAuthQueryKey";
|
|
5
|
+
import { useAuth } from "../../../providers/auth.provider";
|
|
6
6
|
const CARDS_QUERY_KEY = ["cards"];
|
|
7
7
|
function useCards() {
|
|
8
|
+
const { account } = useAuth();
|
|
9
|
+
const isVindi = account?.gateway === "vindi";
|
|
8
10
|
const queryKey = useAuthQueryKey([...CARDS_QUERY_KEY]);
|
|
9
11
|
return useQuery({
|
|
10
12
|
queryKey,
|
|
11
|
-
queryFn:
|
|
13
|
+
queryFn: async () => {
|
|
14
|
+
const { listCardsAction } = await import("../actions/list-cards.action");
|
|
15
|
+
return withAction(listCardsAction)();
|
|
16
|
+
},
|
|
17
|
+
enabled: !isVindi
|
|
12
18
|
});
|
|
13
19
|
}
|
|
14
20
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/modules/cards/hooks/cards.hook.ts"],"sourcesContent":["'use client';\n\nimport { useQuery } from '@tanstack/react-query';\nimport { withAction } from '../../../utils/withAction';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/cards/hooks/cards.hook.ts"],"sourcesContent":["'use client';\n\nimport { useQuery } from '@tanstack/react-query';\nimport { withAction } from '../../../utils/withAction';\nimport { useAuthQueryKey } from '../../../hooks/useAuthQueryKey';\nimport { useAuth } from '../../../providers/auth.provider';\n\nexport const CARDS_QUERY_KEY = ['cards'] as const;\n\nexport function useCards() {\n const { account } = useAuth();\n const isVindi = account?.gateway === 'vindi';\n const queryKey = useAuthQueryKey([...CARDS_QUERY_KEY]);\n\n return useQuery({\n queryKey,\n queryFn: async () => {\n const { listCardsAction } = await import('../actions/list-cards.action');\n return withAction(listCardsAction)();\n },\n enabled: !isVindi,\n });\n}\n"],"mappings":";AAEA,SAAS,gBAAgB;AACzB,SAAS,kBAAkB;AAC3B,SAAS,uBAAuB;AAChC,SAAS,eAAe;AAEjB,MAAM,kBAAkB,CAAC,OAAO;AAEhC,SAAS,WAAW;AACzB,QAAM,EAAE,QAAQ,IAAI,QAAQ;AAC5B,QAAM,UAAU,SAAS,YAAY;AACrC,QAAM,WAAW,gBAAgB,CAAC,GAAG,eAAe,CAAC;AAErD,SAAO,SAAS;AAAA,IACd;AAAA,IACA,SAAS,YAAY;AACnB,YAAM,EAAE,gBAAgB,IAAI,MAAM,OAAO,8BAA8B;AACvE,aAAO,WAAW,eAAe,EAAE;AAAA,IACrC;AAAA,IACA,SAAS,CAAC;AAAA,EACZ,CAAC;AACH;","names":[]}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
3
|
+
import { withAction } from "../../../utils/withAction";
|
|
4
|
+
import { useAuthQueryKey } from "../../../hooks/useAuthQueryKey";
|
|
5
|
+
import { CARDS_QUERY_KEY } from "./cards.hook";
|
|
6
|
+
function useDeleteCard() {
|
|
7
|
+
const queryClient = useQueryClient();
|
|
8
|
+
const cardsKey = useAuthQueryKey([...CARDS_QUERY_KEY]);
|
|
9
|
+
const cardKey = useAuthQueryKey(["card"]);
|
|
10
|
+
return useMutation({
|
|
11
|
+
mutationFn: async (id) => {
|
|
12
|
+
const { deleteCardAction } = await import("../actions/delete-card.action");
|
|
13
|
+
return withAction(deleteCardAction)(id);
|
|
14
|
+
},
|
|
15
|
+
onMutate: async (id) => {
|
|
16
|
+
await queryClient.cancelQueries({ queryKey: cardsKey });
|
|
17
|
+
const previousQueries = queryClient.getQueriesData({
|
|
18
|
+
queryKey: cardsKey
|
|
19
|
+
});
|
|
20
|
+
queryClient.setQueriesData(
|
|
21
|
+
{ queryKey: cardsKey },
|
|
22
|
+
(old) => {
|
|
23
|
+
if (!old?.data) return old;
|
|
24
|
+
return {
|
|
25
|
+
...old,
|
|
26
|
+
data: old.data.map(
|
|
27
|
+
(card) => card.id.toString() === id ? { ...card, deleted: true } : card
|
|
28
|
+
)
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
);
|
|
32
|
+
return { previousQueries };
|
|
33
|
+
},
|
|
34
|
+
onError: (_err, _id, context) => {
|
|
35
|
+
if (context?.previousQueries) {
|
|
36
|
+
for (const [queryKey, data] of context.previousQueries) {
|
|
37
|
+
queryClient.setQueryData(queryKey, data);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
onSettled: () => {
|
|
42
|
+
queryClient.invalidateQueries({ queryKey: cardsKey });
|
|
43
|
+
queryClient.invalidateQueries({ queryKey: cardKey });
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
export {
|
|
48
|
+
useDeleteCard
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=delete-card.hook.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/cards/hooks/delete-card.hook.ts"],"sourcesContent":["'use client';\n\nimport { useMutation, useQueryClient } from '@tanstack/react-query';\nimport { withAction } from '../../../utils/withAction';\nimport { useAuthQueryKey } from '../../../hooks/useAuthQueryKey';\nimport { CARDS_QUERY_KEY } from './cards.hook';\nimport type { PaginatedSuccessResult } from '../../../infra/api/types';\nimport type { Card } from '../types';\n\nexport function useDeleteCard() {\n const queryClient = useQueryClient();\n const cardsKey = useAuthQueryKey([...CARDS_QUERY_KEY]);\n const cardKey = useAuthQueryKey(['card']);\n\n return useMutation({\n mutationFn: async (id: string) => {\n const { deleteCardAction } = await import('../actions/delete-card.action');\n return withAction(deleteCardAction)(id);\n },\n onMutate: async (id: string) => {\n await queryClient.cancelQueries({ queryKey: cardsKey });\n\n const previousQueries = queryClient.getQueriesData<PaginatedSuccessResult<Card>>({\n queryKey: cardsKey,\n });\n\n queryClient.setQueriesData<PaginatedSuccessResult<Card>>(\n { queryKey: cardsKey },\n (old) => {\n if (!old?.data) return old;\n return {\n ...old,\n data: old.data.map((card) =>\n card.id.toString() === id ? { ...card, deleted: true } : card\n ),\n };\n }\n );\n\n return { previousQueries };\n },\n onError: (_err, _id, context) => {\n if (context?.previousQueries) {\n for (const [queryKey, data] of context.previousQueries) {\n queryClient.setQueryData(queryKey, data);\n }\n }\n },\n onSettled: () => {\n queryClient.invalidateQueries({ queryKey: cardsKey });\n queryClient.invalidateQueries({ queryKey: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H;","names":[]}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
3
|
+
import { withAction } from "../../../utils/withAction";
|
|
4
|
+
import { useAuthQueryKey } from "../../../hooks/useAuthQueryKey";
|
|
5
|
+
import { CARDS_QUERY_KEY } from "./cards.hook";
|
|
6
|
+
function useSetDefaultCard() {
|
|
7
|
+
const queryClient = useQueryClient();
|
|
8
|
+
const cardsKey = useAuthQueryKey([...CARDS_QUERY_KEY]);
|
|
9
|
+
const cardKey = useAuthQueryKey(["card"]);
|
|
10
|
+
return useMutation({
|
|
11
|
+
mutationFn: async (cardId) => {
|
|
12
|
+
const { setDefaultCardAction } = await import("../actions/set-default-card.action");
|
|
13
|
+
return withAction(setDefaultCardAction)(cardId);
|
|
14
|
+
},
|
|
15
|
+
onMutate: async (cardId) => {
|
|
16
|
+
await queryClient.cancelQueries({ queryKey: cardsKey });
|
|
17
|
+
const previousQueries = queryClient.getQueriesData({
|
|
18
|
+
queryKey: cardsKey
|
|
19
|
+
});
|
|
20
|
+
queryClient.setQueriesData(
|
|
21
|
+
{ queryKey: cardsKey },
|
|
22
|
+
(old) => {
|
|
23
|
+
if (!old?.data) return old;
|
|
24
|
+
return {
|
|
25
|
+
...old,
|
|
26
|
+
data: old.data.map((card) => ({
|
|
27
|
+
...card,
|
|
28
|
+
is_default: card.id.toString() === cardId
|
|
29
|
+
}))
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
return { previousQueries };
|
|
34
|
+
},
|
|
35
|
+
onError: (_err, _cardId, context) => {
|
|
36
|
+
if (context?.previousQueries) {
|
|
37
|
+
for (const [queryKey, data] of context.previousQueries) {
|
|
38
|
+
queryClient.setQueryData(queryKey, data);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
onSettled: () => {
|
|
43
|
+
queryClient.invalidateQueries({ queryKey: cardsKey });
|
|
44
|
+
queryClient.invalidateQueries({ queryKey: cardKey });
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
export {
|
|
49
|
+
useSetDefaultCard
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=set-default-card.hook.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/cards/hooks/set-default-card.hook.ts"],"sourcesContent":["'use client';\n\nimport { useMutation, useQueryClient } from '@tanstack/react-query';\nimport { withAction } from '../../../utils/withAction';\nimport { useAuthQueryKey } from '../../../hooks/useAuthQueryKey';\nimport { CARDS_QUERY_KEY } from './cards.hook';\nimport type { PaginatedSuccessResult } from '../../../infra/api/types';\nimport type { Card } from '../types';\n\nexport function useSetDefaultCard() {\n const queryClient = useQueryClient();\n const cardsKey = useAuthQueryKey([...CARDS_QUERY_KEY]);\n const cardKey = useAuthQueryKey(['card']);\n\n return useMutation({\n mutationFn: async (cardId: string) => {\n const { setDefaultCardAction } = await import('../actions/set-default-card.action');\n return withAction(setDefaultCardAction)(cardId);\n },\n onMutate: async (cardId: string) => {\n await queryClient.cancelQueries({ queryKey: cardsKey });\n\n const previousQueries = queryClient.getQueriesData<PaginatedSuccessResult<Card>>({\n queryKey: cardsKey,\n });\n\n queryClient.setQueriesData<PaginatedSuccessResult<Card>>(\n { queryKey: cardsKey },\n (old) => {\n if (!old?.data) return old;\n return {\n ...old,\n data: old.data.map((card) => ({\n ...card,\n is_default: card.id.toString() === cardId,\n })),\n };\n }\n );\n\n return { previousQueries };\n },\n onError: (_err, _cardId, context) => {\n if (context?.previousQueries) {\n for (const [queryKey, data] of context.previousQueries) {\n queryClient.setQueryData(queryKey, data);\n }\n }\n },\n onSettled: () => {\n queryClient.invalidateQueries({ queryKey: cardsKey });\n queryClient.invalidateQueries({ queryKey: cardKey });\n },\n });\n}\n"],"mappings":";AAEA,SAAS,aAAa,sBAAsB;AAC5C,SAAS,kBAAkB;AAC3B,SAAS,uBAAuB;AAChC,SAAS,uBAAuB;AAIzB,SAAS,oBAAoB;AAClC,QAAM,cAAc,eAAe;AACnC,QAAM,WAAW,gBAAgB,CAAC,GAAG,eAAe,CAAC;AACrD,QAAM,UAAU,gBAAgB,CAAC,MAAM,CAAC;AAExC,SAAO,YAAY;AAAA,IACjB,YAAY,OAAO,WAAmB;AACpC,YAAM,EAAE,qBAAqB,IAAI,MAAM,OAAO,oCAAoC;AAClF,aAAO,WAAW,oBAAoB,EAAE,MAAM;AAAA,IAChD;AAAA,IACA,UAAU,OAAO,WAAmB;AAClC,YAAM,YAAY,cAAc,EAAE,UAAU,SAAS,CAAC;AAEtD,YAAM,kBAAkB,YAAY,eAA6C;AAAA,QAC/E,UAAU;AAAA,MACZ,CAAC;AAED,kBAAY;AAAA,QACV,EAAE,UAAU,SAAS;AAAA,QACrB,CAAC,QAAQ;AACP,cAAI,CAAC,KAAK,KAAM,QAAO;AACvB,iBAAO;AAAA,YACL,GAAG;AAAA,YACH,MAAM,IAAI,KAAK,IAAI,CAAC,UAAU;AAAA,cAC5B,GAAG;AAAA,cACH,YAAY,KAAK,GAAG,SAAS,MAAM;AAAA,YACrC,EAAE;AAAA,UACJ;AAAA,QACF;AAAA,MACF;AAEA,aAAO,EAAE,gBAAgB;AAAA,IAC3B;AAAA,IACA,SAAS,CAAC,MAAM,SAAS,YAAY;AACnC,UAAI,SAAS,iBAAiB;AAC5B,mBAAW,CAAC,UAAU,IAAI,KAAK,QAAQ,iBAAiB;AACtD,sBAAY,aAAa,UAAU,IAAI;AAAA,QACzC;AAAA,MACF;AAAA,IACF;AAAA,IACA,WAAW,MAAM;AACf,kBAAY,kBAAkB,EAAE,UAAU,SAAS,CAAC;AACpD,kBAAY,kBAAkB,EAAE,UAAU,QAAQ,CAAC;AAAA,IACrD;AAAA,EACF,CAAC;AACH;","names":[]}
|
|
@@ -21,6 +21,24 @@ class CardsService {
|
|
|
21
21
|
const data = response.data.map((item) => CardSchema.parse(item));
|
|
22
22
|
return { data, total: response.total, success: true };
|
|
23
23
|
}
|
|
24
|
+
async findCardById(id) {
|
|
25
|
+
const { id_account } = await getUserContext();
|
|
26
|
+
const response = await api.apps.get(
|
|
27
|
+
`/accounts/${id_account}/cards/${id}`
|
|
28
|
+
);
|
|
29
|
+
if (response.status === 0) {
|
|
30
|
+
throw new ApiError(
|
|
31
|
+
response.message || "Erro ao buscar cart\xE3o",
|
|
32
|
+
"FIND_CARD_BY_ID_FAILED",
|
|
33
|
+
400
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
if (!response.data?.length) {
|
|
37
|
+
throw new ApiError("Cart\xE3o n\xE3o encontrado", "CARD_NOT_FOUND", 404);
|
|
38
|
+
}
|
|
39
|
+
const data = CardSchema.parse(response.data[0]);
|
|
40
|
+
return { success: true, data };
|
|
41
|
+
}
|
|
24
42
|
async createCard(data) {
|
|
25
43
|
const { id_account } = await getUserContext();
|
|
26
44
|
const response = await api.apps.post(
|
|
@@ -31,10 +49,33 @@ class CardsService {
|
|
|
31
49
|
throw new ApiError(response.message || "Erro ao criar cart\xE3o", "CREATE_CARD_FAILED", 400);
|
|
32
50
|
}
|
|
33
51
|
const cardData = CardSchema.parse(response.data[0]);
|
|
34
|
-
return {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
};
|
|
52
|
+
return { success: true, data: cardData };
|
|
53
|
+
}
|
|
54
|
+
async setDefaultCard(cardId) {
|
|
55
|
+
const { id_account } = await getUserContext();
|
|
56
|
+
const response = await api.apps.put(
|
|
57
|
+
`/accounts/${id_account}/cards/${cardId}`,
|
|
58
|
+
{ set_default: true }
|
|
59
|
+
);
|
|
60
|
+
if (response.status === 0) {
|
|
61
|
+
throw new ApiError(
|
|
62
|
+
response.message || "Erro ao definir cart\xE3o padr\xE3o",
|
|
63
|
+
"SET_DEFAULT_CARD_FAILED",
|
|
64
|
+
400
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
const data = CardSchema.parse(response.data[0]);
|
|
68
|
+
return { success: true, data };
|
|
69
|
+
}
|
|
70
|
+
async deleteCard(id) {
|
|
71
|
+
const { id_account } = await getUserContext();
|
|
72
|
+
const response = await api.apps.delete(
|
|
73
|
+
`/accounts/${id_account}/cards/${id}`
|
|
74
|
+
);
|
|
75
|
+
if (response.status === 0) {
|
|
76
|
+
throw new ApiError(response.message || "Erro ao excluir cart\xE3o", "DELETE_CARD_FAILED", 400);
|
|
77
|
+
}
|
|
78
|
+
return { success: true };
|
|
38
79
|
}
|
|
39
80
|
}
|
|
40
81
|
const cardsService = new CardsService();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/modules/cards/services/cards.service.ts"],"sourcesContent":["import 'server-only';\n\nimport { api } from '../../../infra/api/client';\nimport { ApiError, ApiPaginatedActionResult, PaginatedSuccessResult, SuccessResult } from '../../../infra/api/types';\nimport { buildQueryParams } from '../../../infra/utils/params';\nimport { getUserContext } from '../../auth/utils/get-user-context';\nimport { Card, CardSchema, CreateCardRequest } from '../types';\n\nclass CardsService {\n async listCards(): Promise<PaginatedSuccessResult<Card>> {\n const { id_account } = await getUserContext();\n\n const query = buildQueryParams({ id_account });\n const response = await api.apps.get<ApiPaginatedActionResult<Card>>(\n `/accounts/${id_account}/cards?${query}`\n );\n\n if (response.status === 0) {\n throw new ApiError(\n response.message || 'Erro ao listar cartões',\n 'LIST_CARDS_FAILED',\n 400\n );\n }\n\n const data = response.data.map((item) => CardSchema.parse(item));\n\n return { data, total: response.total, success: true };\n }\n async createCard(data: CreateCardRequest): Promise<SuccessResult<Card>> {\n const { id_account } = await getUserContext();\n\n const response = await api.apps.post<ApiPaginatedActionResult<Card>>(\n `/accounts/${id_account}/cards`,\n data\n );\n\n if (response.status === 0) {\n throw new ApiError(response.message || 'Erro ao criar cartão', 'CREATE_CARD_FAILED', 400);\n }\n\n const cardData = CardSchema.parse(response.data[0]);\n\n return {\n
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/cards/services/cards.service.ts"],"sourcesContent":["import 'server-only';\n\nimport { api } from '../../../infra/api/client';\nimport { ApiError, ApiActionResult, ApiPaginatedActionResult, PaginatedSuccessResult, SuccessResult } from '../../../infra/api/types';\nimport { buildQueryParams } from '../../../infra/utils/params';\nimport { getUserContext } from '../../auth/utils/get-user-context';\nimport { Card, CardSchema, CreateCardRequest } from '../types';\n\nclass CardsService {\n async listCards(): Promise<PaginatedSuccessResult<Card>> {\n const { id_account } = await getUserContext();\n\n const query = buildQueryParams({ id_account });\n const response = await api.apps.get<ApiPaginatedActionResult<Card>>(\n `/accounts/${id_account}/cards?${query}`\n );\n\n if (response.status === 0) {\n throw new ApiError(\n response.message || 'Erro ao listar cartões',\n 'LIST_CARDS_FAILED',\n 400\n );\n }\n\n const data = response.data.map((item) => CardSchema.parse(item));\n\n return { data, total: response.total, success: true };\n }\n\n async findCardById(id: number): Promise<SuccessResult<Card>> {\n const { id_account } = await getUserContext();\n\n const response = await api.apps.get<ApiPaginatedActionResult<Card>>(\n `/accounts/${id_account}/cards/${id}`\n );\n\n if (response.status === 0) {\n throw new ApiError(\n response.message || 'Erro ao buscar cartão',\n 'FIND_CARD_BY_ID_FAILED',\n 400\n );\n }\n\n if (!response.data?.length) {\n throw new ApiError('Cartão não encontrado', 'CARD_NOT_FOUND', 404);\n }\n\n const data = CardSchema.parse(response.data[0]);\n\n return { success: true, data };\n }\n\n async createCard(data: CreateCardRequest): Promise<SuccessResult<Card>> {\n const { id_account } = await getUserContext();\n\n const response = await api.apps.post<ApiPaginatedActionResult<Card>>(\n `/accounts/${id_account}/cards`,\n data\n );\n\n if (response.status === 0) {\n throw new ApiError(response.message || 'Erro ao criar cartão', 'CREATE_CARD_FAILED', 400);\n }\n\n const cardData = CardSchema.parse(response.data[0]);\n\n return { success: true, data: cardData };\n }\n\n async setDefaultCard(cardId: string): Promise<SuccessResult<Card>> {\n const { id_account } = await getUserContext();\n\n const response = await api.apps.put<ApiPaginatedActionResult<Card>>(\n `/accounts/${id_account}/cards/${cardId}`,\n { set_default: true }\n );\n\n if (response.status === 0) {\n throw new ApiError(\n response.message || 'Erro ao definir cartão padrão',\n 'SET_DEFAULT_CARD_FAILED',\n 400\n );\n }\n\n const data = CardSchema.parse(response.data[0]);\n\n return { success: true, data };\n }\n\n async deleteCard(id: string): Promise<SuccessResult<void>> {\n const { id_account } = await getUserContext();\n\n const response = await api.apps.delete<ApiActionResult<void>>(\n `/accounts/${id_account}/cards/${id}`\n );\n\n if (response.status === 0) {\n throw new ApiError(response.message || 'Erro ao excluir cartão', 'DELETE_CARD_FAILED', 400);\n }\n\n return { success: true };\n }\n}\n\nexport const cardsService = new CardsService();\n"],"mappings":"AAAA,OAAO;AAEP,SAAS,WAAW;AACpB,SAAS,gBAAkG;AAC3G,SAAS,wBAAwB;AACjC,SAAS,sBAAsB;AAC/B,SAAe,kBAAqC;AAEpD,MAAM,aAAa;AAAA,EACjB,MAAM,YAAmD;AACvD,UAAM,EAAE,WAAW,IAAI,MAAM,eAAe;AAE5C,UAAM,QAAQ,iBAAiB,EAAE,WAAW,CAAC;AAC7C,UAAM,WAAW,MAAM,IAAI,KAAK;AAAA,MAC9B,aAAa,UAAU,UAAU,KAAK;AAAA,IACxC;AAEA,QAAI,SAAS,WAAW,GAAG;AACzB,YAAM,IAAI;AAAA,QACR,SAAS,WAAW;AAAA,QACpB;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAEA,UAAM,OAAO,SAAS,KAAK,IAAI,CAAC,SAAS,WAAW,MAAM,IAAI,CAAC;AAE/D,WAAO,EAAE,MAAM,OAAO,SAAS,OAAO,SAAS,KAAK;AAAA,EACtD;AAAA,EAEA,MAAM,aAAa,IAA0C;AAC3D,UAAM,EAAE,WAAW,IAAI,MAAM,eAAe;AAE5C,UAAM,WAAW,MAAM,IAAI,KAAK;AAAA,MAC9B,aAAa,UAAU,UAAU,EAAE;AAAA,IACrC;AAEA,QAAI,SAAS,WAAW,GAAG;AACzB,YAAM,IAAI;AAAA,QACR,SAAS,WAAW;AAAA,QACpB;AA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WAAW,6BAA0B,sBAAsB,GAAG;AAAA,IAC5F;AAEA,WAAO,EAAE,SAAS,KAAK;AAAA,EACzB;AACF;AAEO,MAAM,eAAe,IAAI,aAAa;","names":[]}
|
|
@@ -8,8 +8,8 @@ const CardSchema = z.object({
|
|
|
8
8
|
gateway_card: z.string().optional(),
|
|
9
9
|
brand: z.string(),
|
|
10
10
|
name: z.string(),
|
|
11
|
-
number: z.string(),
|
|
12
|
-
date: z.string().optional(),
|
|
11
|
+
number: z.string().nullable(),
|
|
12
|
+
date: z.string().nullable().optional(),
|
|
13
13
|
deleted: z.number().transform((val) => val === 1).optional().default(false),
|
|
14
14
|
is_default: z.boolean().optional().default(false),
|
|
15
15
|
datetime_add: z.union([z.date(), z.coerce.date()]).nullable().optional(),
|
|
@@ -20,8 +20,16 @@ const CreateCardRequestSchema = z.object({
|
|
|
20
20
|
payment_method_id: z.string().min(1, "payment_method_id \xE9 obrigat\xF3rio"),
|
|
21
21
|
set_default: z.boolean().optional()
|
|
22
22
|
});
|
|
23
|
+
const FindCardsParamsSchema = z.object({
|
|
24
|
+
page: z.number().optional(),
|
|
25
|
+
limit: z.number().optional(),
|
|
26
|
+
search: z.string().optional(),
|
|
27
|
+
sort: z.string().optional(),
|
|
28
|
+
order: z.enum(["asc", "desc"]).optional()
|
|
29
|
+
});
|
|
23
30
|
export {
|
|
24
31
|
CardSchema,
|
|
25
|
-
CreateCardRequestSchema
|
|
32
|
+
CreateCardRequestSchema,
|
|
33
|
+
FindCardsParamsSchema
|
|
26
34
|
};
|
|
27
35
|
//# sourceMappingURL=types.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/modules/cards/types.ts"],"sourcesContent":["import z from 'zod';\n\nexport const CardSchema = z.object({\n id: z.union([z.number(), z.string()]),\n id_wl: z.number().optional(),\n id_account: z.union([z.number(), z.string()]).optional(),\n id_gateway: z.union([z.number(), z.string()]).optional(),\n gateway_account: z.string().optional(),\n gateway_card: z.string().optional(),\n brand: z.string(),\n name: z.string(),\n number: z.string(),\n date: z.string().optional(),\n deleted: z\n .number()\n .transform((val) => val === 1)\n .optional()\n .default(false),\n is_default: z.boolean().optional().default(false),\n datetime_add: z.union([z.date(), z.coerce.date()]).nullable().optional(),\n datetime_alt: z.union([z.date(), z.coerce.date()]).nullable().optional(),\n datetime_del: z.union([z.date(), z.coerce.date()]).nullable().optional(),\n});\n\nexport type Card = z.infer<typeof CardSchema>;\n\nexport const CreateCardRequestSchema = z.object({\n payment_method_id: z.string().min(1, 'payment_method_id é obrigatório'),\n set_default: z.boolean().optional(),\n});\n\nexport type CreateCardRequest = z.infer<typeof CreateCardRequestSchema>;\n"],"mappings":"AAAA,OAAO,OAAO;AAEP,MAAM,aAAa,EAAE,OAAO;AAAA,EACjC,IAAI,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC,CAAC;AAAA,EACpC,OAAO,EAAE,OAAO,EAAE,SAAS;AAAA,EAC3B,YAAY,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC,CAAC,EAAE,SAAS;AAAA,EACvD,YAAY,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC,CAAC,EAAE,SAAS;AAAA,EACvD,iBAAiB,EAAE,OAAO,EAAE,SAAS;AAAA,EACrC,cAAc,EAAE,OAAO,EAAE,SAAS;AAAA,EAClC,OAAO,EAAE,OAAO;AAAA,EAChB,MAAM,EAAE,OAAO;AAAA,EACf,QAAQ,EAAE,OAAO;AAAA,
|
|
1
|
+
{"version":3,"sources":["../../../src/modules/cards/types.ts"],"sourcesContent":["import z from 'zod';\n\nexport const CardSchema = z.object({\n id: z.union([z.number(), z.string()]),\n id_wl: z.number().optional(),\n id_account: z.union([z.number(), z.string()]).optional(),\n id_gateway: z.union([z.number(), z.string()]).optional(),\n gateway_account: z.string().optional(),\n gateway_card: z.string().optional(),\n brand: z.string(),\n name: z.string(),\n number: z.string().nullable(),\n date: z.string().nullable().optional(),\n deleted: z\n .number()\n .transform((val) => val === 1)\n .optional()\n .default(false),\n is_default: z.boolean().optional().default(false),\n datetime_add: z.union([z.date(), z.coerce.date()]).nullable().optional(),\n datetime_alt: z.union([z.date(), z.coerce.date()]).nullable().optional(),\n datetime_del: z.union([z.date(), z.coerce.date()]).nullable().optional(),\n});\n\nexport type Card = z.infer<typeof CardSchema>;\n\nexport const CreateCardRequestSchema = z.object({\n payment_method_id: z.string().min(1, 'payment_method_id é obrigatório'),\n set_default: z.boolean().optional(),\n});\n\nexport type CreateCardRequest = z.infer<typeof CreateCardRequestSchema>;\n\nexport const FindCardsParamsSchema = z.object({\n page: z.number().optional(),\n limit: z.number().optional(),\n search: z.string().optional(),\n sort: z.string().optional(),\n order: z.enum(['asc', 'desc']).optional(),\n});\n\nexport type FindCardsParams = z.infer<typeof FindCardsParamsSchema>;\n"],"mappings":"AAAA,OAAO,OAAO;AAEP,MAAM,aAAa,EAAE,OAAO;AAAA,EACjC,IAAI,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC,CAAC;AAAA,EACpC,OAAO,EAAE,OAAO,EAAE,SAAS;AAAA,EAC3B,YAAY,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC,CAAC,EAAE,SAAS;AAAA,EACvD,YAAY,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC,CAAC,EAAE,SAAS;AAAA,EACvD,iBAAiB,EAAE,OAAO,EAAE,SAAS;AAAA,EACrC,cAAc,EAAE,OAAO,EAAE,SAAS;AAAA,EAClC,OAAO,EAAE,OAAO;AAAA,EAChB,MAAM,EAAE,OAAO;AAAA,EACf,QAAQ,EAAE,OAAO,EAAE,SAAS;AAAA,EAC5B,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS;AAAA,EACrC,SAAS,EACN,OAAO,EACP,UAAU,CAAC,QAAQ,QAAQ,CAAC,EAC5B,SAAS,EACT,QAAQ,KAAK;AAAA,EAChB,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,KAAK;AAAA,EAChD,cAAc,EAAE,MAAM,CAAC,EAAE,KAAK,GAAG,EAAE,OAAO,KAAK,CAAC,CAAC,EAAE,SAAS,EAAE,SAAS;AAAA,EACvE,cAAc,EAAE,MAAM,CAAC,EAAE,KAAK,GAAG,EAAE,OAAO,KAAK,CAAC,CAAC,EAAE,SAAS,EAAE,SAAS;AAAA,EACvE,cAAc,EAAE,MAAM,CAAC,EAAE,KAAK,GAAG,EAAE,OAAO,KAAK,CAAC,CAAC,EAAE,SAAS,EAAE,SAAS;AACzE,CAAC;AAIM,MAAM,0BAA0B,EAAE,OAAO;AAAA,EAC9C,mBAAmB,EAAE,OAAO,EAAE,IAAI,GAAG,uCAAiC;AAAA,EACtE,aAAa,EAAE,QAAQ,EAAE,SAAS;AACpC,CAAC;AAIM,MAAM,wBAAwB,EAAE,OAAO;AAAA,EAC5C,MAAM,EAAE,OAAO,EAAE,SAAS;AAAA,EAC1B,OAAO,EAAE,OAAO,EAAE,SAAS;AAAA,EAC3B,QAAQ,EAAE,OAAO,EAAE,SAAS;AAAA,EAC5B,MAAM,EAAE,OAAO,EAAE,SAAS;AAAA,EAC1B,OAAO,EAAE,KAAK,CAAC,OAAO,MAAM,CAAC,EAAE,SAAS;AAC1C,CAAC;","names":[]}
|
package/package.json
CHANGED
|
@@ -38,7 +38,7 @@ export function CardItem({
|
|
|
38
38
|
{card.name}
|
|
39
39
|
</span>
|
|
40
40
|
<span className="paragraph-small-medium text-zinc-950">
|
|
41
|
-
•••• {card.number.replaceAll(/\D/g, '').slice(-4)}
|
|
41
|
+
•••• {(card.number ?? '').replaceAll(/\D/g, '').slice(-4)}
|
|
42
42
|
</span>
|
|
43
43
|
</div>
|
|
44
44
|
<CardBrandIcon brand={card.brand} />
|
|
@@ -56,7 +56,7 @@ export function PaymentInfoCard({
|
|
|
56
56
|
if (canDeleteCards) {
|
|
57
57
|
openModal('deleteCardModal', {
|
|
58
58
|
cardId: card.id.toString(),
|
|
59
|
-
cardLastDigits: card.number.replaceAll(/\D/g, '').slice(-4),
|
|
59
|
+
cardLastDigits: (card.number ?? '').replaceAll(/\D/g, '').slice(-4),
|
|
60
60
|
onSuccess: () => {
|
|
61
61
|
if (card.id === selectedCardId && cards.length > 1) {
|
|
62
62
|
const remainingCards = cards.filter((c) => c.id !== card.id);
|
package/src/index.ts
CHANGED
|
@@ -52,7 +52,10 @@ export { useHasPlanAddon } from "./modules/plans/hooks/use-has-plan-addon.hook";
|
|
|
52
52
|
export { useCalculateSubscription } from "./modules/subscriptions/hooks/calculate-subscription.hook";
|
|
53
53
|
export { useUpdateSubscriptionPlan } from "./modules/subscriptions/hooks/update-subscription-plan.hook";
|
|
54
54
|
export { useCards, CARDS_QUERY_KEY } from "./modules/cards/hooks/cards.hook";
|
|
55
|
+
export { useCardById } from "./modules/cards/hooks/card-by-id.hook";
|
|
55
56
|
export { useCreateCard } from "./modules/cards/hooks/create-card.hook";
|
|
57
|
+
export { useSetDefaultCard } from "./modules/cards/hooks/set-default-card.hook";
|
|
58
|
+
export { useDeleteCard } from "./modules/cards/hooks/delete-card.hook";
|
|
56
59
|
export { useIaCredits } from "./modules/ia-credits/hooks/ia-credits.hook";
|
|
57
60
|
export type {
|
|
58
61
|
IaCreditsSummary,
|
|
@@ -80,8 +83,8 @@ export type {
|
|
|
80
83
|
CalculateSubscriptionResponse,
|
|
81
84
|
UpdateSubscriptionPlanRequest,
|
|
82
85
|
} from "./modules/subscriptions/types/calculate-subscription.type";
|
|
83
|
-
export type { Card as PaymentCard, CreateCardRequest } from "./modules/cards/types";
|
|
84
|
-
export { CardSchema as PaymentCardSchema, CreateCardRequestSchema } from "./modules/cards/types";
|
|
86
|
+
export type { Card as PaymentCard, CreateCardRequest, FindCardsParams } from "./modules/cards/types";
|
|
87
|
+
export { CardSchema as PaymentCardSchema, CreateCardRequestSchema, FindCardsParamsSchema } from "./modules/cards/types";
|
|
85
88
|
export { buildPlanExtras } from "./modules/subscriptions/utils/build-plan-extras";
|
|
86
89
|
export { hasSubscriptionExpired } from "./modules/subscriptions/utils/has-subscription-expired";
|
|
87
90
|
export { getPriceFromCalculatedData, periodicityToBillingPeriod } from "./modules/subscriptions/utils/periodicity";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
'use server';
|
|
2
|
+
|
|
3
|
+
import { safeServerAction } from '../../../utils/safeServerAction';
|
|
4
|
+
import { cardsService } from '../services/cards.service';
|
|
5
|
+
|
|
6
|
+
export async function deleteCardAction(id: string) {
|
|
7
|
+
return safeServerAction(() => cardsService.deleteCard(id));
|
|
8
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
'use server';
|
|
2
|
+
|
|
3
|
+
import { safeServerAction } from '../../../utils/safeServerAction';
|
|
4
|
+
import { cardsService } from '../services/cards.service';
|
|
5
|
+
|
|
6
|
+
export async function findCardByIdAction(id: number) {
|
|
7
|
+
return safeServerAction(() => cardsService.findCardById(id));
|
|
8
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
'use server';
|
|
2
|
+
|
|
3
|
+
import { safeServerAction } from '../../../utils/safeServerAction';
|
|
4
|
+
import { cardsService } from '../services/cards.service';
|
|
5
|
+
|
|
6
|
+
export async function setDefaultCardAction(cardId: string) {
|
|
7
|
+
return safeServerAction(() => cardsService.setDefaultCard(cardId));
|
|
8
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useQuery } from '@tanstack/react-query';
|
|
4
|
+
import { withAction } from '../../../utils/withAction';
|
|
5
|
+
import { useAuthQueryKey } from '../../../hooks/useAuthQueryKey';
|
|
6
|
+
import { useAuth } from '../../../providers/auth.provider';
|
|
7
|
+
|
|
8
|
+
export function useCardById(id: number | undefined) {
|
|
9
|
+
const { account } = useAuth();
|
|
10
|
+
const isVindi = account?.gateway === 'vindi';
|
|
11
|
+
const cardKey = useAuthQueryKey(['card', id]);
|
|
12
|
+
|
|
13
|
+
return useQuery({
|
|
14
|
+
queryKey: cardKey,
|
|
15
|
+
queryFn: async () => {
|
|
16
|
+
const { findCardByIdAction } = await import('../actions/find-card-by-id.action');
|
|
17
|
+
return withAction(findCardByIdAction)(id!);
|
|
18
|
+
},
|
|
19
|
+
enabled: id != null && !isVindi,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
@@ -2,16 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
import { useQuery } from '@tanstack/react-query';
|
|
4
4
|
import { withAction } from '../../../utils/withAction';
|
|
5
|
-
import { listCardsAction } from '../actions/list-cards.action';
|
|
6
5
|
import { useAuthQueryKey } from '../../../hooks/useAuthQueryKey';
|
|
6
|
+
import { useAuth } from '../../../providers/auth.provider';
|
|
7
7
|
|
|
8
8
|
export const CARDS_QUERY_KEY = ['cards'] as const;
|
|
9
9
|
|
|
10
10
|
export function useCards() {
|
|
11
|
+
const { account } = useAuth();
|
|
12
|
+
const isVindi = account?.gateway === 'vindi';
|
|
11
13
|
const queryKey = useAuthQueryKey([...CARDS_QUERY_KEY]);
|
|
12
14
|
|
|
13
15
|
return useQuery({
|
|
14
16
|
queryKey,
|
|
15
|
-
queryFn:
|
|
17
|
+
queryFn: async () => {
|
|
18
|
+
const { listCardsAction } = await import('../actions/list-cards.action');
|
|
19
|
+
return withAction(listCardsAction)();
|
|
20
|
+
},
|
|
21
|
+
enabled: !isVindi,
|
|
16
22
|
});
|
|
17
23
|
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
|
4
|
+
import { withAction } from '../../../utils/withAction';
|
|
5
|
+
import { useAuthQueryKey } from '../../../hooks/useAuthQueryKey';
|
|
6
|
+
import { CARDS_QUERY_KEY } from './cards.hook';
|
|
7
|
+
import type { PaginatedSuccessResult } from '../../../infra/api/types';
|
|
8
|
+
import type { Card } from '../types';
|
|
9
|
+
|
|
10
|
+
export function useDeleteCard() {
|
|
11
|
+
const queryClient = useQueryClient();
|
|
12
|
+
const cardsKey = useAuthQueryKey([...CARDS_QUERY_KEY]);
|
|
13
|
+
const cardKey = useAuthQueryKey(['card']);
|
|
14
|
+
|
|
15
|
+
return useMutation({
|
|
16
|
+
mutationFn: async (id: string) => {
|
|
17
|
+
const { deleteCardAction } = await import('../actions/delete-card.action');
|
|
18
|
+
return withAction(deleteCardAction)(id);
|
|
19
|
+
},
|
|
20
|
+
onMutate: async (id: string) => {
|
|
21
|
+
await queryClient.cancelQueries({ queryKey: cardsKey });
|
|
22
|
+
|
|
23
|
+
const previousQueries = queryClient.getQueriesData<PaginatedSuccessResult<Card>>({
|
|
24
|
+
queryKey: cardsKey,
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
queryClient.setQueriesData<PaginatedSuccessResult<Card>>(
|
|
28
|
+
{ queryKey: cardsKey },
|
|
29
|
+
(old) => {
|
|
30
|
+
if (!old?.data) return old;
|
|
31
|
+
return {
|
|
32
|
+
...old,
|
|
33
|
+
data: old.data.map((card) =>
|
|
34
|
+
card.id.toString() === id ? { ...card, deleted: true } : card
|
|
35
|
+
),
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
return { previousQueries };
|
|
41
|
+
},
|
|
42
|
+
onError: (_err, _id, context) => {
|
|
43
|
+
if (context?.previousQueries) {
|
|
44
|
+
for (const [queryKey, data] of context.previousQueries) {
|
|
45
|
+
queryClient.setQueryData(queryKey, data);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
onSettled: () => {
|
|
50
|
+
queryClient.invalidateQueries({ queryKey: cardsKey });
|
|
51
|
+
queryClient.invalidateQueries({ queryKey: cardKey });
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
|
4
|
+
import { withAction } from '../../../utils/withAction';
|
|
5
|
+
import { useAuthQueryKey } from '../../../hooks/useAuthQueryKey';
|
|
6
|
+
import { CARDS_QUERY_KEY } from './cards.hook';
|
|
7
|
+
import type { PaginatedSuccessResult } from '../../../infra/api/types';
|
|
8
|
+
import type { Card } from '../types';
|
|
9
|
+
|
|
10
|
+
export function useSetDefaultCard() {
|
|
11
|
+
const queryClient = useQueryClient();
|
|
12
|
+
const cardsKey = useAuthQueryKey([...CARDS_QUERY_KEY]);
|
|
13
|
+
const cardKey = useAuthQueryKey(['card']);
|
|
14
|
+
|
|
15
|
+
return useMutation({
|
|
16
|
+
mutationFn: async (cardId: string) => {
|
|
17
|
+
const { setDefaultCardAction } = await import('../actions/set-default-card.action');
|
|
18
|
+
return withAction(setDefaultCardAction)(cardId);
|
|
19
|
+
},
|
|
20
|
+
onMutate: async (cardId: string) => {
|
|
21
|
+
await queryClient.cancelQueries({ queryKey: cardsKey });
|
|
22
|
+
|
|
23
|
+
const previousQueries = queryClient.getQueriesData<PaginatedSuccessResult<Card>>({
|
|
24
|
+
queryKey: cardsKey,
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
queryClient.setQueriesData<PaginatedSuccessResult<Card>>(
|
|
28
|
+
{ queryKey: cardsKey },
|
|
29
|
+
(old) => {
|
|
30
|
+
if (!old?.data) return old;
|
|
31
|
+
return {
|
|
32
|
+
...old,
|
|
33
|
+
data: old.data.map((card) => ({
|
|
34
|
+
...card,
|
|
35
|
+
is_default: card.id.toString() === cardId,
|
|
36
|
+
})),
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
return { previousQueries };
|
|
42
|
+
},
|
|
43
|
+
onError: (_err, _cardId, context) => {
|
|
44
|
+
if (context?.previousQueries) {
|
|
45
|
+
for (const [queryKey, data] of context.previousQueries) {
|
|
46
|
+
queryClient.setQueryData(queryKey, data);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
onSettled: () => {
|
|
51
|
+
queryClient.invalidateQueries({ queryKey: cardsKey });
|
|
52
|
+
queryClient.invalidateQueries({ queryKey: cardKey });
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import 'server-only';
|
|
2
2
|
|
|
3
3
|
import { api } from '../../../infra/api/client';
|
|
4
|
-
import { ApiError, ApiPaginatedActionResult, PaginatedSuccessResult, SuccessResult } from '../../../infra/api/types';
|
|
4
|
+
import { ApiError, ApiActionResult, ApiPaginatedActionResult, PaginatedSuccessResult, SuccessResult } from '../../../infra/api/types';
|
|
5
5
|
import { buildQueryParams } from '../../../infra/utils/params';
|
|
6
6
|
import { getUserContext } from '../../auth/utils/get-user-context';
|
|
7
7
|
import { Card, CardSchema, CreateCardRequest } from '../types';
|
|
@@ -27,6 +27,31 @@ class CardsService {
|
|
|
27
27
|
|
|
28
28
|
return { data, total: response.total, success: true };
|
|
29
29
|
}
|
|
30
|
+
|
|
31
|
+
async findCardById(id: number): Promise<SuccessResult<Card>> {
|
|
32
|
+
const { id_account } = await getUserContext();
|
|
33
|
+
|
|
34
|
+
const response = await api.apps.get<ApiPaginatedActionResult<Card>>(
|
|
35
|
+
`/accounts/${id_account}/cards/${id}`
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
if (response.status === 0) {
|
|
39
|
+
throw new ApiError(
|
|
40
|
+
response.message || 'Erro ao buscar cartão',
|
|
41
|
+
'FIND_CARD_BY_ID_FAILED',
|
|
42
|
+
400
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (!response.data?.length) {
|
|
47
|
+
throw new ApiError('Cartão não encontrado', 'CARD_NOT_FOUND', 404);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const data = CardSchema.parse(response.data[0]);
|
|
51
|
+
|
|
52
|
+
return { success: true, data };
|
|
53
|
+
}
|
|
54
|
+
|
|
30
55
|
async createCard(data: CreateCardRequest): Promise<SuccessResult<Card>> {
|
|
31
56
|
const { id_account } = await getUserContext();
|
|
32
57
|
|
|
@@ -41,10 +66,42 @@ class CardsService {
|
|
|
41
66
|
|
|
42
67
|
const cardData = CardSchema.parse(response.data[0]);
|
|
43
68
|
|
|
44
|
-
return {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
69
|
+
return { success: true, data: cardData };
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
async setDefaultCard(cardId: string): Promise<SuccessResult<Card>> {
|
|
73
|
+
const { id_account } = await getUserContext();
|
|
74
|
+
|
|
75
|
+
const response = await api.apps.put<ApiPaginatedActionResult<Card>>(
|
|
76
|
+
`/accounts/${id_account}/cards/${cardId}`,
|
|
77
|
+
{ set_default: true }
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
if (response.status === 0) {
|
|
81
|
+
throw new ApiError(
|
|
82
|
+
response.message || 'Erro ao definir cartão padrão',
|
|
83
|
+
'SET_DEFAULT_CARD_FAILED',
|
|
84
|
+
400
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const data = CardSchema.parse(response.data[0]);
|
|
89
|
+
|
|
90
|
+
return { success: true, data };
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
async deleteCard(id: string): Promise<SuccessResult<void>> {
|
|
94
|
+
const { id_account } = await getUserContext();
|
|
95
|
+
|
|
96
|
+
const response = await api.apps.delete<ApiActionResult<void>>(
|
|
97
|
+
`/accounts/${id_account}/cards/${id}`
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
if (response.status === 0) {
|
|
101
|
+
throw new ApiError(response.message || 'Erro ao excluir cartão', 'DELETE_CARD_FAILED', 400);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return { success: true };
|
|
48
105
|
}
|
|
49
106
|
}
|
|
50
107
|
|
|
@@ -9,8 +9,8 @@ export const CardSchema = z.object({
|
|
|
9
9
|
gateway_card: z.string().optional(),
|
|
10
10
|
brand: z.string(),
|
|
11
11
|
name: z.string(),
|
|
12
|
-
number: z.string(),
|
|
13
|
-
date: z.string().optional(),
|
|
12
|
+
number: z.string().nullable(),
|
|
13
|
+
date: z.string().nullable().optional(),
|
|
14
14
|
deleted: z
|
|
15
15
|
.number()
|
|
16
16
|
.transform((val) => val === 1)
|
|
@@ -30,3 +30,13 @@ export const CreateCardRequestSchema = z.object({
|
|
|
30
30
|
});
|
|
31
31
|
|
|
32
32
|
export type CreateCardRequest = z.infer<typeof CreateCardRequestSchema>;
|
|
33
|
+
|
|
34
|
+
export const FindCardsParamsSchema = z.object({
|
|
35
|
+
page: z.number().optional(),
|
|
36
|
+
limit: z.number().optional(),
|
|
37
|
+
search: z.string().optional(),
|
|
38
|
+
sort: z.string().optional(),
|
|
39
|
+
order: z.enum(['asc', 'desc']).optional(),
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
export type FindCardsParams = z.infer<typeof FindCardsParamsSchema>;
|