@greatapps/common 1.1.539 → 1.1.541
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/account/ConfigurationsMyAccountModal.mjs +7 -3
- package/dist/components/account/ConfigurationsMyAccountModal.mjs.map +1 -1
- package/dist/components/modals/Modals.mjs +3 -3
- package/dist/components/modals/Modals.mjs.map +1 -1
- package/dist/components/ui/buttons/Button.mjs +12 -2
- package/dist/components/ui/buttons/Button.mjs.map +1 -1
- package/dist/store/useAccountModals.mjs.map +1 -1
- package/package.json +1 -1
- package/src/components/account/ConfigurationsMyAccountModal.tsx +14 -3
- package/src/components/modals/Modals.tsx +3 -4
- package/src/components/ui/buttons/Button.tsx +16 -1
- package/src/store/useAccountModals.ts +0 -1
|
@@ -14,16 +14,20 @@ import useIsMobile from "../../hooks/useIsMobile";
|
|
|
14
14
|
import { useAccountModals } from "../../store/useAccountModals";
|
|
15
15
|
import { useAuth } from "../../providers/auth.provider";
|
|
16
16
|
import { UserProfile } from "../../modules/users/schema";
|
|
17
|
+
import { useActiveSubscription } from "../../modules/subscriptions/hooks/find-active-subscription.hook";
|
|
18
|
+
import { hasSubscriptionExpired } from "../../modules/subscriptions/utils/has-subscription-expired";
|
|
17
19
|
function ConfigurationsMyAccountModal() {
|
|
18
20
|
const {
|
|
19
21
|
activeModal,
|
|
20
|
-
config,
|
|
21
22
|
openDeleteAccount,
|
|
22
23
|
openIsntPossibleDelete,
|
|
23
24
|
close
|
|
24
25
|
} = useAccountModals();
|
|
25
26
|
const open = activeModal === "configurations";
|
|
26
|
-
const {
|
|
27
|
+
const { data: subscriptionData } = useActiveSubscription();
|
|
28
|
+
const subscription = subscriptionData?.data?.[0] ?? null;
|
|
29
|
+
const isPaidSubscriptionType = !!subscription && subscription.type !== "free" && subscription.type !== "trial";
|
|
30
|
+
const isBlockingSubscription = isPaidSubscriptionType && subscription.active === true && !hasSubscriptionExpired(subscription.date_due);
|
|
27
31
|
const { user } = useAuth();
|
|
28
32
|
const isOwner = user?.profile === UserProfile.owner;
|
|
29
33
|
const isMobile = useIsMobile();
|
|
@@ -32,7 +36,7 @@ function ConfigurationsMyAccountModal() {
|
|
|
32
36
|
});
|
|
33
37
|
const handleDeleteAccount = () => {
|
|
34
38
|
close();
|
|
35
|
-
if (
|
|
39
|
+
if (isBlockingSubscription) {
|
|
36
40
|
openIsntPossibleDelete();
|
|
37
41
|
} else {
|
|
38
42
|
openDeleteAccount();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/account/ConfigurationsMyAccountModal.tsx"],"sourcesContent":["'use client';\n\nimport { IconKey, IconLock, IconSettings2, IconX } from '@tabler/icons-react';\nimport { Dialog, DialogContent, DialogHeader, DialogTitle } from '../ui/overlay/Dialog';\nimport { Tabs, TabsList, TabsTrigger, TabsContent } from '../ui/data-display/Tabs';\nimport { cn } from '../../infra/utils/clsx';\nimport { AccountSectionType } from '../../enums/AccountSectionType';\nimport { PreferencesSection } from './sections/PreferencesSection';\nimport { ChangePasswordSection } from './sections/ChangePasswordSection';\nimport { TokenSection } from './sections/TokenSection';\nimport { SecuritySection } from './sections/SecuritySection';\nimport useConfigurationsModal from './hooks/useConfigurationsModal';\nimport useIsMobile from '../../hooks/useIsMobile';\nimport { useAccountModals } from '../../store/useAccountModals';\nimport { useAuth } from '../../providers/auth.provider';\nimport { UserProfile } from '../../modules/users/schema';\n\nexport default function ConfigurationsMyAccountModal() {\n const {\n activeModal,\n config,\n openDeleteAccount,\n openIsntPossibleDelete,\n close,\n } = useAccountModals();\n\n const open = activeModal === 'configurations';\n const { hasActiveSubscription } = config;\n\n const { user } = useAuth();\n const isOwner = user?.profile === UserProfile.owner;\n\n const isMobile = useIsMobile();\n const { activeSection, setActiveSection } = useConfigurationsModal({\n isOpen: open,\n });\n\n const handleDeleteAccount = () => {\n close();\n if (hasActiveSubscription) {\n openIsntPossibleDelete();\n } else {\n openDeleteAccount();\n }\n };\n\n const tabTriggerClasses = cn(\n 'border-0! px-0 py-0',\n\n 'lg:rounded-md lg:flex lg:items-center lg:gap-2 lg:p-3 lg:justify-start lg:w-full',\n 'lg:bg-white lg:hover:bg-gray-100 lg:active:bg-gray-50 lg:border-0',\n 'lg:data-[state=active]:bg-gray-50',\n\n 'flex items-center gap-1.5 px-3 py-3 justify-center whitespace-nowrap',\n 'border-b-2 border-transparent',\n 'data-[state=active]:bg-gray-50 rounded-lg',\n\n 'text-gray-500 data-[state=active]:text-gray-950',\n 'hover:text-gray-900 transition-colors'\n );\n\n return (\n <Dialog open={open} onOpenChange={close}>\n <DialogContent\n showCloseButton={!isMobile}\n overlayClassName=\"bg-black/20 lg:bg-black/50\"\n className=\"\n flex flex-col p-0 gap-0 max-w-full sm:max-w-full overflow-x-hidden border-0\n rounded-t-2xl rounded-b-none h-[100dvh] top-0 bottom-0 left-0 right-0 translate-x-0 translate-y-0\n lg:flex-row lg:w-[892px] lg:max-w-[892px] lg:h-[626px] lg:rounded-lg lg:border\n lg:top-[50%] lg:bottom-auto lg:left-[50%] lg:right-auto lg:translate-x-[-50%] lg:translate-y-[-50%]\"\n >\n <DialogHeader className=\"sr-only\">\n <DialogTitle>Configurações</DialogTitle>\n </DialogHeader>\n <div className=\"md:hidden flex items-center justify-between px-5 py-3 border-b border-gray-200\">\n <span className=\"text-gray-950 paragraph-medium-semibold\">Configurações</span>\n <button\n type=\"button\"\n className=\"size-8 flex items-center justify-center text-gray-500 cursor-pointer\"\n onClick={close}\n >\n <IconX size={18} />\n </button>\n </div>\n <Tabs\n value={activeSection}\n onValueChange={(value) => setActiveSection(value as AccountSectionType)}\n orientation=\"vertical\"\n className=\"flex lg:flex-row flex-col w-full h-full flex-1 lg:h-full lg:pt-0 lg:gap-0\"\n >\n <TabsList\n className={cn(\n 'flex gap-0 bg-transparent border-b-0',\n\n 'lg:flex-col lg:items-stretch lg:justify-start lg:w-auto lg:min-w-60',\n 'lg:border-r lg:border-gray-200 lg:pl-5 lg:pr-5 lg:pt-5 lg:gap-5 lg:overflow-x-visible lg:self-stretch',\n\n 'flex-row items-center justify-start w-full overflow-x-auto scrollbar-hide shrink-0',\n 'px-4 py-3',\n '[mask-image:linear-gradient(to_right,transparent,black_16px,black_calc(100%-24px),transparent)] lg:[mask-image:none]'\n )}\n >\n <span className=\"hidden lg:block paragraph-medium-semibold text-gray-950 mb-0\">\n Configurações\n </span>\n\n <div className=\"lg:flex lg:flex-col flex flex-row lg:gap-0 gap-0 lg:w-full\">\n <TabsTrigger value={AccountSectionType.PREFERENCES} className={tabTriggerClasses}>\n <IconSettings2 size={20} className=\"shrink-0\" />\n <span className=\"paragraph-small-medium\">Preferências</span>\n </TabsTrigger>\n\n {isOwner && (\n <TabsTrigger value={AccountSectionType.TOKEN} className={tabTriggerClasses}>\n <IconKey size={20} className=\"shrink-0\" />\n <span className=\"paragraph-small-medium\">Token da conta</span>\n </TabsTrigger>\n )}\n\n {isOwner && (\n <TabsTrigger value={AccountSectionType.SECURITY} className={tabTriggerClasses}>\n <IconLock size={20} className=\"shrink-0\" />\n <span className=\"paragraph-small-medium\">Segurança</span>\n </TabsTrigger>\n )}\n </div>\n </TabsList>\n\n <div className=\"w-full flex-1 min-h-0 lg:h-full overflow-hidden lg:overflow-visible relative flex flex-col\">\n <TabsContent value={AccountSectionType.PREFERENCES} className=\"h-full! relative overflow-hidden\">\n <PreferencesSection onClose={close} />\n </TabsContent>\n\n {isOwner && (\n <TabsContent value={AccountSectionType.TOKEN} className=\"h-full! relative overflow-hidden\">\n <TokenSection />\n </TabsContent>\n )}\n\n {isOwner && (\n <>\n <TabsContent value={AccountSectionType.SECURITY} className=\"h-full! relative overflow-hidden\">\n <SecuritySection\n setActiveSection={setActiveSection}\n onClose={close}\n onDeleteAccount={handleDeleteAccount}\n />\n </TabsContent>\n\n <TabsContent value={AccountSectionType.CHANGE_PASSWORD} className=\"h-full! relative overflow-hidden\">\n <ChangePasswordSection onBack={() => setActiveSection(AccountSectionType.SECURITY)} />\n </TabsCont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,8BAAC,sBAAmB,SAAS,OAAO,GACtC;AAAA,gBAEC,WACC,oBAAC,eAAY,OAAO,mBAAmB,OAAO,WAAU,oCACtD,8BAAC,gBAAa,GAChB;AAAA,gBAGD,WACC,iCACE;AAAA,sCAAC,eAAY,OAAO,mBAAmB,UAAU,WAAU,oCACzD;AAAA,oBAAC;AAAA;AAAA,sBACC;AAAA,sBACA,SAAS;AAAA,sBACT,iBAAiB;AAAA;AAAA,kBACnB,GACF;AAAA,kBAEA,oBAAC,eAAY,OAAO,mBAAmB,iBAAiB,WAAU,oCAChE,8BAAC,yBAAsB,QAAQ,MAAM,iBAAiB,mBAAmB,QAAQ,GAAG,GACtF;AAAA,mBACF;AAAA,iBAEJ;AAAA;AAAA;AAAA,QACF;AAAA;AAAA;AAAA,EACF,GACF;AAEJ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../src/components/account/ConfigurationsMyAccountModal.tsx"],"sourcesContent":["'use client';\n\nimport { IconKey, IconLock, IconSettings2, IconX } from '@tabler/icons-react';\nimport { Dialog, DialogContent, DialogHeader, DialogTitle } from '../ui/overlay/Dialog';\nimport { Tabs, TabsList, TabsTrigger, TabsContent } from '../ui/data-display/Tabs';\nimport { cn } from '../../infra/utils/clsx';\nimport { AccountSectionType } from '../../enums/AccountSectionType';\nimport { PreferencesSection } from './sections/PreferencesSection';\nimport { ChangePasswordSection } from './sections/ChangePasswordSection';\nimport { TokenSection } from './sections/TokenSection';\nimport { SecuritySection } from './sections/SecuritySection';\nimport useConfigurationsModal from './hooks/useConfigurationsModal';\nimport useIsMobile from '../../hooks/useIsMobile';\nimport { useAccountModals } from '../../store/useAccountModals';\nimport { useAuth } from '../../providers/auth.provider';\nimport { UserProfile } from '../../modules/users/schema';\nimport { useActiveSubscription } from '../../modules/subscriptions/hooks/find-active-subscription.hook';\nimport { hasSubscriptionExpired } from '../../modules/subscriptions/utils/has-subscription-expired';\n\nexport default function ConfigurationsMyAccountModal() {\n const {\n activeModal,\n openDeleteAccount,\n openIsntPossibleDelete,\n close,\n } = useAccountModals();\n\n const open = activeModal === 'configurations';\n\n const { data: subscriptionData } = useActiveSubscription();\n const subscription = subscriptionData?.data?.[0] ?? null;\n const isPaidSubscriptionType =\n !!subscription &&\n subscription.type !== 'free' &&\n subscription.type !== 'trial';\n const isBlockingSubscription =\n isPaidSubscriptionType &&\n subscription.active === true &&\n !hasSubscriptionExpired(subscription.date_due);\n\n const { user } = useAuth();\n const isOwner = user?.profile === UserProfile.owner;\n\n const isMobile = useIsMobile();\n const { activeSection, setActiveSection } = useConfigurationsModal({\n isOpen: open,\n });\n\n const handleDeleteAccount = () => {\n close();\n if (isBlockingSubscription) {\n openIsntPossibleDelete();\n } else {\n openDeleteAccount();\n }\n };\n\n const tabTriggerClasses = cn(\n 'border-0! px-0 py-0',\n\n 'lg:rounded-md lg:flex lg:items-center lg:gap-2 lg:p-3 lg:justify-start lg:w-full',\n 'lg:bg-white lg:hover:bg-gray-100 lg:active:bg-gray-50 lg:border-0',\n 'lg:data-[state=active]:bg-gray-50',\n\n 'flex items-center gap-1.5 px-3 py-3 justify-center whitespace-nowrap',\n 'border-b-2 border-transparent',\n 'data-[state=active]:bg-gray-50 rounded-lg',\n\n 'text-gray-500 data-[state=active]:text-gray-950',\n 'hover:text-gray-900 transition-colors'\n );\n\n return (\n <Dialog open={open} onOpenChange={close}>\n <DialogContent\n showCloseButton={!isMobile}\n overlayClassName=\"bg-black/20 lg:bg-black/50\"\n className=\"\n flex flex-col p-0 gap-0 max-w-full sm:max-w-full overflow-x-hidden border-0\n rounded-t-2xl rounded-b-none h-[100dvh] top-0 bottom-0 left-0 right-0 translate-x-0 translate-y-0\n lg:flex-row lg:w-[892px] lg:max-w-[892px] lg:h-[626px] lg:rounded-lg lg:border\n lg:top-[50%] lg:bottom-auto lg:left-[50%] lg:right-auto lg:translate-x-[-50%] lg:translate-y-[-50%]\"\n >\n <DialogHeader className=\"sr-only\">\n <DialogTitle>Configurações</DialogTitle>\n </DialogHeader>\n <div className=\"md:hidden flex items-center justify-between px-5 py-3 border-b border-gray-200\">\n <span className=\"text-gray-950 paragraph-medium-semibold\">Configurações</span>\n <button\n type=\"button\"\n className=\"size-8 flex items-center justify-center text-gray-500 cursor-pointer\"\n onClick={close}\n >\n <IconX size={18} />\n </button>\n </div>\n <Tabs\n value={activeSection}\n onValueChange={(value) => setActiveSection(value as AccountSectionType)}\n orientation=\"vertical\"\n className=\"flex lg:flex-row flex-col w-full h-full flex-1 lg:h-full lg:pt-0 lg:gap-0\"\n >\n <TabsList\n className={cn(\n 'flex gap-0 bg-transparent border-b-0',\n\n 'lg:flex-col lg:items-stretch lg:justify-start lg:w-auto lg:min-w-60',\n 'lg:border-r lg:border-gray-200 lg:pl-5 lg:pr-5 lg:pt-5 lg:gap-5 lg:overflow-x-visible lg:self-stretch',\n\n 'flex-row items-center justify-start w-full overflow-x-auto scrollbar-hide shrink-0',\n 'px-4 py-3',\n '[mask-image:linear-gradient(to_right,transparent,black_16px,black_calc(100%-24px),transparent)] lg:[mask-image:none]'\n )}\n >\n <span className=\"hidden lg:block paragraph-medium-semibold text-gray-950 mb-0\">\n Configurações\n </span>\n\n <div className=\"lg:flex lg:flex-col flex flex-row lg:gap-0 gap-0 lg:w-full\">\n <TabsTrigger value={AccountSectionType.PREFERENCES} className={tabTriggerClasses}>\n <IconSettings2 size={20} className=\"shrink-0\" />\n <span className=\"paragraph-small-medium\">Preferências</span>\n </TabsTrigger>\n\n {isOwner && (\n <TabsTrigger value={AccountSectionType.TOKEN} className={tabTriggerClasses}>\n <IconKey size={20} className=\"shrink-0\" />\n <span className=\"paragraph-small-medium\">Token da conta</span>\n </TabsTrigger>\n )}\n\n {isOwner && (\n <TabsTrigger value={AccountSectionType.SECURITY} className={tabTriggerClasses}>\n <IconLock size={20} className=\"shrink-0\" />\n <span className=\"paragraph-small-medium\">Segurança</span>\n </TabsTrigger>\n )}\n </div>\n </TabsList>\n\n <div className=\"w-full flex-1 min-h-0 lg:h-full overflow-hidden lg:overflow-visible relative flex flex-col\">\n <TabsContent value={AccountSectionType.PREFERENCES} className=\"h-full! relative overflow-hidden\">\n <PreferencesSection onClose={close} />\n </TabsContent>\n\n {isOwner && (\n <TabsContent value={AccountSectionType.TOKEN} className=\"h-full! relative overflow-hidden\">\n <TokenSection />\n </TabsContent>\n )}\n\n {isOwner && (\n <>\n <TabsContent value={AccountSectionType.SECURITY} className=\"h-full! relative overflow-hidden\">\n <SecuritySection\n setActiveSection={setActiveSection}\n onClose={close}\n onDeleteAccount={handleDeleteAccount}\n />\n </TabsContent>\n\n <TabsContent value={AccountSectionType.CHANGE_PASSWORD} className=\"h-full! relative overflow-hidden\">\n <ChangePasswordSection onBack={() => setActiveSection(AccountSectionType.SECURITY)} />\n </TabsContent>\n </>\n )}\n </div>\n </Tabs>\n </DialogContent>\n </Dialog>\n );\n}\n"],"mappings":";AAoFU,SAoEI,UApEJ,KAEF,YAFE;AAlFV,SAAS,SAAS,UAAU,eAAe,aAAa;AACxD,SAAS,QAAQ,eAAe,cAAc,mBAAmB;AACjE,SAAS,MAAM,UAAU,aAAa,mBAAmB;AACzD,SAAS,UAAU;AACnB,SAAS,0BAA0B;AACnC,SAAS,0BAA0B;AACnC,SAAS,6BAA6B;AACtC,SAAS,oBAAoB;AAC7B,SAAS,uBAAuB;AAChC,OAAO,4BAA4B;AACnC,OAAO,iBAAiB;AACxB,SAAS,wBAAwB;AACjC,SAAS,eAAe;AACxB,SAAS,mBAAmB;AAC5B,SAAS,6BAA6B;AACtC,SAAS,8BAA8B;AAExB,SAAR,+BAAgD;AACrD,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI,iBAAiB;AAErB,QAAM,OAAO,gBAAgB;AAE7B,QAAM,EAAE,MAAM,iBAAiB,IAAI,sBAAsB;AACzD,QAAM,eAAe,kBAAkB,OAAO,CAAC,KAAK;AACpD,QAAM,yBACJ,CAAC,CAAC,gBACF,aAAa,SAAS,UACtB,aAAa,SA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 import { useEffect } from "react";
|
|
|
4
4
|
import AccountModals from "../account/AccountModals";
|
|
5
5
|
import { ModalManager } from "./ModalManager";
|
|
6
6
|
import { useAccountModals } from "../../store/useAccountModals";
|
|
7
|
-
function Modals({ registry,
|
|
7
|
+
function Modals({ registry, onGoToSubscription }) {
|
|
8
8
|
const { updateConfig } = useAccountModals();
|
|
9
9
|
useEffect(() => {
|
|
10
|
-
updateConfig({
|
|
11
|
-
}, [
|
|
10
|
+
updateConfig({ onGoToSubscription });
|
|
11
|
+
}, [onGoToSubscription, updateConfig]);
|
|
12
12
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
13
13
|
/* @__PURE__ */ jsx(AccountModals, {}),
|
|
14
14
|
/* @__PURE__ */ jsx(ModalManager, { registry })
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/modals/Modals.tsx"],"sourcesContent":["'use client';\n\nimport { ComponentType, useEffect } from 'react';\nimport AccountModals from '../account/AccountModals';\nimport { ModalManager } from './ModalManager';\nimport { useAccountModals } from '../../store/useAccountModals';\ninterface ModalsProps {\n registry: Record<string, ComponentType>;\n
|
|
1
|
+
{"version":3,"sources":["../../../src/components/modals/Modals.tsx"],"sourcesContent":["'use client';\n\nimport { ComponentType, useEffect } from 'react';\nimport AccountModals from '../account/AccountModals';\nimport { ModalManager } from './ModalManager';\nimport { useAccountModals } from '../../store/useAccountModals';\ninterface ModalsProps {\n registry: Record<string, ComponentType>;\n onGoToSubscription?: () => void;\n}\n\nexport function Modals({ registry, onGoToSubscription }: ModalsProps) {\n const { updateConfig } = useAccountModals();\n\n useEffect(() => {\n updateConfig({ onGoToSubscription });\n }, [onGoToSubscription, updateConfig]);\n\n return (\n <>\n <AccountModals />\n <ModalManager registry={registry} />\n </>\n );\n}\n"],"mappings":";AAmBI,mBACE,KADF;AAjBJ,SAAwB,iBAAiB;AACzC,OAAO,mBAAmB;AAC1B,SAAS,oBAAoB;AAC7B,SAAS,wBAAwB;AAM1B,SAAS,OAAO,EAAE,UAAU,mBAAmB,GAAgB;AACpE,QAAM,EAAE,aAAa,IAAI,iBAAiB;AAE1C,YAAU,MAAM;AACd,iBAAa,EAAE,mBAAmB,CAAC;AAAA,EACrC,GAAG,CAAC,oBAAoB,YAAY,CAAC;AAErC,SACE,iCACE;AAAA,wBAAC,iBAAc;AAAA,IACf,oBAAC,gBAAa,UAAoB;AAAA,KACpC;AAEJ;","names":[]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { Slot } from "@radix-ui/react-slot";
|
|
4
|
+
import { IconLoader2 } from "@tabler/icons-react";
|
|
4
5
|
import { cva } from "class-variance-authority";
|
|
5
6
|
import { cn } from "../../../infra/utils/clsx";
|
|
6
7
|
import { useIsDefaultWhitelabel } from "../../../providers/whitelabel.provider";
|
|
@@ -34,19 +35,28 @@ function Button({
|
|
|
34
35
|
variant,
|
|
35
36
|
size,
|
|
36
37
|
asChild = false,
|
|
38
|
+
loading = false,
|
|
39
|
+
children,
|
|
40
|
+
disabled,
|
|
37
41
|
...props
|
|
38
42
|
}) {
|
|
39
43
|
const isDefaultWl = useIsDefaultWhitelabel();
|
|
40
44
|
const Comp = asChild ? Slot : "button";
|
|
45
|
+
const content = asChild ? children : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
46
|
+
loading && /* @__PURE__ */ jsx(IconLoader2, { className: "size-4 animate-spin" }),
|
|
47
|
+
children
|
|
48
|
+
] });
|
|
41
49
|
return /* @__PURE__ */ jsx(
|
|
42
50
|
Comp,
|
|
43
51
|
{
|
|
44
52
|
"data-slot": "button",
|
|
53
|
+
disabled: disabled || loading,
|
|
45
54
|
className: cn(
|
|
46
55
|
buttonVariants({ variant, size, className }),
|
|
47
56
|
variant === "brand" && (isDefaultWl ? "bg-cyan-300 hover:bg-cyan-200" : "bg-zinc-300 hover:bg-zinc-200")
|
|
48
57
|
),
|
|
49
|
-
...props
|
|
58
|
+
...props,
|
|
59
|
+
children: content
|
|
50
60
|
}
|
|
51
61
|
);
|
|
52
62
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/ui/buttons/Button.tsx"],"sourcesContent":["'use client';\n\nimport * as React from \"react\"\nimport { Slot } from \"@radix-ui/react-slot\"\nimport { cva, type VariantProps } from \"class-variance-authority\"\nimport { cn } from \"../../../infra/utils/clsx\"\nimport { useIsDefaultWhitelabel } from \"../../../providers/whitelabel.provider\"\n\nconst buttonVariants = cva(\n \"paragraph-small-semibold cursor-pointer flex items-center justify-center gap-1.5 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive\",\n {\n variants: {\n variant: {\n default: \" bg-gray-950 text-white hover:bg-gray-950/90\",\n secondary:\n \"bg-white text-gray-950 border-gray-200 hover:border-gray-400 border\",\n ghost:\n \"text-gray-600 hover:bg-accent hover:text-gray-950 dark:hover:bg-accent/50\",\n brand: \"text-gray-950\",\n },\n size: {\n default: \"h-12 px-4 py-2 has-[>svg]:px-3\",\n sm: \"rounded-md gap-1.5 px-2 py-2 has-[>svg]:px-2.5\",\n lg: \"rounded-md px-6 has-[>svg]:px-4\",\n icon: \"size-9\",\n \"icon-sm\": \"size-8\",\n \"icon-lg\": \"size-10\",\n },\n },\n defaultVariants: {\n variant: \"default\",\n size: \"default\",\n },\n }\n)\n\nfunction Button({\n className,\n variant,\n size,\n asChild = false,\n ...props\n}: React.ComponentProps<\"button\"> &\n VariantProps<typeof buttonVariants> & {\n asChild?: boolean\n }) {\n const isDefaultWl = useIsDefaultWhitelabel();\n const Comp = asChild ? Slot : \"button\"\n\n return (\n <Comp\n data-slot=\"button\"\n className={cn(\n buttonVariants({ variant, size, className }),\n variant === \"brand\" && (isDefaultWl ? \"bg-cyan-300 hover:bg-cyan-200\" : \"bg-zinc-300 hover:bg-zinc-200\")\n )}\n {...props}\n
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/ui/buttons/Button.tsx"],"sourcesContent":["'use client';\n\nimport * as React from \"react\"\nimport { Slot } from \"@radix-ui/react-slot\"\nimport { IconLoader2 } from \"@tabler/icons-react\"\nimport { cva, type VariantProps } from \"class-variance-authority\"\nimport { cn } from \"../../../infra/utils/clsx\"\nimport { useIsDefaultWhitelabel } from \"../../../providers/whitelabel.provider\"\n\nconst buttonVariants = cva(\n \"paragraph-small-semibold cursor-pointer flex items-center justify-center gap-1.5 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive\",\n {\n variants: {\n variant: {\n default: \" bg-gray-950 text-white hover:bg-gray-950/90\",\n secondary:\n \"bg-white text-gray-950 border-gray-200 hover:border-gray-400 border\",\n ghost:\n \"text-gray-600 hover:bg-accent hover:text-gray-950 dark:hover:bg-accent/50\",\n brand: \"text-gray-950\",\n },\n size: {\n default: \"h-12 px-4 py-2 has-[>svg]:px-3\",\n sm: \"rounded-md gap-1.5 px-2 py-2 has-[>svg]:px-2.5\",\n lg: \"rounded-md px-6 has-[>svg]:px-4\",\n icon: \"size-9\",\n \"icon-sm\": \"size-8\",\n \"icon-lg\": \"size-10\",\n },\n },\n defaultVariants: {\n variant: \"default\",\n size: \"default\",\n },\n }\n)\n\nfunction Button({\n className,\n variant,\n size,\n asChild = false,\n loading = false,\n children,\n disabled,\n ...props\n}: React.ComponentProps<\"button\"> &\n VariantProps<typeof buttonVariants> & {\n asChild?: boolean\n loading?: boolean\n }) {\n const isDefaultWl = useIsDefaultWhitelabel();\n const Comp = asChild ? Slot : \"button\"\n\n const content = asChild ? children : (\n <>\n {loading && <IconLoader2 className=\"size-4 animate-spin\" />}\n {children}\n </>\n )\n\n return (\n <Comp\n data-slot=\"button\"\n disabled={disabled || loading}\n className={cn(\n buttonVariants({ variant, size, className }),\n variant === \"brand\" && (isDefaultWl ? \"bg-cyan-300 hover:bg-cyan-200\" : \"bg-zinc-300 hover:bg-zinc-200\")\n )}\n {...props}\n >\n {content}\n </Comp>\n )\n}\n\nexport { Button, buttonVariants }\n"],"mappings":";AAuDI,mBACc,KADd;AApDJ,SAAS,YAAY;AACrB,SAAS,mBAAmB;AAC5B,SAAS,WAA8B;AACvC,SAAS,UAAU;AACnB,SAAS,8BAA8B;AAEvC,MAAM,iBAAiB;AAAA,EACrB;AAAA,EACA;AAAA,IACE,UAAU;AAAA,MACR,SAAS;AAAA,QACP,SAAS;AAAA,QACT,WACE;AAAA,QACF,OACE;AAAA,QACF,OAAO;AAAA,MACT;AAAA,MACA,MAAM;AAAA,QACJ,SAAS;AAAA,QACT,IAAI;AAAA,QACJ,IAAI;AAAA,QACJ,MAAM;AAAA,QACN,WAAW;AAAA,QACX,WAAW;AAAA,MACb;AAAA,IACF;AAAA,IACA,iBAAiB;AAAA,MACf,SAAS;AAAA,MACT,MAAM;AAAA,IACR;AAAA,EACF;AACF;AAEA,SAAS,OAAO;AAAA,EACd;AAAA,EACA;AAAA,EACA;AAAA,EACA,UAAU;AAAA,EACV,UAAU;AAAA,EACV;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAIK;AACH,QAAM,cAAc,uBAAuB;AAC3C,QAAM,OAAO,UAAU,OAAO;AAE9B,QAAM,UAAU,UAAU,WACxB,iCACG;AAAA,eAAW,oBAAC,eAAY,WAAU,uBAAsB;AAAA,IACxD;AAAA,KACH;AAGF,SACE;AAAA,IAAC;AAAA;AAAA,MACC,aAAU;AAAA,MACV,UAAU,YAAY;AAAA,MACtB,WAAW;AAAA,QACT,eAAe,EAAE,SAAS,MAAM,UAAU,CAAC;AAAA,QAC3C,YAAY,YAAY,cAAc,kCAAkC;AAAA,MAC1E;AAAA,MACC,GAAG;AAAA,MAEH;AAAA;AAAA,EACH;AAEJ;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/store/useAccountModals.ts"],"sourcesContent":["'use client';\n\nimport { create } from 'zustand';\nimport type { AccountSectionType } from '../enums/AccountSectionType';\n\ntype AccountModalType =\n | 'configurations'\n | 'deleteAccount'\n | 'isntPossibleDelete'\n | 'confirmDelete';\n\nexport interface AccountModalsConfig {\n
|
|
1
|
+
{"version":3,"sources":["../../src/store/useAccountModals.ts"],"sourcesContent":["'use client';\n\nimport { create } from 'zustand';\nimport type { AccountSectionType } from '../enums/AccountSectionType';\n\ntype AccountModalType =\n | 'configurations'\n | 'deleteAccount'\n | 'isntPossibleDelete'\n | 'confirmDelete';\n\nexport interface AccountModalsConfig {\n onGoToSubscription?: () => void;\n}\n\ninterface AccountModalsState {\n activeModal: AccountModalType | null;\n config: AccountModalsConfig;\n initialSection?: AccountSectionType;\n pagesCount: number;\n\n /** Called by <AccountModals> to keep app-level config in sync */\n updateConfig: (config: AccountModalsConfig) => void;\n\n openConfigurations: (initialSection?: AccountSectionType) => void;\n openDeleteAccount: (pagesCount?: number) => void;\n openIsntPossibleDelete: () => void;\n openConfirmDelete: (pagesCount?: number) => void;\n close: () => void;\n}\n\nexport const useAccountModals = create<AccountModalsState>((set) => ({\n activeModal: null,\n config: {},\n initialSection: undefined,\n pagesCount: 0,\n\n updateConfig: (config) => set({ config }),\n\n openConfigurations: (initialSection) =>\n set({ activeModal: 'configurations', initialSection }),\n\n openDeleteAccount: (pagesCount = 0) =>\n set({ activeModal: 'deleteAccount', pagesCount }),\n\n openIsntPossibleDelete: () =>\n set({ activeModal: 'isntPossibleDelete' }),\n\n openConfirmDelete: (pagesCount = 0) =>\n set({ activeModal: 'confirmDelete', pagesCount }),\n\n close: () =>\n set({ activeModal: null, initialSection: undefined }),\n}));\n"],"mappings":";AAEA,SAAS,cAAc;AA6BhB,MAAM,mBAAmB,OAA2B,CAAC,SAAS;AAAA,EACnE,aAAa;AAAA,EACb,QAAQ,CAAC;AAAA,EACT,gBAAgB;AAAA,EAChB,YAAY;AAAA,EAEZ,cAAc,CAAC,WAAW,IAAI,EAAE,OAAO,CAAC;AAAA,EAExC,oBAAoB,CAAC,mBACnB,IAAI,EAAE,aAAa,kBAAkB,eAAe,CAAC;AAAA,EAEvD,mBAAmB,CAAC,aAAa,MAC/B,IAAI,EAAE,aAAa,iBAAiB,WAAW,CAAC;AAAA,EAElD,wBAAwB,MACtB,IAAI,EAAE,aAAa,qBAAqB,CAAC;AAAA,EAE3C,mBAAmB,CAAC,aAAa,MAC/B,IAAI,EAAE,aAAa,iBAAiB,WAAW,CAAC;AAAA,EAElD,OAAO,MACL,IAAI,EAAE,aAAa,MAAM,gBAAgB,OAAU,CAAC;AACxD,EAAE;","names":[]}
|
package/package.json
CHANGED
|
@@ -14,18 +14,29 @@ import useIsMobile from '../../hooks/useIsMobile';
|
|
|
14
14
|
import { useAccountModals } from '../../store/useAccountModals';
|
|
15
15
|
import { useAuth } from '../../providers/auth.provider';
|
|
16
16
|
import { UserProfile } from '../../modules/users/schema';
|
|
17
|
+
import { useActiveSubscription } from '../../modules/subscriptions/hooks/find-active-subscription.hook';
|
|
18
|
+
import { hasSubscriptionExpired } from '../../modules/subscriptions/utils/has-subscription-expired';
|
|
17
19
|
|
|
18
20
|
export default function ConfigurationsMyAccountModal() {
|
|
19
21
|
const {
|
|
20
22
|
activeModal,
|
|
21
|
-
config,
|
|
22
23
|
openDeleteAccount,
|
|
23
24
|
openIsntPossibleDelete,
|
|
24
25
|
close,
|
|
25
26
|
} = useAccountModals();
|
|
26
27
|
|
|
27
28
|
const open = activeModal === 'configurations';
|
|
28
|
-
|
|
29
|
+
|
|
30
|
+
const { data: subscriptionData } = useActiveSubscription();
|
|
31
|
+
const subscription = subscriptionData?.data?.[0] ?? null;
|
|
32
|
+
const isPaidSubscriptionType =
|
|
33
|
+
!!subscription &&
|
|
34
|
+
subscription.type !== 'free' &&
|
|
35
|
+
subscription.type !== 'trial';
|
|
36
|
+
const isBlockingSubscription =
|
|
37
|
+
isPaidSubscriptionType &&
|
|
38
|
+
subscription.active === true &&
|
|
39
|
+
!hasSubscriptionExpired(subscription.date_due);
|
|
29
40
|
|
|
30
41
|
const { user } = useAuth();
|
|
31
42
|
const isOwner = user?.profile === UserProfile.owner;
|
|
@@ -37,7 +48,7 @@ export default function ConfigurationsMyAccountModal() {
|
|
|
37
48
|
|
|
38
49
|
const handleDeleteAccount = () => {
|
|
39
50
|
close();
|
|
40
|
-
if (
|
|
51
|
+
if (isBlockingSubscription) {
|
|
41
52
|
openIsntPossibleDelete();
|
|
42
53
|
} else {
|
|
43
54
|
openDeleteAccount();
|
|
@@ -6,16 +6,15 @@ import { ModalManager } from './ModalManager';
|
|
|
6
6
|
import { useAccountModals } from '../../store/useAccountModals';
|
|
7
7
|
interface ModalsProps {
|
|
8
8
|
registry: Record<string, ComponentType>;
|
|
9
|
-
hasActiveSubscription?: boolean;
|
|
10
9
|
onGoToSubscription?: () => void;
|
|
11
10
|
}
|
|
12
11
|
|
|
13
|
-
export function Modals({ registry,
|
|
12
|
+
export function Modals({ registry, onGoToSubscription }: ModalsProps) {
|
|
14
13
|
const { updateConfig } = useAccountModals();
|
|
15
14
|
|
|
16
15
|
useEffect(() => {
|
|
17
|
-
updateConfig({
|
|
18
|
-
}, [
|
|
16
|
+
updateConfig({ onGoToSubscription });
|
|
17
|
+
}, [onGoToSubscription, updateConfig]);
|
|
19
18
|
|
|
20
19
|
return (
|
|
21
20
|
<>
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import * as React from "react"
|
|
4
4
|
import { Slot } from "@radix-ui/react-slot"
|
|
5
|
+
import { IconLoader2 } from "@tabler/icons-react"
|
|
5
6
|
import { cva, type VariantProps } from "class-variance-authority"
|
|
6
7
|
import { cn } from "../../../infra/utils/clsx"
|
|
7
8
|
import { useIsDefaultWhitelabel } from "../../../providers/whitelabel.provider"
|
|
@@ -39,23 +40,37 @@ function Button({
|
|
|
39
40
|
variant,
|
|
40
41
|
size,
|
|
41
42
|
asChild = false,
|
|
43
|
+
loading = false,
|
|
44
|
+
children,
|
|
45
|
+
disabled,
|
|
42
46
|
...props
|
|
43
47
|
}: React.ComponentProps<"button"> &
|
|
44
48
|
VariantProps<typeof buttonVariants> & {
|
|
45
49
|
asChild?: boolean
|
|
50
|
+
loading?: boolean
|
|
46
51
|
}) {
|
|
47
52
|
const isDefaultWl = useIsDefaultWhitelabel();
|
|
48
53
|
const Comp = asChild ? Slot : "button"
|
|
49
54
|
|
|
55
|
+
const content = asChild ? children : (
|
|
56
|
+
<>
|
|
57
|
+
{loading && <IconLoader2 className="size-4 animate-spin" />}
|
|
58
|
+
{children}
|
|
59
|
+
</>
|
|
60
|
+
)
|
|
61
|
+
|
|
50
62
|
return (
|
|
51
63
|
<Comp
|
|
52
64
|
data-slot="button"
|
|
65
|
+
disabled={disabled || loading}
|
|
53
66
|
className={cn(
|
|
54
67
|
buttonVariants({ variant, size, className }),
|
|
55
68
|
variant === "brand" && (isDefaultWl ? "bg-cyan-300 hover:bg-cyan-200" : "bg-zinc-300 hover:bg-zinc-200")
|
|
56
69
|
)}
|
|
57
70
|
{...props}
|
|
58
|
-
|
|
71
|
+
>
|
|
72
|
+
{content}
|
|
73
|
+
</Comp>
|
|
59
74
|
)
|
|
60
75
|
}
|
|
61
76
|
|