Skip to content

The complete open source platform to run your entire marketplace. Storefront, vendor panel, admin console, and integrations in one enterprise-grade platform you own.

feat(admin): add order-groups hooks and update components

vholikf200bec3d6f9
diff --git a/packages/admin/src/hooks/api/index.ts b/packages/admin/src/hooks/api/index.ts
index c64874a26..6a96f9278 100644
--- a/packages/admin/src/hooks/api/index.ts
+++ b/packages/admin/src/hooks/api/index.ts
@@ -4,7 +4,6 @@ export * from "./campaigns";
export * from "./categories";
export * from "./collections";
export * from "./currencies";
-export * from "./customer-groups";
export * from "./customers";
export * from "./fulfillment";
export * from "./fulfillment-providers";
@@ -12,10 +11,10 @@ export * from "./fulfillment-sets";
export * from "./inventory";
export * from "./invites";
export * from "./notification";
+export * from "./order-groups"
export * from "./orders";
export * from "./payment-collections";
export * from "./payments";
-export * from "./plugins";
export * from "./price-lists";
export * from "./product-types";
export * from "./product-variants";
@@ -34,7 +33,3 @@ export * from "./tags";
export * from "./tax-rates";
export * from "./tax-regions";
export * from "./users";
-export * from "./views";
-export * from "./workflow-executions";
-export * from "./algolia";
-export * from "./commission";
diff --git a/packages/admin/src/hooks/api/order-groups.tsx b/packages/admin/src/hooks/api/order-groups.tsx
new file mode 100644
index 000000000..f310f6979
--- /dev/null
+++ b/packages/admin/src/hooks/api/order-groups.tsx
@@ -0,0 +1,57 @@
+import {
+ ClientError,
+ InferClientInput,
+ InferClientOutput,
+} from "@mercurjs/client"
+import { QueryKey, UseQueryOptions, useQuery } from "@tanstack/react-query"
+import { sdk } from "../../lib/client"
+import { queryKeysFactory } from "../../lib/query-key-factory"
+
+const ORDER_GROUPS_QUERY_KEY = "order_groups" as const
+export const orderGroupsQueryKeys = queryKeysFactory(ORDER_GROUPS_QUERY_KEY)
+
+export const useOrderGroup = (
+ id: string,
+ query?: Omit<
+ InferClientInput<typeof sdk.admin.orderGroups.$id.query>,
+ "$id"
+ >,
+ options?: Omit<
+ UseQueryOptions<
+ InferClientOutput<typeof sdk.admin.orderGroups.$id.query>,
+ ClientError,
+ InferClientOutput<typeof sdk.admin.orderGroups.$id.query>,
+ QueryKey
+ >,
+ "queryKey" | "queryFn"
+ >
+) => {
+ const { data, ...rest } = useQuery({
+ queryFn: () => sdk.admin.orderGroups.$id.query({ $id: id, ...query }),
+ queryKey: orderGroupsQueryKeys.detail(id),
+ ...options,
+ })
+
+ return { ...data, ...rest }
+}
+
+export const useOrderGroups = (
+ query?: InferClientInput<typeof sdk.admin.orderGroups.query>,
+ options?: Omit<
+ UseQueryOptions<
+ InferClientOutput<typeof sdk.admin.orderGroups.query>,
+ ClientError,
+ InferClientOutput<typeof sdk.admin.orderGroups.query>,
+ QueryKey
+ >,
+ "queryKey" | "queryFn"
+ >
+) => {
+ const { data, ...rest } = useQuery({
+ queryFn: () => sdk.admin.orderGroups.query({ ...query }),
+ queryKey: orderGroupsQueryKeys.list(query),
+ ...options,
+ })
+
+ return { ...data, ...rest }
+}
diff --git a/packages/admin/src/pages/orders/order-detail/components/copy-payment-link/copy-payment-link.tsx b/packages/admin/src/pages/orders/order-detail/components/copy-payment-link/copy-payment-link.tsx
deleted file mode 100644
index c4c1391a7..000000000
--- a/packages/admin/src/pages/orders/order-detail/components/copy-payment-link/copy-payment-link.tsx
+++ /dev/null
@@ -1,80 +0,0 @@
-import { CheckCircleSolid, SquareTwoStack } from "@medusajs/icons"
-import { AdminOrder, AdminPaymentCollection } from "@medusajs/types"
-import { Button, Tooltip } from "@medusajs/ui"
-import copy from "copy-to-clipboard"
-import React, { useState } from "react"
-import { useTranslation } from "react-i18next"
-import { getStylizedAmount } from "../../../../../lib/money-amount-helpers"
-import { MEDUSA_STOREFRONT_URL } from "../../../../../lib/storefront"
-
-type CopyPaymentLinkProps = {
- paymentCollection: AdminPaymentCollection
- order: AdminOrder
-}
-
-/**
- * This component is based on the `button` element and supports all of its props
- */
-const CopyPaymentLink = React.forwardRef<any, CopyPaymentLinkProps>(
- ({ paymentCollection, order }: CopyPaymentLinkProps, ref) => {
- const [done, setDone] = useState(false)
- const [open, setOpen] = useState(false)
- const [text, setText] = useState("CopyPaymentLink")
- const { t } = useTranslation()
-
- const copyToClipboard = async (
- e:
- | React.MouseEvent<HTMLElement, MouseEvent>
- | React.MouseEvent<HTMLButtonElement, MouseEvent>
- ) => {
- e.stopPropagation()
-
- setDone(true)
- copy(
- `${MEDUSA_STOREFRONT_URL}/payment-collection/${paymentCollection.id}`
- )
-
- setTimeout(() => {
- setDone(false)
- }, 2000)
- }
-
- React.useEffect(() => {
- if (done) {
- setText(t("actions.copied"))
- return
- }
-
- setTimeout(() => {
- setText(t("actions.copy"))
- }, 500)
- }, [done])
-
- return (
- <Tooltip content={text} open={done || open} onOpenChange={setOpen}>
- <Button
- ref={ref}
- variant="secondary"
- size="small"
- aria-label="CopyPaymentLink code snippet"
- onClick={copyToClipboard}
- >
- {done ? (
- <CheckCircleSolid className="inline" />
- ) : (
- <SquareTwoStack className="inline" />
- )}
- {t("orders.payment.paymentLink", {
- amount: getStylizedAmount(
- paymentCollection.amount as number,
- order?.currency_code
- ),
- })}
- </Button>
- </Tooltip>
- )
- }
-)
-CopyPaymentLink.displayName = "CopyPaymentLink"
-
-export { CopyPaymentLink }
diff --git a/packages/admin/src/pages/orders/order-detail/components/copy-payment-link/index.ts b/packages/admin/src/pages/orders/order-detail/components/copy-payment-link/index.ts
deleted file mode 100644
index e496ff07b..000000000
--- a/packages/admin/src/pages/orders/order-detail/components/copy-payment-link/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from "./copy-payment-link"
diff --git a/packages/admin/src/pages/orders/order-detail/components/order-remaining-orders-group-section/order-remaining-orders-group-section.tsx b/packages/admin/src/pages/orders/order-detail/components/order-remaining-orders-group-section/order-remaining-orders-group-section.tsx
index 3ec18b59b..553b20df8 100644
--- a/packages/admin/src/pages/orders/order-detail/components/order-remaining-orders-group-section/order-remaining-orders-group-section.tsx
+++ b/packages/admin/src/pages/orders/order-detail/components/order-remaining-orders-group-section/order-remaining-orders-group-section.tsx
@@ -1,26 +1,66 @@
-import { Badge, Button, Container, Heading, Text } from "@medusajs/ui";
+import {
+ Badge,
+ Button,
+ Container,
+ Heading,
+ StatusBadge,
+ Text,
+} from "@medusajs/ui";
import { useNavigate, useParams } from "react-router-dom";
-import { useOrderSet } from "../../../../../hooks/api/sellers";
-import { PaymentStatusBadge } from "../../../../../components/common/payments-status-badge";
-import { OrderStatusBadge } from "../../../../../components/common/order-status-badge";
+import { HttpTypes } from "@mercurjs/types";
+import {
+ getCanceledOrderStatus,
+ getOrderPaymentStatus,
+} from "@/lib/order-helpers";
+import { useTranslation } from "react-i18next";
+import { useOrderGroup } from "@/hooks/api";
+
+const OrderBadge = ({ order }: { order: HttpTypes.AdminOrder }) => {
+ const { t } = useTranslation();
+ const orderStatus = getCanceledOrderStatus(t, order.status);
+
+ if (!orderStatus) {
+ return null;
+ }
+
+ return (
+ <StatusBadge color={orderStatus.color} className="text-nowrap">
+ {orderStatus.label}
+ </StatusBadge>
+ );
+};
+
+const PaymentBadge = ({ order }: { order: HttpTypes.AdminOrder }) => {
+ const { t } = useTranslation();
+
+ const { label, color } = getOrderPaymentStatus(t, order.payment_status);
+
+ return (
+ <StatusBadge color={color} className="text-nowrap">
+ {label}
+ </StatusBadge>
+ );
+};
export const OrderRemainingOrdersGroupSection = () => {
const { id } = useParams();
const navigate = useNavigate();
- const { data, isLoading } = useOrderSet(id!);
+ const { order_group, isLoading } = useOrderGroup(id!);
if (isLoading) {
return <div>Loading...</div>;
}
- const { order_sets } = data || {};
-
- const { orders } = order_sets?.[0] || {};
+ const { orders } = order_group || {};
return (
<Container data-testid="order-remaining-orders-group-section">
- <Heading level="h2" className="text-lg font-medium" data-testid="order-remaining-orders-group-heading">
+ <Heading
+ level="h2"
+ className="text-lg font-medium"
+ data-testid="order-remaining-orders-group-heading"
+ >
Remaining orders group
</Heading>
<div data-testid="order-remaining-orders-group-list">
@@ -48,20 +88,26 @@ export const OrderRemainingOrdersGroupSection = () => {
>
#{order.display_id}
</Heading>
- <div className="flex w-2/3" data-testid={`order-remaining-orders-group-item-${order.id}-badges`}>
+ <div
+ className="flex w-2/3"
+ data-testid={`order-remaining-orders-group-item-${order.id}-badges`}
+ >
<Badge className="scale-75 -mr-8">
<span className="text-xs mr-2">Payment</span>
- <PaymentStatusBadge
- status={order.payment_collections[0].status}
- />
+ <PaymentBadge order={order} />
</Badge>
<Badge className="scale-75 -mr-4">
<span className="text-xs mr-2">Order</span>
- <OrderStatusBadge status={order.status} />
+ <OrderBadge order={order} />
</Badge>
</div>
</div>
- <Text className="truncate" data-testid={`order-remaining-orders-group-item-${order.id}-items`}>{items}</Text>
+ <Text
+ className="truncate"
+ data-testid={`order-remaining-orders-group-item-${order.id}-items`}
+ >
+ {items}
+ </Text>
</div>
</Button>
);
diff --git a/packages/admin/src/pages/orders/order-detail/components/order-summary-section/order-summary-section.tsx b/packages/admin/src/pages/orders/order-detail/components/order-summary-section/order-summary-section.tsx
index 4741e54a2..9bdcb01b5 100644
--- a/packages/admin/src/pages/orders/order-detail/components/order-summary-section/order-summary-section.tsx
+++ b/packages/admin/src/pages/orders/order-detail/components/order-summary-section/order-summary-section.tsx
@@ -60,7 +60,6 @@ import {
import { getTotalCaptured } from "../../../../../lib/payment.ts";
import { getLoyaltyPlugin } from "../../../../../lib/plugins.ts";
import { getReturnableQuantity } from "../../../../../lib/rma.ts";
-import { CopyPaymentLink } from "../copy-payment-link/copy-payment-link.tsx";
import ReturnInfoPopover from "./return-info-popover.tsx";
import ShippingInfoPopover from "./shipping-info-popover.tsx";
import { formatPercentage } from "../../../../../lib/percentage-helpers.ts";
@@ -267,13 +266,6 @@ export const OrderSummarySection = ({
</Button>
)}
- {showPayment && (
- <CopyPaymentLink
- paymentCollection={unpaidPaymentCollection}
- order={order}
- />
- )}
-
{showPayment && (
<Button
size="small"
diff --git a/packages/admin/src/pages/products/product-create/components/product-create-details-form/product-create-details-form.tsx b/packages/admin/src/pages/products/product-create/components/product-create-details-form/product-create-details-form.tsx
index d55a46890..6074275b3 100644
--- a/packages/admin/src/pages/products/product-create/components/product-create-details-form/product-create-details-form.tsx
+++ b/packages/admin/src/pages/products/product-create/components/product-create-details-form/product-create-details-form.tsx
@@ -1,44 +1,52 @@
-import { Divider, Heading } from "@medusajs/ui"
-import { UseFormReturn } from "react-hook-form"
-import { useTranslation } from "react-i18next"
+import { Divider, Heading } from "@medusajs/ui";
+import { UseFormReturn } from "react-hook-form";
+import { useTranslation } from "react-i18next";
-import { FormExtensionZone } from "../../../../../dashboard-app"
-import { useExtension } from "../../../../../providers/extension-provider"
-import { ProductCreateSchemaType } from "../../types"
-import { ProductCreateGeneralSection } from "./components/product-create-details-general-section"
-import { ProductCreateMediaSection } from "./components/product-create-details-media-section"
-import { ProductCreateVariantsSection } from "./components/product-create-details-variant-section"
+import { ProductCreateSchemaType } from "../../types";
+import { ProductCreateGeneralSection } from "./components/product-create-details-general-section";
+import { ProductCreateMediaSection } from "./components/product-create-details-media-section";
+import { ProductCreateVariantsSection } from "./components/product-create-details-variant-section";
type ProductAttributesProps = {
- form: UseFormReturn<ProductCreateSchemaType>
-}
+ form: UseFormReturn<ProductCreateSchemaType>;
+};
export const ProductCreateDetailsForm = ({ form }: ProductAttributesProps) => {
- const { getFormFields } = useExtension()
- const fields = getFormFields("product", "create", "general")
-
return (
- <div className="flex flex-col items-center p-16" data-testid="product-create-details-form">
- <div className="flex w-full max-w-[720px] flex-col gap-y-8" data-testid="product-create-details-form-content">
+ <div
+ className="flex flex-col items-center p-16"
+ data-testid="product-create-details-form"
+ >
+ <div
+ className="flex w-full max-w-[720px] flex-col gap-y-8"
+ data-testid="product-create-details-form-content"
+ >
<Header />
- <div className="flex flex-col gap-y-6" data-testid="product-create-details-form-sections">
+ <div
+ className="flex flex-col gap-y-6"
+ data-testid="product-create-details-form-sections"
+ >
<ProductCreateGeneralSection form={form} />
- <FormExtensionZone fields={fields} form={form} />
<ProductCreateMediaSection form={form} />
</div>
<Divider data-testid="product-create-details-form-divider" />
<ProductCreateVariantsSection form={form} />
</div>
</div>
- )
-}
+ );
+};
const Header = () => {
- const { t } = useTranslation()
+ const { t } = useTranslation();
return (
- <div className="flex flex-col" data-testid="product-create-details-form-header">
- <Heading data-testid="product-create-details-form-heading">{t("products.create.header")}</Heading>
+ <div
+ className="flex flex-col"
+ data-testid="product-create-details-form-header"
+ >
+ <Heading data-testid="product-create-details-form-heading">
+ {t("products.create.header")}
+ </Heading>
</div>
- )
-}
+ );
+};
diff --git a/packages/admin/src/pages/products/product-create/components/product-create-organize-form/product-create-organize-form.tsx b/packages/admin/src/pages/products/product-create/components/product-create-organize-form/product-create-organize-form.tsx
index f73cb75c7..3dfa1beee 100644
--- a/packages/admin/src/pages/products/product-create/components/product-create-organize-form/product-create-organize-form.tsx
+++ b/packages/admin/src/pages/products/product-create/components/product-create-organize-form/product-create-organize-form.tsx
@@ -1,33 +1,30 @@
-import { UseFormReturn } from "react-hook-form"
+import { UseFormReturn } from "react-hook-form";
-import { StackedFocusModal } from "../../../../../components/modals"
-import { FormExtensionZone } from "../../../../../dashboard-app"
-import { useExtension } from "../../../../../providers/extension-provider"
-import { ProductCreateSchemaType } from "../../types"
-import { ProductCreateOrganizationSection } from "./components/product-create-organize-section"
-import { ProductCreateSalesChannelStackedModal } from "./components/product-create-sales-channel-stacked-modal"
-import { SC_STACKED_MODAL_ID } from "./constants"
+import { StackedFocusModal } from "../../../../../components/modals";
+import { ProductCreateSchemaType } from "../../types";
+import { ProductCreateOrganizationSection } from "./components/product-create-organize-section";
+import { ProductCreateSalesChannelStackedModal } from "./components/product-create-sales-channel-stacked-modal";
+import { SC_STACKED_MODAL_ID } from "./constants";
type ProductAttributesProps = {
- form: UseFormReturn<ProductCreateSchemaType>
-}
+ form: UseFormReturn<ProductCreateSchemaType>;
+};
export const ProductCreateOrganizeForm = ({ form }: ProductAttributesProps) => {
- const { getFormFields } = useExtension()
- const fields = getFormFields("product", "create", "organize")
-
return (
<StackedFocusModal id={SC_STACKED_MODAL_ID}>
- <div className="flex flex-col items-center p-16" data-testid="product-create-organize-form">
- <div className="flex w-full max-w-[720px] flex-col gap-y-8" data-testid="product-create-organize-form-content">
+ <div
+ className="flex flex-col items-center p-16"
+ data-testid="product-create-organize-form"
+ >
+ <div
+ className="flex w-full max-w-[720px] flex-col gap-y-8"
+ data-testid="product-create-organize-form-content"
+ >
<ProductCreateOrganizationSection form={form} />
- <FormExtensionZone fields={fields} form={form} />
- {/* TODO: WHERE DO WE SET PRODUCT ATTRIBUTES? -> the plan is to moved that to Inventory UI */}
- {/* <Divider />*/}
- {/* <ProductCreateAttributeSection form={form} />*/}
</div>
</div>
<ProductCreateSalesChannelStackedModal form={form} />
</StackedFocusModal>
- )
-}
+ );
+};
diff --git a/packages/admin/src/pages/products/product-detail/components/product-attribute-section/product-attribute-section.tsx b/packages/admin/src/pages/products/product-detail/components/product-attribute-section/product-attribute-section.tsx
index 6813ed58a..3b9203dfb 100644
--- a/packages/admin/src/pages/products/product-detail/components/product-attribute-section/product-attribute-section.tsx
+++ b/packages/admin/src/pages/products/product-detail/components/product-attribute-section/product-attribute-section.tsx
@@ -1,26 +1,29 @@
-import { PencilSquare } from "@medusajs/icons"
-import { HttpTypes } from "@medusajs/types"
-import { Container, Heading } from "@medusajs/ui"
-import { useTranslation } from "react-i18next"
-import { ActionMenu } from "../../../../../components/common/action-menu"
-import { SectionRow } from "../../../../../components/common/section"
-import { getFormattedCountry } from "../../../../../lib/addresses"
-import { useExtension } from "../../../../../providers/extension-provider"
+import { PencilSquare } from "@medusajs/icons";
+import { HttpTypes } from "@medusajs/types";
+import { Container, Heading } from "@medusajs/ui";
+import { useTranslation } from "react-i18next";
+import { ActionMenu } from "../../../../../components/common/action-menu";
+import { SectionRow } from "../../../../../components/common/section";
+import { getFormattedCountry } from "../../../../../lib/addresses";
type ProductAttributeSectionProps = {
- product: HttpTypes.AdminProduct
-}
+ product: HttpTypes.AdminProduct;
+};
export const ProductAttributeSection = ({
product,
}: ProductAttributeSectionProps) => {
- const { t } = useTranslation()
- const { getDisplays } = useExtension()
+ const { t } = useTranslation();
return (
<Container className="divide-y p-0" data-testid="product-attribute-section">
- <div className="flex items-center justify-between px-6 py-4" data-testid="product-attribute-header">
- <Heading level="h2" data-testid="product-attribute-title">{t("products.attributes")}</Heading>
+ <div
+ className="flex items-center justify-between px-6 py-4"
+ data-testid="product-attribute-header"
+ >
+ <Heading level="h2" data-testid="product-attribute-title">
+ {t("products.attributes")}
+ </Heading>
<ActionMenu
groups={[
{
@@ -36,20 +39,41 @@ export const ProductAttributeSection = ({
data-testid="product-attribute-action-menu"
/>
</div>
- <SectionRow title={t("fields.height")} value={product.height} data-testid="product-height-row" />
- <SectionRow title={t("fields.width")} value={product.width} data-testid="product-width-row" />
- <SectionRow title={t("fields.length")} value={product.length} data-testid="product-length-row" />
- <SectionRow title={t("fields.weight")} value={product.weight} data-testid="product-weight-row" />
- <SectionRow title={t("fields.midCode")} value={product.mid_code} data-testid="product-mid-code-row" />
- <SectionRow title={t("fields.hsCode")} value={product.hs_code} data-testid="product-hs-code-row" />
+ <SectionRow
+ title={t("fields.height")}
+ value={product.height}
+ data-testid="product-height-row"
+ />
+ <SectionRow
+ title={t("fields.width")}
+ value={product.width}
+ data-testid="product-width-row"
+ />
+ <SectionRow
+ title={t("fields.length")}
+ value={product.length}
+ data-testid="product-length-row"
+ />
+ <SectionRow
+ title={t("fields.weight")}
+ value={product.weight}
+ data-testid="product-weight-row"
+ />
+ <SectionRow
+ title={t("fields.midCode")}
+ value={product.mid_code}
+ data-testid="product-mid-code-row"
+ />
+ <SectionRow
+ title={t("fields.hsCode")}
+ value={product.hs_code}
+ data-testid="product-hs-code-row"
+ />
<SectionRow
title={t("fields.countryOfOrigin")}
value={getFormattedCountry(product.origin_country)}
data-testid="product-country-of-origin-row"
/>
- {getDisplays("product", "attributes").map((Component, i) => {
- return <Component key={i} data={product} />
- })}
</Container>
- )
-}
+ );
+};
diff --git a/packages/admin/src/pages/products/product-detail/components/product-general-section/product-general-section.tsx b/packages/admin/src/pages/products/product-detail/components/product-general-section/product-general-section.tsx
index 6475b5d41..cc4fd233d 100644
--- a/packages/admin/src/pages/products/product-detail/components/product-general-section/product-general-section.tsx
+++ b/packages/admin/src/pages/products/product-detail/components/product-general-section/product-general-section.tsx
@@ -8,7 +8,6 @@ import { useNavigate } from "react-router-dom";
import { ActionMenu } from "../../../../../components/common/action-menu";
import { SectionRow } from "../../../../../components/common/section";
import { useDeleteProduct } from "../../../../../hooks/api/products";
-import { useExtension } from "../../../../../providers/extension-provider";
const productStatusColor = (status: string) => {
switch (status) {
@@ -35,9 +34,6 @@ export const ProductGeneralSection = ({
const { t } = useTranslation();
const prompt = usePrompt();
const navigate = useNavigate();
- const { getDisplays } = useExtension();
-
- const displays = getDisplays("product", "general");
const { mutateAsync } = useDeleteProduct(product.id);
@@ -125,9 +121,6 @@ export const ProductGeneralSection = ({
value={product.discountable ? t("fields.true") : t("fields.false")}
data-testid="product-discountable-row"
/>
- {displays.map((Component, index) => {
- return <Component key={index} data={product} />;
- })}
</Container>
);
};
diff --git a/packages/admin/src/pages/products/product-detail/components/product-organization-section/product-organization-section.tsx b/packages/admin/src/pages/products/product-detail/components/product-organization-section/product-organization-section.tsx
index 12bdf9630..b2233ed05 100644
--- a/packages/admin/src/pages/products/product-detail/components/product-organization-section/product-organization-section.tsx
+++ b/packages/admin/src/pages/products/product-detail/components/product-organization-section/product-organization-section.tsx
@@ -1,26 +1,32 @@
-import { PencilSquare } from "@medusajs/icons"
-import { HttpTypes } from "@medusajs/types"
-import { Badge, Container, Heading, Tooltip } from "@medusajs/ui"
-import { useTranslation } from "react-i18next"
-import { Link } from "react-router-dom"
-import { ActionMenu } from "../../../../../components/common/action-menu"
-import { SectionRow } from "../../../../../components/common/section"
-import { useExtension } from "../../../../../providers/extension-provider"
+import { PencilSquare } from "@medusajs/icons";
+import { HttpTypes } from "@medusajs/types";
+import { Badge, Container, Heading, Tooltip } from "@medusajs/ui";
+import { useTranslation } from "react-i18next";
+import { Link } from "react-router-dom";
+import { ActionMenu } from "../../../../../components/common/action-menu";
+import { SectionRow } from "../../../../../components/common/section";
type ProductOrganizationSectionProps = {
- product: HttpTypes.AdminProduct
-}
+ product: HttpTypes.AdminProduct;
+};
export const ProductOrganizationSection = ({
product,
}: ProductOrganizationSectionProps) => {
- const { t } = useTranslation()
- const { getDisplays } = useExtension()
+ const { t } = useTranslation();
return (
- <Container className="divide-y p-0" data-testid="product-organization-section">
- <div className="flex items-center justify-between px-6 py-4" data-testid="product-organization-header">
- <Heading level="h2" data-testid="product-organization-title">{t("products.organization.header")}</Heading>
+ <Container
+ className="divide-y p-0"
+ data-testid="product-organization-section"
+ >
+ <div
+ className="flex items-center justify-between px-6 py-4"
+ data-testid="product-organization-header"
+ >
+ <Heading level="h2" data-testid="product-organization-title">
+ {t("products.organization.header")}
+ </Heading>
<ActionMenu
groups={[
{
@@ -93,20 +99,21 @@ export const ProductOrganizationSection = ({
}
data-testid="product-categories-row"
/>
-
- {getDisplays("product", "organize").map((Component, i) => {
- return <Component key={i} data={product} />
- })}
</Container>
- )
-}
+ );
+};
const OrganizationTag = ({ label, to }: { label: string; to: string }) => {
return (
<Tooltip content={label}>
<Badge size="2xsmall" className="block w-fit truncate" asChild>
- <Link to={to} data-testid={`organization-tag-${label.toLowerCase().replace(/\s+/g, "-")}`}>{label}</Link>
+ <Link
+ to={to}
+ data-testid={`organization-tag-${label.toLowerCase().replace(/\s+/g, "-")}`}
+ >
+ {label}
+ </Link>
</Badge>
</Tooltip>
- )
-}
+ );
+};