The complete open source platform to run your entire marketplace. Storefront, vendor panel, admin console, and integrations in one enterprise-grade platform you own.
TypeScript b2b-marketplacecomposable-commerceecommerceenterpriseheadless-commercemarketplacemedusamedusajsmulti-vendortypescript
fix(vendor): comment out customer group references in customers and price list config
vholik0d58206f448e
diff --git a/packages/vendor/src/pages/customers/[id]/index.tsx b/packages/vendor/src/pages/customers/[id]/index.tsxindex f7fef739a..c6d1c36b4 100644--- a/packages/vendor/src/pages/customers/[id]/index.tsx+++ b/packages/vendor/src/pages/customers/[id]/index.tsx@@ -1,18 +1,22 @@// Route: /customers/:id-import { HttpTypes } from "@medusajs/types"-import { UIMatch, useLoaderData, useParams, LoaderFunctionArgs } from "react-router-dom"+import { HttpTypes } from "@medusajs/types";+import {+ UIMatch,+ useLoaderData,+ useParams,+ LoaderFunctionArgs,+} from "react-router-dom";-import { SingleColumnPageSkeleton } from "@components/common/skeleton"-import { SingleColumnPage } from "@components/layout/pages"-import { useDashboardExtension } from "@/extensions"-import { useCustomer } from "@hooks/api/customers"-import { productsQueryKeys } from "@hooks/api/products"-import { fetchQuery } from "@lib/client"-import { queryClient } from "@lib/query-client"+import { SingleColumnPageSkeleton } from "@components/common/skeleton";+import { SingleColumnPage } from "@components/layout/pages";+import { useDashboardExtension } from "@/extensions";+import { useCustomer } from "@hooks/api/customers";+import { productsQueryKeys } from "@hooks/api/products";+import { fetchQuery } from "@lib/client";+import { queryClient } from "@lib/query-client";-import { CustomerGeneralSection } from "./_components/customer-general-section"-import { CustomerGroupSection } from "./_components/customer-group-section"-import { CustomerOrderSection } from "./_components/customer-order-section"+import { CustomerGeneralSection } from "./_components/customer-general-section";+import { CustomerOrderSection } from "./_components/customer-order-section";// Loaderconst customerDetailQuery = (id: string) => ({@@ -22,49 +26,52 @@ const customerDetailQuery = (id: string) => ({method: "GET",query: { fields: "*groups, *groups.customers" },}),-})+});export const loader = async ({ params }: LoaderFunctionArgs) => {- const id = params.id- const query = customerDetailQuery(id!)- return queryClient.ensureQueryData(query)-}+ const id = params.id;+ const query = customerDetailQuery(id!);+ return queryClient.ensureQueryData(query);+};// Breadcrumb-type CustomerDetailBreadcrumbProps = UIMatch<HttpTypes.AdminCustomerResponse>+type CustomerDetailBreadcrumbProps = UIMatch<HttpTypes.AdminCustomerResponse>;export const Breadcrumb = (props: CustomerDetailBreadcrumbProps) => {- const { id } = props.params || {}- const { customer } = useCustomer(id!, undefined, { initialData: props.data, enabled: Boolean(id) })+ const { id } = props.params || {};+ const { customer } = useCustomer(id!, undefined, {+ initialData: props.data,+ enabled: Boolean(id),+ });- if (!customer) return null+ if (!customer) return null;- const name = [customer.first_name, customer.last_name].filter(Boolean).join(" ")- return <span>{name || customer.email}</span>-}+ const name = [customer.first_name, customer.last_name]+ .filter(Boolean)+ .join(" ");+ return <span>{name || customer.email}</span>;+};// Main componentexport const Component = () => {- const { id } = useParams()- const initialData = useLoaderData() as Awaited<ReturnType<typeof loader>>- const { customer, isLoading, isError, error } = useCustomer(id!, { fields: "*groups, *groups.customers" }, { initialData })- const { getWidgets } = useDashboardExtension()+ const { id } = useParams();+ const initialData = useLoaderData() as Awaited<ReturnType<typeof loader>>;+ const { customer, isLoading, isError, error } = useCustomer(+ id!,+ {},+ { initialData },+ );- if (isLoading || !customer) return <SingleColumnPageSkeleton sections={2} />- if (isError) throw error+ if (isLoading || !customer) return <SingleColumnPageSkeleton sections={2} />;+ if (isError) throw error;return (- <SingleColumnPage- widgets={{- before: getWidgets("customer.details.before"),- after: getWidgets("customer.details.after"),- }}- data={customer}- hasOutlet- >+ <SingleColumnPage data={customer} hasOutlet><CustomerGeneralSection customer={customer} /><CustomerOrderSection customer={customer} />+ {/* TODO: Customer groups - vendor API does not support customer groups yet<CustomerGroupSection customer={customer} />+ */}</SingleColumnPage>- )-}+ );+};diff --git a/packages/vendor/src/pages/customers/_components/customer-list-table/customer-list-table.tsx b/packages/vendor/src/pages/customers/_components/customer-list-table/customer-list-table.tsxindex 741d573b2..c3562a6a0 100644--- a/packages/vendor/src/pages/customers/_components/customer-list-table/customer-list-table.tsx+++ b/packages/vendor/src/pages/customers/_components/customer-list-table/customer-list-table.tsx@@ -1,23 +1,23 @@-import { Container, Heading } from "@medusajs/ui"-import { keepPreviousData } from "@tanstack/react-query"-import { useMemo } from "react"-import { useTranslation } from "react-i18next"+import { Container, Heading } from "@medusajs/ui";+import { keepPreviousData } from "@tanstack/react-query";+import { useMemo } from "react";+import { useTranslation } from "react-i18next";-import { _DataTable } from "@components/table/data-table"-import { useCustomers } from "@hooks/api/customers"-import { useCustomerTableColumns } from "@hooks/table/columns/use-customer-table-columns"-import { useCustomerTableFilters } from "@hooks/table/filters/use-customer-table-filters"-import { useCustomerTableQuery } from "@hooks/table/query/use-customer-table-query"-import { useDataTable } from "@hooks/use-data-table"+import { _DataTable } from "@components/table/data-table";+import { useCustomers } from "@hooks/api/customers";+import { useCustomerTableColumns } from "@hooks/table/columns/use-customer-table-columns";+import { useCustomerTableFilters } from "@hooks/table/filters/use-customer-table-filters";+import { useCustomerTableQuery } from "@hooks/table/query/use-customer-table-query";+import { useDataTable } from "@hooks/use-data-table";-const PAGE_SIZE = 20+const PAGE_SIZE = 20;export const CustomerListTable = () => {- const { t } = useTranslation()+ const { t } = useTranslation();const { searchParams, raw } = useCustomerTableQuery({pageSize: PAGE_SIZE,- })+ });const { customers, count, isLoading, isError, error } = useCustomers({@@ -28,15 +28,15 @@ export const CustomerListTable = () => {placeholderData: keepPreviousData,},{- groups: searchParams.groups,+ // groups: searchParams.groups,has_account: searchParams.has_account,order: searchParams.order,q: searchParams.q,- }- )+ },+ );- const filters = useCustomerTableFilters()- const columns = useColumns()+ const filters = useCustomerTableFilters();+ const columns = useColumns();const { table } = useDataTable({data: customers ?? [],@@ -45,10 +45,10 @@ export const CustomerListTable = () => {enablePagination: true,getRowId: (row) => row.id,pageSize: PAGE_SIZE,- })+ });if (isError) {- throw error+ throw error;}return (@@ -91,11 +91,11 @@ export const CustomerListTable = () => {}}/></Container>- )-}+ );+};const useColumns = () => {- const columns = useCustomerTableColumns()+ const columns = useCustomerTableColumns();- return useMemo(() => [...columns], [columns])-}+ return useMemo(() => [...columns], [columns]);+};diff --git a/packages/vendor/src/pages/customers/index.tsx b/packages/vendor/src/pages/customers/index.tsxindex c09859adc..c80a784e0 100644--- a/packages/vendor/src/pages/customers/index.tsx+++ b/packages/vendor/src/pages/customers/index.tsx@@ -1,19 +1,11 @@// Route: /customers-import { SingleColumnPage } from "@components/layout/pages"-import { useDashboardExtension } from "@/extensions"-import { CustomerListTable } from "./_components/customer-list-table"+import { SingleColumnPage } from "@components/layout/pages";+import { CustomerListTable } from "./_components/customer-list-table";export const Component = () => {- const { getWidgets } = useDashboardExtension()-return (- <SingleColumnPage- widgets={{- after: getWidgets("customer.list.after"),- before: getWidgets("customer.list.before"),- }}- >+ <SingleColumnPage><CustomerListTable /></SingleColumnPage>- )-}+ );+};diff --git a/packages/vendor/src/pages/price-lists/[id]/configuration/index.tsx b/packages/vendor/src/pages/price-lists/[id]/configuration/index.tsxindex 81bba2c07..aea5e8a69 100644--- a/packages/vendor/src/pages/price-lists/[id]/configuration/index.tsx+++ b/packages/vendor/src/pages/price-lists/[id]/configuration/index.tsx@@ -1,51 +1,50 @@-// Route: /price-lists/:id/configuration-import { Heading } from "@medusajs/ui"-import { useTranslation } from "react-i18next"-import { useParams } from "react-router-dom"-import { RouteDrawer } from "@components/modals"-import { useCustomerGroups } from "@hooks/api/customer-groups"-import { usePriceList } from "@hooks/api/price-lists"-import { PriceListConfigurationForm } from "./price-list-configuration-form"+import { Heading } from "@medusajs/ui";+import { useTranslation } from "react-i18next";+import { useParams } from "react-router-dom";+import { RouteDrawer } from "@components/modals";+// import { useCustomerGroups } from "@hooks/api/customer-groups";+import { usePriceList } from "@hooks/api/price-lists";+import { PriceListConfigurationForm } from "./price-list-configuration-form";export const Component = () => {- const { t } = useTranslation()- const { id } = useParams()+ const { t } = useTranslation();+ const { id } = useParams();- const { price_list, isPending, isError, error } = usePriceList(id!)+ const { price_list, isPending, isError, error } = usePriceList(id!);- const customerGroupIds =- price_list?.price_list_rules?.find(- (rule: any) => rule.attribute === "customer.groups.id"- )?.value || ([] as string[])+ // const customerGroupIds =+ // price_list?.price_list_rules?.find(+ // (rule: any) => rule.attribute === "customer.groups.id",+ // )?.value || ([] as string[]);- const {- customer_groups: customerGroupsData,- isPending: isCustomerGroupsPending,- isError: isCustomerGroupsError,- error: customerGroupsError,- } = useCustomerGroups(undefined, { enabled: !!customerGroupIds?.length })+ // const {+ // customer_groups: customerGroupsData,+ // isPending: isCustomerGroupsPending,+ // isError: isCustomerGroupsError,+ // error: customerGroupsError,+ // } = useCustomerGroups(undefined, { enabled: !!customerGroupIds?.length })- const customerGroups = customerGroupsData?.map((item) => item.customer_group)+ // const customerGroups = customerGroupsData?.map((item) => item.customer_group)- const initialCustomerGroups = (customerGroups || []).filter((group) =>- customerGroupIds.includes(group.id)- )+ // const initialCustomerGroups = (customerGroups || []).filter((group) =>+ // customerGroupIds.includes(group.id)+ // )- const isCustomerGroupsReady = isPending- ? false- : !!customerGroupIds?.length && isCustomerGroupsPending- ? false- : true+ // const isCustomerGroupsReady = isPending+ // ? false+ // : !!customerGroupIds?.length && isCustomerGroupsPending+ // ? false+ // : true- const ready = !isPending && !!price_list && isCustomerGroupsReady+ const ready = !isPending && !!price_list; // && isCustomerGroupsReadyif (isError) {- throw error+ throw error;}- if (isCustomerGroupsError) {- throw customerGroupsError- }+ // if (isCustomerGroupsError) {+ // throw customerGroupsError;+ // }return (<RouteDrawer>@@ -57,12 +56,9 @@ export const Component = () => {{ready && (<PriceListConfigurationFormpriceList={price_list}- customerGroups={initialCustomerGroups.map((group) => ({- id: group.id,- name: group.name || "",- }))}+ customerGroups={[]}/>)}</RouteDrawer>- )-}+ );+};