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 remaining list and detail pages

vholike38f811ab79f
diff --git a/packages/admin/src/pages/campaigns/campaign-detail/campaign-detail.tsx b/packages/admin/src/pages/campaigns/campaign-detail/campaign-detail.tsx
index df59c48bb..076d76f56 100644
--- a/packages/admin/src/pages/campaigns/campaign-detail/campaign-detail.tsx
+++ b/packages/admin/src/pages/campaigns/campaign-detail/campaign-detail.tsx
@@ -1,28 +1,28 @@
-import { useLoaderData, useParams } from "react-router-dom";
+import { Children, ReactNode } from "react"
+import { useLoaderData, useParams } from "react-router-dom"
-import { useCampaign } from "../../../hooks/api/campaigns";
-import { CampaignBudget } from "./components/campaign-budget";
-import { CampaignGeneralSection } from "./components/campaign-general-section";
-import { CampaignPromotionSection } from "./components/campaign-promotion-section";
-import { CampaignSpend } from "./components/campaign-spend";
-import { campaignLoader } from "./loader";
+import { TwoColumnPageSkeleton } from "../../../components/common/skeleton"
+import { TwoColumnPage } from "../../../components/layout/pages"
+import { useCampaign } from "../../../hooks/api/campaigns"
+import { CampaignBudget } from "./components/campaign-budget"
+import { CampaignConfigurationSection } from "./components/campaign-configuration-section"
+import { CampaignGeneralSection } from "./components/campaign-general-section"
+import { CampaignPromotionSection } from "./components/campaign-promotion-section"
+import { CampaignSpend } from "./components/campaign-spend"
+import { campaignLoader } from "./loader"
+import { CAMPAIGN_DETAIL_FIELDS } from "./constants"
-import { TwoColumnPageSkeleton } from "../../../components/common/skeleton";
-import { TwoColumnPage } from "../../../components/layout/pages";
-import { CampaignConfigurationSection } from "./components/campaign-configuration-section";
-import { CAMPAIGN_DETAIL_FIELDS } from "./constants";
-
-export const CampaignDetail = () => {
+const Root = ({ children }: { children?: ReactNode }) => {
const initialData = useLoaderData() as Awaited<
ReturnType<typeof campaignLoader>
- >;
+ >
- const { id } = useParams();
+ const { id } = useParams()
const { campaign, isLoading, isError, error } = useCampaign(
id!,
{ fields: CAMPAIGN_DETAIL_FIELDS },
- { initialData },
- );
+ { initialData }
+ )
if (isLoading || !campaign) {
return (
@@ -32,24 +32,40 @@ export const CampaignDetail = () => {
showJSON
showMetadata
/>
- );
+ )
}
if (isError) {
- throw error;
+ throw error
}
return (
- <TwoColumnPage hasOutlet showJSON showMetadata data={campaign}>
- <TwoColumnPage.Main>
- <CampaignGeneralSection campaign={campaign} />
- <CampaignPromotionSection campaign={campaign} />
- </TwoColumnPage.Main>
- <TwoColumnPage.Sidebar>
- <CampaignConfigurationSection campaign={campaign} />
- <CampaignSpend campaign={campaign} />
- <CampaignBudget campaign={campaign} />
- </TwoColumnPage.Sidebar>
- </TwoColumnPage>
- );
-};
+ <>
+ {Children.count(children) > 0 ? (
+ children
+ ) : (
+ <TwoColumnPage hasOutlet showJSON showMetadata data={campaign}>
+ <TwoColumnPage.Main>
+ <CampaignGeneralSection campaign={campaign} />
+ <CampaignPromotionSection campaign={campaign} />
+ </TwoColumnPage.Main>
+ <TwoColumnPage.Sidebar>
+ <CampaignConfigurationSection campaign={campaign} />
+ <CampaignSpend campaign={campaign} />
+ <CampaignBudget campaign={campaign} />
+ </TwoColumnPage.Sidebar>
+ </TwoColumnPage>
+ )}
+ </>
+ )
+}
+
+export const CampaignDetail = Object.assign(Root, {
+ Main: TwoColumnPage.Main,
+ Sidebar: TwoColumnPage.Sidebar,
+ MainGeneralSection: CampaignGeneralSection,
+ MainPromotionSection: CampaignPromotionSection,
+ SidebarConfigurationSection: CampaignConfigurationSection,
+ SidebarSpendSection: CampaignSpend,
+ SidebarBudgetSection: CampaignBudget,
+})
diff --git a/packages/admin/src/pages/campaigns/campaign-list/campaign-list.tsx b/packages/admin/src/pages/campaigns/campaign-list/campaign-list.tsx
index 0890d3aa6..b1b931212 100644
--- a/packages/admin/src/pages/campaigns/campaign-list/campaign-list.tsx
+++ b/packages/admin/src/pages/campaigns/campaign-list/campaign-list.tsx
@@ -1,12 +1,16 @@
+import { Children, ReactNode } from "react"
+
import { SingleColumnPage } from "../../../components/layout/pages"
import { CampaignListTable } from "./components/campaign-list-table"
-export const CampaignList = () => {
+const Root = ({ children }: { children?: ReactNode }) => {
return (
- <SingleColumnPage
- hasOutlet
- >
- <CampaignListTable />
+ <SingleColumnPage hasOutlet>
+ {Children.count(children) > 0 ? children : <CampaignListTable />}
</SingleColumnPage>
)
}
+
+export const CampaignList = Object.assign(Root, {
+ Table: CampaignListTable,
+})
diff --git a/packages/admin/src/pages/inventory/inventory-detail/inventory-detail.tsx b/packages/admin/src/pages/inventory/inventory-detail/inventory-detail.tsx
index 4d2ef6108..c64c36f1f 100644
--- a/packages/admin/src/pages/inventory/inventory-detail/inventory-detail.tsx
+++ b/packages/admin/src/pages/inventory/inventory-detail/inventory-detail.tsx
@@ -1,18 +1,21 @@
+import { Children, ReactNode } from "react"
import { useLoaderData, useParams } from "react-router-dom"
-import { INVENTORY_DETAIL_FIELDS } from "./constants"
-import type { inventoryItemLoader } from "./loader"
-import { useInventoryItem } from "@hooks/api"
+
import { TwoColumnPageSkeleton } from "@components/common/skeleton"
import { TwoColumnPage } from "@components/layout/pages"
+import { useInventoryItem } from "@hooks/api"
+
+import { InventoryItemAttributeSection } from "./components/inventory-item-attributes/attributes-section"
import { InventoryItemGeneralSection } from "./components/inventory-item-general-section"
import { InventoryItemLocationLevelsSection } from "./components/inventory-item-location-levels"
import { InventoryItemReservationsSection } from "./components/inventory-item-reservations"
import { InventoryItemVariantsSection } from "./components/inventory-item-variants/variants-section"
-import { InventoryItemAttributeSection } from "./components/inventory-item-attributes/attributes-section"
+import { INVENTORY_DETAIL_FIELDS } from "./constants"
-export const InventoryDetail = () => {
- const { id } = useParams()
+import type { inventoryItemLoader } from "./loader"
+const Root = ({ children }: { children?: ReactNode }) => {
+ const { id } = useParams()
const initialData = useLoaderData() as Awaited<
ReturnType<typeof inventoryItemLoader>
>
@@ -49,25 +52,38 @@ export const InventoryDetail = () => {
return (
<div data-testid="inventory-detail-page">
- <TwoColumnPage
- data={inventory_item}
- showJSON
- showMetadata
- >
- <TwoColumnPage.Main data-testid="inventory-detail-main">
- <InventoryItemGeneralSection inventoryItem={inventory_item} />
- <InventoryItemLocationLevelsSection inventoryItem={inventory_item} />
- <InventoryItemReservationsSection inventoryItem={inventory_item} />
- </TwoColumnPage.Main>
- <TwoColumnPage.Sidebar data-testid="inventory-detail-sidebar">
- {inventory_item.variants && inventory_item.variants?.length > 0 && (
- <InventoryItemVariantsSection
- variants={inventory_item.variants}
+ {Children.count(children) > 0 ? (
+ children
+ ) : (
+ <TwoColumnPage data={inventory_item} showJSON showMetadata>
+ <TwoColumnPage.Main data-testid="inventory-detail-main">
+ <InventoryItemGeneralSection inventoryItem={inventory_item} />
+ <InventoryItemLocationLevelsSection
+ inventoryItem={inventory_item}
/>
- )}
- <InventoryItemAttributeSection inventoryItem={inventory_item} />
- </TwoColumnPage.Sidebar>
- </TwoColumnPage>
+ <InventoryItemReservationsSection inventoryItem={inventory_item} />
+ </TwoColumnPage.Main>
+ <TwoColumnPage.Sidebar data-testid="inventory-detail-sidebar">
+ {inventory_item.variants &&
+ inventory_item.variants?.length > 0 && (
+ <InventoryItemVariantsSection
+ variants={inventory_item.variants}
+ />
+ )}
+ <InventoryItemAttributeSection inventoryItem={inventory_item} />
+ </TwoColumnPage.Sidebar>
+ </TwoColumnPage>
+ )}
</div>
)
}
+
+export const InventoryDetail = Object.assign(Root, {
+ Main: TwoColumnPage.Main,
+ Sidebar: TwoColumnPage.Sidebar,
+ MainGeneralSection: InventoryItemGeneralSection,
+ MainLocationLevelsSection: InventoryItemLocationLevelsSection,
+ MainReservationsSection: InventoryItemReservationsSection,
+ SidebarVariantsSection: InventoryItemVariantsSection,
+ SidebarAttributeSection: InventoryItemAttributeSection,
+})
diff --git a/packages/admin/src/pages/inventory/inventory-list/inventory-list.tsx b/packages/admin/src/pages/inventory/inventory-list/inventory-list.tsx
index 9973f5627..cd699f277 100644
--- a/packages/admin/src/pages/inventory/inventory-list/inventory-list.tsx
+++ b/packages/admin/src/pages/inventory/inventory-list/inventory-list.tsx
@@ -1,12 +1,18 @@
+import { Children, ReactNode } from "react"
+
import { SingleColumnPage } from "../../../components/layout/pages"
import { InventoryListTable } from "./components/inventory-list-table"
-export const InventoryItemListTable = () => {
+const Root = ({ children }: { children?: ReactNode }) => {
return (
<div data-testid="inventory-page">
<SingleColumnPage>
- <InventoryListTable />
+ {Children.count(children) > 0 ? children : <InventoryListTable />}
</SingleColumnPage>
</div>
)
}
+
+export const InventoryItemListTable = Object.assign(Root, {
+ Table: InventoryListTable,
+})
diff --git a/packages/admin/src/pages/marketplace/marketplace-detail/marketplace-detail.tsx b/packages/admin/src/pages/marketplace/marketplace-detail/marketplace-detail.tsx
index cd3817889..1392e320b 100644
--- a/packages/admin/src/pages/marketplace/marketplace-detail/marketplace-detail.tsx
+++ b/packages/admin/src/pages/marketplace/marketplace-detail/marketplace-detail.tsx
@@ -1,14 +1,14 @@
+import { Children, ReactNode } from "react"
import { useLoaderData } from "react-router-dom"
-import { useStore } from "../../../hooks/api/store"
-import { MarketplaceGeneralSection } from "./components/marketplace-general-section"
-import { storeLoader } from "./loader"
-
import { SingleColumnPageSkeleton } from "../../../components/common/skeleton"
import { SingleColumnPage } from "../../../components/layout/pages"
+import { useStore } from "../../../hooks/api/store"
import { MarketplaceCurrencySection } from "./components/marketplace-currency-section"
+import { MarketplaceGeneralSection } from "./components/marketplace-general-section"
+import { storeLoader } from "./loader"
-export const MarketplaceDetail = () => {
+const Root = ({ children }: { children?: ReactNode }) => {
const initialData = useLoaderData() as Awaited<ReturnType<typeof storeLoader>>
const { store, isPending, isError, error } = useStore(undefined, {
@@ -24,14 +24,20 @@ export const MarketplaceDetail = () => {
}
return (
- <SingleColumnPage
- data={store}
- hasOutlet
- showMetadata
- showJSON
- >
- <MarketplaceGeneralSection store={store} />
- <MarketplaceCurrencySection store={store} />
+ <SingleColumnPage data={store} hasOutlet showMetadata showJSON>
+ {Children.count(children) > 0 ? (
+ children
+ ) : (
+ <>
+ <MarketplaceGeneralSection store={store} />
+ <MarketplaceCurrencySection store={store} />
+ </>
+ )}
</SingleColumnPage>
)
}
+
+export const MarketplaceDetail = Object.assign(Root, {
+ GeneralSection: MarketplaceGeneralSection,
+ CurrencySection: MarketplaceCurrencySection,
+})
diff --git a/packages/admin/src/pages/payouts/payout-detail/payout-detail.tsx b/packages/admin/src/pages/payouts/payout-detail/payout-detail.tsx
index e33044d7b..ab49848e8 100644
--- a/packages/admin/src/pages/payouts/payout-detail/payout-detail.tsx
+++ b/packages/admin/src/pages/payouts/payout-detail/payout-detail.tsx
@@ -1,3 +1,4 @@
+import { Children, ReactNode } from "react"
import { useParams } from "react-router-dom"
import { SingleColumnPageSkeleton } from "../../../components/common/skeleton"
@@ -5,7 +6,7 @@ import { SingleColumnPage } from "../../../components/layout/pages"
import { usePayout } from "../../../hooks/api/payouts"
import { PayoutGeneralSection } from "./components/payout-general-section"
-export const PayoutDetail = () => {
+const Root = ({ children }: { children?: ReactNode }) => {
const { id } = useParams()
const { payout, isLoading, isError, error } = usePayout(id!)
@@ -20,7 +21,15 @@ export const PayoutDetail = () => {
return (
<SingleColumnPage data={payout} showJSON showMetadata>
- <PayoutGeneralSection payout={payout} />
+ {Children.count(children) > 0 ? (
+ children
+ ) : (
+ <PayoutGeneralSection payout={payout} />
+ )}
</SingleColumnPage>
)
}
+
+export const PayoutDetail = Object.assign(Root, {
+ GeneralSection: PayoutGeneralSection,
+})
diff --git a/packages/admin/src/pages/payouts/payout-list/payout-list.tsx b/packages/admin/src/pages/payouts/payout-list/payout-list.tsx
index 15e70dafe..70dc6f247 100644
--- a/packages/admin/src/pages/payouts/payout-list/payout-list.tsx
+++ b/packages/admin/src/pages/payouts/payout-list/payout-list.tsx
@@ -1,3 +1,4 @@
+import { Children, ReactNode } from "react"
import { Container, Heading } from "@medusajs/ui"
import { keepPreviousData } from "@tanstack/react-query"
import { useTranslation } from "react-i18next"
@@ -10,7 +11,7 @@ import { useDataTable } from "../../../hooks/use-data-table"
const PAGE_SIZE = 10
-export const PayoutList = () => {
+const PayoutListTable = () => {
const { t } = useTranslation()
const { searchParams, raw } = usePayoutTableQuery({
@@ -64,3 +65,15 @@ export const PayoutList = () => {
</Container>
)
}
+
+const Root = ({ children }: { children?: ReactNode }) => {
+ return (
+ <>
+ {Children.count(children) > 0 ? children : <PayoutListTable />}
+ </>
+ )
+}
+
+export const PayoutList = Object.assign(Root, {
+ Table: PayoutListTable,
+})
diff --git a/packages/admin/src/pages/promotions/promotion-detail/promotion-detail.tsx b/packages/admin/src/pages/promotions/promotion-detail/promotion-detail.tsx
index 5cac7b9c6..4c7f1271f 100644
--- a/packages/admin/src/pages/promotions/promotion-detail/promotion-detail.tsx
+++ b/packages/admin/src/pages/promotions/promotion-detail/promotion-detail.tsx
@@ -1,59 +1,77 @@
-import { useLoaderData, useParams } from "react-router-dom";
+import { Children, ReactNode } from "react"
+import { useLoaderData, useParams } from "react-router-dom"
-import { TwoColumnPageSkeleton } from "../../../components/common/skeleton";
-import { TwoColumnPage } from "../../../components/layout/pages";
-import { usePromotion, usePromotionRules } from "../../../hooks/api/promotions";
-import { CampaignSection } from "./components/campaign-section";
-import { PromotionConditionsSection } from "./components/promotion-conditions-section";
-import { PromotionGeneralSection } from "./components/promotion-general-section";
-import { promotionLoader } from "./loader";
+import { TwoColumnPageSkeleton } from "../../../components/common/skeleton"
+import { TwoColumnPage } from "../../../components/layout/pages"
+import { usePromotion, usePromotionRules } from "../../../hooks/api/promotions"
+import { CampaignSection } from "./components/campaign-section"
+import { PromotionConditionsSection } from "./components/promotion-conditions-section"
+import { PromotionGeneralSection } from "./components/promotion-general-section"
+import { promotionLoader } from "./loader"
-export const PromotionDetail = () => {
+const Root = ({ children }: { children?: ReactNode }) => {
const initialData = useLoaderData() as Awaited<
ReturnType<typeof promotionLoader>
- >;
+ >
- const { id } = useParams();
- const { promotion, isLoading } = usePromotion(id!, { initialData });
- const query: Record<string, string> = {};
+ const { id } = useParams()
+ const { promotion, isLoading } = usePromotion(id!, { initialData })
+ const query: Record<string, string> = {}
if (promotion?.type === "buyget") {
- query.promotion_type = promotion.type;
+ query.promotion_type = promotion.type
}
- const { rules } = usePromotionRules(id!, "rules", query);
- const { rules: targetRules } = usePromotionRules(id!, "target-rules", query);
- const { rules: buyRules } = usePromotionRules(id!, "buy-rules", query);
+ const { rules } = usePromotionRules(id!, "rules", query)
+ const { rules: targetRules } = usePromotionRules(id!, "target-rules", query)
+ const { rules: buyRules } = usePromotionRules(id!, "buy-rules", query)
if (isLoading || !promotion) {
return (
<TwoColumnPageSkeleton mainSections={3} sidebarSections={1} showJSON />
- );
+ )
}
return (
- <TwoColumnPage data={promotion} hasOutlet showJSON>
- <TwoColumnPage.Main>
- <PromotionGeneralSection promotion={promotion} />
- <PromotionConditionsSection rules={rules || []} ruleType={"rules"} />
- <PromotionConditionsSection
- rules={targetRules || []}
- ruleType={"target-rules"}
- applicationMethodTargetType={
- promotion.application_method.target_type || "items"
- }
- />
- {promotion.type === "buyget" && (
- <PromotionConditionsSection
- rules={buyRules || []}
- ruleType={"buy-rules"}
- applicationMethodTargetType={"items"}
- />
- )}
- </TwoColumnPage.Main>
- <TwoColumnPage.Sidebar>
- <CampaignSection campaign={promotion.campaign!} />
- </TwoColumnPage.Sidebar>
- </TwoColumnPage>
- );
-};
+ <>
+ {Children.count(children) > 0 ? (
+ children
+ ) : (
+ <TwoColumnPage data={promotion} hasOutlet showJSON>
+ <TwoColumnPage.Main>
+ <PromotionGeneralSection promotion={promotion} />
+ <PromotionConditionsSection
+ rules={rules || []}
+ ruleType={"rules"}
+ />
+ <PromotionConditionsSection
+ rules={targetRules || []}
+ ruleType={"target-rules"}
+ applicationMethodTargetType={
+ promotion.application_method.target_type || "items"
+ }
+ />
+ {promotion.type === "buyget" && (
+ <PromotionConditionsSection
+ rules={buyRules || []}
+ ruleType={"buy-rules"}
+ applicationMethodTargetType={"items"}
+ />
+ )}
+ </TwoColumnPage.Main>
+ <TwoColumnPage.Sidebar>
+ <CampaignSection campaign={promotion.campaign!} />
+ </TwoColumnPage.Sidebar>
+ </TwoColumnPage>
+ )}
+ </>
+ )
+}
+
+export const PromotionDetail = Object.assign(Root, {
+ Main: TwoColumnPage.Main,
+ Sidebar: TwoColumnPage.Sidebar,
+ MainGeneralSection: PromotionGeneralSection,
+ MainConditionsSection: PromotionConditionsSection,
+ SidebarCampaignSection: CampaignSection,
+})
diff --git a/packages/admin/src/pages/promotions/promotion-list/promotions-list.tsx b/packages/admin/src/pages/promotions/promotion-list/promotions-list.tsx
index fc7c16b8a..7e792e98e 100644
--- a/packages/admin/src/pages/promotions/promotion-list/promotions-list.tsx
+++ b/packages/admin/src/pages/promotions/promotion-list/promotions-list.tsx
@@ -1,10 +1,16 @@
+import { Children, ReactNode } from "react"
+
import { SingleColumnPage } from "../../../components/layout/pages"
import { PromotionListTable } from "./components/promotion-list-table"
-export const PromotionsList = () => {
+const Root = ({ children }: { children?: ReactNode }) => {
return (
<SingleColumnPage>
- <PromotionListTable />
+ {Children.count(children) > 0 ? children : <PromotionListTable />}
</SingleColumnPage>
)
}
+
+export const PromotionsList = Object.assign(Root, {
+ Table: PromotionListTable,
+})
diff --git a/packages/admin/src/pages/refund-reasons/refund-reason-list/components/refund-reason-list-table/refund-reason-list-data-table.tsx b/packages/admin/src/pages/refund-reasons/refund-reason-list/components/refund-reason-list-table/refund-reason-list-data-table.tsx
new file mode 100644
index 000000000..2a8783185
--- /dev/null
+++ b/packages/admin/src/pages/refund-reasons/refund-reason-list/components/refund-reason-list-table/refund-reason-list-data-table.tsx
@@ -0,0 +1,141 @@
+import { useCallback, useMemo } from "react"
+
+import { PencilSquare, Trash } from "@medusajs/icons"
+import { HttpTypes } from "@medusajs/types"
+import {
+ Container,
+ createDataTableColumnHelper,
+ toast,
+ usePrompt,
+} from "@medusajs/ui"
+
+import { keepPreviousData } from "@tanstack/react-query"
+import { useTranslation } from "react-i18next"
+import { useNavigate } from "react-router-dom"
+
+import { DataTable } from "../../../../../components/data-table"
+import {
+ useDeleteRefundReasonLazy,
+ useRefundReasons,
+} from "../../../../../hooks/api"
+import { useRefundReasonTableColumns } from "../../../../../hooks/table/columns"
+import { useRefundReasonTableQuery } from "../../../../../hooks/table/query"
+
+const PAGE_SIZE = 20
+
+export const RefundReasonListDataTable = () => {
+ const { t } = useTranslation()
+ const { searchParams } = useRefundReasonTableQuery({
+ pageSize: PAGE_SIZE,
+ })
+
+ const { refund_reasons, count, isLoading, isError, error } = useRefundReasons(
+ searchParams,
+ {
+ placeholderData: keepPreviousData,
+ },
+ )
+
+ const columns = useColumns()
+
+ if (isError) {
+ throw error
+ }
+
+ return (
+ <Container className="divide-y px-0 py-0">
+ <DataTable
+ data={refund_reasons}
+ columns={columns}
+ rowCount={count}
+ pageSize={PAGE_SIZE}
+ getRowId={(row) => row.id}
+ heading={t("refundReasons.domain")}
+ subHeading={t("refundReasons.subtitle")}
+ emptyState={{
+ empty: {
+ heading: t("general.noRecordsMessage"),
+ },
+ filtered: {
+ heading: t("general.noRecordsMessage"),
+ description: t("general.noRecordsMessageFiltered"),
+ },
+ }}
+ actions={[
+ {
+ label: t("actions.create"),
+ to: "create",
+ },
+ ]}
+ isLoading={isLoading}
+ enableSearch={true}
+ />
+ </Container>
+ )
+}
+
+const columnHelper = createDataTableColumnHelper<HttpTypes.AdminRefundReason>()
+
+const useColumns = () => {
+ const { t } = useTranslation()
+ const prompt = usePrompt()
+ const navigate = useNavigate()
+ const base = useRefundReasonTableColumns()
+
+ const { mutateAsync } = useDeleteRefundReasonLazy()
+
+ const handleDelete = useCallback(
+ async (refundReason: HttpTypes.AdminRefundReason) => {
+ const confirm = await prompt({
+ title: t("general.areYouSure"),
+ description: t("refundReasons.delete.confirmation", {
+ label: refundReason.label,
+ }),
+ confirmText: t("actions.delete"),
+ cancelText: t("actions.cancel"),
+ })
+
+ if (!confirm) {
+ return
+ }
+
+ await mutateAsync(refundReason.id, {
+ onSuccess: () => {
+ toast.success(t("refundReasons.delete.successToast"))
+ },
+ onError: (e) => {
+ toast.error(e.message)
+ },
+ })
+ },
+ [t, prompt, mutateAsync],
+ )
+
+ return useMemo(
+ () => [
+ ...base,
+ columnHelper.action({
+ actions: (ctx) => [
+ [
+ {
+ icon: <PencilSquare />,
+ label: t("actions.edit"),
+ onClick: () =>
+ navigate(
+ `/settings/refund-reasons/${ctx.row.original.id}/edit`,
+ ),
+ },
+ ],
+ [
+ {
+ icon: <Trash />,
+ label: t("actions.delete"),
+ onClick: () => handleDelete(ctx.row.original),
+ },
+ ],
+ ],
+ }),
+ ],
+ [base, handleDelete, navigate, t],
+ )
+}
diff --git a/packages/admin/src/pages/refund-reasons/refund-reason-list/components/refund-reason-list-table/refund-reason-list-header.tsx b/packages/admin/src/pages/refund-reasons/refund-reason-list/components/refund-reason-list-table/refund-reason-list-header.tsx
new file mode 100644
index 000000000..764d53847
--- /dev/null
+++ b/packages/admin/src/pages/refund-reasons/refund-reason-list/components/refund-reason-list-table/refund-reason-list-header.tsx
@@ -0,0 +1,44 @@
+import { Children, ReactNode } from "react"
+import { Heading, Text } from "@medusajs/ui"
+import { useTranslation } from "react-i18next"
+
+export const RefundReasonListTitle = () => {
+ const { t } = useTranslation()
+ return (
+ <div>
+ <Heading>{t("refundReasons.domain")}</Heading>
+ <Text className="text-ui-fg-subtle" size="small">
+ {t("refundReasons.subtitle")}
+ </Text>
+ </div>
+ )
+}
+
+export const RefundReasonListActions = ({
+ children,
+}: {
+ children?: ReactNode
+}) => {
+ return (
+ <div className="flex items-center justify-center gap-x-2">{children}</div>
+ )
+}
+
+export const RefundReasonListHeader = ({
+ children,
+}: {
+ children?: ReactNode
+}) => {
+ return (
+ <div className="flex items-center justify-between px-6 py-4">
+ {Children.count(children) > 0 ? (
+ children
+ ) : (
+ <>
+ <RefundReasonListTitle />
+ <RefundReasonListActions />
+ </>
+ )}
+ </div>
+ )
+}
diff --git a/packages/admin/src/pages/refund-reasons/refund-reason-list/components/refund-reason-list-table/refund-reason-list-table.tsx b/packages/admin/src/pages/refund-reasons/refund-reason-list/components/refund-reason-list-table/refund-reason-list-table.tsx
index 711df57bb..511037d06 100644
--- a/packages/admin/src/pages/refund-reasons/refund-reason-list/components/refund-reason-list-table/refund-reason-list-table.tsx
+++ b/packages/admin/src/pages/refund-reasons/refund-reason-list/components/refund-reason-list-table/refund-reason-list-table.tsx
@@ -1,141 +1,18 @@
-import { useCallback, useMemo } from "react";
-
-import { PencilSquare, Trash } from "@medusajs/icons";
-import { HttpTypes } from "@medusajs/types";
-import {
- Container,
- createDataTableColumnHelper,
- toast,
- usePrompt,
-} from "@medusajs/ui";
-
-import { keepPreviousData } from "@tanstack/react-query";
-import { useTranslation } from "react-i18next";
-import { useNavigate } from "react-router-dom";
-
-import { DataTable } from "../../../../../components/data-table";
-import {
- useDeleteRefundReasonLazy,
- useRefundReasons,
-} from "../../../../../hooks/api";
-import { useRefundReasonTableColumns } from "../../../../../hooks/table/columns";
-import { useRefundReasonTableQuery } from "../../../../../hooks/table/query";
-
-const PAGE_SIZE = 20;
-
-export const RefundReasonListTable = () => {
- const { t } = useTranslation();
- const { searchParams } = useRefundReasonTableQuery({
- pageSize: PAGE_SIZE,
- });
-
- const { refund_reasons, count, isLoading, isError, error } = useRefundReasons(
- searchParams,
- {
- placeholderData: keepPreviousData,
- },
- );
-
- const columns = useColumns();
-
- if (isError) {
- throw error;
- }
-
- return (
- <Container className="divide-y px-0 py-0" data-testid="refund-reason-list-table-container">
- <DataTable
- data={refund_reasons}
- columns={columns}
- rowCount={count}
- pageSize={PAGE_SIZE}
- getRowId={(row) => row.id}
- heading={t("refundReasons.domain")}
- subHeading={t("refundReasons.subtitle")}
- emptyState={{
- empty: {
- heading: t("general.noRecordsMessage"),
- },
- filtered: {
- heading: t("general.noRecordsMessage"),
- description: t("general.noRecordsMessageFiltered"),
- },
- }}
- actions={[
- {
- label: t("actions.create"),
- to: "create",
- },
- ]}
- isLoading={isLoading}
- enableSearch={true}
- />
- </Container>
- );
-};
-
-const columnHelper = createDataTableColumnHelper<HttpTypes.AdminRefundReason>();
-
-const useColumns = () => {
- const { t } = useTranslation();
- const prompt = usePrompt();
- const navigate = useNavigate();
- const base = useRefundReasonTableColumns();
-
- const { mutateAsync } = useDeleteRefundReasonLazy();
-
- const handleDelete = useCallback(
- async (refundReason: HttpTypes.AdminRefundReason) => {
- const confirm = await prompt({
- title: t("general.areYouSure"),
- description: t("refundReasons.delete.confirmation", {
- label: refundReason.label,
- }),
- confirmText: t("actions.delete"),
- cancelText: t("actions.cancel"),
- });
-
- if (!confirm) {
- return;
- }
-
- await mutateAsync(refundReason.id, {
- onSuccess: () => {
- toast.success(t("refundReasons.delete.successToast"));
- },
- onError: (e) => {
- toast.error(e.message);
- },
- });
- },
- [t, prompt, mutateAsync],
- );
-
- return useMemo(
- () => [
- ...base,
- columnHelper.action({
- actions: (ctx) => [
- [
- {
- icon: <PencilSquare />,
- label: t("actions.edit"),
- onClick: () =>
- navigate(
- `/settings/refund-reasons/${ctx.row.original.id}/edit`,
- ),
- },
- ],
- [
- {
- icon: <Trash />,
- label: t("actions.delete"),
- onClick: () => handleDelete(ctx.row.original),
- },
- ],
- ],
- }),
- ],
- [base, handleDelete, navigate, t],
- );
-};
+import { Children, ReactNode } from "react"
+
+import { RefundReasonListDataTable } from "./refund-reason-list-data-table"
+
+export { RefundReasonListDataTable } from "./refund-reason-list-data-table"
+export {
+ RefundReasonListHeader,
+ RefundReasonListTitle,
+ RefundReasonListActions,
+} from "./refund-reason-list-header"
+
+export const RefundReasonListTable = ({ children }: { children?: ReactNode }) => {
+ return Children.count(children) > 0 ? (
+ <>{children}</>
+ ) : (
+ <RefundReasonListDataTable />
+ )
+}
diff --git a/packages/admin/src/pages/refund-reasons/refund-reason-list/refund-reason-list.tsx b/packages/admin/src/pages/refund-reasons/refund-reason-list/refund-reason-list.tsx
index e510bd4b2..df0d1c840 100644
--- a/packages/admin/src/pages/refund-reasons/refund-reason-list/refund-reason-list.tsx
+++ b/packages/admin/src/pages/refund-reasons/refund-reason-list/refund-reason-list.tsx
@@ -1,14 +1,26 @@
+import { Children, ReactNode } from "react"
+
import { SingleColumnPage } from "../../../components/layout/pages"
-import { RefundReasonListTable } from "./components/refund-reason-list-table"
+import {
+ RefundReasonListTable,
+ RefundReasonListDataTable,
+ RefundReasonListHeader,
+ RefundReasonListActions,
+ RefundReasonListTitle,
+} from "./components/refund-reason-list-table"
-export const RefundReasonList = () => {
+const Root = ({ children }: { children?: ReactNode }) => {
return (
- <SingleColumnPage
- showMetadata={false}
- showJSON={false}
- hasOutlet
- >
- <RefundReasonListTable />
+ <SingleColumnPage showMetadata={false} showJSON={false} hasOutlet>
+ {Children.count(children) > 0 ? children : <RefundReasonListTable />}
</SingleColumnPage>
)
}
+
+export const RefundReasonList = Object.assign(Root, {
+ Table: RefundReasonListTable,
+ Header: RefundReasonListHeader,
+ HeaderTitle: RefundReasonListTitle,
+ HeaderActions: RefundReasonListActions,
+ DataTable: RefundReasonListDataTable,
+})
diff --git a/packages/admin/src/pages/regions/region-detail/region-detail.tsx b/packages/admin/src/pages/regions/region-detail/region-detail.tsx
index 100995ccb..8604f0ab3 100644
--- a/packages/admin/src/pages/regions/region-detail/region-detail.tsx
+++ b/packages/admin/src/pages/regions/region-detail/region-detail.tsx
@@ -1,21 +1,21 @@
-import { useLoaderData, useParams } from "react-router-dom";
+import { Children, ReactNode } from "react"
+import { useLoaderData, useParams } from "react-router-dom"
-import { useRegion } from "../../../hooks/api/regions";
-import { RegionCountrySection } from "./components/region-country-section";
-import { RegionGeneralSection } from "./components/region-general-section";
-import { regionLoader } from "./loader";
+import { SingleColumnPageSkeleton } from "../../../components/common/skeleton"
+import { SingleColumnPage } from "../../../components/layout/pages"
+import { usePricePreferences } from "../../../hooks/api/price-preferences"
+import { useRegion } from "../../../hooks/api/regions"
+import { RegionCountrySection } from "./components/region-country-section"
+import { RegionGeneralSection } from "./components/region-general-section"
+import { regionLoader } from "./loader"
+import { REGION_DETAIL_FIELDS } from "./constants"
-import { SingleColumnPageSkeleton } from "../../../components/common/skeleton";
-import { SingleColumnPage } from "../../../components/layout/pages";
-import { usePricePreferences } from "../../../hooks/api/price-preferences";
-import { REGION_DETAIL_FIELDS } from "./constants";
-
-export const RegionDetail = () => {
+const Root = ({ children }: { children?: ReactNode }) => {
const initialData = useLoaderData() as Awaited<
ReturnType<typeof regionLoader>
- >;
+ >
- const { id } = useParams();
+ const { id } = useParams()
const {
region,
isPending: isLoading,
@@ -26,8 +26,8 @@ export const RegionDetail = () => {
{ fields: REGION_DETAIL_FIELDS },
{
initialData,
- },
- );
+ }
+ )
const {
price_preferences: pricePreferences,
@@ -39,28 +39,39 @@ export const RegionDetail = () => {
attribute: "region_id",
value: id,
},
- { enabled: !!region },
- );
+ { enabled: !!region }
+ )
if (isLoading || isLoadingPreferences || !region) {
- return <SingleColumnPageSkeleton sections={2} showJSON showMetadata />;
+ return <SingleColumnPageSkeleton sections={2} showJSON showMetadata />
}
if (isRegionError) {
- throw regionError;
+ throw regionError
}
if (isPreferencesError) {
- throw preferencesError;
+ throw preferencesError
}
return (
<SingleColumnPage data={region} showMetadata showJSON>
- <RegionGeneralSection
- region={region}
- pricePreferences={pricePreferences ?? []}
- />
- <RegionCountrySection region={region} />
+ {Children.count(children) > 0 ? (
+ children
+ ) : (
+ <>
+ <RegionGeneralSection
+ region={region}
+ pricePreferences={pricePreferences ?? []}
+ />
+ <RegionCountrySection region={region} />
+ </>
+ )}
</SingleColumnPage>
- );
-};
+ )
+}
+
+export const RegionDetail = Object.assign(Root, {
+ GeneralSection: RegionGeneralSection,
+ CountrySection: RegionCountrySection,
+})
diff --git a/packages/admin/src/pages/regions/region-list/region-list.tsx b/packages/admin/src/pages/regions/region-list/region-list.tsx
index b35b0c7c0..fdfffc735 100644
--- a/packages/admin/src/pages/regions/region-list/region-list.tsx
+++ b/packages/admin/src/pages/regions/region-list/region-list.tsx
@@ -1,10 +1,16 @@
+import { Children, ReactNode } from "react"
+
import { SingleColumnPage } from "../../../components/layout/pages"
import { RegionListTable } from "./components/region-list-table"
-export const RegionList = () => {
+const Root = ({ children }: { children?: ReactNode }) => {
return (
<SingleColumnPage>
- <RegionListTable />
+ {Children.count(children) > 0 ? children : <RegionListTable />}
</SingleColumnPage>
)
}
+
+export const RegionList = Object.assign(Root, {
+ Table: RegionListTable,
+})
diff --git a/packages/admin/src/pages/reservations/reservation-detail/reservation-detail.tsx b/packages/admin/src/pages/reservations/reservation-detail/reservation-detail.tsx
index 78e6e5a0b..72e31f763 100644
--- a/packages/admin/src/pages/reservations/reservation-detail/reservation-detail.tsx
+++ b/packages/admin/src/pages/reservations/reservation-detail/reservation-detail.tsx
@@ -1,3 +1,4 @@
+import { Children, ReactNode } from "react"
import { useLoaderData, useParams } from "react-router-dom"
import { TwoColumnPageSkeleton } from "../../../components/common/skeleton"
@@ -9,7 +10,7 @@ import { InventoryItemGeneralSection } from "../../inventory/inventory-detail/co
import { ReservationGeneralSection } from "./components/reservation-general-section"
import { reservationItemLoader } from "./loader"
-export const ReservationDetail = () => {
+const Root = ({ children }: { children?: ReactNode }) => {
const { id } = useParams()
const initialData = useLoaderData() as Awaited<
@@ -47,19 +48,28 @@ export const ReservationDetail = () => {
}
return (
- <TwoColumnPage
- data={reservation}
- showJSON
- showMetadata
- >
- <TwoColumnPage.Main>
- <ReservationGeneralSection reservation={reservation} />
- </TwoColumnPage.Main>
- <TwoColumnPage.Sidebar>
- {inventory_item && (
- <InventoryItemGeneralSection inventoryItem={inventory_item} />
- )}
- </TwoColumnPage.Sidebar>
- </TwoColumnPage>
+ <>
+ {Children.count(children) > 0 ? (
+ children
+ ) : (
+ <TwoColumnPage data={reservation} showJSON showMetadata>
+ <TwoColumnPage.Main>
+ <ReservationGeneralSection reservation={reservation} />
+ </TwoColumnPage.Main>
+ <TwoColumnPage.Sidebar>
+ {inventory_item && (
+ <InventoryItemGeneralSection inventoryItem={inventory_item} />
+ )}
+ </TwoColumnPage.Sidebar>
+ </TwoColumnPage>
+ )}
+ </>
)
}
+
+export const ReservationDetail = Object.assign(Root, {
+ Main: TwoColumnPage.Main,
+ Sidebar: TwoColumnPage.Sidebar,
+ MainGeneralSection: ReservationGeneralSection,
+ SidebarInventorySection: InventoryItemGeneralSection,
+})
diff --git a/packages/admin/src/pages/reservations/reservation-list/reservation-list.tsx b/packages/admin/src/pages/reservations/reservation-list/reservation-list.tsx
index 15695c5bb..2e216154d 100644
--- a/packages/admin/src/pages/reservations/reservation-list/reservation-list.tsx
+++ b/packages/admin/src/pages/reservations/reservation-list/reservation-list.tsx
@@ -1,10 +1,16 @@
+import { Children, ReactNode } from "react"
+
import { SingleColumnPage } from "../../../components/layout/pages"
import { ReservationListTable } from "./components/reservation-list-table"
-export const ReservationList = () => {
+const Root = ({ children }: { children?: ReactNode }) => {
return (
<SingleColumnPage>
- <ReservationListTable />
+ {Children.count(children) > 0 ? children : <ReservationListTable />}
</SingleColumnPage>
)
}
+
+export const ReservationList = Object.assign(Root, {
+ Table: ReservationListTable,
+})
diff --git a/packages/admin/src/pages/return-reasons/return-reason-list/return-reason-list.tsx b/packages/admin/src/pages/return-reasons/return-reason-list/return-reason-list.tsx
index 648a4f563..e152c095c 100644
--- a/packages/admin/src/pages/return-reasons/return-reason-list/return-reason-list.tsx
+++ b/packages/admin/src/pages/return-reasons/return-reason-list/return-reason-list.tsx
@@ -1,14 +1,16 @@
+import { Children, ReactNode } from "react"
+
import { SingleColumnPage } from "../../../components/layout/pages"
import { ReturnReasonListTable } from "./components/return-reason-list-table"
-export const ReturnReasonList = () => {
+const Root = ({ children }: { children?: ReactNode }) => {
return (
- <SingleColumnPage
- showMetadata={false}
- showJSON={false}
- hasOutlet
- >
- <ReturnReasonListTable />
+ <SingleColumnPage showMetadata={false} showJSON={false} hasOutlet>
+ {Children.count(children) > 0 ? children : <ReturnReasonListTable />}
</SingleColumnPage>
)
}
+
+export const ReturnReasonList = Object.assign(Root, {
+ Table: ReturnReasonListTable,
+})
diff --git a/packages/admin/src/pages/sales-channels/sales-channel-detail/sales-channel-detail.tsx b/packages/admin/src/pages/sales-channels/sales-channel-detail/sales-channel-detail.tsx
index 463f58ef8..a0f3e54d9 100644
--- a/packages/admin/src/pages/sales-channels/sales-channel-detail/sales-channel-detail.tsx
+++ b/packages/admin/src/pages/sales-channels/sales-channel-detail/sales-channel-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 { SalesChannelGeneralSection } from "./components/sales-channel-general-s
import { SalesChannelProductSection } from "./components/sales-channel-product-section"
import { salesChannelLoader } from "./loader"
-export const SalesChannelDetail = () => {
+const Root = ({ children }: { children?: ReactNode }) => {
const initialData = useLoaderData() as Awaited<
ReturnType<typeof salesChannelLoader>
>
@@ -22,13 +23,20 @@ export const SalesChannelDetail = () => {
}
return (
- <SingleColumnPage
- showJSON
- showMetadata
- data={sales_channel}
- >
- <SalesChannelGeneralSection salesChannel={sales_channel} />
- <SalesChannelProductSection salesChannel={sales_channel} />
+ <SingleColumnPage showJSON showMetadata data={sales_channel}>
+ {Children.count(children) > 0 ? (
+ children
+ ) : (
+ <>
+ <SalesChannelGeneralSection salesChannel={sales_channel} />
+ <SalesChannelProductSection salesChannel={sales_channel} />
+ </>
+ )}
</SingleColumnPage>
)
}
+
+export const SalesChannelDetail = Object.assign(Root, {
+ GeneralSection: SalesChannelGeneralSection,
+ ProductSection: SalesChannelProductSection,
+})
diff --git a/packages/admin/src/pages/sales-channels/sales-channel-list/sales-channel-list.tsx b/packages/admin/src/pages/sales-channels/sales-channel-list/sales-channel-list.tsx
index 44eb5aceb..7acc8a69a 100644
--- a/packages/admin/src/pages/sales-channels/sales-channel-list/sales-channel-list.tsx
+++ b/packages/admin/src/pages/sales-channels/sales-channel-list/sales-channel-list.tsx
@@ -1,13 +1,16 @@
-import { SalesChannelListTable } from "./components/sales-channel-list-table"
+import { Children, ReactNode } from "react"
import { SingleColumnPage } from "../../../components/layout/pages"
+import { SalesChannelListTable } from "./components/sales-channel-list-table"
-export const SalesChannelList = () => {
+const Root = ({ children }: { children?: ReactNode }) => {
return (
- <SingleColumnPage
- hasOutlet
- >
- <SalesChannelListTable />
+ <SingleColumnPage hasOutlet>
+ {Children.count(children) > 0 ? children : <SalesChannelListTable />}
</SingleColumnPage>
)
}
+
+export const SalesChannelList = Object.assign(Root, {
+ Table: SalesChannelListTable,
+})
diff --git a/packages/admin/src/pages/tax-regions/tax-region-detail/tax-region-detail.tsx b/packages/admin/src/pages/tax-regions/tax-region-detail/tax-region-detail.tsx
index c91aa2671..d398f680b 100644
--- a/packages/admin/src/pages/tax-regions/tax-region-detail/tax-region-detail.tsx
+++ b/packages/admin/src/pages/tax-regions/tax-region-detail/tax-region-detail.tsx
@@ -1,54 +1,68 @@
-import { useLoaderData, useParams } from "react-router-dom";
-import { useState } from "react";
+import { Children, ReactNode } from "react"
+import { useLoaderData, useParams } from "react-router-dom"
+import { useState } from "react"
-import { SingleColumnPage } from "../../../components/layout/pages";
-import { useTaxRegion } from "../../../hooks/api/tax-regions";
-import { TaxRegionDetailSection } from "./components/tax-region-detail-section";
-import { TaxRegionProvinceSection } from "./components/tax-region-province-section";
+import { SingleColumnPageSkeleton } from "../../../components/common/skeleton"
+import { SingleColumnPage } from "../../../components/layout/pages"
+import { useTaxRegion } from "../../../hooks/api/tax-regions"
+import { TaxRegionDetailSection } from "./components/tax-region-detail-section"
+import { TaxRegionProvinceSection } from "./components/tax-region-province-section"
+import { TaxRegionOverrideSection } from "./components/tax-region-override-section"
+import { TaxRegionSublevelAlert } from "./components/tax-region-sublevel-alert"
+import { TaxRegionProviderSection } from "./tax-region-provider-section"
+import { taxRegionLoader } from "./loader"
-import { SingleColumnPageSkeleton } from "../../../components/common/skeleton";
-import { TaxRegionOverrideSection } from "./components/tax-region-override-section";
-import { TaxRegionSublevelAlert } from "./components/tax-region-sublevel-alert";
-import { TaxRegionProviderSection } from "./tax-region-provider-section";
-import { taxRegionLoader } from "./loader";
-
-export const TaxRegionDetail = () => {
- const { id } = useParams();
- const [showSublevelRegions, setShowSublevelRegions] = useState(false);
+const Root = ({ children }: { children?: ReactNode }) => {
+ const { id } = useParams()
+ const [showSublevelRegions, setShowSublevelRegions] = useState(false)
const initialData = useLoaderData() as Awaited<
ReturnType<typeof taxRegionLoader>
- >;
+ >
const {
tax_region: taxRegion,
isLoading,
isError,
error,
- } = useTaxRegion(id!, undefined, { initialData });
+ } = useTaxRegion(id!, undefined, { initialData })
if (isLoading || !taxRegion) {
- return <SingleColumnPageSkeleton sections={4} showJSON />;
+ return <SingleColumnPageSkeleton sections={4} showJSON />
}
if (isError) {
- throw error;
+ throw error
}
return (
- <SingleColumnPage data={taxRegion} showJSON showMetadata>
- <TaxRegionSublevelAlert
- taxRegion={taxRegion}
- showSublevelRegions={showSublevelRegions}
- setShowSublevelRegions={setShowSublevelRegions}
- />
- <TaxRegionDetailSection taxRegion={taxRegion} />
- <TaxRegionProvinceSection
- taxRegion={taxRegion}
- showSublevelRegions={showSublevelRegions}
- />
- <TaxRegionOverrideSection taxRegion={taxRegion} />
- <TaxRegionProviderSection taxRegion={taxRegion} />
- </SingleColumnPage>
- );
-};
+ <>
+ {Children.count(children) > 0 ? (
+ children
+ ) : (
+ <SingleColumnPage data={taxRegion} showJSON showMetadata>
+ <TaxRegionSublevelAlert
+ taxRegion={taxRegion}
+ showSublevelRegions={showSublevelRegions}
+ setShowSublevelRegions={setShowSublevelRegions}
+ />
+ <TaxRegionDetailSection taxRegion={taxRegion} />
+ <TaxRegionProvinceSection
+ taxRegion={taxRegion}
+ showSublevelRegions={showSublevelRegions}
+ />
+ <TaxRegionOverrideSection taxRegion={taxRegion} />
+ <TaxRegionProviderSection taxRegion={taxRegion} />
+ </SingleColumnPage>
+ )}
+ </>
+ )
+}
+
+export const TaxRegionDetail = Object.assign(Root, {
+ SublevelAlert: TaxRegionSublevelAlert,
+ DetailSection: TaxRegionDetailSection,
+ ProvinceSection: TaxRegionProvinceSection,
+ OverrideSection: TaxRegionOverrideSection,
+ ProviderSection: TaxRegionProviderSection,
+})
diff --git a/packages/admin/src/pages/tax-regions/tax-region-list/components/tax-region-list-view/tax-region-list-data-table.tsx b/packages/admin/src/pages/tax-regions/tax-region-list/components/tax-region-list-view/tax-region-list-data-table.tsx
new file mode 100644
index 000000000..759ae0d2c
--- /dev/null
+++ b/packages/admin/src/pages/tax-regions/tax-region-list/components/tax-region-list-view/tax-region-list-data-table.tsx
@@ -0,0 +1,58 @@
+import { Container, Heading, Text } from "@medusajs/ui"
+
+import { keepPreviousData } from "@tanstack/react-query"
+import { useTranslation } from "react-i18next"
+
+import { useTaxRegions } from "../../../../../hooks/api/tax-regions"
+import { useTaxRegionTableQuery } from "../../../../../hooks/table/query/use-tax-region-table-query"
+import { TaxRegionTable } from "../../../common/components/tax-region-table"
+import { useTaxRegionTable } from "../../../common/hooks/use-tax-region-table"
+
+const PAGE_SIZE = 20
+
+export const TaxRegionListDataTable = () => {
+ const { t } = useTranslation()
+
+ const { searchParams, raw } = useTaxRegionTableQuery({
+ pageSize: PAGE_SIZE,
+ })
+ const { tax_regions, count, isPending, isError, error } = useTaxRegions(
+ {
+ ...searchParams,
+ parent_id: "null",
+ },
+ {
+ placeholderData: keepPreviousData,
+ },
+ )
+
+ const { table } = useTaxRegionTable({
+ count,
+ data: tax_regions,
+ pageSize: PAGE_SIZE,
+ })
+
+ if (isError) {
+ throw error
+ }
+
+ return (
+ <Container className="divide-y p-0">
+ <TaxRegionTable
+ action={{
+ to: "create",
+ label: t("actions.create"),
+ }}
+ isPending={isPending}
+ queryObject={raw}
+ table={table}
+ count={count}
+ >
+ <Heading>{t("taxes.domain")}</Heading>
+ <Text size="small" className="text-pretty text-ui-fg-subtle">
+ {t("taxRegions.list.hint")}
+ </Text>
+ </TaxRegionTable>
+ </Container>
+ )
+}
diff --git a/packages/admin/src/pages/tax-regions/tax-region-list/components/tax-region-list-view/tax-region-list-header.tsx b/packages/admin/src/pages/tax-regions/tax-region-list/components/tax-region-list-view/tax-region-list-header.tsx
new file mode 100644
index 000000000..01a018ee3
--- /dev/null
+++ b/packages/admin/src/pages/tax-regions/tax-region-list/components/tax-region-list-view/tax-region-list-header.tsx
@@ -0,0 +1,44 @@
+import { Children, ReactNode } from "react"
+import { Heading, Text } from "@medusajs/ui"
+import { useTranslation } from "react-i18next"
+
+export const TaxRegionListTitle = () => {
+ const { t } = useTranslation()
+ return (
+ <div>
+ <Heading>{t("taxes.domain")}</Heading>
+ <Text size="small" className="text-pretty text-ui-fg-subtle">
+ {t("taxRegions.list.hint")}
+ </Text>
+ </div>
+ )
+}
+
+export const TaxRegionListActions = ({
+ children,
+}: {
+ children?: ReactNode
+}) => {
+ return (
+ <div className="flex items-center justify-center gap-x-2">{children}</div>
+ )
+}
+
+export const TaxRegionListHeader = ({
+ children,
+}: {
+ children?: ReactNode
+}) => {
+ return (
+ <div className="flex items-center justify-between px-6 py-4">
+ {Children.count(children) > 0 ? (
+ children
+ ) : (
+ <>
+ <TaxRegionListTitle />
+ <TaxRegionListActions />
+ </>
+ )}
+ </div>
+ )
+}
diff --git a/packages/admin/src/pages/tax-regions/tax-region-list/components/tax-region-list-view/tax-region-list-view.tsx b/packages/admin/src/pages/tax-regions/tax-region-list/components/tax-region-list-view/tax-region-list-view.tsx
index e48d0900a..9f0388c21 100644
--- a/packages/admin/src/pages/tax-regions/tax-region-list/components/tax-region-list-view/tax-region-list-view.tsx
+++ b/packages/admin/src/pages/tax-regions/tax-region-list/components/tax-region-list-view/tax-region-list-view.tsx
@@ -1,59 +1,18 @@
-import { Container, Heading, Text } from "@medusajs/ui";
-
-import { keepPreviousData } from "@tanstack/react-query";
-import { useTranslation } from "react-i18next";
-
-import { useTaxRegions } from "../../../../../hooks/api/tax-regions";
-import { useTaxRegionTableQuery } from "../../../../../hooks/table/query/use-tax-region-table-query";
-import { TaxRegionTable } from "../../../common/components/tax-region-table";
-import { useTaxRegionTable } from "../../../common/hooks/use-tax-region-table";
-
-const PAGE_SIZE = 20;
-
-export const TaxRegionListView = () => {
- const { t } = useTranslation();
-
- const { searchParams, raw } = useTaxRegionTableQuery({
- pageSize: PAGE_SIZE,
- });
- const { tax_regions, count, isPending, isError, error } = useTaxRegions(
- {
- ...searchParams,
- parent_id: "null",
- },
- {
- placeholderData: keepPreviousData,
- },
- );
-
- const { table } = useTaxRegionTable({
- count,
- data: tax_regions,
- pageSize: PAGE_SIZE,
- });
-
- if (isError) {
- throw error;
- }
-
- return (
- <Container className="divide-y p-0" data-testid="tax-region-list-view-container">
- <TaxRegionTable
- action={{
- to: "create",
- label: t("actions.create"),
- }}
- isPending={isPending}
- queryObject={raw}
- table={table}
- count={count}
- data-testid="tax-region-list-view-table"
- >
- <Heading data-testid="tax-region-list-view-heading">{t("taxes.domain")}</Heading>
- <Text size="small" className="text-pretty text-ui-fg-subtle" data-testid="tax-region-list-view-hint">
- {t("taxRegions.list.hint")}
- </Text>
- </TaxRegionTable>
- </Container>
- );
-};
+import { Children, ReactNode } from "react"
+
+import { TaxRegionListDataTable } from "./tax-region-list-data-table"
+
+export { TaxRegionListDataTable } from "./tax-region-list-data-table"
+export {
+ TaxRegionListHeader,
+ TaxRegionListTitle,
+ TaxRegionListActions,
+} from "./tax-region-list-header"
+
+export const TaxRegionListView = ({ children }: { children?: ReactNode }) => {
+ return Children.count(children) > 0 ? (
+ <>{children}</>
+ ) : (
+ <TaxRegionListDataTable />
+ )
+}
diff --git a/packages/admin/src/pages/tax-regions/tax-region-list/tax-region-list.tsx b/packages/admin/src/pages/tax-regions/tax-region-list/tax-region-list.tsx
index 8dbd65cd1..5e00837e7 100644
--- a/packages/admin/src/pages/tax-regions/tax-region-list/tax-region-list.tsx
+++ b/packages/admin/src/pages/tax-regions/tax-region-list/tax-region-list.tsx
@@ -1,12 +1,26 @@
+import { Children, ReactNode } from "react"
+
import { SingleColumnPage } from "../../../components/layout/pages"
-import { TaxRegionListView } from "./components/tax-region-list-view"
+import {
+ TaxRegionListView,
+ TaxRegionListDataTable,
+ TaxRegionListHeader,
+ TaxRegionListActions,
+ TaxRegionListTitle,
+} from "./components/tax-region-list-view"
-export const TaxRegionsList = () => {
+const Root = ({ children }: { children?: ReactNode }) => {
return (
- <SingleColumnPage
- hasOutlet
- >
- <TaxRegionListView />
+ <SingleColumnPage hasOutlet>
+ {Children.count(children) > 0 ? children : <TaxRegionListView />}
</SingleColumnPage>
)
}
+
+export const TaxRegionsList = Object.assign(Root, {
+ Table: TaxRegionListView,
+ Header: TaxRegionListHeader,
+ HeaderTitle: TaxRegionListTitle,
+ HeaderActions: TaxRegionListActions,
+ DataTable: TaxRegionListDataTable,
+})
diff --git a/packages/admin/src/pages/users/user-detail/user-detail.tsx b/packages/admin/src/pages/users/user-detail/user-detail.tsx
index ac6f47d64..ff64614ce 100644
--- a/packages/admin/src/pages/users/user-detail/user-detail.tsx
+++ b/packages/admin/src/pages/users/user-detail/user-detail.tsx
@@ -1,13 +1,13 @@
+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 { useUser } from "../../../hooks/api/users"
import { UserGeneralSection } from "./components/user-general-section"
import { userLoader } from "./loader"
-import { SingleColumnPageSkeleton } from "../../../components/common/skeleton"
-import { SingleColumnPage } from "../../../components/layout/pages"
-
-export const UserDetail = () => {
+const Root = ({ children }: { children?: ReactNode }) => {
const initialData = useLoaderData() as Awaited<ReturnType<typeof userLoader>>
const { id } = useParams()
@@ -29,12 +29,18 @@ export const UserDetail = () => {
}
return (
- <SingleColumnPage
- data={user}
- showJSON
- showMetadata
- >
- <UserGeneralSection user={user} />
- </SingleColumnPage>
+ <>
+ {Children.count(children) > 0 ? (
+ children
+ ) : (
+ <SingleColumnPage data={user} showJSON showMetadata>
+ <UserGeneralSection user={user} />
+ </SingleColumnPage>
+ )}
+ </>
)
}
+
+export const UserDetail = Object.assign(Root, {
+ GeneralSection: UserGeneralSection,
+})
diff --git a/packages/admin/src/pages/users/user-list/components/user-list-table/user-list-data-table.tsx b/packages/admin/src/pages/users/user-list/components/user-list-table/user-list-data-table.tsx
new file mode 100644
index 000000000..3ad4a904a
--- /dev/null
+++ b/packages/admin/src/pages/users/user-list/components/user-list-table/user-list-data-table.tsx
@@ -0,0 +1,179 @@
+import { useMemo } from "react"
+
+import { PencilSquare } from "@medusajs/icons"
+import { HttpTypes } from "@medusajs/types"
+import { keepPreviousData } from "@tanstack/react-query"
+import { createColumnHelper } from "@tanstack/react-table"
+import { useTranslation } from "react-i18next"
+import { useNavigate } from "react-router-dom"
+
+import { ActionMenu } from "../../../../../components/common/action-menu"
+import { _DataTable } from "../../../../../components/table/data-table/data-table"
+import { DateCell } from "../../../../../components/table/table-cells/common/date-cell"
+import { useUsers } from "../../../../../hooks/api/users"
+import { useUserTableQuery } from "../../../../../hooks/table/query/use-user-table-query"
+import { useDataTable } from "../../../../../hooks/use-data-table"
+import { useUserTableFilters } from "./use-user-table-filters"
+
+const PAGE_SIZE = 20
+
+export const UserListDataTable = () => {
+ const { t } = useTranslation()
+
+ const { searchParams, raw } = useUserTableQuery({ pageSize: PAGE_SIZE } as { pageSize: number })
+ const { users, count, isPending, isError, error } = useUsers(
+ {
+ ...searchParams,
+ },
+ {
+ placeholderData: keepPreviousData,
+ }
+ )
+
+ const filters = useUserTableFilters()
+ const columns = useColumns()
+
+ const { table } = useDataTable({
+ data: users ?? [],
+ columns,
+ enablePagination: true,
+ count,
+ pageSize: PAGE_SIZE,
+ getRowId: (row) => row.id,
+ })
+
+ if (isError) {
+ throw error
+ }
+
+ return (
+ <_DataTable
+ table={table}
+ columns={columns}
+ count={count}
+ pageSize={PAGE_SIZE}
+ filters={filters}
+ search
+ pagination
+ isLoading={isPending}
+ queryObject={raw}
+ navigateTo={(row) => `${row.original.id}`}
+ orderBy={[
+ { key: "email", label: t("fields.email") },
+ { key: "first_name", label: t("fields.firstName") },
+ { key: "last_name", label: t("fields.lastName") },
+ { key: "created_at", label: t("fields.createdAt") },
+ { key: "updated_at", label: t("fields.updatedAt") },
+ ]}
+ noRecords={{
+ message: t("users.list.empty.description"),
+ }}
+ />
+ )
+}
+
+const columnHelper = createColumnHelper<HttpTypes.AdminUser>()
+
+const useColumns = () => {
+ const { t } = useTranslation()
+ const navigate = useNavigate()
+
+ return useMemo(
+ () => [
+ columnHelper.accessor("email", {
+ header: () => (
+ <div className="flex h-full w-full items-center">
+ <span>{t("fields.email")}</span>
+ </div>
+ ),
+ cell: ({ row }) => {
+ return (
+ <div className="flex size-full items-center overflow-hidden">
+ <span className="truncate">{row.original.email}</span>
+ </div>
+ )
+ },
+ }),
+ columnHelper.accessor("first_name", {
+ header: () => (
+ <div className="flex h-full w-full items-center">
+ <span>{t("fields.firstName")}</span>
+ </div>
+ ),
+ cell: ({ row }) => {
+ return (
+ <div className="flex size-full items-center overflow-hidden">
+ <span className="truncate">{row.original.first_name || "-"}</span>
+ </div>
+ )
+ },
+ }),
+ columnHelper.accessor("last_name", {
+ header: () => (
+ <div className="flex h-full w-full items-center">
+ <span>{t("fields.lastName")}</span>
+ </div>
+ ),
+ cell: ({ row }) => {
+ return (
+ <div className="flex size-full items-center overflow-hidden">
+ <span className="truncate">{row.original.last_name || "-"}</span>
+ </div>
+ )
+ },
+ }),
+ columnHelper.accessor("created_at", {
+ header: () => (
+ <div className="flex h-full w-full items-center">
+ <span>{t("fields.createdAt")}</span>
+ </div>
+ ),
+ cell: ({ getValue }) => {
+ const date = getValue()
+ return <DateCell date={date ? new Date(date) : null} />
+ },
+ }),
+ columnHelper.accessor("updated_at", {
+ header: () => (
+ <div className="flex h-full w-full items-center">
+ <span>{t("fields.updatedAt")}</span>
+ </div>
+ ),
+ cell: ({ getValue }) => {
+ const date = getValue()
+ return <DateCell date={date ? new Date(date) : null} />
+ },
+ }),
+ columnHelper.display({
+ id: "actions",
+ cell: ({ row }) => {
+ return <UserActions user={row.original} />
+ },
+ }),
+ ],
+ [t, navigate]
+ )
+}
+
+const UserActions = ({ user }: { user: HttpTypes.AdminUser }) => {
+ const { t } = useTranslation()
+ const navigate = useNavigate()
+
+ return (
+ <ActionMenu
+ groups={[
+ {
+ actions: [
+ {
+ icon: <PencilSquare />,
+ label: t("actions.edit"),
+ onClick: () => {
+ navigate(`${user.id}/edit`)
+ },
+ },
+ ],
+ },
+ ]}
+ />
+ )
+}
diff --git a/packages/admin/src/pages/users/user-list/components/user-list-table/user-list-header.tsx b/packages/admin/src/pages/users/user-list/components/user-list-table/user-list-header.tsx
new file mode 100644
index 000000000..252b85465
--- /dev/null
+++ b/packages/admin/src/pages/users/user-list/components/user-list-table/user-list-header.tsx
@@ -0,0 +1,53 @@
+import { Children, ReactNode } from "react"
+import { Button, Heading } from "@medusajs/ui"
+import { useTranslation } from "react-i18next"
+import { Link } from "react-router-dom"
+
+export const UserListTitle = () => {
+ const { t } = useTranslation()
+ return (
+ <div>
+ <Heading level="h2">{t("users.domain")}</Heading>
+ </div>
+ )
+}
+
+export const UserListActions = ({
+ children,
+}: {
+ children?: ReactNode
+}) => {
+ const { t } = useTranslation()
+ return (
+ <div className="flex items-center justify-center gap-x-2">
+ {Children.count(children) > 0 ? (
+ children
+ ) : (
+ <Link to="invite">
+ <Button size="small" variant="secondary">
+ {t("users.invite")}
+ </Button>
+ </Link>
+ )}
+ </div>
+ )
+}
+
+export const UserListHeader = ({
+ children,
+}: {
+ children?: ReactNode
+}) => {
+ return (
+ <div className="flex items-center justify-between px-6 py-4">
+ {Children.count(children) > 0 ? (
+ children
+ ) : (
+ <>
+ <UserListTitle />
+ <UserListActions />
+ </>
+ )}
+ </div>
+ )
+}
diff --git a/packages/admin/src/pages/users/user-list/components/user-list-table/user-list-table.tsx b/packages/admin/src/pages/users/user-list/components/user-list-table/user-list-table.tsx
index 427406305..c35d25b02 100644
--- a/packages/admin/src/pages/users/user-list/components/user-list-table/user-list-table.tsx
+++ b/packages/admin/src/pages/users/user-list/components/user-list-table/user-list-table.tsx
@@ -1,264 +1,27 @@
-import { useMemo } from 'react';
+import { Children, ReactNode } from "react"
+import { Container } from "@medusajs/ui"
-import { PencilSquare } from '@medusajs/icons';
-import { HttpTypes } from '@medusajs/types';
-import { Button, Container, Heading } from '@medusajs/ui';
-import { keepPreviousData } from '@tanstack/react-query';
-import { createColumnHelper } from '@tanstack/react-table';
-import { useTranslation } from 'react-i18next';
-import { Link, useNavigate } from 'react-router-dom';
+import { UserListHeader } from "./user-list-header"
+import { UserListDataTable } from "./user-list-data-table"
-import { ActionMenu } from '../../../../../components/common/action-menu';
-import { _DataTable } from '../../../../../components/table/data-table/data-table';
-import { DateCell } from '../../../../../components/table/table-cells/common/date-cell';
-import { useUsers } from '../../../../../hooks/api/users';
-import { useUserTableQuery } from '../../../../../hooks/table/query/use-user-table-query';
-import { useDataTable } from '../../../../../hooks/use-data-table';
-import { useUserTableFilters } from './use-user-table-filters';
-
-const PAGE_SIZE = 20;
-
-export const UserListTable = () => {
- const { t } = useTranslation();
-
- const { searchParams, raw } = useUserTableQuery({ pageSize: PAGE_SIZE } as { pageSize: number });
- const { users, count, isPending, isError, error } = useUsers(
- {
- ...searchParams
- },
- {
- placeholderData: keepPreviousData
- }
- );
-
- const filters = useUserTableFilters();
- const columns = useColumns();
-
- const { table } = useDataTable({
- data: users ?? [],
- columns,
- enablePagination: true,
- count,
- pageSize: PAGE_SIZE,
- getRowId: row => row.id
- });
-
- if (isError) {
- throw error;
- }
+export { UserListDataTable } from "./user-list-data-table"
+export {
+ UserListHeader,
+ UserListTitle,
+ UserListActions,
+} from "./user-list-header"
+export const UserListTable = ({ children }: { children?: ReactNode }) => {
return (
- <Container
- className="divide-y p-0"
- data-testid="users-list-table"
- >
- <div
- className="flex items-center justify-between px-6 py-4"
- data-testid="users-list-header"
- >
- <Heading
- level="h2"
- data-testid="users-list-title"
- >
- {t('users.domain')}
- </Heading>
- <Link
- to="invite"
- data-testid="users-invite-link"
- >
- <Button
- size="small"
- variant="secondary"
- data-testid="users-invite-button"
- >
- {t('users.invite')}
- </Button>
- </Link>
- </div>
- <div data-testid="users-data-table">
- <_DataTable
- table={table}
- columns={columns}
- count={count}
- pageSize={PAGE_SIZE}
- filters={filters}
- search
- pagination
- isLoading={isPending}
- queryObject={raw}
- navigateTo={row => `${row.original.id}`}
- orderBy={[
- { key: 'email', label: t('fields.email') },
- { key: 'first_name', label: t('fields.firstName') },
- { key: 'last_name', label: t('fields.lastName') },
- { key: 'created_at', label: t('fields.createdAt') },
- { key: 'updated_at', label: t('fields.updatedAt') }
- ]}
- noRecords={{
- message: t('users.list.empty.description')
- }}
- />
- </div>
+ <Container className="divide-y p-0">
+ {Children.count(children) > 0 ? (
+ children
+ ) : (
+ <>
+ <UserListHeader />
+ <UserListDataTable />
+ </>
+ )}
</Container>
- );
-};
-
-const columnHelper = createColumnHelper<HttpTypes.AdminUser>();
-
-const useColumns = () => {
- const { t } = useTranslation();
- const navigate = useNavigate();
-
- return useMemo(
- () => [
- columnHelper.accessor('email', {
- header: () => (
- <div
- className="flex h-full w-full items-center"
- data-testid="users-table-header-email"
- >
- <span data-testid="users-table-header-email-text">{t('fields.email')}</span>
- </div>
- ),
- cell: ({ row }) => {
- return (
- <div className="flex size-full items-center overflow-hidden">
- <span
- className="truncate"
- data-testid={`users-table-cell-${row.index}-email-value`}
- >
- {row.original.email}
- </span>
- </div>
- );
- }
- }),
- columnHelper.accessor('first_name', {
- header: () => (
- <div
- className="flex h-full w-full items-center"
- data-testid="users-table-header-first_name"
- >
- <span data-testid="users-table-header-first_name-text">{t('fields.firstName')}</span>
- </div>
- ),
- cell: ({ row }) => {
- return (
- <div className="flex size-full items-center overflow-hidden">
- <span
- className="truncate"
- data-testid={`users-table-cell-${row.index}-first_name-value`}
- >
- {row.original.first_name || '-'}
- </span>
- </div>
- );
- }
- }),
- columnHelper.accessor('last_name', {
- header: () => (
- <div
- className="flex h-full w-full items-center"
- data-testid="users-table-header-last_name"
- >
- <span data-testid="users-table-header-last_name-text">{t('fields.lastName')}</span>
- </div>
- ),
- cell: ({ row }) => {
- return (
- <div className="flex size-full items-center overflow-hidden">
- <span
- className="truncate"
- data-testid={`users-table-cell-${row.index}-last_name-value`}
- >
- {row.original.last_name || '-'}
- </span>
- </div>
- );
- }
- }),
- columnHelper.accessor('created_at', {
- header: () => (
- <div
- className="flex h-full w-full items-center"
- data-testid="users-table-header-created_at"
- >
- <span data-testid="users-table-header-created_at-text">{t('fields.createdAt')}</span>
- </div>
- ),
- cell: ({ getValue, row }) => {
- const date = getValue();
- return (
- <DateCell
- date={date ? new Date(date) : null}
- data-testid={`users-table-cell-${row.index}-created_at-value`}
- />
- );
- }
- }),
- columnHelper.accessor('updated_at', {
- header: () => (
- <div
- className="flex h-full w-full items-center"
- data-testid="users-table-header-updated_at"
- >
- <span data-testid="users-table-header-updated_at-text">{t('fields.updatedAt')}</span>
- </div>
- ),
- cell: ({ getValue, row }) => {
- const date = getValue();
- return (
- <DateCell
- date={date ? new Date(date) : null}
- data-testid={`users-table-cell-${row.index}-updated_at-value`}
- />
- );
- }
- }),
- columnHelper.display({
- id: 'actions',
- header: () => (
- <div
- className="flex h-full w-full items-center"
- data-testid="users-table-header-actions"
- >
- <span data-testid="users-table-header-actions-text"></span>
- </div>
- ),
- cell: ({ row }) => {
- return (
- <UserActions
- user={row.original}
- index={row.index}
- />
- );
- }
- })
- ],
- [t, navigate]
- );
-};
-
-const UserActions = ({ user, index }: { user: HttpTypes.AdminUser; index: number }) => {
- const { t } = useTranslation();
- const navigate = useNavigate();
-
- return (
- <ActionMenu
- groups={[
- {
- actions: [
- {
- icon: <PencilSquare />,
- label: t('actions.edit'),
- onClick: () => {
- navigate(`${user.id}/edit`);
- }
- }
- ]
- }
- ]}
- data-testid={`user-actions-${index}`}
- />
- );
-};
+ )
+}
diff --git a/packages/admin/src/pages/users/user-list/user-list.tsx b/packages/admin/src/pages/users/user-list/user-list.tsx
index c0b673304..94f23e8fa 100644
--- a/packages/admin/src/pages/users/user-list/user-list.tsx
+++ b/packages/admin/src/pages/users/user-list/user-list.tsx
@@ -1,10 +1,26 @@
+import { Children, ReactNode } from "react"
+
import { SingleColumnPage } from "../../../components/layout/pages"
-import { UserListTable } from "./components/user-list-table"
+import {
+ UserListTable,
+ UserListDataTable,
+ UserListHeader,
+ UserListActions,
+ UserListTitle,
+} from "./components/user-list-table"
-export const UserList = () => {
+const Root = ({ children }: { children?: ReactNode }) => {
return (
<SingleColumnPage>
- <UserListTable />
+ {Children.count(children) > 0 ? children : <UserListTable />}
</SingleColumnPage>
)
}
+
+export const UserList = Object.assign(Root, {
+ Table: UserListTable,
+ Header: UserListHeader,
+ HeaderTitle: UserListTitle,
+ HeaderActions: UserListActions,
+ DataTable: UserListDataTable,
+})
diff --git a/packages/vendor/src/pages/reservations/index.tsx b/packages/vendor/src/pages/reservations/index.tsx
index 747472267..375cd25bd 100644
--- a/packages/vendor/src/pages/reservations/index.tsx
+++ b/packages/vendor/src/pages/reservations/index.tsx
@@ -1,19 +1,11 @@
// Route: /reservations
-import { SingleColumnPage } from "@components/layout/pages"
-import { useDashboardExtension } from "@/extensions"
-import { ReservationListTable } from "./_components/reservation-list-table"
+import { SingleColumnPage } from "@components/layout/pages";
+import { ReservationListTable } from "./_components/reservation-list-table";
export const Component = () => {
- const { getWidgets } = useDashboardExtension()
-
return (
- <SingleColumnPage
- widgets={{
- before: getWidgets("reservation.list.before"),
- after: getWidgets("reservation.list.after"),
- }}
- >
+ <SingleColumnPage>
<ReservationListTable />
</SingleColumnPage>
- )
-}
+ );
+};