diff --git a/web/ee/components/workspace/delete-workspace-section.tsx b/web/ee/components/workspace/delete-workspace-section.tsx index 9b2628048e..773a4e0a3b 100644 --- a/web/ee/components/workspace/delete-workspace-section.tsx +++ b/web/ee/components/workspace/delete-workspace-section.tsx @@ -1 +1,104 @@ -export * from "ce/components/workspace/delete-workspace-section"; +import { FC, useState } from "react"; +import { observer } from "mobx-react"; +import { useParams } from "next/navigation"; +import { ChevronDown, ChevronUp } from "lucide-react"; +// types +import { IWorkspace } from "@plane/types"; +// ui +import { AlertModalCore, Button, Collapsible } from "@plane/ui"; +// components +import { DeleteWorkspaceModal } from "@/components/workspace"; +// plane web hooks +import { useAppRouter } from "@/hooks/use-app-router"; +import { useWorkspaceSubscription } from "@/plane-web/hooks/store"; + +type TDeleteWorkspace = { + workspace: IWorkspace | null; +}; + +export const DeleteWorkspaceSection: FC = observer((props) => { + const { workspace } = props; + // router + const router = useAppRouter(); + const { workspaceSlug } = useParams(); + // states + const [isOpen, setIsOpen] = useState(false); + const [deleteWorkspaceModal, setDeleteWorkspaceModal] = useState(false); + const [redirectingToBillingPage, setRedirectingToBillingPage] = useState(false); + const [activeSubscriptionModal, setActiveSubscriptionModal] = useState(false); + // store hooks + const { currentWorkspaceSubscribedPlanDetail } = useWorkspaceSubscription(); + // derived values + const isAnySubscriptionActive = + currentWorkspaceSubscribedPlanDetail && currentWorkspaceSubscribedPlanDetail?.product !== "FREE"; + + const handleDeleteWorkspace = () => { + if (isAnySubscriptionActive) { + setActiveSubscriptionModal(true); + } else { + setDeleteWorkspaceModal(true); + } + }; + + const handleBillingPageRedirection = () => { + setRedirectingToBillingPage(true); + router.push(`/${workspaceSlug}/settings/billing`); + }; + + return ( + <> + setActiveSubscriptionModal(false)} + handleSubmit={handleBillingPageRedirection} + isOpen={activeSubscriptionModal} + title="Active Subscription" + isSubmitting={redirectingToBillingPage} + content={ + <> + You have an active subscription. Please visit the billing page to cancel your subscription before deleting + your workspace. + + } + secondaryButtonText="Close" + primaryButtonText={{ + loading: "Redirecting...", + default: "Go to billing", + }} + /> + setDeleteWorkspaceModal(false)} + /> +
+
+ setIsOpen(!isOpen)} + className="w-full" + buttonClassName="flex w-full items-center justify-between py-4" + title={ + <> + Delete Workspace + {isOpen ? : } + + } + > +
+ + When deleting a workspace, all of the data and resources within that workspace will be permanently + removed and cannot be recovered. + +
+ +
+
+
+
+
+ + ); +});