Self-Hosting Update (#842)

This commit is contained in:
Luke Vella 2023-09-11 15:34:55 +01:00 committed by GitHub
parent 3e616d1e41
commit 7a5f9ae474
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
51 changed files with 945 additions and 781 deletions

View file

@ -3,9 +3,33 @@ import { Badge } from "@rallly/ui/badge";
import React from "react";
import { Trans } from "@/components/trans";
import { useUser } from "@/components/user-provider";
import { isSelfHosted } from "@/utils/constants";
export const useSubscription = () => {
const { user } = useUser();
const { data } = trpc.user.subscription.useQuery(undefined, {
enabled: !isSelfHosted && user.isGuest === false,
});
if (isSelfHosted) {
return {
active: true,
};
}
if (user.isGuest) {
return {
active: false,
};
}
return data;
};
export const usePlan = () => {
const { data } = trpc.user.subscription.useQuery();
const data = useSubscription();
const isPaid = data?.active === true;
@ -34,6 +58,7 @@ export const Plan = () => {
</Badge>
);
}
return (
<Badge variant="secondary">
<Trans i18nKey="planFree" defaults="Free" />