mirror of
https://github.com/webstudio-is/webstudio.git
synced 2026-10-23 03:27:27 +09:00
chore: Profile menu improvements (#5596)
This commit is contained in:
1 parent
8cc1458001
commit
8e02c86e5f
1 file changed
+17
-11
@@ -29,9 +29,9 @@ const ProfileButton = forwardRef<
|
||||
{
|
||||
name: string;
|
||||
image?: string;
|
||||
badge?: string;
|
||||
hasPurchases?: boolean;
|
||||
}
|
||||
>(({ image, name, badge, ...rest }, forwardedRef) => {
|
||||
>(({ image, name, hasPurchases, ...rest }, forwardedRef) => {
|
||||
return (
|
||||
<Button
|
||||
color="ghost"
|
||||
@@ -47,7 +47,7 @@ const ProfileButton = forwardRef<
|
||||
height: theme.spacing[13],
|
||||
}}
|
||||
>
|
||||
{badge && <ProBadge>{badge}</ProBadge>}
|
||||
{hasPurchases === false && <ProBadge>Free</ProBadge>}
|
||||
</Button>
|
||||
);
|
||||
});
|
||||
@@ -62,31 +62,37 @@ export const ProfileMenu = ({
|
||||
const navigate = useNavigate();
|
||||
const nameOrEmail = user.username ?? user.email ?? defaultUserName;
|
||||
const hasPaidPlan = userPlanFeatures.purchases.length > 0;
|
||||
const latestPlanName = userPlanFeatures.purchases[0]?.planName;
|
||||
const subscriptions = userPlanFeatures.purchases.filter((purchase) =>
|
||||
Boolean(purchase.subscriptionId)
|
||||
);
|
||||
return (
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<ProfileButton
|
||||
image={user.image || undefined}
|
||||
name={nameOrEmail}
|
||||
badge={latestPlanName}
|
||||
hasPurchases={hasPaidPlan}
|
||||
/>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="start">
|
||||
<DropdownMenuContent align="start" width="regular">
|
||||
<DropdownMenuLabel>
|
||||
{user.username ?? defaultUserName}
|
||||
<Text>{user.email}</Text>
|
||||
</DropdownMenuLabel>
|
||||
{userPlanFeatures.purchases
|
||||
.filter((purchase) => Boolean(purchase.subscriptionId))
|
||||
.map((purchase) => (
|
||||
{subscriptions.length > 0 && (
|
||||
<>
|
||||
<DropdownMenuSeparator />
|
||||
<DropdownMenuLabel>Purchases</DropdownMenuLabel>
|
||||
</>
|
||||
)}
|
||||
{subscriptions.map((purchase) => (
|
||||
<DropdownMenuItem
|
||||
key={purchase.subscriptionId}
|
||||
onSelect={() =>
|
||||
navigate(userPlanSubscriptionPath(purchase.subscriptionId))
|
||||
}
|
||||
>
|
||||
Manage {purchase.planName}
|
||||
{purchase.planName}
|
||||
</DropdownMenuItem>
|
||||
))}
|
||||
{hasPaidPlan === false && (
|
||||
@@ -97,7 +103,7 @@ export const ProfileMenu = ({
|
||||
css={{ gap: theme.spacing[3] }}
|
||||
>
|
||||
<UpgradeIcon />
|
||||
<div>Upgrade to Pro</div>
|
||||
<div>Upgrade</div>
|
||||
</DropdownMenuItem>
|
||||
)}
|
||||
<DropdownMenuSeparator />
|
||||
|
||||
Reference in new issue
Block a user