From 67c0b7326094d43563af6143ac0b95ba669271e7 Mon Sep 17 00:00:00 2001 From: sriramveeraghanta Date: Wed, 25 Oct 2023 11:58:40 +0530 Subject: [PATCH] feat: Workspace upgrade functionality --- web/components/project/sidebar-list.tsx | 3 - web/components/workspace/help-section.tsx | 20 +++- web/components/workspace/index.ts | 1 + web/components/workspace/upgrade-modal.tsx | 113 ++++++++++++++++++ web/layouts/app-layout-legacy/app-sidebar.tsx | 2 +- web/services/license.service.ts | 16 +++ 6 files changed, 147 insertions(+), 8 deletions(-) create mode 100644 web/components/workspace/upgrade-modal.tsx create mode 100644 web/services/license.service.ts diff --git a/web/components/project/sidebar-list.tsx b/web/components/project/sidebar-list.tsx index 2c33ca1b4..a03184c20 100644 --- a/web/components/project/sidebar-list.tsx +++ b/web/components/project/sidebar-list.tsx @@ -6,7 +6,6 @@ import { Disclosure, Transition } from "@headlessui/react"; import { observer } from "mobx-react-lite"; // hooks import useToast from "hooks/use-toast"; -import useUserAuth from "hooks/use-user-auth"; // components import { CreateProjectModal, ProjectSidebarListItem } from "components/project"; @@ -36,8 +35,6 @@ export const ProjectSidebarList: FC = observer(() => { const [isScrolled, setIsScrolled] = useState(false); // scroll animation state // refs const containerRef = useRef(null); - // user - const { user } = useUserAuth(); // toast const { setToastAlert } = useToast(); diff --git a/web/components/workspace/help-section.tsx b/web/components/workspace/help-section.tsx index 87dbbf373..a7cfef88e 100644 --- a/web/components/workspace/help-section.tsx +++ b/web/components/workspace/help-section.tsx @@ -12,6 +12,7 @@ import { FileText, HelpCircle, MessagesSquare, MoveLeft, Zap } from "lucide-reac import { DiscordIcon, GithubIcon } from "@plane/ui"; // assets import packageJson from "package.json"; +import { UpgradeWorkspaceModal } from "./upgrade-modal"; const helpOptions = [ { @@ -37,15 +38,14 @@ const helpOptions = [ }, ]; -export interface WorkspaceHelpSectionProps { - setSidebarActive?: React.Dispatch>; -} +export interface WorkspaceHelpSectionProps {} export const WorkspaceHelpSection: React.FC = observer(() => { // store const { theme: themeStore } = useMobxStore(); // states const [isNeedHelpOpen, setIsNeedHelpOpen] = useState(false); + const [isUpgradeModalOpen, setUpgradeModalOpen] = useState(false); // refs const helpOptionsRef = useRef(null); @@ -53,15 +53,27 @@ export const WorkspaceHelpSection: React.FC = observe const isCollapsed = themeStore.sidebarCollapsed || false; + const openUpgradeModal = () => { + setUpgradeModalOpen(true); + }; + + const handleUpgradeModalClose = () => { + setUpgradeModalOpen(false); + }; + return ( <> +
{!isCollapsed && ( -
+
Free Plan
)} diff --git a/web/components/workspace/index.ts b/web/components/workspace/index.ts index 9fe2934b0..de4946f9e 100644 --- a/web/components/workspace/index.ts +++ b/web/components/workspace/index.ts @@ -11,3 +11,4 @@ export * from "./sidebar-dropdown"; export * from "./sidebar-menu"; export * from "./sidebar-quick-action"; export * from "./member-select"; +export * from "./upgrade-modal"; diff --git a/web/components/workspace/upgrade-modal.tsx b/web/components/workspace/upgrade-modal.tsx new file mode 100644 index 000000000..ec3683eae --- /dev/null +++ b/web/components/workspace/upgrade-modal.tsx @@ -0,0 +1,113 @@ +import { FC, Fragment } from "react"; +import { Dialog, Transition } from "@headlessui/react"; +// icons +import { Check } from "lucide-react"; +import useSWR from "swr"; +// services +import { LicenseService } from "services/license.service"; +const licenseService = new LicenseService(); + +export interface IUpgradeWorkspaceModal { + isOpen: boolean; + handleClose: () => void; +} + +export const UpgradeWorkspaceModal: FC = (props) => { + const { isOpen, handleClose } = props; + + const { data: products } = useSWR("UPGRADE_PRODUCTS", () => licenseService.getProducts()); + + console.log("products", products); + + return ( + <> + + + +
+ + +
+
+ + + + Upgrade your plan + +
+
+ {products?.map((product: any) => ( +
+
+

+ {product.name} +

+ {product?.mostPopular ? ( +

+ Most popular +

+ ) : null} +
+

{product.description}

+

+ + {product.default_price.price} + + +

+ + Upgrade + +
    + {product.features?.map((feature: any) => ( +
  • +
  • + ))} +
+
+ ))} +
+
+
+
+
+
+
+
+ + ); +}; diff --git a/web/layouts/app-layout-legacy/app-sidebar.tsx b/web/layouts/app-layout-legacy/app-sidebar.tsx index 1db9dc983..ad53bc1f0 100644 --- a/web/layouts/app-layout-legacy/app-sidebar.tsx +++ b/web/layouts/app-layout-legacy/app-sidebar.tsx @@ -34,7 +34,7 @@ const Sidebar: React.FC = observer(({ toggleSidebar, setToggleSide - +
); diff --git a/web/services/license.service.ts b/web/services/license.service.ts new file mode 100644 index 000000000..aa0094c18 --- /dev/null +++ b/web/services/license.service.ts @@ -0,0 +1,16 @@ +// services +import { APIService } from "services/api.service"; + +export class LicenseService extends APIService { + constructor() { + super("http://localhost:8080"); + } + + async getProducts(): Promise { + return this.get(`/api/products/`) + .then((response) => response?.data) + .catch((error) => { + throw error?.response?.data; + }); + } +}