chore: move subscription utils to shared
This commit is contained in:
@@ -7,9 +7,10 @@ import { HiXMark } from "react-icons/hi2";
|
|||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
|
|
||||||
import type { InviteMemberInput } from "@kan/api/types";
|
import type { InviteMemberInput } from "@kan/api/types";
|
||||||
|
import type { Subscription } from "@kan/shared/utils";
|
||||||
import { authClient } from "@kan/auth/client";
|
import { authClient } from "@kan/auth/client";
|
||||||
|
import { getSubscriptionByPlan } from "@kan/shared/utils";
|
||||||
|
|
||||||
import type { Subscription } from "~/utils/subscriptions";
|
|
||||||
import Button from "~/components/Button";
|
import Button from "~/components/Button";
|
||||||
import Input from "~/components/Input";
|
import Input from "~/components/Input";
|
||||||
import Toggle from "~/components/Toggle";
|
import Toggle from "~/components/Toggle";
|
||||||
@@ -17,7 +18,6 @@ import { useModal } from "~/providers/modal";
|
|||||||
import { usePopup } from "~/providers/popup";
|
import { usePopup } from "~/providers/popup";
|
||||||
import { useWorkspace } from "~/providers/workspace";
|
import { useWorkspace } from "~/providers/workspace";
|
||||||
import { api } from "~/utils/api";
|
import { api } from "~/utils/api";
|
||||||
import { getSubscriptionByPlan } from "~/utils/subscriptions";
|
|
||||||
|
|
||||||
export function InviteMemberForm({
|
export function InviteMemberForm({
|
||||||
numberOfMembers,
|
numberOfMembers,
|
||||||
|
|||||||
@@ -3,9 +3,10 @@ import { env } from "next-runtime-env";
|
|||||||
import { HiEllipsisHorizontal, HiOutlinePlusSmall } from "react-icons/hi2";
|
import { HiEllipsisHorizontal, HiOutlinePlusSmall } from "react-icons/hi2";
|
||||||
import { twMerge } from "tailwind-merge";
|
import { twMerge } from "tailwind-merge";
|
||||||
|
|
||||||
|
import type { Subscription } from "@kan/shared/utils";
|
||||||
import { authClient } from "@kan/auth/client";
|
import { authClient } from "@kan/auth/client";
|
||||||
|
import { getSubscriptionByPlan, hasUnlimitedSeats } from "@kan/shared/utils";
|
||||||
|
|
||||||
import type { Subscription } from "~/utils/subscriptions";
|
|
||||||
import Avatar from "~/components/Avatar";
|
import Avatar from "~/components/Avatar";
|
||||||
import Button from "~/components/Button";
|
import Button from "~/components/Button";
|
||||||
import Dropdown from "~/components/Dropdown";
|
import Dropdown from "~/components/Dropdown";
|
||||||
@@ -17,10 +18,6 @@ import { useModal } from "~/providers/modal";
|
|||||||
import { useWorkspace } from "~/providers/workspace";
|
import { useWorkspace } from "~/providers/workspace";
|
||||||
import { api } from "~/utils/api";
|
import { api } from "~/utils/api";
|
||||||
import { getAvatarUrl } from "~/utils/helpers";
|
import { getAvatarUrl } from "~/utils/helpers";
|
||||||
import {
|
|
||||||
getSubscriptionByPlan,
|
|
||||||
hasUnlimitedSeats,
|
|
||||||
} from "~/utils/subscriptions";
|
|
||||||
import { DeleteMemberConfirmation } from "./components/DeleteMemberConfirmation";
|
import { DeleteMemberConfirmation } from "./components/DeleteMemberConfirmation";
|
||||||
import { InviteMemberForm } from "./components/InviteMemberForm";
|
import { InviteMemberForm } from "./components/InviteMemberForm";
|
||||||
|
|
||||||
|
|||||||
@@ -1,2 +1,3 @@
|
|||||||
export * from "./generateUID";
|
export * from "./generateUID";
|
||||||
export * from "./generateSlug";
|
export * from "./generateSlug";
|
||||||
|
export * from "./subscriptions";
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
import { env } from "next-runtime-env";
|
|
||||||
|
|
||||||
export type SubscriptionStatus =
|
export type SubscriptionStatus =
|
||||||
| "active"
|
| "active"
|
||||||
| "trialing"
|
| "trialing"
|
||||||
@@ -46,14 +44,6 @@ export const hasActiveSubscription = (
|
|||||||
return getSubscriptionByPlan(subscriptions, plan) !== undefined;
|
return getSubscriptionByPlan(subscriptions, plan) !== undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const canInviteMembers = (subscriptions: Subscription[] | undefined) => {
|
|
||||||
if (env("NEXT_PUBLIC_KAN_ENV") === "cloud") {
|
|
||||||
return hasActiveSubscription(subscriptions, "team");
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const hasUnlimitedSeats = (
|
export const hasUnlimitedSeats = (
|
||||||
subscriptions: Subscription[] | undefined,
|
subscriptions: Subscription[] | undefined,
|
||||||
) => {
|
) => {
|
||||||
Reference in New Issue
Block a user