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.

chore: v2.0.0-canary.53

vholik59fbcc583a27
diff --git a/apps/admin-test/src/hooks/api/requests.tsx b/apps/admin-test/src/hooks/api/requests.tsx
new file mode 100644
index 000000000..16fd5409e
--- /dev/null
+++ b/apps/admin-test/src/hooks/api/requests.tsx
@@ -0,0 +1,129 @@
+import {
+ useQuery,
+ useMutation,
+ useQueryClient,
+ UseQueryOptions,
+ UseMutationOptions,
+} from "@tanstack/react-query";
+import { queryKeysFactory } from "@mercurjs/dashboard-shared";
+import { client } from "../../lib/client";
+import {
+ ClientError,
+ InferClientInput,
+ InferClientOutput,
+} from "@mercurjs/client";
+
+const REQUESTS_QUERY_KEY = "admin_requests" as const;
+export const requestsQueryKeys = queryKeysFactory(REQUESTS_QUERY_KEY);
+
+export type RequestDTO = InferClientOutput<
+ typeof client.admin.requests.$type.$id.query
+>["request"];
+
+export const useRequests = (
+ type: string,
+ query?: Record<string, any>,
+ options?: Omit<
+ UseQueryOptions<
+ unknown,
+ ClientError,
+ InferClientOutput<typeof client.admin.requests.$type.query>
+ >,
+ "queryKey" | "queryFn"
+ >,
+) => {
+ const { data, ...rest } = useQuery({
+ queryKey: requestsQueryKeys.list({ type, ...query }),
+ queryFn: async () =>
+ client.admin.requests.$type.query({
+ $type: type,
+ ...query,
+ offset: query?.offset ?? 0,
+ limit: query?.limit ?? 20,
+ }),
+ ...options,
+ });
+
+ return { ...data, ...rest };
+};
+
+export const useRequest = (
+ type: string,
+ id: string,
+ query?: Record<string, any>,
+ options?: Omit<
+ UseQueryOptions<
+ unknown,
+ ClientError,
+ InferClientOutput<typeof client.admin.requests.$type.$id.query>
+ >,
+ "queryKey" | "queryFn"
+ >,
+) => {
+ const { data, ...rest } = useQuery({
+ queryKey: requestsQueryKeys.detail(id, { type, ...query }),
+ queryFn: async () =>
+ client.admin.requests.$type.$id.query({
+ $type: type,
+ $id: id,
+ ...query,
+ }),
+ ...options,
+ });
+
+ return { ...data, ...rest };
+};
+
+export const useAcceptRequest = (
+ type: string,
+ id: string,
+ options?: UseMutationOptions<
+ InferClientOutput<typeof client.admin.requests.$type.$id.accept.mutate>,
+ ClientError,
+ { reviewer_note?: string }
+ >,
+) => {
+ const queryClient = useQueryClient();
+
+ return useMutation({
+ mutationFn: async (payload: { reviewer_note?: string }) =>
+ client.admin.requests.$type.$id.accept.mutate({
+ $type: type,
+ $id: id,
+ ...payload,
+ }),
+ onSuccess: (data, variables, context) => {
+ queryClient.invalidateQueries({ queryKey: requestsQueryKeys.detail(id) });
+ queryClient.invalidateQueries({ queryKey: requestsQueryKeys.lists() });
+ options?.onSuccess?.(data, variables, context);
+ },
+ ...options,
+ });
+};
+
+export const useRejectRequest = (
+ type: string,
+ id: string,
+ options?: UseMutationOptions<
+ InferClientOutput<typeof client.admin.requests.$type.$id.reject.mutate>,
+ ClientError,
+ { reviewer_note?: string }
+ >,
+) => {
+ const queryClient = useQueryClient();
+
+ return useMutation({
+ mutationFn: async (payload: { reviewer_note?: string }) =>
+ client.admin.requests.$type.$id.reject.mutate({
+ $type: type,
+ $id: id,
+ ...payload,
+ }),
+ onSuccess: (data, variables, context) => {
+ queryClient.invalidateQueries({ queryKey: requestsQueryKeys.detail(id) });
+ queryClient.invalidateQueries({ queryKey: requestsQueryKeys.lists() });
+ options?.onSuccess?.(data, variables, context);
+ },
+ ...options,
+ });
+};
diff --git a/apps/admin-test/src/hooks/table/columns/use-request-table-columns.tsx b/apps/admin-test/src/hooks/table/columns/use-request-table-columns.tsx
new file mode 100644
index 000000000..792ab8bf1
--- /dev/null
+++ b/apps/admin-test/src/hooks/table/columns/use-request-table-columns.tsx
@@ -0,0 +1,66 @@
+import { createColumnHelper } from "@tanstack/react-table";
+import { useMemo } from "react";
+import { useTranslation } from "react-i18next";
+import { StatusBadge, Text } from "@medusajs/ui";
+import { DateCell, DateHeader } from "@mercurjs/dashboard-shared";
+import { RequestDTO } from "../../api/requests";
+
+const columnHelper = createColumnHelper<RequestDTO>();
+
+const statusColor = (status: string) => {
+ switch (status) {
+ case "accepted":
+ return "green" as const;
+ case "pending":
+ return "orange" as const;
+ case "rejected":
+ return "red" as const;
+ default:
+ return "grey" as const;
+ }
+};
+
+export const useRequestTableColumns = () => {
+ const { t } = useTranslation();
+
+ return useMemo(
+ () => [
+ columnHelper.accessor("id", {
+ header: () => (
+ <div className="flex h-full w-full items-center">
+ <span className="truncate">ID</span>
+ </div>
+ ),
+ cell: ({ getValue }) => (
+ <Text size="small" leading="compact" className="text-ui-fg-subtle">
+ {getValue()}
+ </Text>
+ ),
+ }),
+ columnHelper.accessor("custom_fields", {
+ header: () => (
+ <div className="flex h-full w-full items-center">
+ <span className="truncate">Status</span>
+ </div>
+ ),
+ cell: ({ getValue }) => {
+ const customFields = getValue() as any;
+ const status = customFields?.request_status ?? "draft";
+ return (
+ <StatusBadge color={statusColor(status)}>
+ {status.charAt(0).toUpperCase() + status.slice(1)}
+ </StatusBadge>
+ );
+ },
+ }),
+ columnHelper.accessor("created_at", {
+ header: () => <DateHeader />,
+ cell: ({ getValue }) => {
+ const date = new Date(getValue() as string);
+ return <DateCell date={date} />;
+ },
+ }),
+ ],
+ [t],
+ );
+};
diff --git a/apps/admin-test/src/hooks/table/filters/use-request-table-filters.tsx b/apps/admin-test/src/hooks/table/filters/use-request-table-filters.tsx
new file mode 100644
index 000000000..d76c937b7
--- /dev/null
+++ b/apps/admin-test/src/hooks/table/filters/use-request-table-filters.tsx
@@ -0,0 +1,38 @@
+import { useTranslation } from "react-i18next";
+import { useMemo } from "react";
+
+import type { Filter } from "@mercurjs/dashboard-shared";
+
+export const useRequestTableFilters = (): Filter[] => {
+ const { t } = useTranslation();
+
+ return useMemo(() => {
+ const filters: Filter[] = [
+ {
+ key: "request_status",
+ label: "Status",
+ type: "select",
+ multiple: true,
+ options: [
+ { label: "Draft", value: "draft" },
+ { label: "Pending", value: "pending" },
+ { label: "Accepted", value: "accepted" },
+ { label: "Rejected", value: "rejected" },
+ ],
+ },
+ ];
+
+ const dateFilters: Filter[] = [
+ { label: t("fields.createdAt"), key: "created_at" },
+ { label: t("fields.updatedAt"), key: "updated_at" },
+ ].map((f) => ({
+ key: f.key,
+ label: f.label,
+ type: "date" as const,
+ }));
+
+ filters.push(...dateFilters);
+
+ return filters;
+ }, [t]);
+};
diff --git a/apps/admin-test/src/hooks/table/query/use-request-table-query.tsx b/apps/admin-test/src/hooks/table/query/use-request-table-query.tsx
new file mode 100644
index 000000000..ff23d4393
--- /dev/null
+++ b/apps/admin-test/src/hooks/table/query/use-request-table-query.tsx
@@ -0,0 +1,33 @@
+import { useQueryParams } from "@mercurjs/dashboard-shared";
+
+type UseRequestTableQueryProps = {
+ prefix?: string;
+ pageSize?: number;
+};
+
+export const useRequestTableQuery = ({
+ prefix,
+ pageSize = 20,
+}: UseRequestTableQueryProps) => {
+ const queryObject = useQueryParams(
+ ["offset", "q", "created_at", "updated_at", "order", "request_status"],
+ prefix,
+ );
+
+ const { offset, created_at, updated_at, q, order, request_status } = queryObject;
+
+ const searchParams: Record<string, any> = {
+ limit: pageSize,
+ offset: offset ? Number(offset) : 0,
+ created_at: created_at ? JSON.parse(created_at) : undefined,
+ updated_at: updated_at ? JSON.parse(updated_at) : undefined,
+ order: order ? order : "-created_at",
+ request_status: request_status || undefined,
+ q,
+ };
+
+ return {
+ searchParams,
+ raw: queryObject,
+ };
+};
diff --git a/apps/admin-test/src/pages/requests/categories/page.tsx b/apps/admin-test/src/pages/requests/categories/page.tsx
new file mode 100644
index 000000000..8b8b3d48c
--- /dev/null
+++ b/apps/admin-test/src/pages/requests/categories/page.tsx
@@ -0,0 +1,73 @@
+import { useTranslation } from "react-i18next";
+import { keepPreviousData } from "@tanstack/react-query";
+import { Container, Heading } from "@medusajs/ui";
+import type { RouteConfig } from "@mercurjs/dashboard-sdk";
+
+export const config: RouteConfig = {
+ label: "Categories",
+ nested: "/requests",
+};
+
+import { useRequests } from "../../../hooks/api/requests";
+import { useRequestTableColumns } from "../../../hooks/table/columns/use-request-table-columns";
+import { useRequestTableQuery } from "../../../hooks/table/query/use-request-table-query";
+import { useRequestTableFilters } from "../../../hooks/table/filters/use-request-table-filters";
+import {
+ _DataTable,
+ SingleColumnPage,
+ useDataTable,
+} from "@mercurjs/dashboard-shared";
+
+const PAGE_SIZE = 10;
+
+const CategoryRequestsPage = () => {
+ const { t } = useTranslation();
+ const { raw, searchParams } = useRequestTableQuery({ pageSize: PAGE_SIZE });
+
+ const { requests, count, isError, error, isLoading } = useRequests(
+ "product_category",
+ searchParams,
+ { placeholderData: keepPreviousData },
+ );
+
+ const columns = useRequestTableColumns();
+ const filters = useRequestTableFilters();
+
+ const { table } = useDataTable({
+ data: requests ?? [],
+ columns,
+ enablePagination: true,
+ count: count,
+ pageSize: PAGE_SIZE,
+ });
+
+ if (isError) throw error;
+
+ return (
+ <SingleColumnPage>
+ <Container className="divide-y p-0">
+ <div className="flex items-center justify-between px-6 py-4">
+ <Heading>Category Requests</Heading>
+ </div>
+ <_DataTable
+ columns={columns}
+ table={table}
+ pagination
+ filters={filters}
+ navigateTo={(row) => `/requests/product_category/${row.original.id}`}
+ count={count}
+ isLoading={isLoading}
+ pageSize={PAGE_SIZE}
+ orderBy={[
+ { key: "created_at", label: t("fields.createdAt") },
+ { key: "updated_at", label: t("fields.updatedAt") },
+ ]}
+ queryObject={raw}
+ noRecords={{ message: "No category requests found" }}
+ />
+ </Container>
+ </SingleColumnPage>
+ );
+};
+
+export default CategoryRequestsPage;
diff --git a/apps/admin-test/src/pages/requests/collections/page.tsx b/apps/admin-test/src/pages/requests/collections/page.tsx
new file mode 100644
index 000000000..f503dc340
--- /dev/null
+++ b/apps/admin-test/src/pages/requests/collections/page.tsx
@@ -0,0 +1,73 @@
+import { useTranslation } from "react-i18next";
+import { keepPreviousData } from "@tanstack/react-query";
+import { Container, Heading } from "@medusajs/ui";
+import type { RouteConfig } from "@mercurjs/dashboard-sdk";
+
+export const config: RouteConfig = {
+ label: "Collections",
+ nested: "/requests",
+};
+
+import { useRequests } from "../../../hooks/api/requests";
+import { useRequestTableColumns } from "../../../hooks/table/columns/use-request-table-columns";
+import { useRequestTableQuery } from "../../../hooks/table/query/use-request-table-query";
+import { useRequestTableFilters } from "../../../hooks/table/filters/use-request-table-filters";
+import {
+ _DataTable,
+ SingleColumnPage,
+ useDataTable,
+} from "@mercurjs/dashboard-shared";
+
+const PAGE_SIZE = 10;
+
+const CollectionRequestsPage = () => {
+ const { t } = useTranslation();
+ const { raw, searchParams } = useRequestTableQuery({ pageSize: PAGE_SIZE });
+
+ const { requests, count, isError, error, isLoading } = useRequests(
+ "product_collection",
+ searchParams,
+ { placeholderData: keepPreviousData },
+ );
+
+ const columns = useRequestTableColumns();
+ const filters = useRequestTableFilters();
+
+ const { table } = useDataTable({
+ data: requests ?? [],
+ columns,
+ enablePagination: true,
+ count: count,
+ pageSize: PAGE_SIZE,
+ });
+
+ if (isError) throw error;
+
+ return (
+ <SingleColumnPage>
+ <Container className="divide-y p-0">
+ <div className="flex items-center justify-between px-6 py-4">
+ <Heading>Collection Requests</Heading>
+ </div>
+ <_DataTable
+ columns={columns}
+ table={table}
+ pagination
+ filters={filters}
+ navigateTo={(row) => `/requests/product_collection/${row.original.id}`}
+ count={count}
+ isLoading={isLoading}
+ pageSize={PAGE_SIZE}
+ orderBy={[
+ { key: "created_at", label: t("fields.createdAt") },
+ { key: "updated_at", label: t("fields.updatedAt") },
+ ]}
+ queryObject={raw}
+ noRecords={{ message: "No collection requests found" }}
+ />
+ </Container>
+ </SingleColumnPage>
+ );
+};
+
+export default CollectionRequestsPage;
diff --git a/apps/admin-test/src/pages/requests/page.tsx b/apps/admin-test/src/pages/requests/page.tsx
new file mode 100644
index 000000000..370125356
--- /dev/null
+++ b/apps/admin-test/src/pages/requests/page.tsx
@@ -0,0 +1,14 @@
+import { Navigate } from "react-router-dom";
+import type { RouteConfig } from "@mercurjs/dashboard-sdk";
+import { InboxSolid } from "@medusajs/icons";
+
+export const config: RouteConfig = {
+ label: "Requests",
+ icon: InboxSolid,
+};
+
+const RequestsPage = () => {
+ return <Navigate to="/requests/categories" replace />;
+};
+
+export default RequestsPage;
diff --git a/apps/admin-test/src/pages/requests/tags/page.tsx b/apps/admin-test/src/pages/requests/tags/page.tsx
new file mode 100644
index 000000000..ce3d07702
--- /dev/null
+++ b/apps/admin-test/src/pages/requests/tags/page.tsx
@@ -0,0 +1,73 @@
+import { useTranslation } from "react-i18next";
+import { keepPreviousData } from "@tanstack/react-query";
+import { Container, Heading } from "@medusajs/ui";
+import type { RouteConfig } from "@mercurjs/dashboard-sdk";
+
+export const config: RouteConfig = {
+ label: "Tags",
+ nested: "/requests",
+};
+
+import { useRequests } from "../../../hooks/api/requests";
+import { useRequestTableColumns } from "../../../hooks/table/columns/use-request-table-columns";
+import { useRequestTableQuery } from "../../../hooks/table/query/use-request-table-query";
+import { useRequestTableFilters } from "../../../hooks/table/filters/use-request-table-filters";
+import {
+ _DataTable,
+ SingleColumnPage,
+ useDataTable,
+} from "@mercurjs/dashboard-shared";
+
+const PAGE_SIZE = 10;
+
+const TagRequestsPage = () => {
+ const { t } = useTranslation();
+ const { raw, searchParams } = useRequestTableQuery({ pageSize: PAGE_SIZE });
+
+ const { requests, count, isError, error, isLoading } = useRequests(
+ "product_tag",
+ searchParams,
+ { placeholderData: keepPreviousData },
+ );
+
+ const columns = useRequestTableColumns();
+ const filters = useRequestTableFilters();
+
+ const { table } = useDataTable({
+ data: requests ?? [],
+ columns,
+ enablePagination: true,
+ count: count,
+ pageSize: PAGE_SIZE,
+ });
+
+ if (isError) throw error;
+
+ return (
+ <SingleColumnPage>
+ <Container className="divide-y p-0">
+ <div className="flex items-center justify-between px-6 py-4">
+ <Heading>Tag Requests</Heading>
+ </div>
+ <_DataTable
+ columns={columns}
+ table={table}
+ pagination
+ filters={filters}
+ navigateTo={(row) => `/requests/product_tag/${row.original.id}`}
+ count={count}
+ isLoading={isLoading}
+ pageSize={PAGE_SIZE}
+ orderBy={[
+ { key: "created_at", label: t("fields.createdAt") },
+ { key: "updated_at", label: t("fields.updatedAt") },
+ ]}
+ queryObject={raw}
+ noRecords={{ message: "No tag requests found" }}
+ />
+ </Container>
+ </SingleColumnPage>
+ );
+};
+
+export default TagRequestsPage;
diff --git a/apps/admin-test/src/pages/requests/types/page.tsx b/apps/admin-test/src/pages/requests/types/page.tsx
new file mode 100644
index 000000000..1965e491d
--- /dev/null
+++ b/apps/admin-test/src/pages/requests/types/page.tsx
@@ -0,0 +1,73 @@
+import { useTranslation } from "react-i18next";
+import { keepPreviousData } from "@tanstack/react-query";
+import { Container, Heading } from "@medusajs/ui";
+import type { RouteConfig } from "@mercurjs/dashboard-sdk";
+
+export const config: RouteConfig = {
+ label: "Types",
+ nested: "/requests",
+};
+
+import { useRequests } from "../../../hooks/api/requests";
+import { useRequestTableColumns } from "../../../hooks/table/columns/use-request-table-columns";
+import { useRequestTableQuery } from "../../../hooks/table/query/use-request-table-query";
+import { useRequestTableFilters } from "../../../hooks/table/filters/use-request-table-filters";
+import {
+ _DataTable,
+ SingleColumnPage,
+ useDataTable,
+} from "@mercurjs/dashboard-shared";
+
+const PAGE_SIZE = 10;
+
+const TypeRequestsPage = () => {
+ const { t } = useTranslation();
+ const { raw, searchParams } = useRequestTableQuery({ pageSize: PAGE_SIZE });
+
+ const { requests, count, isError, error, isLoading } = useRequests(
+ "product_type",
+ searchParams,
+ { placeholderData: keepPreviousData },
+ );
+
+ const columns = useRequestTableColumns();
+ const filters = useRequestTableFilters();
+
+ const { table } = useDataTable({
+ data: requests ?? [],
+ columns,
+ enablePagination: true,
+ count: count,
+ pageSize: PAGE_SIZE,
+ });
+
+ if (isError) throw error;
+
+ return (
+ <SingleColumnPage>
+ <Container className="divide-y p-0">
+ <div className="flex items-center justify-between px-6 py-4">
+ <Heading>Type Requests</Heading>
+ </div>
+ <_DataTable
+ columns={columns}
+ table={table}
+ pagination
+ filters={filters}
+ navigateTo={(row) => `/requests/product_type/${row.original.id}`}
+ count={count}
+ isLoading={isLoading}
+ pageSize={PAGE_SIZE}
+ orderBy={[
+ { key: "created_at", label: t("fields.createdAt") },
+ { key: "updated_at", label: t("fields.updatedAt") },
+ ]}
+ queryObject={raw}
+ noRecords={{ message: "No type requests found" }}
+ />
+ </Container>
+ </SingleColumnPage>
+ );
+};
+
+export default TypeRequestsPage;
diff --git a/apps/vendor-test/.gitignore b/apps/vendor-test/.gitignore
new file mode 100644
index 000000000..a547bf36d
--- /dev/null
+++ b/apps/vendor-test/.gitignore
@@ -0,0 +1,24 @@
+# Logs
+logs
+*.log
+npm-debug.log*
+yarn-debug.log*
+yarn-error.log*
+pnpm-debug.log*
+lerna-debug.log*
+
+node_modules
+dist
+dist-ssr
+*.local
+
+# Editor directories and files
+.vscode/*
+!.vscode/extensions.json
+.idea
+.DS_Store
+*.suo
+*.ntvs*
+*.njsproj
+*.sln
+*.sw?
diff --git a/apps/vendor-test/README.md b/apps/vendor-test/README.md
new file mode 100644
index 000000000..d2e77611f
--- /dev/null
+++ b/apps/vendor-test/README.md
@@ -0,0 +1,73 @@
+# React + TypeScript + Vite
+
+This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
+
+Currently, two official plugins are available:
+
+- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) (or [oxc](https://oxc.rs) when used in [rolldown-vite](https://vite.dev/guide/rolldown)) for Fast Refresh
+- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
+
+## React Compiler
+
+The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation).
+
+## Expanding the ESLint configuration
+
+If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:
+
+```js
+export default defineConfig([
+ globalIgnores(['dist']),
+ {
+ files: ['**/*.{ts,tsx}'],
+ extends: [
+ // Other configs...
+
+ // Remove tseslint.configs.recommended and replace with this
+ tseslint.configs.recommendedTypeChecked,
+ // Alternatively, use this for stricter rules
+ tseslint.configs.strictTypeChecked,
+ // Optionally, add this for stylistic rules
+ tseslint.configs.stylisticTypeChecked,
+
+ // Other configs...
+ ],
+ languageOptions: {
+ parserOptions: {
+ project: ['./tsconfig.node.json', './tsconfig.app.json'],
+ tsconfigRootDir: import.meta.dirname,
+ },
+ // other options...
+ },
+ },
+])
+```
+
+You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules:
+
+```js
+// eslint.config.js
+import reactX from 'eslint-plugin-react-x'
+import reactDom from 'eslint-plugin-react-dom'
+
+export default defineConfig([
+ globalIgnores(['dist']),
+ {
+ files: ['**/*.{ts,tsx}'],
+ extends: [
+ // Other configs...
+ // Enable lint rules for React
+ reactX.configs['recommended-typescript'],
+ // Enable lint rules for React DOM
+ reactDom.configs.recommended,
+ ],
+ languageOptions: {
+ parserOptions: {
+ project: ['./tsconfig.node.json', './tsconfig.app.json'],
+ tsconfigRootDir: import.meta.dirname,
+ },
+ // other options...
+ },
+ },
+])
+```
diff --git a/apps/vendor-test/eslint.config.js b/apps/vendor-test/eslint.config.js
new file mode 100644
index 000000000..97fee7139
--- /dev/null
+++ b/apps/vendor-test/eslint.config.js
@@ -0,0 +1,26 @@
+import js from '@eslint/js'
+import globals from 'globals'
+import reactHooks from 'eslint-plugin-react-hooks'
+import reactRefresh from 'eslint-plugin-react-refresh'
+import tseslint from 'typescript-eslint'
+import { defineConfig, globalIgnores } from 'eslint/config'
+
+export default defineConfig([
+ globalIgnores(['dist']),
+ {
+ files: ['**/*.{ts,tsx}'],
+ extends: [
+ js.configs.recommended,
+ tseslint.configs.recommended,
+ reactHooks.configs.flat.recommended,
+ reactRefresh.configs.vite,
+ ],
+ languageOptions: {
+ ecmaVersion: 2020,
+ globals: globals.browser,
+ parserOptions: {
+ tsconfigRootDir: import.meta.dirname,
+ },
+ },
+ },
+])
diff --git a/apps/vendor-test/index.html b/apps/vendor-test/index.html
new file mode 100644
index 000000000..3eba2070a
--- /dev/null
+++ b/apps/vendor-test/index.html
@@ -0,0 +1,13 @@
+<!doctype html>
+<html lang="en">
+ <head>
+ <meta charset="UTF-8" />
+ <link rel="icon" type="image/svg+xml" href="/public/logo.svg" />
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+ <title>Vendor Hub</title>
+ </head>
+ <body>
+ <div id="root"></div>
+ <script type="module" src="/src/main.tsx"></script>
+ </body>
+</html>
diff --git a/apps/vendor-test/mercur.config.ts b/apps/vendor-test/mercur.config.ts
new file mode 100644
index 000000000..9e3f2a3e9
--- /dev/null
+++ b/apps/vendor-test/mercur.config.ts
@@ -0,0 +1,4 @@
+import { defineConfig } from '@mercurjs/dashboard-sdk'
+
+export default defineConfig({
+})
diff --git a/apps/vendor-test/package.json b/apps/vendor-test/package.json
new file mode 100644
index 000000000..c514d7b4f
--- /dev/null
+++ b/apps/vendor-test/package.json
@@ -0,0 +1,47 @@
+{
+ "name": "@acme/vendor",
+ "private": true,
+ "version": "0.0.0",
+ "type": "module",
+ "scripts": {
+ "dev": "vite --port 7001",
+ "lint": "eslint .",
+ "preview": "vite preview --port 7001"
+ },
+ "dependencies": {
+ "@medusajs/icons": "^2.13.3",
+ "@mercurjs/dashboard-sdk": "*",
+ "@mercurjs/dashboard-shared": "*",
+ "@mercurjs/vendor": "*",
+ "react": "^18.0.0",
+ "react-dom": "^18.0.0",
+ "react-i18next": "13.5.0",
+ "@tanstack/react-query": "5.64.2",
+ "@medusajs/ui": "4.1.1",
+ "react-router-dom": "6.30.3",
+ "@mercurjs/client": "*",
+ "@mercurjs/core-plugin": "*",
+ "@tanstack/react-table": "8.20.5",
+ "react-hook-form": "7.49.1",
+ "@hookform/resolvers": "3.4.2",
+ "jsonwebtoken": "9.0.2",
+ "react-jwt": "^2.0.0",
+ "zod": "3.25.76",
+ "lodash.debounce": "^4.0.8"
+ },
+ "devDependencies": {
+ "@eslint/js": "^9.39.1",
+ "@types/jsonwebtoken": "^9.0.9",
+ "@types/node": "^24.10.1",
+ "@types/react": "^18.2.66",
+ "@types/react-dom": "^18.2.22",
+ "@vitejs/plugin-react": "^4.2.1",
+ "eslint": "^9.39.1",
+ "eslint-plugin-react-hooks": "^7.0.1",
+ "eslint-plugin-react-refresh": "^0.4.24",
+ "globals": "^16.5.0",
+ "typescript": "5.9.3",
+ "typescript-eslint": "^8.46.4",
+ "vite": "^5.4.21"
+ }
+}
\ No newline at end of file
diff --git a/apps/vendor-test/public/logo.svg b/apps/vendor-test/public/logo.svg
new file mode 100644
index 000000000..8c2518166
--- /dev/null
+++ b/apps/vendor-test/public/logo.svg
@@ -0,0 +1,38 @@
+ <svg
+ width='44'
+ height='44'
+ viewBox='0 0 44 44'
+ fill='none'
+ xmlns='http://www.w3.org/2000/svg'
+ >
+ <rect
+ width='44'
+ height='44'
+ rx='10'
+ fill='#FAFAFA'
+ />
+ <g clipPath='url(#clip0_11_175)'>
+ <path
+ d='M8 7V20.7349L19.821 13.8675L8 7Z'
+ fill='#4C24DD'
+ />
+ <path
+ d='M36.0002 37.0001V23.2651L24.1792 30.1326L36.0002 37.0001Z'
+ fill='#4C24DD'
+ />
+ <path
+ d='M8 23.2651V37L36 20.7349V7L8 23.2651Z'
+ fill='#4C24DD'
+ />
+ </g>
+ <defs>
+ <clipPath id='clip0_11_175'>
+ <rect
+ width='28'
+ height='30'
+ fill='white'
+ transform='translate(8 7)'
+ />
+ </clipPath>
+ </defs>
+ </svg>
\ No newline at end of file
diff --git a/apps/vendor-test/src/README.md b/apps/vendor-test/src/README.md
new file mode 100644
index 000000000..1b2697508
--- /dev/null
+++ b/apps/vendor-test/src/README.md
@@ -0,0 +1,130 @@
+# Custom Pages
+
+A custom page lets you add new views to the vendor portal. Pages are automatically discovered using file-based routing powered by the `@mercurjs/dashboard-sdk` Vite plugin.
+
+> Learn more about the dashboard SDK in the [Mercur documentation](https://docs.mercurjs.com).
+
+To create a custom page:
+
+## 1. Create a Page File
+
+Create a `page.tsx` file inside the `src/pages/` directory. The file path determines the URL route.
+
+For example, create the file `src/pages/blog/page.tsx` with the following content:
+
+```tsx
+const BlogPage = () => {
+ return (
+ <div>
+ <h1>Blog Posts</h1>
+ <p>My custom vendor page</p>
+ </div>
+ )
+}
+
+export default BlogPage
+```
+
+This page will be accessible at `/blog` in the vendor portal.
+
+## 2. File-Based Routing
+
+The route is derived from the file path relative to `src/pages/`. Each route must be defined in a file named `page.tsx` (or `.ts`, `.jsx`, `.js`).
+
+| File Path | Route |
+|---|---|
+| `src/pages/page.tsx` | `/` |
+| `src/pages/blog/page.tsx` | `/blog` |
+| `src/pages/blog/[id]/page.tsx` | `/blog/:id` (dynamic) |
+| `src/pages/blog/[[id]]/page.tsx` | `/blog/:id?` (optional dynamic) |
+| `src/pages/blog/[*]/page.tsx` | `/blog/*` (splat/catch-all) |
+| `src/pages/(group)/foo/page.tsx` | `/foo` (route grouping) |
+| `src/pages/dashboard/@sidebar/page.tsx` | Parallel route (nested child) |
+
+## 3. Add a Sidebar Menu Item
+
+To add your page to the sidebar navigation, export a `config` object from the page file:
+
+```tsx
+import { Building } from "lucide-react"
+import type { RouteConfig } from "@mercurjs/dashboard-sdk"
+
+export const config: RouteConfig = {
+ label: "Blog",
+ icon: Building,
+}
+
+const BlogPage = () => {
+ return (
+ <div>
+ <h1>Blog Posts</h1>
+ </div>
+ )
+}
+
+export default BlogPage
+```
+
+### Config Options
+
+| Property | Type | Description |
+|---|---|---|
+| `label` | `string` | **(required)** Display name in the sidebar |
+| `icon` | `ComponentType` | Icon component shown next to the label |
+| `rank` | `number` | Controls ordering in the sidebar |
+| `nested` | `string` | Parent menu item path to nest under |
+| `translationNs` | `string` | i18n translation namespace for the label |
+
+## 4. Add Data Loading
+
+Use React Router's loader pattern to pre-fetch data before the page renders:
+
+```tsx
+import { useLoaderData } from "react-router-dom"
+import type { LoaderFunctionArgs } from "react-router-dom"
+
+export const loader = async ({ params }: LoaderFunctionArgs) => {
+ const response = await fetch(`/api/blog/${params.id}`)
+ return response.json()
+}
+
+const BlogDetailPage = () => {
+ const data = useLoaderData()
+
+ return (
+ <div>
+ <h1>{data.title}</h1>
+ <p>{data.content}</p>
+ </div>
+ )
+}
+
+export default BlogDetailPage
+```
+
+## 5. Add Route Metadata
+
+Export a `handle` object to attach metadata to the route, accessible via React Router's `useMatches()`:
+
+```tsx
+export const handle = {
+ breadcrumb: "Blog",
+}
+
+const BlogPage = () => {
+ return <div>Blog</div>
+}
+
+export default BlogPage
+```
+
+## Summary
+
+Each `page.tsx` file supports these exports:
+
+| Export | Required | Description |
+|---|---|---|
+| `default` | Yes | The React component to render |
+| `config` | No | Sidebar menu item configuration |
+| `loader` | No | Data loading function (React Router) |
+| `handle` | No | Route metadata (React Router) |
diff --git a/apps/vendor-test/src/hooks/api/requests.tsx b/apps/vendor-test/src/hooks/api/requests.tsx
new file mode 100644
index 000000000..16fd5409e
--- /dev/null
+++ b/apps/vendor-test/src/hooks/api/requests.tsx
@@ -0,0 +1,129 @@
+import {
+ useQuery,
+ useMutation,
+ useQueryClient,
+ UseQueryOptions,
+ UseMutationOptions,
+} from "@tanstack/react-query";
+import { queryKeysFactory } from "@mercurjs/dashboard-shared";
+import { client } from "../../lib/client";
+import {
+ ClientError,
+ InferClientInput,
+ InferClientOutput,
+} from "@mercurjs/client";
+
+const REQUESTS_QUERY_KEY = "admin_requests" as const;
+export const requestsQueryKeys = queryKeysFactory(REQUESTS_QUERY_KEY);
+
+export type RequestDTO = InferClientOutput<
+ typeof client.admin.requests.$type.$id.query
+>["request"];
+
+export const useRequests = (
+ type: string,
+ query?: Record<string, any>,
+ options?: Omit<
+ UseQueryOptions<
+ unknown,
+ ClientError,
+ InferClientOutput<typeof client.admin.requests.$type.query>
+ >,
+ "queryKey" | "queryFn"
+ >,
+) => {
+ const { data, ...rest } = useQuery({
+ queryKey: requestsQueryKeys.list({ type, ...query }),
+ queryFn: async () =>
+ client.admin.requests.$type.query({
+ $type: type,
+ ...query,
+ offset: query?.offset ?? 0,
+ limit: query?.limit ?? 20,
+ }),
+ ...options,
+ });
+
+ return { ...data, ...rest };
+};
+
+export const useRequest = (
+ type: string,
+ id: string,
+ query?: Record<string, any>,
+ options?: Omit<
+ UseQueryOptions<
+ unknown,
+ ClientError,
+ InferClientOutput<typeof client.admin.requests.$type.$id.query>
+ >,
+ "queryKey" | "queryFn"
+ >,
+) => {
+ const { data, ...rest } = useQuery({
+ queryKey: requestsQueryKeys.detail(id, { type, ...query }),
+ queryFn: async () =>
+ client.admin.requests.$type.$id.query({
+ $type: type,
+ $id: id,
+ ...query,
+ }),
+ ...options,
+ });
+
+ return { ...data, ...rest };
+};
+
+export const useAcceptRequest = (
+ type: string,
+ id: string,
+ options?: UseMutationOptions<
+ InferClientOutput<typeof client.admin.requests.$type.$id.accept.mutate>,
+ ClientError,
+ { reviewer_note?: string }
+ >,
+) => {
+ const queryClient = useQueryClient();
+
+ return useMutation({
+ mutationFn: async (payload: { reviewer_note?: string }) =>
+ client.admin.requests.$type.$id.accept.mutate({
+ $type: type,
+ $id: id,
+ ...payload,
+ }),
+ onSuccess: (data, variables, context) => {
+ queryClient.invalidateQueries({ queryKey: requestsQueryKeys.detail(id) });
+ queryClient.invalidateQueries({ queryKey: requestsQueryKeys.lists() });
+ options?.onSuccess?.(data, variables, context);
+ },
+ ...options,
+ });
+};
+
+export const useRejectRequest = (
+ type: string,
+ id: string,
+ options?: UseMutationOptions<
+ InferClientOutput<typeof client.admin.requests.$type.$id.reject.mutate>,
+ ClientError,
+ { reviewer_note?: string }
+ >,
+) => {
+ const queryClient = useQueryClient();
+
+ return useMutation({
+ mutationFn: async (payload: { reviewer_note?: string }) =>
+ client.admin.requests.$type.$id.reject.mutate({
+ $type: type,
+ $id: id,
+ ...payload,
+ }),
+ onSuccess: (data, variables, context) => {
+ queryClient.invalidateQueries({ queryKey: requestsQueryKeys.detail(id) });
+ queryClient.invalidateQueries({ queryKey: requestsQueryKeys.lists() });
+ options?.onSuccess?.(data, variables, context);
+ },
+ ...options,
+ });
+};
diff --git a/apps/vendor-test/src/hooks/table/columns/use-request-table-columns.tsx b/apps/vendor-test/src/hooks/table/columns/use-request-table-columns.tsx
new file mode 100644
index 000000000..792ab8bf1
--- /dev/null
+++ b/apps/vendor-test/src/hooks/table/columns/use-request-table-columns.tsx
@@ -0,0 +1,66 @@
+import { createColumnHelper } from "@tanstack/react-table";
+import { useMemo } from "react";
+import { useTranslation } from "react-i18next";
+import { StatusBadge, Text } from "@medusajs/ui";
+import { DateCell, DateHeader } from "@mercurjs/dashboard-shared";
+import { RequestDTO } from "../../api/requests";
+
+const columnHelper = createColumnHelper<RequestDTO>();
+
+const statusColor = (status: string) => {
+ switch (status) {
+ case "accepted":
+ return "green" as const;
+ case "pending":
+ return "orange" as const;
+ case "rejected":
+ return "red" as const;
+ default:
+ return "grey" as const;
+ }
+};
+
+export const useRequestTableColumns = () => {
+ const { t } = useTranslation();
+
+ return useMemo(
+ () => [
+ columnHelper.accessor("id", {
+ header: () => (
+ <div className="flex h-full w-full items-center">
+ <span className="truncate">ID</span>
+ </div>
+ ),
+ cell: ({ getValue }) => (
+ <Text size="small" leading="compact" className="text-ui-fg-subtle">
+ {getValue()}
+ </Text>
+ ),
+ }),
+ columnHelper.accessor("custom_fields", {
+ header: () => (
+ <div className="flex h-full w-full items-center">
+ <span className="truncate">Status</span>
+ </div>
+ ),
+ cell: ({ getValue }) => {
+ const customFields = getValue() as any;
+ const status = customFields?.request_status ?? "draft";
+ return (
+ <StatusBadge color={statusColor(status)}>
+ {status.charAt(0).toUpperCase() + status.slice(1)}
+ </StatusBadge>
+ );
+ },
+ }),
+ columnHelper.accessor("created_at", {
+ header: () => <DateHeader />,
+ cell: ({ getValue }) => {
+ const date = new Date(getValue() as string);
+ return <DateCell date={date} />;
+ },
+ }),
+ ],
+ [t],
+ );
+};
diff --git a/apps/vendor-test/src/hooks/table/filters/use-request-table-filters.tsx b/apps/vendor-test/src/hooks/table/filters/use-request-table-filters.tsx
new file mode 100644
index 000000000..d76c937b7
--- /dev/null
+++ b/apps/vendor-test/src/hooks/table/filters/use-request-table-filters.tsx
@@ -0,0 +1,38 @@
+import { useTranslation } from "react-i18next";
+import { useMemo } from "react";
+
+import type { Filter } from "@mercurjs/dashboard-shared";
+
+export const useRequestTableFilters = (): Filter[] => {
+ const { t } = useTranslation();
+
+ return useMemo(() => {
+ const filters: Filter[] = [
+ {
+ key: "request_status",
+ label: "Status",
+ type: "select",
+ multiple: true,
+ options: [
+ { label: "Draft", value: "draft" },
+ { label: "Pending", value: "pending" },
+ { label: "Accepted", value: "accepted" },
+ { label: "Rejected", value: "rejected" },
+ ],
+ },
+ ];
+
+ const dateFilters: Filter[] = [
+ { label: t("fields.createdAt"), key: "created_at" },
+ { label: t("fields.updatedAt"), key: "updated_at" },
+ ].map((f) => ({
+ key: f.key,
+ label: f.label,
+ type: "date" as const,
+ }));
+
+ filters.push(...dateFilters);
+
+ return filters;
+ }, [t]);
+};
diff --git a/apps/vendor-test/src/hooks/table/query/use-request-table-query.tsx b/apps/vendor-test/src/hooks/table/query/use-request-table-query.tsx
new file mode 100644
index 000000000..ff23d4393
--- /dev/null
+++ b/apps/vendor-test/src/hooks/table/query/use-request-table-query.tsx
@@ -0,0 +1,33 @@
+import { useQueryParams } from "@mercurjs/dashboard-shared";
+
+type UseRequestTableQueryProps = {
+ prefix?: string;
+ pageSize?: number;
+};
+
+export const useRequestTableQuery = ({
+ prefix,
+ pageSize = 20,
+}: UseRequestTableQueryProps) => {
+ const queryObject = useQueryParams(
+ ["offset", "q", "created_at", "updated_at", "order", "request_status"],
+ prefix,
+ );
+
+ const { offset, created_at, updated_at, q, order, request_status } = queryObject;
+
+ const searchParams: Record<string, any> = {
+ limit: pageSize,
+ offset: offset ? Number(offset) : 0,
+ created_at: created_at ? JSON.parse(created_at) : undefined,
+ updated_at: updated_at ? JSON.parse(updated_at) : undefined,
+ order: order ? order : "-created_at",
+ request_status: request_status || undefined,
+ q,
+ };
+
+ return {
+ searchParams,
+ raw: queryObject,
+ };
+};
diff --git a/apps/vendor-test/src/i18n/en.json b/apps/vendor-test/src/i18n/en.json
new file mode 100644
index 000000000..72011729b
--- /dev/null
+++ b/apps/vendor-test/src/i18n/en.json
@@ -0,0 +1,7 @@
+{
+ "customFields": {
+ "title": "Custom Fields",
+ "description": "Manage your custom fields and configurations",
+ "noFields": "No custom fields configured yet"
+ }
+}
diff --git a/apps/vendor-test/src/i18n/index.ts b/apps/vendor-test/src/i18n/index.ts
new file mode 100644
index 000000000..84da0cb86
--- /dev/null
+++ b/apps/vendor-test/src/i18n/index.ts
@@ -0,0 +1,9 @@
+import en from "./en.json"
+
+const i18nResources = {
+ en: {
+ translation: en,
+ },
+}
+
+export default i18nResources
diff --git a/apps/vendor-test/src/lib/client.ts b/apps/vendor-test/src/lib/client.ts
new file mode 100644
index 000000000..6116165ca
--- /dev/null
+++ b/apps/vendor-test/src/lib/client.ts
@@ -0,0 +1,11 @@
+import { createClient, type InferClient } from "@mercurjs/client"
+import type { Routes } from '@mercurjs/core-plugin/_generated'
+
+declare const __BACKEND_URL__: string
+
+export const client: InferClient<Routes> = createClient({
+ baseUrl: __BACKEND_URL__,
+ fetchOptions: {
+ credentials: 'include',
+ }
+})
diff --git a/apps/vendor-test/src/main.tsx b/apps/vendor-test/src/main.tsx
new file mode 100644
index 000000000..ce1b1e708
--- /dev/null
+++ b/apps/vendor-test/src/main.tsx
@@ -0,0 +1,10 @@
+import { StrictMode } from "react";
+import { createRoot } from "react-dom/client";
+import "@mercurjs/vendor/index.css";
+import App from "@mercurjs/vendor";
+
+createRoot(document.getElementById("root")!).render(
+ <StrictMode>
+ <App />
+ </StrictMode>,
+);
diff --git a/apps/vendor-test/src/pages/requests/categories/page.tsx b/apps/vendor-test/src/pages/requests/categories/page.tsx
new file mode 100644
index 000000000..8b8b3d48c
--- /dev/null
+++ b/apps/vendor-test/src/pages/requests/categories/page.tsx
@@ -0,0 +1,73 @@
+import { useTranslation } from "react-i18next";
+import { keepPreviousData } from "@tanstack/react-query";
+import { Container, Heading } from "@medusajs/ui";
+import type { RouteConfig } from "@mercurjs/dashboard-sdk";
+
+export const config: RouteConfig = {
+ label: "Categories",
+ nested: "/requests",
+};
+
+import { useRequests } from "../../../hooks/api/requests";
+import { useRequestTableColumns } from "../../../hooks/table/columns/use-request-table-columns";
+import { useRequestTableQuery } from "../../../hooks/table/query/use-request-table-query";
+import { useRequestTableFilters } from "../../../hooks/table/filters/use-request-table-filters";
+import {
+ _DataTable,
+ SingleColumnPage,
+ useDataTable,
+} from "@mercurjs/dashboard-shared";
+
+const PAGE_SIZE = 10;
+
+const CategoryRequestsPage = () => {
+ const { t } = useTranslation();
+ const { raw, searchParams } = useRequestTableQuery({ pageSize: PAGE_SIZE });
+
+ const { requests, count, isError, error, isLoading } = useRequests(
+ "product_category",
+ searchParams,
+ { placeholderData: keepPreviousData },
+ );
+
+ const columns = useRequestTableColumns();
+ const filters = useRequestTableFilters();
+
+ const { table } = useDataTable({
+ data: requests ?? [],
+ columns,
+ enablePagination: true,
+ count: count,
+ pageSize: PAGE_SIZE,
+ });
+
+ if (isError) throw error;
+
+ return (
+ <SingleColumnPage>
+ <Container className="divide-y p-0">
+ <div className="flex items-center justify-between px-6 py-4">
+ <Heading>Category Requests</Heading>
+ </div>
+ <_DataTable
+ columns={columns}
+ table={table}
+ pagination
+ filters={filters}
+ navigateTo={(row) => `/requests/product_category/${row.original.id}`}
+ count={count}
+ isLoading={isLoading}
+ pageSize={PAGE_SIZE}
+ orderBy={[
+ { key: "created_at", label: t("fields.createdAt") },
+ { key: "updated_at", label: t("fields.updatedAt") },
+ ]}
+ queryObject={raw}
+ noRecords={{ message: "No category requests found" }}
+ />
+ </Container>
+ </SingleColumnPage>
+ );
+};
+
+export default CategoryRequestsPage;
diff --git a/apps/vendor-test/src/pages/requests/collections/page.tsx b/apps/vendor-test/src/pages/requests/collections/page.tsx
new file mode 100644
index 000000000..f503dc340
--- /dev/null
+++ b/apps/vendor-test/src/pages/requests/collections/page.tsx
@@ -0,0 +1,73 @@
+import { useTranslation } from "react-i18next";
+import { keepPreviousData } from "@tanstack/react-query";
+import { Container, Heading } from "@medusajs/ui";
+import type { RouteConfig } from "@mercurjs/dashboard-sdk";
+
+export const config: RouteConfig = {
+ label: "Collections",
+ nested: "/requests",
+};
+
+import { useRequests } from "../../../hooks/api/requests";
+import { useRequestTableColumns } from "../../../hooks/table/columns/use-request-table-columns";
+import { useRequestTableQuery } from "../../../hooks/table/query/use-request-table-query";
+import { useRequestTableFilters } from "../../../hooks/table/filters/use-request-table-filters";
+import {
+ _DataTable,
+ SingleColumnPage,
+ useDataTable,
+} from "@mercurjs/dashboard-shared";
+
+const PAGE_SIZE = 10;
+
+const CollectionRequestsPage = () => {
+ const { t } = useTranslation();
+ const { raw, searchParams } = useRequestTableQuery({ pageSize: PAGE_SIZE });
+
+ const { requests, count, isError, error, isLoading } = useRequests(
+ "product_collection",
+ searchParams,
+ { placeholderData: keepPreviousData },
+ );
+
+ const columns = useRequestTableColumns();
+ const filters = useRequestTableFilters();
+
+ const { table } = useDataTable({
+ data: requests ?? [],
+ columns,
+ enablePagination: true,
+ count: count,
+ pageSize: PAGE_SIZE,
+ });
+
+ if (isError) throw error;
+
+ return (
+ <SingleColumnPage>
+ <Container className="divide-y p-0">
+ <div className="flex items-center justify-between px-6 py-4">
+ <Heading>Collection Requests</Heading>
+ </div>
+ <_DataTable
+ columns={columns}
+ table={table}
+ pagination
+ filters={filters}
+ navigateTo={(row) => `/requests/product_collection/${row.original.id}`}
+ count={count}
+ isLoading={isLoading}
+ pageSize={PAGE_SIZE}
+ orderBy={[
+ { key: "created_at", label: t("fields.createdAt") },
+ { key: "updated_at", label: t("fields.updatedAt") },
+ ]}
+ queryObject={raw}
+ noRecords={{ message: "No collection requests found" }}
+ />
+ </Container>
+ </SingleColumnPage>
+ );
+};
+
+export default CollectionRequestsPage;
diff --git a/apps/vendor-test/src/pages/requests/page.tsx b/apps/vendor-test/src/pages/requests/page.tsx
new file mode 100644
index 000000000..370125356
--- /dev/null
+++ b/apps/vendor-test/src/pages/requests/page.tsx
@@ -0,0 +1,14 @@
+import { Navigate } from "react-router-dom";
+import type { RouteConfig } from "@mercurjs/dashboard-sdk";
+import { InboxSolid } from "@medusajs/icons";
+
+export const config: RouteConfig = {
+ label: "Requests",
+ icon: InboxSolid,
+};
+
+const RequestsPage = () => {
+ return <Navigate to="/requests/categories" replace />;
+};
+
+export default RequestsPage;
diff --git a/apps/vendor-test/src/pages/requests/tags/page.tsx b/apps/vendor-test/src/pages/requests/tags/page.tsx
new file mode 100644
index 000000000..ce3d07702
--- /dev/null
+++ b/apps/vendor-test/src/pages/requests/tags/page.tsx
@@ -0,0 +1,73 @@
+import { useTranslation } from "react-i18next";
+import { keepPreviousData } from "@tanstack/react-query";
+import { Container, Heading } from "@medusajs/ui";
+import type { RouteConfig } from "@mercurjs/dashboard-sdk";
+
+export const config: RouteConfig = {
+ label: "Tags",
+ nested: "/requests",
+};
+
+import { useRequests } from "../../../hooks/api/requests";
+import { useRequestTableColumns } from "../../../hooks/table/columns/use-request-table-columns";
+import { useRequestTableQuery } from "../../../hooks/table/query/use-request-table-query";
+import { useRequestTableFilters } from "../../../hooks/table/filters/use-request-table-filters";
+import {
+ _DataTable,
+ SingleColumnPage,
+ useDataTable,
+} from "@mercurjs/dashboard-shared";
+
+const PAGE_SIZE = 10;
+
+const TagRequestsPage = () => {
+ const { t } = useTranslation();
+ const { raw, searchParams } = useRequestTableQuery({ pageSize: PAGE_SIZE });
+
+ const { requests, count, isError, error, isLoading } = useRequests(
+ "product_tag",
+ searchParams,
+ { placeholderData: keepPreviousData },
+ );
+
+ const columns = useRequestTableColumns();
+ const filters = useRequestTableFilters();
+
+ const { table } = useDataTable({
+ data: requests ?? [],
+ columns,
+ enablePagination: true,
+ count: count,
+ pageSize: PAGE_SIZE,
+ });
+
+ if (isError) throw error;
+
+ return (
+ <SingleColumnPage>
+ <Container className="divide-y p-0">
+ <div className="flex items-center justify-between px-6 py-4">
+ <Heading>Tag Requests</Heading>
+ </div>
+ <_DataTable
+ columns={columns}
+ table={table}
+ pagination
+ filters={filters}
+ navigateTo={(row) => `/requests/product_tag/${row.original.id}`}
+ count={count}
+ isLoading={isLoading}
+ pageSize={PAGE_SIZE}
+ orderBy={[
+ { key: "created_at", label: t("fields.createdAt") },
+ { key: "updated_at", label: t("fields.updatedAt") },
+ ]}
+ queryObject={raw}
+ noRecords={{ message: "No tag requests found" }}
+ />
+ </Container>
+ </SingleColumnPage>
+ );
+};
+
+export default TagRequestsPage;
diff --git a/apps/vendor-test/src/pages/requests/types/page.tsx b/apps/vendor-test/src/pages/requests/types/page.tsx
new file mode 100644
index 000000000..1965e491d
--- /dev/null
+++ b/apps/vendor-test/src/pages/requests/types/page.tsx
@@ -0,0 +1,73 @@
+import { useTranslation } from "react-i18next";
+import { keepPreviousData } from "@tanstack/react-query";
+import { Container, Heading } from "@medusajs/ui";
+import type { RouteConfig } from "@mercurjs/dashboard-sdk";
+
+export const config: RouteConfig = {
+ label: "Types",
+ nested: "/requests",
+};
+
+import { useRequests } from "../../../hooks/api/requests";
+import { useRequestTableColumns } from "../../../hooks/table/columns/use-request-table-columns";
+import { useRequestTableQuery } from "../../../hooks/table/query/use-request-table-query";
+import { useRequestTableFilters } from "../../../hooks/table/filters/use-request-table-filters";
+import {
+ _DataTable,
+ SingleColumnPage,
+ useDataTable,
+} from "@mercurjs/dashboard-shared";
+
+const PAGE_SIZE = 10;
+
+const TypeRequestsPage = () => {
+ const { t } = useTranslation();
+ const { raw, searchParams } = useRequestTableQuery({ pageSize: PAGE_SIZE });
+
+ const { requests, count, isError, error, isLoading } = useRequests(
+ "product_type",
+ searchParams,
+ { placeholderData: keepPreviousData },
+ );
+
+ const columns = useRequestTableColumns();
+ const filters = useRequestTableFilters();
+
+ const { table } = useDataTable({
+ data: requests ?? [],
+ columns,
+ enablePagination: true,
+ count: count,
+ pageSize: PAGE_SIZE,
+ });
+
+ if (isError) throw error;
+
+ return (
+ <SingleColumnPage>
+ <Container className="divide-y p-0">
+ <div className="flex items-center justify-between px-6 py-4">
+ <Heading>Type Requests</Heading>
+ </div>
+ <_DataTable
+ columns={columns}
+ table={table}
+ pagination
+ filters={filters}
+ navigateTo={(row) => `/requests/product_type/${row.original.id}`}
+ count={count}
+ isLoading={isLoading}
+ pageSize={PAGE_SIZE}
+ orderBy={[
+ { key: "created_at", label: t("fields.createdAt") },
+ { key: "updated_at", label: t("fields.updatedAt") },
+ ]}
+ queryObject={raw}
+ noRecords={{ message: "No type requests found" }}
+ />
+ </Container>
+ </SingleColumnPage>
+ );
+};
+
+export default TypeRequestsPage;
diff --git a/apps/vendor-test/tsconfig.app.json b/apps/vendor-test/tsconfig.app.json
new file mode 100644
index 000000000..a5eded23c
--- /dev/null
+++ b/apps/vendor-test/tsconfig.app.json
@@ -0,0 +1,35 @@
+{
+ "compilerOptions": {
+ "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
+ "target": "ES2022",
+ "useDefineForClassFields": true,
+ "lib": [
+ "ES2022",
+ "DOM",
+ "DOM.Iterable"
+ ],
+ "module": "ESNext",
+ "types": [
+ "vite/client"
+ ],
+ "skipLibCheck": true,
+ "baseUrl": ".",
+ /* Bundler mode */
+ "moduleResolution": "bundler",
+ "allowImportingTsExtensions": true,
+ "verbatimModuleSyntax": false,
+ "moduleDetection": "force",
+ "noEmit": true,
+ "jsx": "react-jsx",
+ /* Linting */
+ "strict": true,
+ "noUnusedLocals": true,
+ "noUnusedParameters": true,
+ "erasableSyntaxOnly": true,
+ "noFallthroughCasesInSwitch": true,
+ "noUncheckedSideEffectImports": true
+ },
+ "include": [
+ "src",
+ ]
+}
\ No newline at end of file
diff --git a/apps/vendor-test/tsconfig.json b/apps/vendor-test/tsconfig.json
new file mode 100644
index 000000000..1ffef600d
--- /dev/null
+++ b/apps/vendor-test/tsconfig.json
@@ -0,0 +1,7 @@
+{
+ "files": [],
+ "references": [
+ { "path": "./tsconfig.app.json" },
+ { "path": "./tsconfig.node.json" }
+ ]
+}
diff --git a/apps/vendor-test/tsconfig.node.json b/apps/vendor-test/tsconfig.node.json
new file mode 100644
index 000000000..ed01be245
--- /dev/null
+++ b/apps/vendor-test/tsconfig.node.json
@@ -0,0 +1,32 @@
+{
+ "compilerOptions": {
+ "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
+ "target": "ES2023",
+ "lib": [
+ "ES2023"
+ ],
+ "module": "ESNext",
+ "jsx": "react-jsx",
+ "types": [
+ "node"
+ ],
+ "skipLibCheck": true,
+ /* Bundler mode */
+ "moduleResolution": "bundler",
+ "allowImportingTsExtensions": true,
+ "verbatimModuleSyntax": true,
+ "moduleDetection": "force",
+ "noEmit": true,
+ /* Linting */
+ "strict": true,
+ "noUnusedLocals": true,
+ "noUnusedParameters": true,
+ "erasableSyntaxOnly": true,
+ "noFallthroughCasesInSwitch": true,
+ "noUncheckedSideEffectImports": true
+ },
+ "include": [
+ "vite.config.ts",
+ "mercur.config.ts"
+ ]
+}
\ No newline at end of file
diff --git a/apps/vendor-test/vite.config.ts b/apps/vendor-test/vite.config.ts
new file mode 100644
index 000000000..2d9bc2f9b
--- /dev/null
+++ b/apps/vendor-test/vite.config.ts
@@ -0,0 +1,8 @@
+import { defineConfig } from 'vite'
+import react from '@vitejs/plugin-react'
+import { dashboardPlugin } from '@mercurjs/dashboard-sdk'
+
+// https://vite.dev/config/
+export default defineConfig({
+ plugins: [react(), dashboardPlugin()],
+})
diff --git a/bun.lock b/bun.lock
index 8d5809a76..ddd2b21e5 100644
--- a/bun.lock
+++ b/bun.lock
@@ -54,6 +54,46 @@
"vite": "^5.4.21",
},
},
+ "apps/vendor-test": {
+ "name": "@acme/vendpr",
+ "version": "0.0.0",
+ "dependencies": {
+ "@hookform/resolvers": "3.4.2",
+ "@medusajs/icons": "^2.13.3",
+ "@medusajs/ui": "4.1.1",
+ "@mercurjs/client": "*",
+ "@mercurjs/core-plugin": "*",
+ "@mercurjs/dashboard-sdk": "*",
+ "@mercurjs/dashboard-shared": "*",
+ "@mercurjs/vendor": "*",
+ "@tanstack/react-query": "5.64.2",
+ "@tanstack/react-table": "8.20.5",
+ "jsonwebtoken": "9.0.2",
+ "lodash.debounce": "^4.0.8",
+ "react": "^18.0.0",
+ "react-dom": "^18.0.0",
+ "react-hook-form": "7.49.1",
+ "react-i18next": "13.5.0",
+ "react-jwt": "^2.0.0",
+ "react-router-dom": "6.30.3",
+ "zod": "3.25.76",
+ },
+ "devDependencies": {
+ "@eslint/js": "^9.39.1",
+ "@types/jsonwebtoken": "^9.0.9",
+ "@types/node": "^24.10.1",
+ "@types/react": "^18.2.66",
+ "@types/react-dom": "^18.2.22",
+ "@vitejs/plugin-react": "^4.2.1",
+ "eslint": "^9.39.1",
+ "eslint-plugin-react-hooks": "^7.0.1",
+ "eslint-plugin-react-refresh": "^0.4.24",
+ "globals": "^16.5.0",
+ "typescript": "5.9.3",
+ "typescript-eslint": "^8.46.4",
+ "vite": "^5.4.21",
+ },
+ },
"integration-tests": {
"name": "@mercurjs/integration-tests",
"version": "0.0.1",
@@ -78,7 +118,7 @@
},
"packages/admin": {
"name": "@mercurjs/admin",
- "version": "2.0.0-canary.49",
+ "version": "2.0.0-canary.52",
"dependencies": {
"@ariakit/react": "^0.4.15",
"@babel/runtime": "^7.26.10",
@@ -138,7 +178,7 @@
},
"packages/cli": {
"name": "@mercurjs/cli",
- "version": "2.0.0-canary.49",
+ "version": "2.0.0-canary.52",
"bin": {
"mercurjs": "./dist/index.js",
},
@@ -178,7 +218,7 @@
},
"packages/client": {
"name": "@mercurjs/client",
- "version": "2.0.0-canary.49",
+ "version": "2.0.0-canary.52",
"dependencies": {
"@tanstack/react-query": "^5.64.2",
"qs": "^6.12.1",
@@ -195,7 +235,7 @@
},
"packages/core-plugin": {
"name": "@mercurjs/core-plugin",
- "version": "2.0.0-canary.49",
+ "version": "2.0.0-canary.52",
"devDependencies": {
"@medusajs/cli": "^2.13.3",
"@medusajs/core-flows": "^2.13.3",
@@ -234,7 +274,7 @@
},
"packages/dashboard-sdk": {
"name": "@mercurjs/dashboard-sdk",
- "version": "2.0.0-canary.49",
+ "version": "2.0.0-canary.52",
"dependencies": {
"esbuild-register": "^3.6.0",
},
@@ -248,7 +288,7 @@
},
"packages/dashboard-shared": {
"name": "@mercurjs/dashboard-shared",
- "version": "2.0.0-canary.49",
+ "version": "2.0.0-canary.52",
"dependencies": {
"@ariakit/react": "^0.4.15",
"@babel/runtime": "^7.26.10",
@@ -339,7 +379,7 @@
},
"packages/types": {
"name": "@mercurjs/types",
- "version": "2.0.0-canary.49",
+ "version": "2.0.0-canary.52",
"dependencies": {
"@medusajs/types": "2.13.3",
},
@@ -349,7 +389,7 @@
},
"packages/vendor": {
"name": "@mercurjs/vendor",
- "version": "2.0.0-canary.49",
+ "version": "2.0.0-canary.52",
"dependencies": {
"@ariakit/react": "^0.4.15",
"@babel/runtime": "^7.26.10",
@@ -411,6 +451,8 @@
"packages": {
"@acme/admin": ["@acme/admin@workspace:apps/admin-test"],
+ "@acme/vendpr": ["@acme/vendpr@workspace:apps/vendor-test"],
+
"@algolia/abtesting": ["@algolia/[email protected]", "", { "dependencies": { "@algolia/client-common": "5.49.1", "@algolia/requester-browser-xhr": "5.49.1", "@algolia/requester-fetch": "5.49.1", "@algolia/requester-node-http": "5.49.1" } }, "sha512-2yuIC48rUuHGhU1U5qJ9kJHaxYpJ0jpDHJVI5ekOxSMYXlH4+HP+pA31G820lsAznfmu2nzDV7n5RO44zIY1zw=="],
"@algolia/client-abtesting": ["@algolia/[email protected]", "", { "dependencies": { "@algolia/client-common": "5.49.1", "@algolia/requester-browser-xhr": "5.49.1", "@algolia/requester-fetch": "5.49.1", "@algolia/requester-node-http": "5.49.1" } }, "sha512-h6M7HzPin+45/l09q0r2dYmocSSt2MMGOOk5c4O5K/bBBlEwf1BKfN6z+iX4b8WXcQQhf7rgQwC52kBZJt/ZZw=="],
@@ -3387,6 +3429,8 @@
"@acme/admin/globals": ["[email protected]", "", {}, "sha512-c/c15i26VrJ4IRt5Z89DnIzCGDn9EcebibhAOjw5ibqEHsE1wLUgkPn9RDmNcUKyU87GeaL633nyJ+pplFR2ZQ=="],
+ "@acme/vendpr/globals": ["[email protected]", "", {}, "sha512-c/c15i26VrJ4IRt5Z89DnIzCGDn9EcebibhAOjw5ibqEHsE1wLUgkPn9RDmNcUKyU87GeaL633nyJ+pplFR2ZQ=="],
+
"@antfu/ni/tinyexec": ["[email protected]", "", {}, "sha512-W/KYk+NFhkmsYpuHq5JykngiOCnxeVL8v8dFnqxSD8qEEdRfXk1SDM6JzNqcERbcGYj9tMrDQBYV9cjgnunFIg=="],
"@aws-crypto/crc32/@aws-sdk/types": ["@aws-sdk/[email protected]", "", { "dependencies": { "@smithy/types": "^4.12.0", "tslib": "^2.6.2" } }, "sha512-DwHBiMNOB468JiX6+i34c+THsKHErYUdNQ3HexeXZvVn4zouLjgaS4FejiGSi2HyBuzuyHg7SuOPmjSvoU9NRg=="],
diff --git a/packages/admin/package.json b/packages/admin/package.json
index 84610ef42..927155c4f 100644
--- a/packages/admin/package.json
+++ b/packages/admin/package.json
@@ -1,6 +1,6 @@
{
"name": "@mercurjs/admin",
- "version": "2.0.0-canary.52",
+ "version": "2.0.0-canary.53",
"repository": {
"type": "git",
"url": "https://github.com/mercurjs/mercur",
diff --git a/packages/admin/src/components/layout/main-layout/main-layout.tsx b/packages/admin/src/components/layout/main-layout/main-layout.tsx
index 074609625..fe2fa2546 100644
--- a/packages/admin/src/components/layout/main-layout/main-layout.tsx
+++ b/packages/admin/src/components/layout/main-layout/main-layout.tsx
@@ -74,7 +74,7 @@ const MainSidebar = () => {
.map((item) => ({
label: item.label,
to: item.path,
- icon: item.icon ? undefined : undefined,
+ icon: item.icon ? <item.icon /> : undefined,
translationNs: item.translationNs,
items: addNestedItems(item.path),
}));
diff --git a/packages/admin/src/components/layout/nav-item/nav-item.tsx b/packages/admin/src/components/layout/nav-item/nav-item.tsx
index 1b3a1e269..dfd493055 100644
--- a/packages/admin/src/components/layout/nav-item/nav-item.tsx
+++ b/packages/admin/src/components/layout/nav-item/nav-item.tsx
@@ -101,13 +101,6 @@ export const NavItem = ({
setOpen(getIsOpen(to, items, pathname));
}, [pathname, to, items]);
- const isNestedActive = useCallback(
- (nestedTo: string) => {
- return pathname === nestedTo || pathname.startsWith(nestedTo + "/");
- },
- [pathname],
- );
-
const navLinkClassNames = useCallback(
({
to,
@@ -121,15 +114,15 @@ export const NavItem = ({
isSetting?: boolean;
}) => {
if (["core", "setting"].includes(type)) {
- if (isNested) {
- isActive = isNestedActive(to);
- } else if (items?.length) {
- // Parent is active only if pathname matches it directly
- // and no nested item's path matches
- const nestedMatch = items.some((item) => isNestedActive(item.to));
- isActive = pathname.startsWith(to) && !nestedMatch;
- } else {
- isActive = pathname.startsWith(to);
+ isActive = pathname.startsWith(to);
+
+ if (isActive && !isNested && items?.length) {
+ const nestedIsActive = items.some((item) =>
+ pathname.startsWith(item.to),
+ );
+ if (nestedIsActive) {
+ isActive = false;
+ }
}
}
@@ -139,7 +132,7 @@ export const NavItem = ({
[SETTING_NAV_LINK_CLASSES]: isSetting,
});
},
- [type, pathname, items, isNestedActive],
+ [type, pathname, items],
);
const isSetting = type === "setting";
diff --git a/packages/cli/package.json b/packages/cli/package.json
index 99cf8f3e9..ef3b6b328 100644
--- a/packages/cli/package.json
+++ b/packages/cli/package.json
@@ -1,6 +1,6 @@
{
"name": "@mercurjs/cli",
- "version": "2.0.0-canary.52",
+ "version": "2.0.0-canary.53",
"repository": {
"type": "git",
"url": "https://github.com/mercurjs/mercur",
diff --git a/packages/client/package.json b/packages/client/package.json
index a9c67e30c..facc41b94 100644
--- a/packages/client/package.json
+++ b/packages/client/package.json
@@ -1,6 +1,6 @@
{
"name": "@mercurjs/client",
- "version": "2.0.0-canary.52",
+ "version": "2.0.0-canary.53",
"repository": {
"type": "git",
"url": "https://github.com/mercurjs/mercur",
diff --git a/packages/core-plugin/package.json b/packages/core-plugin/package.json
index 973e57bad..7f810a6fb 100644
--- a/packages/core-plugin/package.json
+++ b/packages/core-plugin/package.json
@@ -1,6 +1,6 @@
{
"name": "@mercurjs/core-plugin",
- "version": "2.0.0-canary.52",
+ "version": "2.0.0-canary.53",
"repository": {
"type": "git",
"url": "https://github.com/mercurjs/mercur",
diff --git a/packages/dashboard-sdk/package.json b/packages/dashboard-sdk/package.json
index 69973dbe6..a6c1c5f77 100644
--- a/packages/dashboard-sdk/package.json
+++ b/packages/dashboard-sdk/package.json
@@ -1,6 +1,6 @@
{
"name": "@mercurjs/dashboard-sdk",
- "version": "2.0.0-canary.52",
+ "version": "2.0.0-canary.53",
"repository": {
"type": "git",
"url": "https://github.com/mercurjs/mercur",
diff --git a/packages/dashboard-shared/package.json b/packages/dashboard-shared/package.json
index 53d92e51c..02953a06a 100644
--- a/packages/dashboard-shared/package.json
+++ b/packages/dashboard-shared/package.json
@@ -1,6 +1,6 @@
{
"name": "@mercurjs/dashboard-shared",
- "version": "2.0.0-canary.52",
+ "version": "2.0.0-canary.53",
"repository": {
"type": "git",
"url": "https://github.com/mercurjs/mercur",
diff --git a/packages/registry/src/requests/vendor/hooks/api/requests.tsx b/packages/registry/src/requests/vendor/hooks/api/requests.tsx
index 225fc8d3f..f17e3bdd3 100644
--- a/packages/registry/src/requests/vendor/hooks/api/requests.tsx
+++ b/packages/registry/src/requests/vendor/hooks/api/requests.tsx
@@ -1,4 +1,10 @@
-import { useQuery, UseQueryOptions } from "@tanstack/react-query";
+import {
+ useQuery,
+ useMutation,
+ useQueryClient,
+ UseQueryOptions,
+ UseMutationOptions,
+} from "@tanstack/react-query";
import { queryKeysFactory } from "@mercurjs/dashboard-shared";
import { client } from "../../lib/client";
import { ClientError } from "@mercurjs/client";
@@ -8,18 +14,24 @@ export const requestsQueryKeys = queryKeysFactory(REQUESTS_QUERY_KEY);
export type VendorRequestDTO = Record<string, any>;
+type RequestType =
+ | "product_category"
+ | "product_collection"
+ | "product_tag"
+ | "product_type";
+
+const clientMap = {
+ product_category: client.vendor.productCategories,
+ product_collection: client.vendor.productCollections,
+ product_tag: client.vendor.productTags,
+ product_type: client.vendor.productTypes,
+} as Record<string, any>;
+
export const useVendorRequests = (
- type: "product_category" | "product_collection" | "product_tag" | "product_type",
+ type: RequestType,
query?: Record<string, any>,
options?: Omit<UseQueryOptions<unknown, ClientError, any>, "queryKey" | "queryFn">,
) => {
- const clientMap = {
- product_category: client.vendor.productCategories,
- product_collection: client.vendor.productCollections,
- product_tag: client.vendor.productTags,
- product_type: client.vendor.productTypes,
- } as Record<string, any>;
-
const { data, ...rest } = useQuery({
queryKey: requestsQueryKeys.list({ type, ...query }),
queryFn: async () => clientMap[type].query({ ...query }),
@@ -28,3 +40,22 @@ export const useVendorRequests = (
return { ...data, ...rest };
};
+
+export const useCreateVendorRequest = (
+ type: RequestType,
+ options?: UseMutationOptions<any, ClientError, Record<string, any>>,
+) => {
+ const queryClient = useQueryClient();
+
+ return useMutation({
+ mutationFn: (payload: Record<string, any>) =>
+ clientMap[type].mutate(payload),
+ onSuccess: (data, variables, context) => {
+ queryClient.invalidateQueries({
+ queryKey: requestsQueryKeys.lists(),
+ });
+ options?.onSuccess?.(data, variables, context);
+ },
+ ...options,
+ });
+};
diff --git a/packages/registry/src/requests/vendor/pages/requests/categories/create/page.tsx b/packages/registry/src/requests/vendor/pages/requests/categories/create/page.tsx
new file mode 100644
index 000000000..0bc6b106a
--- /dev/null
+++ b/packages/registry/src/requests/vendor/pages/requests/categories/create/page.tsx
@@ -0,0 +1,201 @@
+import { zodResolver } from "@hookform/resolvers/zod";
+import {
+ Button,
+ Heading,
+ Input,
+ Select,
+ Text,
+ Textarea,
+ toast,
+} from "@medusajs/ui";
+import { useForm } from "react-hook-form";
+import { useTranslation } from "react-i18next";
+import * as zod from "zod";
+
+import {
+ Form,
+ RouteFocusModal,
+ useRouteModal,
+} from "@mercurjs/dashboard-shared";
+import { useCreateVendorRequest } from "../../../../hooks/api/requests";
+
+const CreateCategoryRequestSchema = zod.object({
+ name: zod.string().min(1),
+ handle: zod.string().optional(),
+ description: zod.string().optional(),
+ is_active: zod.boolean().optional(),
+ is_internal: zod.boolean().optional(),
+});
+
+const CategoryRequestCreatePage = () => {
+ const { t } = useTranslation();
+ const { handleSuccess } = useRouteModal();
+
+ const form = useForm<zod.infer<typeof CreateCategoryRequestSchema>>({
+ defaultValues: {
+ name: "",
+ handle: "",
+ description: "",
+ is_active: true,
+ is_internal: false,
+ },
+ resolver: zodResolver(CreateCategoryRequestSchema),
+ });
+
+ const { mutateAsync, isPending } = useCreateVendorRequest(
+ "product_category",
+ );
+
+ const handleSubmit = form.handleSubmit(async (data) => {
+ await mutateAsync(data, {
+ onSuccess: () => {
+ toast.success("Category request created successfully");
+ handleSuccess(`/requests/categories`);
+ },
+ onError: (error) => {
+ toast.error(error.message);
+ },
+ });
+ });
+
+ return (
+ <RouteFocusModal>
+ <RouteFocusModal.Form form={form}>
+ <form
+ onSubmit={handleSubmit}
+ className="flex h-full flex-col overflow-hidden"
+ >
+ <RouteFocusModal.Header />
+ <RouteFocusModal.Body className="flex size-full flex-col items-center overflow-auto p-16">
+ <div className="flex w-full max-w-[720px] flex-col gap-y-8">
+ <div>
+ <Heading>Request Category</Heading>
+ <Text size="small" className="text-ui-fg-subtle">
+ Submit a request to create a new product category.
+ </Text>
+ </div>
+ <div className="grid grid-cols-1 gap-4 md:grid-cols-2">
+ <Form.Field
+ control={form.control}
+ name="name"
+ render={({ field }) => (
+ <Form.Item>
+ <Form.Label>{t("fields.name")}</Form.Label>
+ <Form.Control>
+ <Input autoComplete="off" {...field} />
+ </Form.Control>
+ <Form.ErrorMessage />
+ </Form.Item>
+ )}
+ />
+ <Form.Field
+ control={form.control}
+ name="handle"
+ render={({ field }) => (
+ <Form.Item>
+ <Form.Label optional>{t("fields.handle")}</Form.Label>
+ <Form.Control>
+ <Input autoComplete="off" {...field} />
+ </Form.Control>
+ <Form.ErrorMessage />
+ </Form.Item>
+ )}
+ />
+ <Form.Field
+ control={form.control}
+ name="description"
+ render={({ field }) => (
+ <Form.Item className="col-span-full">
+ <Form.Label optional>
+ {t("fields.description")}
+ </Form.Label>
+ <Form.Control>
+ <Textarea {...field} />
+ </Form.Control>
+ <Form.ErrorMessage />
+ </Form.Item>
+ )}
+ />
+ <Form.Field
+ control={form.control}
+ name="is_active"
+ render={({ field }) => (
+ <Form.Item>
+ <Form.Label>{t("fields.status")}</Form.Label>
+ <Form.Control>
+ <Select
+ value={field.value ? "active" : "inactive"}
+ onValueChange={(v) =>
+ field.onChange(v === "active")
+ }
+ >
+ <Select.Trigger>
+ <Select.Value />
+ </Select.Trigger>
+ <Select.Content>
+ <Select.Item value="active">
+ {t("categories.fields.status.active")}
+ </Select.Item>
+ <Select.Item value="inactive">
+ {t("categories.fields.status.inactive")}
+ </Select.Item>
+ </Select.Content>
+ </Select>
+ </Form.Control>
+ </Form.Item>
+ )}
+ />
+ <Form.Field
+ control={form.control}
+ name="is_internal"
+ render={({ field }) => (
+ <Form.Item>
+ <Form.Label>{t("fields.visibility")}</Form.Label>
+ <Form.Control>
+ <Select
+ value={field.value ? "internal" : "public"}
+ onValueChange={(v) =>
+ field.onChange(v === "internal")
+ }
+ >
+ <Select.Trigger>
+ <Select.Value />
+ </Select.Trigger>
+ <Select.Content>
+ <Select.Item value="public">
+ {t("categories.fields.visibility.public")}
+ </Select.Item>
+ <Select.Item value="internal">
+ {t("categories.fields.visibility.internal")}
+ </Select.Item>
+ </Select.Content>
+ </Select>
+ </Form.Control>
+ </Form.Item>
+ )}
+ />
+ </div>
+ </div>
+ </RouteFocusModal.Body>
+ <RouteFocusModal.Footer>
+ <RouteFocusModal.Close asChild>
+ <Button size="small" variant="secondary">
+ {t("actions.cancel")}
+ </Button>
+ </RouteFocusModal.Close>
+ <Button
+ size="small"
+ variant="primary"
+ type="submit"
+ isLoading={isPending}
+ >
+ {t("actions.create")}
+ </Button>
+ </RouteFocusModal.Footer>
+ </form>
+ </RouteFocusModal.Form>
+ </RouteFocusModal>
+ );
+};
+
+export default CategoryRequestCreatePage;
diff --git a/packages/registry/src/requests/vendor/pages/requests/categories/page.tsx b/packages/registry/src/requests/vendor/pages/requests/categories/page.tsx
index f778b80cf..0ebe31f9f 100644
--- a/packages/registry/src/requests/vendor/pages/requests/categories/page.tsx
+++ b/packages/registry/src/requests/vendor/pages/requests/categories/page.tsx
@@ -1,6 +1,7 @@
import { useTranslation } from "react-i18next";
+import { Link } from "react-router-dom";
import { keepPreviousData } from "@tanstack/react-query";
-import { Container, Heading } from "@medusajs/ui";
+import { Button, Container, Heading } from "@medusajs/ui";
import type { RouteConfig } from "@mercurjs/dashboard-sdk";
export const config: RouteConfig = {
@@ -48,6 +49,9 @@ const VendorCategoryRequestsPage = () => {
<Container className="divide-y p-0">
<div className="flex items-center justify-between px-6 py-4">
<Heading>Category Requests</Heading>
+ <Button size="small" variant="secondary" asChild>
+ <Link to="create">{t("actions.create")}</Link>
+ </Button>
</div>
<_DataTable
columns={columns}
diff --git a/packages/registry/src/requests/vendor/pages/requests/collections/create/page.tsx b/packages/registry/src/requests/vendor/pages/requests/collections/create/page.tsx
new file mode 100644
index 000000000..33a662eb7
--- /dev/null
+++ b/packages/registry/src/requests/vendor/pages/requests/collections/create/page.tsx
@@ -0,0 +1,114 @@
+import { zodResolver } from "@hookform/resolvers/zod";
+import { Button, Heading, Input, Text, toast } from "@medusajs/ui";
+import { useForm } from "react-hook-form";
+import { useTranslation } from "react-i18next";
+import * as zod from "zod";
+
+import {
+ Form,
+ RouteFocusModal,
+ useRouteModal,
+} from "@mercurjs/dashboard-shared";
+import { useCreateVendorRequest } from "../../../../hooks/api/requests";
+
+const CreateCollectionRequestSchema = zod.object({
+ title: zod.string().min(1),
+ handle: zod.string().optional(),
+});
+
+const CollectionRequestCreatePage = () => {
+ const { t } = useTranslation();
+ const { handleSuccess } = useRouteModal();
+
+ const form = useForm<zod.infer<typeof CreateCollectionRequestSchema>>({
+ defaultValues: {
+ title: "",
+ handle: "",
+ },
+ resolver: zodResolver(CreateCollectionRequestSchema),
+ });
+
+ const { mutateAsync, isPending } = useCreateVendorRequest(
+ "product_collection",
+ );
+
+ const handleSubmit = form.handleSubmit(async (data) => {
+ await mutateAsync(data, {
+ onSuccess: () => {
+ toast.success("Collection request created successfully");
+ handleSuccess(`/requests/collections`);
+ },
+ onError: (error) => {
+ toast.error(error.message);
+ },
+ });
+ });
+
+ return (
+ <RouteFocusModal>
+ <RouteFocusModal.Form form={form}>
+ <form
+ onSubmit={handleSubmit}
+ className="flex h-full flex-col overflow-hidden"
+ >
+ <RouteFocusModal.Header />
+ <RouteFocusModal.Body className="flex size-full flex-col items-center p-16">
+ <div className="flex w-full max-w-[720px] flex-col gap-y-8">
+ <div>
+ <Heading>Request Collection</Heading>
+ <Text size="small" className="text-ui-fg-subtle">
+ Submit a request to create a new product collection.
+ </Text>
+ </div>
+ <div className="grid grid-cols-1 gap-4 md:grid-cols-2">
+ <Form.Field
+ control={form.control}
+ name="title"
+ render={({ field }) => (
+ <Form.Item>
+ <Form.Label>{t("fields.title")}</Form.Label>
+ <Form.Control>
+ <Input autoComplete="off" {...field} />
+ </Form.Control>
+ <Form.ErrorMessage />
+ </Form.Item>
+ )}
+ />
+ <Form.Field
+ control={form.control}
+ name="handle"
+ render={({ field }) => (
+ <Form.Item>
+ <Form.Label optional>{t("fields.handle")}</Form.Label>
+ <Form.Control>
+ <Input autoComplete="off" {...field} />
+ </Form.Control>
+ <Form.ErrorMessage />
+ </Form.Item>
+ )}
+ />
+ </div>
+ </div>
+ </RouteFocusModal.Body>
+ <RouteFocusModal.Footer>
+ <RouteFocusModal.Close asChild>
+ <Button size="small" variant="secondary">
+ {t("actions.cancel")}
+ </Button>
+ </RouteFocusModal.Close>
+ <Button
+ size="small"
+ variant="primary"
+ type="submit"
+ isLoading={isPending}
+ >
+ {t("actions.create")}
+ </Button>
+ </RouteFocusModal.Footer>
+ </form>
+ </RouteFocusModal.Form>
+ </RouteFocusModal>
+ );
+};
+
+export default CollectionRequestCreatePage;
diff --git a/packages/registry/src/requests/vendor/pages/requests/collections/page.tsx b/packages/registry/src/requests/vendor/pages/requests/collections/page.tsx
index 148a2d04d..938185461 100644
--- a/packages/registry/src/requests/vendor/pages/requests/collections/page.tsx
+++ b/packages/registry/src/requests/vendor/pages/requests/collections/page.tsx
@@ -1,6 +1,7 @@
import { useTranslation } from "react-i18next";
+import { Link } from "react-router-dom";
import { keepPreviousData } from "@tanstack/react-query";
-import { Container, Heading } from "@medusajs/ui";
+import { Button, Container, Heading } from "@medusajs/ui";
import type { RouteConfig } from "@mercurjs/dashboard-sdk";
export const config: RouteConfig = {
@@ -48,6 +49,9 @@ const VendorCollectionRequestsPage = () => {
<Container className="divide-y p-0">
<div className="flex items-center justify-between px-6 py-4">
<Heading>Collection Requests</Heading>
+ <Button size="small" variant="secondary" asChild>
+ <Link to="create">{t("actions.create")}</Link>
+ </Button>
</div>
<_DataTable
columns={columns}
diff --git a/packages/registry/src/requests/vendor/pages/requests/tags/create/page.tsx b/packages/registry/src/requests/vendor/pages/requests/tags/create/page.tsx
new file mode 100644
index 000000000..f1a315af3
--- /dev/null
+++ b/packages/registry/src/requests/vendor/pages/requests/tags/create/page.tsx
@@ -0,0 +1,99 @@
+import { zodResolver } from "@hookform/resolvers/zod";
+import { Button, Heading, Input, Text, toast } from "@medusajs/ui";
+import { useForm } from "react-hook-form";
+import { useTranslation } from "react-i18next";
+import * as zod from "zod";
+
+import {
+ Form,
+ RouteFocusModal,
+ useRouteModal,
+} from "@mercurjs/dashboard-shared";
+import { useCreateVendorRequest } from "../../../../hooks/api/requests";
+
+const CreateTagRequestSchema = zod.object({
+ value: zod.string().min(1),
+});
+
+const TagRequestCreatePage = () => {
+ const { t } = useTranslation();
+ const { handleSuccess } = useRouteModal();
+
+ const form = useForm<zod.infer<typeof CreateTagRequestSchema>>({
+ defaultValues: {
+ value: "",
+ },
+ resolver: zodResolver(CreateTagRequestSchema),
+ });
+
+ const { mutateAsync, isPending } = useCreateVendorRequest("product_tag");
+
+ const handleSubmit = form.handleSubmit(async (data) => {
+ await mutateAsync(data, {
+ onSuccess: () => {
+ toast.success("Tag request created successfully");
+ handleSuccess(`/requests/tags`);
+ },
+ onError: (error) => {
+ toast.error(error.message);
+ },
+ });
+ });
+
+ return (
+ <RouteFocusModal>
+ <RouteFocusModal.Form form={form}>
+ <form
+ onSubmit={handleSubmit}
+ className="flex h-full flex-col overflow-hidden"
+ >
+ <RouteFocusModal.Header />
+ <RouteFocusModal.Body className="flex size-full flex-col items-center p-16">
+ <div className="flex w-full max-w-[720px] flex-col gap-y-8">
+ <div>
+ <Heading>Request Tag</Heading>
+ <Text size="small" className="text-ui-fg-subtle">
+ Submit a request to create a new product tag.
+ </Text>
+ </div>
+ <div className="grid grid-cols-1 gap-4 md:grid-cols-2">
+ <Form.Field
+ control={form.control}
+ name="value"
+ render={({ field }) => (
+ <Form.Item>
+ <Form.Label>
+ {t("productTags.fields.value")}
+ </Form.Label>
+ <Form.Control>
+ <Input autoComplete="off" {...field} />
+ </Form.Control>
+ <Form.ErrorMessage />
+ </Form.Item>
+ )}
+ />
+ </div>
+ </div>
+ </RouteFocusModal.Body>
+ <RouteFocusModal.Footer>
+ <RouteFocusModal.Close asChild>
+ <Button size="small" variant="secondary">
+ {t("actions.cancel")}
+ </Button>
+ </RouteFocusModal.Close>
+ <Button
+ size="small"
+ variant="primary"
+ type="submit"
+ isLoading={isPending}
+ >
+ {t("actions.create")}
+ </Button>
+ </RouteFocusModal.Footer>
+ </form>
+ </RouteFocusModal.Form>
+ </RouteFocusModal>
+ );
+};
+
+export default TagRequestCreatePage;
diff --git a/packages/registry/src/requests/vendor/pages/requests/tags/page.tsx b/packages/registry/src/requests/vendor/pages/requests/tags/page.tsx
index e782085e3..68d1e85d4 100644
--- a/packages/registry/src/requests/vendor/pages/requests/tags/page.tsx
+++ b/packages/registry/src/requests/vendor/pages/requests/tags/page.tsx
@@ -1,6 +1,7 @@
import { useTranslation } from "react-i18next";
+import { Link } from "react-router-dom";
import { keepPreviousData } from "@tanstack/react-query";
-import { Container, Heading } from "@medusajs/ui";
+import { Button, Container, Heading } from "@medusajs/ui";
import type { RouteConfig } from "@mercurjs/dashboard-sdk";
export const config: RouteConfig = {
@@ -48,6 +49,9 @@ const VendorTagRequestsPage = () => {
<Container className="divide-y p-0">
<div className="flex items-center justify-between px-6 py-4">
<Heading>Tag Requests</Heading>
+ <Button size="small" variant="secondary" asChild>
+ <Link to="create">{t("actions.create")}</Link>
+ </Button>
</div>
<_DataTable
columns={columns}
diff --git a/packages/registry/src/requests/vendor/pages/requests/types/create/page.tsx b/packages/registry/src/requests/vendor/pages/requests/types/create/page.tsx
new file mode 100644
index 000000000..8f7c942f3
--- /dev/null
+++ b/packages/registry/src/requests/vendor/pages/requests/types/create/page.tsx
@@ -0,0 +1,99 @@
+import { zodResolver } from "@hookform/resolvers/zod";
+import { Button, Heading, Input, Text, toast } from "@medusajs/ui";
+import { useForm } from "react-hook-form";
+import { useTranslation } from "react-i18next";
+import * as zod from "zod";
+
+import {
+ Form,
+ RouteFocusModal,
+ useRouteModal,
+} from "@mercurjs/dashboard-shared";
+import { useCreateVendorRequest } from "../../../../hooks/api/requests";
+
+const CreateTypeRequestSchema = zod.object({
+ value: zod.string().min(1),
+});
+
+const TypeRequestCreatePage = () => {
+ const { t } = useTranslation();
+ const { handleSuccess } = useRouteModal();
+
+ const form = useForm<zod.infer<typeof CreateTypeRequestSchema>>({
+ defaultValues: {
+ value: "",
+ },
+ resolver: zodResolver(CreateTypeRequestSchema),
+ });
+
+ const { mutateAsync, isPending } = useCreateVendorRequest("product_type");
+
+ const handleSubmit = form.handleSubmit(async (data) => {
+ await mutateAsync(data, {
+ onSuccess: () => {
+ toast.success("Type request created successfully");
+ handleSuccess(`/requests/types`);
+ },
+ onError: (error) => {
+ toast.error(error.message);
+ },
+ });
+ });
+
+ return (
+ <RouteFocusModal>
+ <RouteFocusModal.Form form={form}>
+ <form
+ onSubmit={handleSubmit}
+ className="flex h-full flex-col overflow-hidden"
+ >
+ <RouteFocusModal.Header />
+ <RouteFocusModal.Body className="flex size-full flex-col items-center p-16">
+ <div className="flex w-full max-w-[720px] flex-col gap-y-8">
+ <div>
+ <Heading>Request Type</Heading>
+ <Text size="small" className="text-ui-fg-subtle">
+ Submit a request to create a new product type.
+ </Text>
+ </div>
+ <div className="grid grid-cols-1 gap-4 md:grid-cols-2">
+ <Form.Field
+ control={form.control}
+ name="value"
+ render={({ field }) => (
+ <Form.Item>
+ <Form.Label>
+ {t("productTypes.fields.value")}
+ </Form.Label>
+ <Form.Control>
+ <Input autoComplete="off" {...field} />
+ </Form.Control>
+ <Form.ErrorMessage />
+ </Form.Item>
+ )}
+ />
+ </div>
+ </div>
+ </RouteFocusModal.Body>
+ <RouteFocusModal.Footer>
+ <RouteFocusModal.Close asChild>
+ <Button size="small" variant="secondary">
+ {t("actions.cancel")}
+ </Button>
+ </RouteFocusModal.Close>
+ <Button
+ size="small"
+ variant="primary"
+ type="submit"
+ isLoading={isPending}
+ >
+ {t("actions.create")}
+ </Button>
+ </RouteFocusModal.Footer>
+ </form>
+ </RouteFocusModal.Form>
+ </RouteFocusModal>
+ );
+};
+
+export default TypeRequestCreatePage;
diff --git a/packages/registry/src/requests/vendor/pages/requests/types/page.tsx b/packages/registry/src/requests/vendor/pages/requests/types/page.tsx
index 18ee19d09..a658c8789 100644
--- a/packages/registry/src/requests/vendor/pages/requests/types/page.tsx
+++ b/packages/registry/src/requests/vendor/pages/requests/types/page.tsx
@@ -1,6 +1,7 @@
import { useTranslation } from "react-i18next";
+import { Link } from "react-router-dom";
import { keepPreviousData } from "@tanstack/react-query";
-import { Container, Heading } from "@medusajs/ui";
+import { Button, Container, Heading } from "@medusajs/ui";
import type { RouteConfig } from "@mercurjs/dashboard-sdk";
export const config: RouteConfig = {
@@ -48,6 +49,9 @@ const VendorTypeRequestsPage = () => {
<Container className="divide-y p-0">
<div className="flex items-center justify-between px-6 py-4">
<Heading>Type Requests</Heading>
+ <Button size="small" variant="secondary" asChild>
+ <Link to="create">{t("actions.create")}</Link>
+ </Button>
</div>
<_DataTable
columns={columns}
diff --git a/packages/types/package.json b/packages/types/package.json
index a6da4e013..9c37d92cf 100644
--- a/packages/types/package.json
+++ b/packages/types/package.json
@@ -1,6 +1,6 @@
{
"name": "@mercurjs/types",
- "version": "2.0.0-canary.52",
+ "version": "2.0.0-canary.53",
"repository": {
"type": "git",
"url": "https://github.com/mercurjs/mercur",
diff --git a/packages/vendor/package.json b/packages/vendor/package.json
index dc6425aea..fcc39c806 100644
--- a/packages/vendor/package.json
+++ b/packages/vendor/package.json
@@ -1,6 +1,6 @@
{
"name": "@mercurjs/vendor",
- "version": "2.0.0-canary.52",
+ "version": "2.0.0-canary.53",
"repository": {
"type": "git",
"url": "https://github.com/mercurjs/mercur",
diff --git a/packages/vendor/src/components/layout/nav-item/nav-item.tsx b/packages/vendor/src/components/layout/nav-item/nav-item.tsx
index d873d1c35..dfd493055 100644
--- a/packages/vendor/src/components/layout/nav-item/nav-item.tsx
+++ b/packages/vendor/src/components/layout/nav-item/nav-item.tsx
@@ -1,60 +1,61 @@
-import { Kbd, Text, clx } from "@medusajs/ui"
-import { Collapsible as RadixCollapsible } from "radix-ui"
import {
PropsWithChildren,
ReactNode,
useCallback,
useEffect,
useState,
-} from "react"
-import { useTranslation } from "react-i18next"
-import { NavLink, useLocation } from "react-router-dom"
-import { useGlobalShortcuts } from "../../../providers/keybind-provider/hooks"
-import { ConditionalTooltip } from "../../common/conditional-tooltip"
+} from "react";
-type ItemType = "core" | "extension" | "setting"
+import { Kbd, Text, clx } from "@medusajs/ui";
+
+import { Collapsible as RadixCollapsible } from "radix-ui";
+import { useTranslation } from "react-i18next";
+import { NavLink, useLocation } from "react-router-dom";
+
+import { useGlobalShortcuts } from "../../../providers/keybind-provider/hooks";
+import { ConditionalTooltip } from "../../common/conditional-tooltip";
+
+type ItemType = "core" | "extension" | "setting";
type NestedItemProps = {
- label: string
- to: string
- translationNs?: string
-}
+ label: string;
+ to: string;
+};
export type INavItem = {
- icon?: ReactNode
- label: string
- to: string
- items?: NestedItemProps[]
- type?: ItemType
- from?: string
- nested?: string
- translationNs?: string
-}
+ icon?: ReactNode;
+ label: string;
+ to: string;
+ items?: NestedItemProps[];
+ type?: ItemType;
+ from?: string;
+ nested?: string;
+};
const BASE_NAV_LINK_CLASSES =
- "text-ui-fg-subtle transition-fg hover:bg-ui-bg-subtle-hover flex items-center gap-x-2 rounded-md py-0.5 pl-0.5 pr-2 outline-none [&>svg]:text-ui-fg-subtle focus-visible:shadow-borders-focus"
+ "text-ui-fg-subtle transition-fg hover:bg-ui-bg-subtle-hover flex items-center gap-x-2 rounded-md py-0.5 pl-0.5 pr-2 outline-none [&>svg]:text-ui-fg-subtle focus-visible:shadow-borders-focus";
const ACTIVE_NAV_LINK_CLASSES =
- "bg-ui-bg-base shadow-elevation-card-rest text-ui-fg-base hover:bg-ui-bg-base"
-const NESTED_NAV_LINK_CLASSES = "pl-[34px] pr-2 py-1 w-full text-ui-fg-muted"
-const SETTING_NAV_LINK_CLASSES = "pl-2 py-1"
+ "bg-ui-bg-base shadow-elevation-card-rest text-ui-fg-base hover:bg-ui-bg-base";
+const NESTED_NAV_LINK_CLASSES = "pl-[34px] pr-2 py-1 w-full text-ui-fg-muted";
+const SETTING_NAV_LINK_CLASSES = "pl-2 py-1";
const getIsOpen = (
to: string,
items: NestedItemProps[] | undefined,
- pathname: string
+ pathname: string,
) => {
return [to, ...(items?.map((i) => i.to) ?? [])].some((p) =>
- pathname.startsWith(p)
- )
-}
+ pathname.startsWith(p),
+ );
+};
const NavItemTooltip = ({
to,
children,
}: PropsWithChildren<{ to: string }>) => {
- const { t } = useTranslation()
- const globalShortcuts = useGlobalShortcuts()
- const shortcut = globalShortcuts.find((s) => s.to === to)
+ const { t } = useTranslation();
+ const globalShortcuts = useGlobalShortcuts();
+ const shortcut = globalShortcuts.find((s) => s.to === to);
return (
<ConditionalTooltip
@@ -68,7 +69,7 @@ const NavItemTooltip = ({
<div className="flex items-center gap-x-1" key={index}>
<Kbd key={key}>{key}</Kbd>
{index < (shortcut.keys.Mac?.length || 0) - 1 && (
- <span className="text-ui-fg-muted txt-compact-xsmall">
+ <span className="txt-compact-xsmall text-ui-fg-muted">
{t("app.keyboardShortcuts.then")}
</span>
)}
@@ -82,8 +83,8 @@ const NavItemTooltip = ({
>
<div className="w-full">{children}</div>
</ConditionalTooltip>
- )
-}
+ );
+};
export const NavItem = ({
icon,
@@ -92,25 +93,13 @@ export const NavItem = ({
items,
type = "core",
from,
- translationNs,
}: INavItem) => {
- const { t } = useTranslation(translationNs as any)
- const { pathname } = useLocation()
- const [open, setOpen] = useState(getIsOpen(to, items, pathname))
-
- // Use translation if translationNs is provided, otherwise use label as-is
- const displayLabel: string = translationNs ? t(label) : label
+ const { pathname } = useLocation();
+ const [open, setOpen] = useState(getIsOpen(to, items, pathname));
useEffect(() => {
- setOpen(getIsOpen(to, items, pathname))
- }, [pathname, to, items])
-
- const isNestedActive = useCallback(
- (nestedTo: string) => {
- return pathname === nestedTo || pathname.startsWith(nestedTo + "/")
- },
- [pathname]
- )
+ setOpen(getIsOpen(to, items, pathname));
+ }, [pathname, to, items]);
const navLinkClassNames = useCallback(
({
@@ -119,21 +108,21 @@ export const NavItem = ({
isNested = false,
isSetting = false,
}: {
- to: string
- isActive: boolean
- isNested?: boolean
- isSetting?: boolean
+ to: string;
+ isActive: boolean;
+ isNested?: boolean;
+ isSetting?: boolean;
}) => {
if (["core", "setting"].includes(type)) {
- if (isNested) {
- isActive = isNestedActive(to)
- } else if (items?.length) {
- // Parent is active only if pathname matches it directly
- // and no nested item's path matches
- const nestedMatch = items.some((item) => isNestedActive(item.to))
- isActive = pathname.startsWith(to) && !nestedMatch
- } else {
- isActive = pathname.startsWith(to)
+ isActive = pathname.startsWith(to);
+
+ if (isActive && !isNested && items?.length) {
+ const nestedIsActive = items.some((item) =>
+ pathname.startsWith(item.to),
+ );
+ if (nestedIsActive) {
+ isActive = false;
+ }
}
}
@@ -141,15 +130,18 @@ export const NavItem = ({
[NESTED_NAV_LINK_CLASSES]: isNested,
[ACTIVE_NAV_LINK_CLASSES]: isActive,
[SETTING_NAV_LINK_CLASSES]: isSetting,
- })
+ });
},
- [type, pathname, items, isNestedActive]
- )
+ [type, pathname, items],
+ );
- const isSetting = type === "setting"
+ const isSetting = type === "setting";
return (
- <div className="px-3">
+ <div
+ className="px-3"
+ data-testid={`sidebar-nav-item-${to.replace(/\//g, "-").replace(/^-/, "")}`}
+ >
<NavItemTooltip to={to}>
<NavLink
to={to}
@@ -164,8 +156,9 @@ export const NavItem = ({
className={({ isActive }) => {
return clx(navLinkClassNames({ isActive, isSetting, to }), {
"max-lg:hidden": !!items?.length,
- })
+ });
}}
+ data-testid={`sidebar-nav-link-${to.replace(/\//g, "-").replace(/^-/, "")}`}
>
{type !== "setting" && (
<div className="flex size-6 items-center justify-center">
@@ -173,7 +166,7 @@ export const NavItem = ({
</div>
)}
<Text size="small" weight="plus" leading="compact">
- {displayLabel}
+ {label}
</Text>
</NavLink>
</NavItemTooltip>
@@ -181,19 +174,22 @@ export const NavItem = ({
<RadixCollapsible.Root open={open} onOpenChange={setOpen}>
<RadixCollapsible.Trigger
className={clx(
- "text-ui-fg-subtle hover:text-ui-fg-base transition-fg hover:bg-ui-bg-subtle-hover flex w-full items-center gap-x-2 rounded-md py-0.5 pl-0.5 pr-2 outline-none lg:hidden",
- { "pl-2": isSetting }
+ "flex w-full items-center gap-x-2 rounded-md py-0.5 pl-0.5 pr-2 text-ui-fg-subtle outline-none transition-fg hover:bg-ui-bg-subtle-hover hover:text-ui-fg-base lg:hidden",
+ { "pl-2": isSetting },
)}
>
<div className="flex size-6 items-center justify-center">
<Icon icon={icon} type={type} />
</div>
<Text size="small" weight="plus" leading="compact">
- {displayLabel}
+ {label}
</Text>
</RadixCollapsible.Trigger>
<RadixCollapsible.Content>
- <div className="flex flex-col gap-y-0.5 pb-2 pt-0.5">
+ <div
+ className="flex flex-col gap-y-0.5 pb-2 pt-0.5"
+ data-testid={`sidebar-nav-nested-items-${to.replace(/\//g, "-").replace(/^-/, "")}`}
+ >
<ul className="flex flex-col gap-y-0.5">
<li className="flex w-full items-center gap-x-1 lg:hidden">
<NavItemTooltip to={to}>
@@ -207,20 +203,18 @@ export const NavItem = ({
isActive,
isSetting,
isNested: true,
- })
- )
+ }),
+ );
}}
+ data-testid={`sidebar-nav-link-nested-${to.replace(/\//g, "-").replace(/^-/, "")}`}
>
<Text size="small" weight="plus" leading="compact">
- {displayLabel}
+ {label}
</Text>
</NavLink>
</NavItemTooltip>
</li>
{items.map((item) => {
- const { t: itemT } = useTranslation(item.translationNs as any)
- const itemLabel: string = item.translationNs ? itemT(item.label) : item.label
-
return (
<li key={item.to} className="flex h-7 items-center">
<NavItemTooltip to={item.to}>
@@ -234,17 +228,18 @@ export const NavItem = ({
isActive,
isSetting,
isNested: true,
- })
- )
+ }),
+ );
}}
+ data-testid={`sidebar-nav-link-nested-${item.to.replace(/\//g, "-").replace(/^-/, "")}`}
>
<Text size="small" weight="plus" leading="compact">
- {itemLabel}
+ {item.label}
</Text>
</NavLink>
</NavItemTooltip>
</li>
- )
+ );
})}
</ul>
</div>
@@ -252,19 +247,19 @@ export const NavItem = ({
</RadixCollapsible.Root>
)}
</div>
- )
-}
+ );
+};
const Icon = ({ icon, type }: { icon?: ReactNode; type: ItemType }) => {
if (!icon) {
- return null
+ return null;
}
return type === "extension" ? (
- <div className="shadow-borders-base bg-ui-bg-base flex h-5 w-5 items-center justify-center rounded-[4px]">
+ <div className="flex h-5 w-5 items-center justify-center rounded-[4px] bg-ui-bg-base shadow-borders-base">
<div className="h-[15px] w-[15px] overflow-hidden rounded-sm">{icon}</div>
</div>
) : (
icon
- )
-}
+ );
+};
diff --git a/templates/basic/apps/admin/package.json b/templates/basic/apps/admin/package.json
index ef937e48c..58bf4597f 100644
--- a/templates/basic/apps/admin/package.json
+++ b/templates/basic/apps/admin/package.json
@@ -11,16 +11,16 @@
},
"dependencies": {
"@medusajs/icons": "^2.13.3",
- "@mercurjs/dashboard-sdk": "2.0.0-canary.52",
- "@mercurjs/dashboard-shared": "2.0.0-canary.52",
- "@mercurjs/admin": "2.0.0-canary.52",
+ "@mercurjs/dashboard-sdk": "2.0.0-canary.53",
+ "@mercurjs/dashboard-shared": "2.0.0-canary.53",
+ "@mercurjs/admin": "2.0.0-canary.53",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"react-i18next": "13.5.0",
"@tanstack/react-query": "5.64.2",
"@medusajs/ui": "4.1.1",
"react-router-dom": "6.30.3",
- "@mercurjs/client": "2.0.0-canary.52",
+ "@mercurjs/client": "2.0.0-canary.53",
"@acme/api": "*",
"@tanstack/react-table": "8.20.5",
"react-hook-form": "7.49.1",
diff --git a/templates/basic/apps/vendor/package.json b/templates/basic/apps/vendor/package.json
index 379bb6335..772dcf1ff 100644
--- a/templates/basic/apps/vendor/package.json
+++ b/templates/basic/apps/vendor/package.json
@@ -11,16 +11,16 @@
},
"dependencies": {
"@medusajs/icons": "^2.13.3",
- "@mercurjs/dashboard-sdk": "2.0.0-canary.52",
- "@mercurjs/dashboard-shared": "2.0.0-canary.52",
- "@mercurjs/vendor": "2.0.0-canary.52",
+ "@mercurjs/dashboard-sdk": "2.0.0-canary.53",
+ "@mercurjs/dashboard-shared": "2.0.0-canary.53",
+ "@mercurjs/vendor": "2.0.0-canary.53",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"react-i18next": "13.5.0",
"@tanstack/react-query": "5.64.2",
"@medusajs/ui": "4.1.1",
"react-router-dom": "6.30.3",
- "@mercurjs/client": "2.0.0-canary.52",
+ "@mercurjs/client": "2.0.0-canary.53",
"@acme/api": "*",
"@tanstack/react-table": "8.20.5",
"react-hook-form": "7.49.1",
diff --git a/templates/basic/packages/api/package.json b/templates/basic/packages/api/package.json
index 868509386..0da436b98 100644
--- a/templates/basic/packages/api/package.json
+++ b/templates/basic/packages/api/package.json
@@ -36,8 +36,8 @@
"@medusajs/admin-shared": "^2.13.3",
"@medusajs/medusa": "^2.13.3",
"@medusajs/draft-order": "2.13.3",
- "@mercurjs/core-plugin": "2.0.0-canary.52",
- "@mercurjs/types": "2.0.0-canary.52",
+ "@mercurjs/core-plugin": "2.0.0-canary.53",
+ "@mercurjs/types": "2.0.0-canary.53",
"zod": "3.25.76"
},
"devDependencies": {