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.

fix: add typed sellerCreated hook, VendorProduct type, and fix vendor table type imports

vholike503897a6839
diff --git a/packages/core-plugin/src/workflows/seller/workflows/create-seller.ts b/packages/core-plugin/src/workflows/seller/workflows/create-seller.ts
index 5c00015c8..47ec09da3 100644
--- a/packages/core-plugin/src/workflows/seller/workflows/create-seller.ts
+++ b/packages/core-plugin/src/workflows/seller/workflows/create-seller.ts
@@ -2,9 +2,10 @@ import {
WorkflowResponse,
createHook,
createWorkflow,
+ Hook
} from "@medusajs/framework/workflows-sdk"
import { setAuthAppMetadataStep } from "@medusajs/medusa/core-flows"
-import { CreateSellerDTO } from "@mercurjs/types"
+import { CreateSellerDTO, SellerDTO } from "@mercurjs/types"
import { createSellerStep } from "../steps"
@@ -13,7 +14,7 @@ type CreateSellerWorkflowInput = {
auth_identity_id: string
}
-export const createSellerWorkflow = createWorkflow(
+export const createSellerWorkflow = createWorkflow<CreateSellerWorkflowInput, SellerDTO, [Hook<"sellerCreated", { seller: SellerDTO }, unknown>]>(
"create-seller",
function (input: CreateSellerWorkflowInput) {
const seller = createSellerStep(input.seller)
diff --git a/packages/types/src/http/product.ts b/packages/types/src/http/product.ts
index e9eb959e7..8419faea4 100644
--- a/packages/types/src/http/product.ts
+++ b/packages/types/src/http/product.ts
@@ -2,6 +2,7 @@ import {
PaginatedResponse,
ProductDTO,
ProductVariantDTO,
+ SalesChannelDTO,
} from "@medusajs/types"
export interface VendorProductResponse {
@@ -46,3 +47,7 @@ export interface VendorDeleteResponse {
*/
deleted: boolean
}
+
+export interface VendorProduct extends ProductDTO {
+ sales_channels?: SalesChannelDTO[];
+}
\ No newline at end of file
diff --git a/packages/vendor/src/components/table/table-cells/product/collection-cell/collection-cell.tsx b/packages/vendor/src/components/table/table-cells/product/collection-cell/collection-cell.tsx
index bb316c8b3..183dd4cee 100644
--- a/packages/vendor/src/components/table/table-cells/product/collection-cell/collection-cell.tsx
+++ b/packages/vendor/src/components/table/table-cells/product/collection-cell/collection-cell.tsx
@@ -1,30 +1,30 @@
-import { useTranslation } from "react-i18next"
+import { useTranslation } from "react-i18next";
-import { PlaceholderCell } from "../../common/placeholder-cell"
-import { HttpTypes } from "@medusajs/types"
+import { PlaceholderCell } from "../../common/placeholder-cell";
+import { HttpTypes } from "@mercurjs/types";
type CollectionCellProps = {
- collection?: HttpTypes.AdminCollection | null
-}
+ collection?: HttpTypes.VendorCollectionResponse["collection"] | null;
+};
export const CollectionCell = ({ collection }: CollectionCellProps) => {
if (!collection) {
- return <PlaceholderCell />
+ return <PlaceholderCell />;
}
return (
<div className="flex h-full w-full items-center overflow-hidden">
<span className="truncate">{collection.title}</span>
</div>
- )
-}
+ );
+};
export const CollectionHeader = () => {
- const { t } = useTranslation()
+ const { t } = useTranslation();
return (
<div className="flex h-full w-full items-center">
<span>{t("fields.collection")}</span>
</div>
- )
-}
+ );
+};
diff --git a/packages/vendor/src/hooks/table/columns/use-collection-table-columns.tsx b/packages/vendor/src/hooks/table/columns/use-collection-table-columns.tsx
index cbe46d582..c4876e27d 100644
--- a/packages/vendor/src/hooks/table/columns/use-collection-table-columns.tsx
+++ b/packages/vendor/src/hooks/table/columns/use-collection-table-columns.tsx
@@ -1,13 +1,14 @@
-import { HttpTypes } from "@medusajs/types"
-import { createColumnHelper } from "@tanstack/react-table"
-import { useMemo } from "react"
-import { useTranslation } from "react-i18next"
-import { TextCell } from "../../../components/table/table-cells/common/text-cell"
+import { createColumnHelper } from "@tanstack/react-table";
+import { useMemo } from "react";
+import { useTranslation } from "react-i18next";
+import { TextCell } from "../../../components/table/table-cells/common/text-cell";
+import { HttpTypes } from "@mercurjs/types";
-const columnHelper = createColumnHelper<HttpTypes.AdminCollection>()
+const columnHelper =
+ createColumnHelper<HttpTypes.VendorCollectionResponse["collection"]>();
export const useCollectionTableColumns = () => {
- const { t } = useTranslation()
+ const { t } = useTranslation();
return useMemo(
() => [
@@ -22,12 +23,12 @@ export const useCollectionTableColumns = () => {
columnHelper.accessor("products", {
header: t("fields.products"),
cell: ({ getValue }) => {
- const count = getValue()?.length || undefined
+ const count = getValue()?.length || undefined;
- return <TextCell text={count} />
+ return <TextCell text={count} />;
},
}),
],
- [t]
- )
-}
+ [t],
+ );
+};
diff --git a/packages/vendor/src/hooks/table/columns/use-product-table-columns.tsx b/packages/vendor/src/hooks/table/columns/use-product-table-columns.tsx
index 4fa85c428..9eb0ce866 100644
--- a/packages/vendor/src/hooks/table/columns/use-product-table-columns.tsx
+++ b/packages/vendor/src/hooks/table/columns/use-product-table-columns.tsx
@@ -1,29 +1,29 @@
-import { createColumnHelper } from "@tanstack/react-table"
-import { useMemo } from "react"
+import { createColumnHelper } from "@tanstack/react-table";
+import { useMemo } from "react";
import {
CollectionCell,
CollectionHeader,
-} from "../../../components/table/table-cells/product/collection-cell/collection-cell"
+} from "../../../components/table/table-cells/product/collection-cell/collection-cell";
import {
ProductCell,
ProductHeader,
-} from "../../../components/table/table-cells/product/product-cell"
+} from "../../../components/table/table-cells/product/product-cell";
import {
ProductStatusCell,
ProductStatusHeader,
-} from "../../../components/table/table-cells/product/product-status-cell"
+} from "../../../components/table/table-cells/product/product-status-cell";
import {
SalesChannelHeader,
SalesChannelsCell,
-} from "../../../components/table/table-cells/product/sales-channels-cell"
+} from "../../../components/table/table-cells/product/sales-channels-cell";
import {
VariantCell,
VariantHeader,
-} from "../../../components/table/table-cells/product/variant-cell"
-import { HttpTypes } from "@medusajs/types"
+} from "../../../components/table/table-cells/product/variant-cell";
+import { HttpTypes } from "@mercurjs/types";
-const columnHelper = createColumnHelper<HttpTypes.AdminProduct>()
+const columnHelper = createColumnHelper<HttpTypes.VendorProduct>();
export const useProductTableColumns = () => {
return useMemo(
@@ -54,6 +54,6 @@ export const useProductTableColumns = () => {
cell: ({ row }) => <ProductStatusCell status={row.original.status} />,
}),
],
- []
- )
-}
+ [],
+ );
+};