mirror of
https://github.com/lukevella/rallly.git
synced 2025-06-10 22:51:47 +02:00
✨ Self-Hosting Update (#842)
This commit is contained in:
parent
3e616d1e41
commit
7a5f9ae474
51 changed files with 945 additions and 781 deletions
|
@ -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" />
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue