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 type { InviteMemberInput } from "@kan/api/types";
|
||||
import type { Subscription } from "@kan/shared/utils";
|
||||
import { authClient } from "@kan/auth/client";
|
||||
import { getSubscriptionByPlan } from "@kan/shared/utils";
|
||||
|
||||
import type { Subscription } from "~/utils/subscriptions";
|
||||
import Button from "~/components/Button";
|
||||
import Input from "~/components/Input";
|
||||
import Toggle from "~/components/Toggle";
|
||||
@@ -17,7 +18,6 @@ import { useModal } from "~/providers/modal";
|
||||
import { usePopup } from "~/providers/popup";
|
||||
import { useWorkspace } from "~/providers/workspace";
|
||||
import { api } from "~/utils/api";
|
||||
import { getSubscriptionByPlan } from "~/utils/subscriptions";
|
||||
|
||||
export function InviteMemberForm({
|
||||
numberOfMembers,
|
||||
|
||||
@@ -3,9 +3,10 @@ import { env } from "next-runtime-env";
|
||||
import { HiEllipsisHorizontal, HiOutlinePlusSmall } from "react-icons/hi2";
|
||||
import { twMerge } from "tailwind-merge";
|
||||
|
||||
import type { Subscription } from "@kan/shared/utils";
|
||||
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 Button from "~/components/Button";
|
||||
import Dropdown from "~/components/Dropdown";
|
||||
@@ -17,10 +18,6 @@ import { useModal } from "~/providers/modal";
|
||||
import { useWorkspace } from "~/providers/workspace";
|
||||
import { api } from "~/utils/api";
|
||||
import { getAvatarUrl } from "~/utils/helpers";
|
||||
import {
|
||||
getSubscriptionByPlan,
|
||||
hasUnlimitedSeats,
|
||||
} from "~/utils/subscriptions";
|
||||
import { DeleteMemberConfirmation } from "./components/DeleteMemberConfirmation";
|
||||
import { InviteMemberForm } from "./components/InviteMemberForm";
|
||||
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
export * from "./generateUID";
|
||||
export * from "./generateSlug";
|
||||
export * from "./subscriptions";
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import { env } from "next-runtime-env";
|
||||
|
||||
export type SubscriptionStatus =
|
||||
| "active"
|
||||
| "trialing"
|
||||
@@ -46,14 +44,6 @@ export const hasActiveSubscription = (
|
||||
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 = (
|
||||
subscriptions: Subscription[] | undefined,
|
||||
) => {
|
||||
Reference in New Issue
Block a user