♻️ Refactor logic for showing upgrade button

This commit is contained in:
Luke Vella 2023-11-24 22:25:47 +07:00
parent c208b460aa
commit 9ceb27f6e3

View file

@ -21,7 +21,7 @@ import { Logo } from "@/components/logo";
import { Trans } from "@/components/trans"; import { Trans } from "@/components/trans";
import { UserDropdown } from "@/components/user-dropdown"; import { UserDropdown } from "@/components/user-dropdown";
import { IfCloudHosted } from "@/contexts/environment"; import { IfCloudHosted } from "@/contexts/environment";
import { IfFreeUser } from "@/contexts/plan"; import { useSubscription } from "@/contexts/plan";
import { appVersion, isFeedbackEnabled } from "@/utils/constants"; import { appVersion, isFeedbackEnabled } from "@/utils/constants";
import { IconComponent, NextPageWithLayout } from "../../types"; import { IconComponent, NextPageWithLayout } from "../../types";
@ -97,6 +97,7 @@ const Changelog = () => {
}; };
const MainNav = () => { const MainNav = () => {
const subscription = useSubscription();
return ( return (
<m.div <m.div
variants={{ variants={{
@ -122,9 +123,7 @@ const MainNav = () => {
<div className="flex items-center gap-x-2.5"> <div className="flex items-center gap-x-2.5">
<nav className="flex items-center gap-x-1 sm:gap-x-1.5"> <nav className="flex items-center gap-x-1 sm:gap-x-1.5">
<IfCloudHosted> <IfCloudHosted>
<IfFreeUser> {subscription?.active === false ? <Upgrade /> : null}
<Upgrade />
</IfFreeUser>
</IfCloudHosted> </IfCloudHosted>
<IfGuest> <IfGuest>
<Button <Button