diff --git a/frontend/components/profile/index.tsx b/frontend/components/profile/index.tsx index 4246da5..c176c49 100644 --- a/frontend/components/profile/index.tsx +++ b/frontend/components/profile/index.tsx @@ -17,7 +17,7 @@ import { import { Label } from "@/components/ui/label" import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs" import { deleteSandbox, updateSandbox, updateUser } from "@/lib/actions" -import { MAX_FREE_GENERATION } from "@/lib/constant" +import { TIERS } from "@/lib/tiers" import { SandboxWithLiked, User } from "@/lib/types" import { useUser } from "@clerk/nextjs" import { @@ -74,6 +74,7 @@ export default function ProfilePage({ joinedDate={profileOwner.createdAt} generations={isOwnProfile ? loggedInUser.generations : undefined} isOwnProfile={isOwnProfile} + tier={profileOwner.tier} />
@@ -100,6 +101,7 @@ function ProfileCard({ joinedDate, generations, isOwnProfile, + tier, }: { name: string username: string @@ -108,6 +110,7 @@ function ProfileCard({ joinedDate: Date generations?: number isOwnProfile: boolean + tier: string }) { const { user } = useUser() const router = useRouter() @@ -228,7 +231,7 @@ function ProfileCard({

{joinedAt}

{typeof generations === "number" && ( - + )}
@@ -442,11 +445,11 @@ const StatsItem = ({ icon: Icon, label }: StatsItemProps) => ( // #endregion // #region Sub Badge -const SubscriptionBadge = ({ generations }: { generations: number }) => { +const SubscriptionBadge = ({ generations, tier = "FREE" }: { generations: number, tier?: keyof typeof TIERS }) => { return (
- Free + {tier} @@ -458,11 +461,11 @@ const SubscriptionBadge = ({ generations }: { generations: number }) => {
AI Generations - {`${generations} / ${MAX_FREE_GENERATION}`} + {`${generations} / ${TIERS[tier].generations}`}
diff --git a/frontend/components/ui/userButton.tsx b/frontend/components/ui/userButton.tsx index 3abf8d6..ad7a402 100644 --- a/frontend/components/ui/userButton.tsx +++ b/frontend/components/ui/userButton.tsx @@ -7,7 +7,6 @@ import { DropdownMenuSeparator, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu" -import { MAX_FREE_GENERATION } from "@/lib/constant" import { User } from "@/lib/types" import { useClerk } from "@clerk/nextjs" import { @@ -81,7 +80,7 @@ export default function UserButton({ userData: initialUserData }: { userData: Us const usagePercentage = Math.floor((userData.generations || 0) * 100 / tierInfo.limit) const handleUpgrade = async () => { - router.push('/upgrade') + router.push(`/@${userData.username}`) } return ( @@ -104,16 +103,16 @@ export default function UserButton({ userData: initialUserData }: { userData: Us Dashboard - + Profile - +
@@ -122,7 +121,7 @@ export default function UserButton({ userData: initialUserData }: { userData: Us {userData.tier || "FREE"} Plan
- {/* {(userData.tier === "FREE" || userData.tier === "PRO") && ( + {(userData.tier === "FREE" || userData.tier === "PRO") && ( - )} */} + )}
- - -
-
- AI Usage - {userData.generations}/{tierInfo.limit} -
+
+
+
+ AI Usage + {userData.generations}/{tierInfo.limit} +
-
-
+
90 ? 'bg-red-500' : usagePercentage > 75 ? 'bg-yellow-500' : tierInfo.color.replace('text-', 'bg-') }`} - style={{ - width: `${Math.min(usagePercentage, 100)}%`, - }} - /> + style={{ + width: `${Math.min(usagePercentage, 100)}%`, + }} + /> +
- {/* diff --git a/frontend/lib/constant.ts b/frontend/lib/constant.ts deleted file mode 100644 index 2ef53d7..0000000 --- a/frontend/lib/constant.ts +++ /dev/null @@ -1 +0,0 @@ -export const MAX_FREE_GENERATION = 1000