From d4e3e119dea5d95aee33a7ede422b88025ebdbab Mon Sep 17 00:00:00 2001 From: Riqwan Thamir Date: Sun, 5 Mar 2023 16:16:53 +0100 Subject: [PATCH] feat(admin-ui): ProductCategory list page (#3380) --- .changeset/green-cows-bow.md | 5 ++ .../fundamentals/icons/swatch-icon/index.tsx | 29 +++++++ .../ui/src/components/organisms/body-card.tsx | 86 +++++++++++-------- .../components/organisms/sidebar/index.tsx | 16 +++- .../src/domain/product-categories/index.tsx | 13 +++ .../domain/product-categories/pages/index.tsx | 54 ++++++++++++ packages/admin-ui/ui/src/pages/a.tsx | 5 ++ 7 files changed, 169 insertions(+), 39 deletions(-) create mode 100644 .changeset/green-cows-bow.md create mode 100644 packages/admin-ui/ui/src/components/fundamentals/icons/swatch-icon/index.tsx create mode 100644 packages/admin-ui/ui/src/domain/product-categories/index.tsx create mode 100644 packages/admin-ui/ui/src/domain/product-categories/pages/index.tsx diff --git a/.changeset/green-cows-bow.md b/.changeset/green-cows-bow.md new file mode 100644 index 0000000000..b4b95427ea --- /dev/null +++ b/.changeset/green-cows-bow.md @@ -0,0 +1,5 @@ +--- +"@medusajs/admin-ui": patch +--- + +feat(admin-ui): add empty state for product categories diff --git a/packages/admin-ui/ui/src/components/fundamentals/icons/swatch-icon/index.tsx b/packages/admin-ui/ui/src/components/fundamentals/icons/swatch-icon/index.tsx new file mode 100644 index 0000000000..ac89324556 --- /dev/null +++ b/packages/admin-ui/ui/src/components/fundamentals/icons/swatch-icon/index.tsx @@ -0,0 +1,29 @@ +import React from "react" +import IconProps from "../types/icon-type" + +const SwatchIcon: React.FC = ({ + size = "24px", + color = "currentColor", + ...attributes +}) => { + return ( + + + + ) +} + +export default SwatchIcon diff --git a/packages/admin-ui/ui/src/components/organisms/body-card.tsx b/packages/admin-ui/ui/src/components/organisms/body-card.tsx index fddb7843e2..64492ac459 100644 --- a/packages/admin-ui/ui/src/components/organisms/body-card.tsx +++ b/packages/admin-ui/ui/src/components/organisms/body-card.tsx @@ -32,13 +32,15 @@ const BodyCard: React.FC = ({ className, children, compact = false, + setBorders = false, + footerMinHeight = 24, ...rest }) => { const { isScrolled, scrollListener } = useScroll({ threshold: 16 }) return (
= ({ >
{isScrolled && ( -
+
)}
-
- {customHeader ? ( -
{customHeader}
- ) : title ? ( -

{title}

- ) : ( -
- )} +
+
+
+ {customHeader ? ( +
{customHeader}
+ ) : title ? ( +

{title}

+ ) : ( +
+ )} -
- {status && status} - + {subtitle && ( +

+ {subtitle} +

+ )} +
+ +
+ {status && status} + +
- {subtitle && ( -

- {subtitle} -

- )} - {children && ( -
- {children} -
- )} + +
+ {children && ( +
+ {children} +
+ )} +
{events && events.length > 0 ? ( -
-
+
+
{events.map((event, i: React.Key) => { return (
) : ( -
+
)}
) diff --git a/packages/admin-ui/ui/src/components/organisms/sidebar/index.tsx b/packages/admin-ui/ui/src/components/organisms/sidebar/index.tsx index 9699a7e56c..14ee3a30ac 100644 --- a/packages/admin-ui/ui/src/components/organisms/sidebar/index.tsx +++ b/packages/admin-ui/ui/src/components/organisms/sidebar/index.tsx @@ -1,5 +1,5 @@ import { useAdminStore } from "medusa-react" -import { useState } from "react" +import React, { useState } from "react" import { useFeatureFlag } from "../../../providers/feature-flag-provider" import BuildingsIcon from "../../fundamentals/icons/buildings-icon" import CartIcon from "../../fundamentals/icons/cart-icon" @@ -8,15 +8,17 @@ import GearIcon from "../../fundamentals/icons/gear-icon" import GiftIcon from "../../fundamentals/icons/gift-icon" import SaleIcon from "../../fundamentals/icons/sale-icon" import TagIcon from "../../fundamentals/icons/tag-icon" +import SwatchIcon from "../../fundamentals/icons/swatch-icon" import UsersIcon from "../../fundamentals/icons/users-icon" import SidebarMenuItem from "../../molecules/sidebar-menu-item" import UserMenu from "../../molecules/user-menu" const ICON_SIZE = 20 -const Sidebar = () => { +const Sidebar: React.FC = () => { const [currentlyOpen, setCurrentlyOpen] = useState(-1) + const { isFeatureEnabled } = useFeatureFlag() const { store } = useAdminStore() const triggerHandler = () => { @@ -30,8 +32,6 @@ const Sidebar = () => { // infinite updates, and we do not want the variable to be free floating. triggerHandler.id = 0 - const { isFeatureEnabled } = useFeatureFlag() - const inventoryEnabled = isFeatureEnabled("inventoryService") && isFeatureEnabled("stockLocationService") @@ -63,6 +63,14 @@ const Sidebar = () => { text={"Products"} triggerHandler={triggerHandler} /> + {isFeatureEnabled("product_categories") && ( + } + text={"Categories"} + triggerHandler={triggerHandler} + /> + )} } diff --git a/packages/admin-ui/ui/src/domain/product-categories/index.tsx b/packages/admin-ui/ui/src/domain/product-categories/index.tsx new file mode 100644 index 0000000000..a9da57f318 --- /dev/null +++ b/packages/admin-ui/ui/src/domain/product-categories/index.tsx @@ -0,0 +1,13 @@ +import { Route, Routes } from "react-router-dom" + +import ProductCategoryIndex from "./pages" + +const ProductCategories = () => { + return ( + + } /> + + ) +} + +export default ProductCategories diff --git a/packages/admin-ui/ui/src/domain/product-categories/pages/index.tsx b/packages/admin-ui/ui/src/domain/product-categories/pages/index.tsx new file mode 100644 index 0000000000..ecb26804d3 --- /dev/null +++ b/packages/admin-ui/ui/src/domain/product-categories/pages/index.tsx @@ -0,0 +1,54 @@ +import { createContext } from "react" + +import BodyCard from "../../../components/organisms/body-card" + +/** + * Product categories empty state placeholder. + */ +function ProductCategoriesEmptyState() { + return ( +
+

+ No product categories yet, use the above button to create your first + category. +

+
+ ) +} + +export const ProductCategoriesContext = createContext<{}>({} as any) + +/** + * Product category index page container. + */ +function ProductCategoryPage() { + const actions = [ + { + label: "Add category", + onClick: () => {}, + }, + ] + + const context = {} + + return ( + +
+
+ + + +
+
+
+ ) +} + +export default ProductCategoryPage diff --git a/packages/admin-ui/ui/src/pages/a.tsx b/packages/admin-ui/ui/src/pages/a.tsx index ec4593ed3a..be167ba90f 100644 --- a/packages/admin-ui/ui/src/pages/a.tsx +++ b/packages/admin-ui/ui/src/pages/a.tsx @@ -20,6 +20,7 @@ import PublishableApiKeys from "../domain/publishable-api-keys" import SalesChannels from "../domain/sales-channels" import Settings from "../domain/settings" import { AnalyticsProvider } from "../providers/analytics-provider" +import ProductCategories from "../domain/product-categories" const IndexPage = () => { const navigate = useNavigate() @@ -42,6 +43,10 @@ const DashboardRoutes = () => { } /> } /> + } + /> } /> } /> } />