@greatapps/common 1.1.221 → 1.1.222
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.
|
@@ -37,9 +37,8 @@ function ProfilePopover({
|
|
|
37
37
|
}
|
|
38
38
|
};
|
|
39
39
|
const hasSubscription = !isSubscriptionLoading && subscription !== null;
|
|
40
|
-
const
|
|
41
|
-
const
|
|
42
|
-
const creditsPercentage = showCredits && summary.totalCredits > 0 ? summary.usedCredits / summary.totalCredits * 100 : 0;
|
|
40
|
+
const shouldShowCredits = hasSubscription && subscription.id_wl === 1;
|
|
41
|
+
const creditsPercentage = shouldShowCredits && summary.totalCredits > 0 ? summary.usedCredits / summary.totalCredits * 100 : 0;
|
|
43
42
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
44
43
|
/* @__PURE__ */ jsx(
|
|
45
44
|
LoadingOverlay,
|
|
@@ -85,14 +84,7 @@ function ProfilePopover({
|
|
|
85
84
|
] })
|
|
86
85
|
] }),
|
|
87
86
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2 border-t border-gray-200 rounded-2xl p-1.5", children: [
|
|
88
|
-
|
|
89
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-2", children: [
|
|
90
|
-
/* @__PURE__ */ jsx("span", { className: "paragraph-xsmall-semibold text-white truncate", children: "Cr\xE9ditos usados" }),
|
|
91
|
-
/* @__PURE__ */ jsx("div", { className: "skeleton h-3.5 w-16 rounded" })
|
|
92
|
-
] }),
|
|
93
|
-
/* @__PURE__ */ jsx("div", { className: "skeleton h-1.5 w-full rounded-full" })
|
|
94
|
-
] }),
|
|
95
|
-
showCredits && /* @__PURE__ */ jsxs(
|
|
87
|
+
shouldShowCredits && /* @__PURE__ */ jsxs(
|
|
96
88
|
"div",
|
|
97
89
|
{
|
|
98
90
|
className: cn(
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/layouts/ProfilePopover.tsx"],"sourcesContent":["\"use client\";\n\nimport { useState } from \"react\";\nimport { useRouter } from \"next/navigation\";\nimport * as PopoverPrimitive from \"@radix-ui/react-popover\";\nimport { Popover } from \"../ui/overlay/Popover\";\nimport { Progress } from \"../ui/feedback/Progress\";\nimport { Separator } from \"../ui/data-display/Separator\";\nimport { IconSettings } from \"@tabler/icons-react\";\nimport { NavBarItem } from \"./NavBarItem\";\nimport { UserAvatar } from \"../ui/data-display/UserAvatar\";\nimport { LoadingOverlay } from \"../ui/feedback/LoadingOverlay\";\nimport { useAuth } from \"../../providers/auth.provider\";\nimport { cn } from \"../../infra/utils/clsx\";\nimport { useIaCredits } from \"../../modules/ia-credits/hooks/ia-credits.hook\";\n\nexport interface ProfileMenuItem {\n icon?: React.ReactNode;\n label: string;\n onClick: () => void;\n}\n\nexport interface ProfilePopoverProps {\n side?: \"top\" | \"bottom\" | \"left\" | \"right\";\n align?: \"start\" | \"center\" | \"end\";\n contentClassName?: string;\n onEditProfile?: () => void;\n onCreditsClick?: () => void;\n menuItems?: ProfileMenuItem[];\n logoutRedirect?: string;\n}\n\nfunction ProfilePopover({\n side = \"top\",\n align = \"start\",\n contentClassName = \"absolute bottom-2 left-[26px]\",\n onEditProfile,\n onCreditsClick,\n menuItems = [],\n logoutRedirect = \"/login\",\n}: ProfilePopoverProps) {\n const router = useRouter();\n const { user, logout } = useAuth();\n const [isLoggingOut, setIsLoggingOut] = useState(false);\n\n const { summary, subscription, isSubscriptionLoading, isCreditsLoading } =\n useIaCredits();\n\n const handleLogout = async () => {\n try {\n setIsLoggingOut(true);\n await logout();\n } finally {\n setIsLoggingOut(false);\n if (logoutRedirect !== \"/login\") {\n router.push(logoutRedirect);\n }\n }\n };\n\n const hasSubscription = !isSubscriptionLoading && subscription !== null;\n const
|
|
1
|
+
{"version":3,"sources":["../../../src/components/layouts/ProfilePopover.tsx"],"sourcesContent":["\"use client\";\n\nimport { useState } from \"react\";\nimport { useRouter } from \"next/navigation\";\nimport * as PopoverPrimitive from \"@radix-ui/react-popover\";\nimport { Popover } from \"../ui/overlay/Popover\";\nimport { Progress } from \"../ui/feedback/Progress\";\nimport { Separator } from \"../ui/data-display/Separator\";\nimport { IconSettings } from \"@tabler/icons-react\";\nimport { NavBarItem } from \"./NavBarItem\";\nimport { UserAvatar } from \"../ui/data-display/UserAvatar\";\nimport { LoadingOverlay } from \"../ui/feedback/LoadingOverlay\";\nimport { useAuth } from \"../../providers/auth.provider\";\nimport { cn } from \"../../infra/utils/clsx\";\nimport { useIaCredits } from \"../../modules/ia-credits/hooks/ia-credits.hook\";\n\nexport interface ProfileMenuItem {\n icon?: React.ReactNode;\n label: string;\n onClick: () => void;\n}\n\nexport interface ProfilePopoverProps {\n side?: \"top\" | \"bottom\" | \"left\" | \"right\";\n align?: \"start\" | \"center\" | \"end\";\n contentClassName?: string;\n onEditProfile?: () => void;\n onCreditsClick?: () => void;\n menuItems?: ProfileMenuItem[];\n logoutRedirect?: string;\n}\n\nfunction ProfilePopover({\n side = \"top\",\n align = \"start\",\n contentClassName = \"absolute bottom-2 left-[26px]\",\n onEditProfile,\n onCreditsClick,\n menuItems = [],\n logoutRedirect = \"/login\",\n}: ProfilePopoverProps) {\n const router = useRouter();\n const { user, logout } = useAuth();\n const [isLoggingOut, setIsLoggingOut] = useState(false);\n\n const { summary, subscription, isSubscriptionLoading, isCreditsLoading } =\n useIaCredits();\n\n const handleLogout = async () => {\n try {\n setIsLoggingOut(true);\n await logout();\n } finally {\n setIsLoggingOut(false);\n if (logoutRedirect !== \"/login\") {\n router.push(logoutRedirect);\n }\n }\n };\n\n const hasSubscription = !isSubscriptionLoading && subscription !== null;\n\n const shouldShowCredits = hasSubscription && subscription.id_wl === 1;\n const creditsPercentage =\n shouldShowCredits && summary.totalCredits > 0\n ? (summary.usedCredits / summary.totalCredits) * 100\n : 0;\n\n return (\n <>\n <LoadingOverlay\n isLoading={isLoggingOut}\n message=\"Saindo da sua conta...\"\n />\n <Popover>\n <PopoverPrimitive.Trigger className=\"cursor-pointer\">\n {user && (\n <UserAvatar\n key={user.id}\n photo={user.photo}\n name={user.name}\n size={40}\n />\n )}\n </PopoverPrimitive.Trigger>\n\n <PopoverPrimitive.Portal>\n <PopoverPrimitive.Content\n className={cn(\n \"w-64.75 p-0 bg-white rounded-2xl shadow-md border border-gray-200 z-99\",\n contentClassName,\n )}\n side={side}\n align={align}\n sideOffset={8}\n >\n <div className=\"grid grid-cols-[32px_1fr] items-center gap-3 p-3 w-full\">\n {user && (\n <UserAvatar\n key={user.id}\n photo={user.photo}\n name={user.name}\n size={32}\n />\n )}\n\n <div className=\"flex flex-col gap-0.5 min-w-0\">\n <span className=\"paragraph-small-semibold text-gray-950 truncate\">\n {user?.name || \"\"}\n </span>\n <span className=\"paragraph-xsmall-medium text-gray-500 truncate\">\n {user?.email || \"\"}\n </span>\n </div>\n </div>\n\n <div className=\"flex flex-col gap-2 border-t border-gray-200 rounded-2xl p-1.5\">\n {shouldShowCredits && (\n <div\n className={cn(\n \"flex flex-col bg-gray-950 rounded-lg gap-4 w-full p-4 transition-colors\",\n onCreditsClick && \"cursor-pointer hover:bg-gray-900\",\n )}\n onClick={onCreditsClick}\n >\n <div className=\"flex items-center justify-between gap-2\">\n <span className=\"paragraph-xsmall-semibold text-white truncate\">\n Créditos usados\n </span>\n <span className=\"paragraph-xsmall-medium text-white/50\">\n {summary.usedCredits.toLocaleString(\"pt-BR\")}/\n {summary.totalCredits.toLocaleString(\"pt-BR\")}\n </span>\n </div>\n <Progress\n className=\"bg-white/10\"\n indicatorColor=\"bg-white\"\n value={creditsPercentage}\n />\n </div>\n )}\n\n <div className=\"flex flex-col gap-2\">\n {menuItems.length > 0 && (\n <div className=\"flex flex-col\">\n {menuItems.map((item, index) => (\n <NavBarItem\n key={index}\n icon={item.icon}\n label={item.label}\n onClick={item.onClick}\n />\n ))}\n </div>\n )}\n <Separator />\n <NavBarItem label=\"Sair\" onClick={handleLogout} />\n </div>\n </div>\n </PopoverPrimitive.Content>\n </PopoverPrimit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AM,UACpB;AAAA,kBAAC;AAAA;AAAA,oBAEC,MAAM,KAAK;AAAA,oBACX,OAAO,KAAK;AAAA,oBACZ,SAAS,KAAK;AAAA;AAAA,kBAHT;AAAA,gBAIP,CACD,GACH;AAAA,gBAEF,oBAAC,aAAU;AAAA,gBACX,oBAAC,cAAW,OAAM,QAAO,SAAS,cAAc;AAAA,iBAClD;AAAA,eACF;AAAA;AAAA;AAAA,MACF,GACF;AAAA,OACF;AAAA,KACF;AAEJ;","names":[]}
|
package/package.json
CHANGED
|
@@ -59,10 +59,10 @@ function ProfilePopover({
|
|
|
59
59
|
};
|
|
60
60
|
|
|
61
61
|
const hasSubscription = !isSubscriptionLoading && subscription !== null;
|
|
62
|
-
|
|
63
|
-
const
|
|
62
|
+
|
|
63
|
+
const shouldShowCredits = hasSubscription && subscription.id_wl === 1;
|
|
64
64
|
const creditsPercentage =
|
|
65
|
-
|
|
65
|
+
shouldShowCredits && summary.totalCredits > 0
|
|
66
66
|
? (summary.usedCredits / summary.totalCredits) * 100
|
|
67
67
|
: 0;
|
|
68
68
|
|
|
@@ -115,19 +115,7 @@ function ProfilePopover({
|
|
|
115
115
|
</div>
|
|
116
116
|
|
|
117
117
|
<div className="flex flex-col gap-2 border-t border-gray-200 rounded-2xl p-1.5">
|
|
118
|
-
{
|
|
119
|
-
<div className="flex flex-col bg-gray-950 rounded-lg gap-4 w-full p-4">
|
|
120
|
-
<div className="flex items-center justify-between gap-2">
|
|
121
|
-
<span className="paragraph-xsmall-semibold text-white truncate">
|
|
122
|
-
Créditos usados
|
|
123
|
-
</span>
|
|
124
|
-
<div className="skeleton h-3.5 w-16 rounded" />
|
|
125
|
-
</div>
|
|
126
|
-
<div className="skeleton h-1.5 w-full rounded-full" />
|
|
127
|
-
</div>
|
|
128
|
-
)}
|
|
129
|
-
|
|
130
|
-
{showCredits && (
|
|
118
|
+
{shouldShowCredits && (
|
|
131
119
|
<div
|
|
132
120
|
className={cn(
|
|
133
121
|
"flex flex-col bg-gray-950 rounded-lg gap-4 w-full p-4 transition-colors",
|