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 compound components for all remaining list and detail pages

vholik32a22158f6de
diff --git a/packages/admin/src/pages/api-key-management/api-key-management-detail/api-key-management-detail.tsx b/packages/admin/src/pages/api-key-management/api-key-management-detail/api-key-management-detail.tsx
index ef881faf3..382a4a80c 100644
--- a/packages/admin/src/pages/api-key-management/api-key-management-detail/api-key-management-detail.tsx
+++ b/packages/admin/src/pages/api-key-management/api-key-management-detail/api-key-management-detail.tsx
@@ -1,3 +1,4 @@
+import { Children, ReactNode } from "react"
import { useLoaderData, useParams } from "react-router-dom"
import { SingleColumnPageSkeleton } from "../../../components/common/skeleton"
@@ -8,27 +9,31 @@ import { ApiKeyGeneralSection } from "./components/api-key-general-section"
import { ApiKeySalesChannelSection } from "./components/api-key-sales-channel-section"
import { apiKeyLoader } from "./loader"
-export const ApiKeyManagementDetail = () => {
+const Root = ({ children }: { children?: ReactNode }) => {
const initialData = useLoaderData() as Awaited<
ReturnType<typeof apiKeyLoader>
>
const { id } = useParams()
- const { api_key, isLoading, isError, error } = useApiKey(id!, {
- initialData: initialData,
- })
+ const { api_key, isLoading, isError, error } = useApiKey(
+ id!,
+ undefined,
+ {
+ initialData: initialData,
+ }
+ )
if (isLoading || !api_key) {
return <SingleColumnPageSkeleton showJSON sections={1} />
}
- const isPublishable = api_key?.type === ApiKeyType.PUBLISHABLE
-
if (isError) {
throw error
}
+ const isPublishable = api_key?.type === ApiKeyType.PUBLISHABLE
+
return (
<SingleColumnPage
hasOutlet
@@ -36,8 +41,19 @@ export const ApiKeyManagementDetail = () => {
data={api_key}
data-testid={`${api_key.type}-api-key-detail-page`}
>
- <ApiKeyGeneralSection apiKey={api_key} />
- {isPublishable && <ApiKeySalesChannelSection apiKey={api_key} />}
+ {Children.count(children) > 0 ? (
+ children
+ ) : (
+ <>
+ <ApiKeyGeneralSection apiKey={api_key} />
+ {isPublishable && <ApiKeySalesChannelSection apiKey={api_key} />}
+ </>
+ )}
</SingleColumnPage>
)
}
+
+export const ApiKeyManagementDetail = Object.assign(Root, {
+ GeneralSection: ApiKeyGeneralSection,
+ SalesChannelSection: ApiKeySalesChannelSection,
+})
diff --git a/packages/admin/src/pages/api-key-management/api-key-management-list/api-key-management-list.tsx b/packages/admin/src/pages/api-key-management/api-key-management-list/api-key-management-list.tsx
index 798144329..7f25706a4 100644
--- a/packages/admin/src/pages/api-key-management/api-key-management-list/api-key-management-list.tsx
+++ b/packages/admin/src/pages/api-key-management/api-key-management-list/api-key-management-list.tsx
@@ -1,20 +1,25 @@
+import { Children, ReactNode } from "react"
import { useLocation } from "react-router-dom"
-import { getApiKeyTypeFromPathname } from "../common/utils"
-import { ApiKeyManagementListTable } from "./components/api-key-management-list-table"
import { SingleColumnPage } from "../../../components/layout/pages"
+import { getApiKeyTypeFromPathname } from "../common/utils"
+import { ApiKeyManagementListTable } from "./components/api-key-management-list-table"
-export const ApiKeyManagementList = () => {
+const Root = ({ children }: { children?: ReactNode }) => {
const { pathname } = useLocation()
-
const keyType = getApiKeyTypeFromPathname(pathname)
return (
- <SingleColumnPage
- hasOutlet
- data-testid="publishable-api-keys-list-page"
- >
- <ApiKeyManagementListTable keyType={keyType} />
+ <SingleColumnPage hasOutlet data-testid="publishable-api-keys-list-page">
+ {Children.count(children) > 0 ? (
+ children
+ ) : (
+ <ApiKeyManagementListTable keyType={keyType} />
+ )}
</SingleColumnPage>
)
}
+
+export const ApiKeyManagementList = Object.assign(Root, {
+ Table: ApiKeyManagementListTable,
+})
diff --git a/packages/admin/src/pages/commission-rates/commission-rate-detail/commission-rate-detail.tsx b/packages/admin/src/pages/commission-rates/commission-rate-detail/commission-rate-detail.tsx
index 2517c83ac..0ac8772fb 100644
--- a/packages/admin/src/pages/commission-rates/commission-rate-detail/commission-rate-detail.tsx
+++ b/packages/admin/src/pages/commission-rates/commission-rate-detail/commission-rate-detail.tsx
@@ -1,37 +1,49 @@
-import { useLoaderData, useParams } from "react-router-dom";
+import { Children, ReactNode } from "react"
+import { useLoaderData, useParams } from "react-router-dom"
-import { SingleColumnPageSkeleton } from "../../../components/common/skeleton";
-import { SingleColumnPage } from "../../../components/layout/pages";
-import { useCommissionRate } from "../../../hooks/api/commission-rates";
-import { CommissionRateGeneralSection } from "./components/commission-rate-general-section";
-import { CommissionRateRulesSection } from "./components/commission-rate-rules-section";
-import { commissionRateLoader } from "./loader";
+import { SingleColumnPageSkeleton } from "../../../components/common/skeleton"
+import { SingleColumnPage } from "../../../components/layout/pages"
+import { useCommissionRate } from "../../../hooks/api/commission-rates"
+import { CommissionRateGeneralSection } from "./components/commission-rate-general-section"
+import { CommissionRateRulesSection } from "./components/commission-rate-rules-section"
+import { commissionRateLoader } from "./loader"
-export const CommissionRateDetail = () => {
+const Root = ({ children }: { children?: ReactNode }) => {
const initialData = useLoaderData() as Awaited<
ReturnType<typeof commissionRateLoader>
- >;
+ >
- const { id } = useParams();
+ const { id } = useParams()
const {
commission_rate,
isPending: isLoading,
isError,
error,
- } = useCommissionRate(id!, { fields: "*rules" }, { initialData });
+ } = useCommissionRate(id!, { fields: "*rules" }, { initialData })
if (isLoading || !commission_rate) {
- return <SingleColumnPageSkeleton sections={2} showJSON showMetadata />;
+ return <SingleColumnPageSkeleton sections={2} showJSON showMetadata />
}
if (isError) {
- throw error;
+ throw error
}
return (
<SingleColumnPage data={commission_rate} showJSON showMetadata>
- <CommissionRateGeneralSection commissionRate={commission_rate} />
- <CommissionRateRulesSection commissionRate={commission_rate} />
+ {Children.count(children) > 0 ? (
+ children
+ ) : (
+ <>
+ <CommissionRateGeneralSection commissionRate={commission_rate} />
+ <CommissionRateRulesSection commissionRate={commission_rate} />
+ </>
+ )}
</SingleColumnPage>
- );
-};
+ )
+}
+
+export const CommissionRateDetail = Object.assign(Root, {
+ GeneralSection: CommissionRateGeneralSection,
+ RulesSection: CommissionRateRulesSection,
+})
diff --git a/packages/admin/src/pages/commission-rates/commission-rate-list/commission-rate-list.tsx b/packages/admin/src/pages/commission-rates/commission-rate-list/commission-rate-list.tsx
index df9bb2fda..c31ee1ce0 100644
--- a/packages/admin/src/pages/commission-rates/commission-rate-list/commission-rate-list.tsx
+++ b/packages/admin/src/pages/commission-rates/commission-rate-list/commission-rate-list.tsx
@@ -1,10 +1,16 @@
+import { Children, ReactNode } from "react"
+
import { SingleColumnPage } from "../../../components/layout/pages"
import { CommissionRateListTable } from "./components/commission-rate-list-table"
-export const CommissionRateList = () => {
+const Root = ({ children }: { children?: ReactNode }) => {
return (
<SingleColumnPage>
- <CommissionRateListTable />
+ {Children.count(children) > 0 ? children : <CommissionRateListTable />}
</SingleColumnPage>
)
}
+
+export const CommissionRateList = Object.assign(Root, {
+ Table: CommissionRateListTable,
+})
diff --git a/packages/admin/src/pages/locations/location-detail/location-detail.tsx b/packages/admin/src/pages/locations/location-detail/location-detail.tsx
index fd6744af1..5f1f16f7e 100644
--- a/packages/admin/src/pages/locations/location-detail/location-detail.tsx
+++ b/packages/admin/src/pages/locations/location-detail/location-detail.tsx
@@ -1,3 +1,4 @@
+import { Children, ReactNode } from "react";
import { useLoaderData, useParams } from "react-router-dom";
import { useStockLocation } from "../../../hooks/api/stock-locations";
@@ -10,7 +11,7 @@ import { TwoColumnPage } from "../../../components/layout/pages";
import LocationsFulfillmentProvidersSection from "./components/location-fulfillment-providers-section/location-fulfillment-providers-section";
import { LOCATION_DETAILS_FIELD } from "./constants";
-export const LocationDetail = () => {
+const Root = ({ children }: { children?: ReactNode }) => {
const initialData = useLoaderData() as Awaited<
ReturnType<typeof locationLoader>
>;
@@ -44,13 +45,27 @@ export const LocationDetail = () => {
hasOutlet
data-testid="location-detail-page"
>
- <TwoColumnPage.Main data-testid="location-detail-main">
- <LocationGeneralSection location={location} />
- </TwoColumnPage.Main>
- <TwoColumnPage.Sidebar data-testid="location-detail-sidebar">
- <LocationsSalesChannelsSection location={location} />
- <LocationsFulfillmentProvidersSection location={location} />
- </TwoColumnPage.Sidebar>
+ {Children.count(children) > 0 ? (
+ children
+ ) : (
+ <>
+ <TwoColumnPage.Main data-testid="location-detail-main">
+ <LocationGeneralSection location={location} />
+ </TwoColumnPage.Main>
+ <TwoColumnPage.Sidebar data-testid="location-detail-sidebar">
+ <LocationsSalesChannelsSection location={location} />
+ <LocationsFulfillmentProvidersSection location={location} />
+ </TwoColumnPage.Sidebar>
+ </>
+ )}
</TwoColumnPage>
);
};
+
+export const LocationDetail = Object.assign(Root, {
+ Main: TwoColumnPage.Main,
+ Sidebar: TwoColumnPage.Sidebar,
+ MainGeneralSection: LocationGeneralSection,
+ SidebarSalesChannelsSection: LocationsSalesChannelsSection,
+ SidebarFulfillmentProvidersSection: LocationsFulfillmentProvidersSection,
+});
diff --git a/packages/admin/src/pages/locations/location-list/location-list.tsx b/packages/admin/src/pages/locations/location-list/location-list.tsx
index d654a7be2..df1ed9299 100644
--- a/packages/admin/src/pages/locations/location-list/location-list.tsx
+++ b/packages/admin/src/pages/locations/location-list/location-list.tsx
@@ -1,3 +1,4 @@
+import { Children, ReactNode } from "react";
import { ShoppingBag, TruckFast } from "@medusajs/icons";
import { Container, Heading } from "@medusajs/ui";
import { useTranslation } from "react-i18next";
@@ -15,7 +16,7 @@ import { keepPreviousData } from "@tanstack/react-query";
const PAGE_SIZE = 20;
const PREFIX = "loc";
-export function LocationList() {
+const LocationListMain = () => {
const { t } = useTranslation();
const searchParams = useLocationListTableQuery({
@@ -46,51 +47,44 @@ export function LocationList() {
}
return (
- <TwoColumnPage showJSON>
- <TwoColumnPage.Main>
- <Container
- className="flex flex-col divide-y p-0"
- data-testid="location-list-container"
- >
- <DataTable
- data={stockLocations}
- columns={columns}
- rowCount={count}
- pageSize={PAGE_SIZE}
- getRowId={(row) => row.id}
- heading={t("stockLocations.domain")}
- subHeading={t("stockLocations.list.description")}
- emptyState={{
- empty: {
- heading: t("stockLocations.list.noRecordsMessage"),
- description: t("stockLocations.list.noRecordsMessageEmpty"),
- },
- filtered: {
- heading: t("stockLocations.list.noRecordsMessage"),
- description: t("stockLocations.list.noRecordsMessageFiltered"),
- },
- }}
- actions={[
- {
- label: t("actions.create"),
- to: "create",
- },
- ]}
- isLoading={isLoading}
- rowHref={(row) => `/settings/locations/${row.id}`}
- enableSearch={true}
- prefix={PREFIX}
- layout="fill"
- data-testid="location-list-table"
- />
- </Container>
- </TwoColumnPage.Main>
- <TwoColumnPage.Sidebar>
- <LinksSection />
- </TwoColumnPage.Sidebar>
- </TwoColumnPage>
+ <Container
+ className="flex flex-col divide-y p-0"
+ data-testid="location-list-container"
+ >
+ <DataTable
+ data={stockLocations}
+ columns={columns}
+ rowCount={count}
+ pageSize={PAGE_SIZE}
+ getRowId={(row) => row.id}
+ heading={t("stockLocations.domain")}
+ subHeading={t("stockLocations.list.description")}
+ emptyState={{
+ empty: {
+ heading: t("stockLocations.list.noRecordsMessage"),
+ description: t("stockLocations.list.noRecordsMessageEmpty"),
+ },
+ filtered: {
+ heading: t("stockLocations.list.noRecordsMessage"),
+ description: t("stockLocations.list.noRecordsMessageFiltered"),
+ },
+ }}
+ actions={[
+ {
+ label: t("actions.create"),
+ to: "create",
+ },
+ ]}
+ isLoading={isLoading}
+ rowHref={(row) => `/settings/locations/${row.id}`}
+ enableSearch={true}
+ prefix={PREFIX}
+ layout="fill"
+ data-testid="location-list-table"
+ />
+ </Container>
);
-}
+};
const LinksSection = () => {
const { t } = useTranslation();
@@ -127,3 +121,29 @@ const LinksSection = () => {
</Container>
);
};
+
+const Root = ({ children }: { children?: ReactNode }) => {
+ return (
+ <TwoColumnPage showJSON>
+ {Children.count(children) > 0 ? (
+ children
+ ) : (
+ <>
+ <TwoColumnPage.Main>
+ <LocationListMain />
+ </TwoColumnPage.Main>
+ <TwoColumnPage.Sidebar>
+ <LinksSection />
+ </TwoColumnPage.Sidebar>
+ </>
+ )}
+ </TwoColumnPage>
+ );
+};
+
+export const LocationList = Object.assign(Root, {
+ Main: TwoColumnPage.Main,
+ Sidebar: TwoColumnPage.Sidebar,
+ MainContent: LocationListMain,
+ SidebarLinks: LinksSection,
+});
diff --git a/packages/admin/src/pages/product-tags/product-tag-detail/product-tag-detail.tsx b/packages/admin/src/pages/product-tags/product-tag-detail/product-tag-detail.tsx
index 8ad880e14..c0326f7d7 100644
--- a/packages/admin/src/pages/product-tags/product-tag-detail/product-tag-detail.tsx
+++ b/packages/admin/src/pages/product-tags/product-tag-detail/product-tag-detail.tsx
@@ -1,3 +1,4 @@
+import { Children, ReactNode } from "react"
import { useLoaderData, useParams } from "react-router-dom"
import { SingleColumnPageSkeleton } from "../../../components/common/skeleton"
@@ -8,7 +9,7 @@ import { ProductTagGeneralSection } from "./components/product-tag-general-secti
import { ProductTagProductSection } from "./components/product-tag-product-section"
import { productTagLoader } from "./loader"
-export const ProductTagDetail = () => {
+const Root = ({ children }: { children?: ReactNode }) => {
const { id } = useParams()
const initialData = useLoaderData() as Awaited<
@@ -32,13 +33,20 @@ export const ProductTagDetail = () => {
}
return (
- <SingleColumnPage
- showJSON
- showMetadata
- data={product_tag}
- >
- <ProductTagGeneralSection productTag={product_tag} />
- <ProductTagProductSection productTag={product_tag} />
+ <SingleColumnPage showJSON showMetadata data={product_tag}>
+ {Children.count(children) > 0 ? (
+ children
+ ) : (
+ <>
+ <ProductTagGeneralSection productTag={product_tag} />
+ <ProductTagProductSection productTag={product_tag} />
+ </>
+ )}
</SingleColumnPage>
)
}
+
+export const ProductTagDetail = Object.assign(Root, {
+ GeneralSection: ProductTagGeneralSection,
+ ProductSection: ProductTagProductSection,
+})
diff --git a/packages/admin/src/pages/product-tags/product-tag-list/product-tag-list.tsx b/packages/admin/src/pages/product-tags/product-tag-list/product-tag-list.tsx
index 2ce4380ab..9433eae7b 100644
--- a/packages/admin/src/pages/product-tags/product-tag-list/product-tag-list.tsx
+++ b/packages/admin/src/pages/product-tags/product-tag-list/product-tag-list.tsx
@@ -1,14 +1,16 @@
+import { Children, ReactNode } from "react"
+
import { SingleColumnPage } from "../../../components/layout/pages"
import { ProductTagListTable } from "./components/product-tag-list-table"
-export const ProductTagList = () => {
+const Root = ({ children }: { children?: ReactNode }) => {
return (
- <SingleColumnPage
- showMetadata={false}
- showJSON={false}
- hasOutlet
- >
- <ProductTagListTable />
+ <SingleColumnPage showMetadata={false} showJSON={false} hasOutlet>
+ {Children.count(children) > 0 ? children : <ProductTagListTable />}
</SingleColumnPage>
)
}
+
+export const ProductTagList = Object.assign(Root, {
+ Table: ProductTagListTable,
+})
diff --git a/packages/admin/src/pages/product-types/product-type-detail/product-type-detail.tsx b/packages/admin/src/pages/product-types/product-type-detail/product-type-detail.tsx
index 52c302ea6..582375be5 100644
--- a/packages/admin/src/pages/product-types/product-type-detail/product-type-detail.tsx
+++ b/packages/admin/src/pages/product-types/product-type-detail/product-type-detail.tsx
@@ -1,3 +1,4 @@
+import { Children, ReactNode } from "react"
import { useLoaderData, useParams } from "react-router-dom"
import { SingleColumnPageSkeleton } from "../../../components/common/skeleton"
@@ -8,7 +9,7 @@ import { ProductTypeGeneralSection } from "./components/product-type-general-sec
import { ProductTypeProductSection } from "./components/product-type-product-section"
import { productTypeLoader } from "./loader"
-export const ProductTypeDetail = () => {
+const Root = ({ children }: { children?: ReactNode }) => {
const { id } = useParams()
const initialData = useLoaderData() as Awaited<
ReturnType<typeof productTypeLoader>
@@ -31,13 +32,20 @@ export const ProductTypeDetail = () => {
}
return (
- <SingleColumnPage
- showJSON
- showMetadata
- data={product_type}
- >
- <ProductTypeGeneralSection productType={product_type} />
- <ProductTypeProductSection productType={product_type} />
+ <SingleColumnPage showJSON showMetadata data={product_type}>
+ {Children.count(children) > 0 ? (
+ children
+ ) : (
+ <>
+ <ProductTypeGeneralSection productType={product_type} />
+ <ProductTypeProductSection productType={product_type} />
+ </>
+ )}
</SingleColumnPage>
)
}
+
+export const ProductTypeDetail = Object.assign(Root, {
+ GeneralSection: ProductTypeGeneralSection,
+ ProductSection: ProductTypeProductSection,
+})
diff --git a/packages/admin/src/pages/product-types/product-type-list/product-type-list.tsx b/packages/admin/src/pages/product-types/product-type-list/product-type-list.tsx
index 731c68b5a..7a3f85a28 100644
--- a/packages/admin/src/pages/product-types/product-type-list/product-type-list.tsx
+++ b/packages/admin/src/pages/product-types/product-type-list/product-type-list.tsx
@@ -1,10 +1,16 @@
+import { Children, ReactNode } from "react"
+
import { SingleColumnPage } from "../../../components/layout/pages"
import { ProductTypeListTable } from "./components/product-type-list-table"
-export const ProductTypeList = () => {
+const Root = ({ children }: { children?: ReactNode }) => {
return (
<SingleColumnPage>
- <ProductTypeListTable />
+ {Children.count(children) > 0 ? children : <ProductTypeListTable />}
</SingleColumnPage>
)
}
+
+export const ProductTypeList = Object.assign(Root, {
+ Table: ProductTypeListTable,
+})
diff --git a/packages/admin/src/pages/profile/profile-detail/profile-detail.tsx b/packages/admin/src/pages/profile/profile-detail/profile-detail.tsx
index b06deb27e..f6af15223 100644
--- a/packages/admin/src/pages/profile/profile-detail/profile-detail.tsx
+++ b/packages/admin/src/pages/profile/profile-detail/profile-detail.tsx
@@ -1,10 +1,12 @@
+import { Children, ReactNode } from "react"
+
import { useMe } from "../../../hooks/api/users"
import { ProfileGeneralSection } from "./components/profile-general-section"
import { SingleColumnPageSkeleton } from "../../../components/common/skeleton"
import { SingleColumnPage } from "../../../components/layout/pages"
-export const ProfileDetail = () => {
+const Root = ({ children }: { children?: ReactNode }) => {
const { user, isPending: isLoading, isError, error } = useMe()
if (isLoading || !user) {
@@ -16,10 +18,14 @@ export const ProfileDetail = () => {
}
return (
- <SingleColumnPage
- data-testid="profile-detail-page"
- >
- <ProfileGeneralSection user={user} />
+ <SingleColumnPage data-testid="profile-detail-page">
+ {Children.count(children) > 0 ? children : (
+ <ProfileGeneralSection user={user} />
+ )}
</SingleColumnPage>
)
}
+
+export const ProfileDetail = Object.assign(Root, {
+ GeneralSection: ProfileGeneralSection,
+})
diff --git a/packages/admin/src/pages/shipping-option-types/shipping-option-type-detail/shipping-option-type-detail.tsx b/packages/admin/src/pages/shipping-option-types/shipping-option-type-detail/shipping-option-type-detail.tsx
index fb721f7d7..865de6213 100644
--- a/packages/admin/src/pages/shipping-option-types/shipping-option-type-detail/shipping-option-type-detail.tsx
+++ b/packages/admin/src/pages/shipping-option-types/shipping-option-type-detail/shipping-option-type-detail.tsx
@@ -1,3 +1,4 @@
+import { Children, ReactNode } from "react"
import { useLoaderData, useParams } from "react-router-dom"
import { SingleColumnPageSkeleton } from "../../../components/common/skeleton"
@@ -6,7 +7,7 @@ import { useShippingOptionType } from "../../../hooks/api"
import { ShippingOptionTypeGeneralSection } from "./components/shipping-option-type-general-section"
import { shippingOptionTypeLoader } from "./loader"
-export const ShippingOptionTypeDetail = () => {
+const Root = ({ children }: { children?: ReactNode }) => {
const { id } = useParams()
const initialData = useLoaderData() as Awaited<
ReturnType<typeof shippingOptionTypeLoader>
@@ -26,14 +27,18 @@ export const ShippingOptionTypeDetail = () => {
}
return (
- <SingleColumnPage
- showJSON
- showMetadata
- data={shipping_option_type}
- >
- <ShippingOptionTypeGeneralSection
- shippingOptionType={shipping_option_type}
- />
+ <SingleColumnPage showJSON showMetadata data={shipping_option_type}>
+ {Children.count(children) > 0 ? (
+ children
+ ) : (
+ <ShippingOptionTypeGeneralSection
+ shippingOptionType={shipping_option_type}
+ />
+ )}
</SingleColumnPage>
)
}
+
+export const ShippingOptionTypeDetail = Object.assign(Root, {
+ GeneralSection: ShippingOptionTypeGeneralSection,
+})
diff --git a/packages/admin/src/pages/shipping-option-types/shipping-option-type-list/shipping-option-type-list.tsx b/packages/admin/src/pages/shipping-option-types/shipping-option-type-list/shipping-option-type-list.tsx
index bec697fcb..603210388 100644
--- a/packages/admin/src/pages/shipping-option-types/shipping-option-type-list/shipping-option-type-list.tsx
+++ b/packages/admin/src/pages/shipping-option-types/shipping-option-type-list/shipping-option-type-list.tsx
@@ -1,10 +1,20 @@
+import { Children, ReactNode } from "react"
+
import { SingleColumnPage } from "../../../components/layout/pages"
import { ShippingOptionTypeListTable } from "./components/shipping-option-type-list-table"
-export const ShippingOptionTypeList = () => {
+const Root = ({ children }: { children?: ReactNode }) => {
return (
<SingleColumnPage>
- <ShippingOptionTypeListTable />
+ {Children.count(children) > 0 ? (
+ children
+ ) : (
+ <ShippingOptionTypeListTable />
+ )}
</SingleColumnPage>
)
}
+
+export const ShippingOptionTypeList = Object.assign(Root, {
+ Table: ShippingOptionTypeListTable,
+})
diff --git a/packages/admin/src/pages/shipping-profiles/shipping-profile-detail/shipping-profile-detail.tsx b/packages/admin/src/pages/shipping-profiles/shipping-profile-detail/shipping-profile-detail.tsx
index e065c2934..c21496619 100644
--- a/packages/admin/src/pages/shipping-profiles/shipping-profile-detail/shipping-profile-detail.tsx
+++ b/packages/admin/src/pages/shipping-profiles/shipping-profile-detail/shipping-profile-detail.tsx
@@ -1,3 +1,4 @@
+import { Children, ReactNode } from "react"
import { useLoaderData, useParams } from "react-router-dom"
import { SingleColumnPageSkeleton } from "../../../components/common/skeleton"
@@ -7,7 +8,7 @@ import { ShippingProfileGeneralSection } from "./components/shipping-profile-gen
import { SingleColumnPage } from "../../../components/layout/pages"
import { shippingProfileLoader } from "./loader"
-export const ShippingProfileDetail = () => {
+const Root = ({ children }: { children?: ReactNode }) => {
const { shipping_profile_id } = useParams()
const initialData = useLoaderData() as Awaited<
@@ -29,12 +30,16 @@ export const ShippingProfileDetail = () => {
}
return (
- <SingleColumnPage
- showMetadata
- showJSON
- data={shipping_profile}
- >
- <ShippingProfileGeneralSection profile={shipping_profile} />
+ <SingleColumnPage showMetadata showJSON data={shipping_profile}>
+ {Children.count(children) > 0 ? (
+ children
+ ) : (
+ <ShippingProfileGeneralSection profile={shipping_profile} />
+ )}
</SingleColumnPage>
)
}
+
+export const ShippingProfileDetail = Object.assign(Root, {
+ GeneralSection: ShippingProfileGeneralSection,
+})
diff --git a/packages/admin/src/pages/shipping-profiles/shipping-profiles-list/shipping-profile-list.tsx b/packages/admin/src/pages/shipping-profiles/shipping-profiles-list/shipping-profile-list.tsx
index e04f768d2..5ee350328 100644
--- a/packages/admin/src/pages/shipping-profiles/shipping-profiles-list/shipping-profile-list.tsx
+++ b/packages/admin/src/pages/shipping-profiles/shipping-profiles-list/shipping-profile-list.tsx
@@ -1,10 +1,20 @@
+import { Children, ReactNode } from "react"
+
import { SingleColumnPage } from "../../../components/layout/pages"
import { ShippingProfileListTable } from "./components/shipping-profile-list-table"
-export const ShippingProfileList = () => {
+const Root = ({ children }: { children?: ReactNode }) => {
return (
<SingleColumnPage>
- <ShippingProfileListTable />
+ {Children.count(children) > 0 ? (
+ children
+ ) : (
+ <ShippingProfileListTable />
+ )}
</SingleColumnPage>
)
}
+
+export const ShippingProfileList = Object.assign(Root, {
+ Table: ShippingProfileListTable,
+})
diff --git a/packages/admin/src/pages/tax-regions/tax-region-province-detail/tax-region-detail.tsx b/packages/admin/src/pages/tax-regions/tax-region-province-detail/tax-region-detail.tsx
index d7c835774..8296173c5 100644
--- a/packages/admin/src/pages/tax-regions/tax-region-province-detail/tax-region-detail.tsx
+++ b/packages/admin/src/pages/tax-regions/tax-region-province-detail/tax-region-detail.tsx
@@ -1,3 +1,4 @@
+import { Children, ReactNode } from "react"
import { useLoaderData, useParams } from "react-router-dom"
import { SingleColumnPage } from "../../../components/layout/pages"
@@ -8,7 +9,7 @@ import { SingleColumnPageSkeleton } from "../../../components/common/skeleton"
import { TaxRegionProvinceOverrideSection } from "./components/tax-region-province-override-section"
import { taxRegionLoader } from "./loader"
-export const TaxRegionDetail = () => {
+const Root = ({ children }: { children?: ReactNode }) => {
const { province_id } = useParams()
const initialData = useLoaderData() as Awaited<
@@ -31,12 +32,20 @@ export const TaxRegionDetail = () => {
}
return (
- <SingleColumnPage
- data={taxRegion}
- showJSON
- >
- <TaxRegionProvinceDetailSection taxRegion={taxRegion} />
- <TaxRegionProvinceOverrideSection taxRegion={taxRegion} />
+ <SingleColumnPage data={taxRegion} showJSON>
+ {Children.count(children) > 0 ? (
+ children
+ ) : (
+ <>
+ <TaxRegionProvinceDetailSection taxRegion={taxRegion} />
+ <TaxRegionProvinceOverrideSection taxRegion={taxRegion} />
+ </>
+ )}
</SingleColumnPage>
)
}
+
+export const TaxRegionDetail = Object.assign(Root, {
+ DetailSection: TaxRegionProvinceDetailSection,
+ OverrideSection: TaxRegionProvinceOverrideSection,
+})