@deenruv/admin-dashboard 1.0.17-dev.15 → 1.0.17-dev.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,11 +2,11 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  // eslint-disable-next-line no-restricted-imports
3
3
  import { I18nextProvider } from 'react-i18next';
4
4
  import { useEffect, useMemo } from 'react';
5
- import { createBrowserRouter, Navigate, RouterProvider } from 'react-router';
5
+ import { createBrowserRouter, RouterProvider } from 'react-router';
6
6
  import { AnimatePresence } from 'framer-motion';
7
7
  import { Toaster } from 'sonner';
8
8
  import i18n from './i18.js';
9
- import { Routes, PluginProvider, PluginStore, useServer, useSettings, GlobalStoreProvider, DEFAULT_CHANNEL_CODE, NotificationProvider, } from '@deenruv/react-ui-devkit';
9
+ import { PluginProvider, PluginStore, useServer, useSettings, GlobalStoreProvider, DEFAULT_CHANNEL_CODE, NotificationProvider, } from '@deenruv/react-ui-devkit';
10
10
  import { useShallow } from 'zustand/react/shallow';
11
11
  import { LanguageCode } from '@deenruv/admin-types';
12
12
  import { Root } from "./pages/Root.js";
@@ -17,6 +17,7 @@ import { ADMIN_DASHBOARD_VERSION } from "./version.js";
17
17
  import { ORDER_STATUS_NOTIFICATION } from "./notifications/OrderStatusNotification.js";
18
18
  import { SYSTEM_STATUS_NOTIFICATION } from "./notifications/SystemStatusNotification.js";
19
19
  import { AdminAccessProvider, builtInAdminRoutes, getDefaultAdminRoute, getPermittedAdminRoutes, } from "./access/index.js";
20
+ import { createAdminRouterRoutes } from "./access/admin-router.js";
20
21
  const loadTranslations = () => {
21
22
  Object.entries(resources).forEach(([lang, value]) => {
22
23
  Object.entries(value).forEach(([, translations]) => {
@@ -63,22 +64,12 @@ export const DeenruvAdminPanel = ({ plugins, settings }) => {
63
64
  })), [plugins]);
64
65
  const permittedRoutes = useMemo(() => getPermittedAdminRoutes([...builtInAdminRoutes, ...pluginRoutes], userPermissions), [pluginRoutes, userPermissions]);
65
66
  const defaultRoute = getDefaultAdminRoute(permittedRoutes);
66
- const router = useMemo(() => {
67
- const routerChildren = permittedRoutes.map(({ path, element }) => ({ path, element }));
68
- if (defaultRoute && !permittedRoutes.some((route) => route.path === Routes.dashboard)) {
69
- routerChildren.push({ path: Routes.dashboard, element: _jsx(Navigate, { to: defaultRoute.path, replace: true }) });
70
- }
71
- if (defaultRoute) {
72
- routerChildren.push({ path: '*', element: _jsx(Navigate, { to: defaultRoute.path, replace: true }) });
73
- }
74
- return createBrowserRouter([
75
- {
76
- element: _jsx(Root, { allPaths: permittedRoutes.map((route) => route.path).filter(Boolean) }),
77
- errorElement: _jsx(ErrorPage, {}),
78
- children: routerChildren,
79
- },
80
- ]);
81
- }, [defaultRoute, permittedRoutes]);
67
+ const router = useMemo(() => createBrowserRouter(createAdminRouterRoutes({
68
+ permittedRoutes,
69
+ defaultRoute,
70
+ rootElement: _jsx(Root, { allPaths: permittedRoutes.map((route) => route.path).filter(Boolean) }),
71
+ errorElement: _jsx(ErrorPage, {}),
72
+ })), [defaultRoute, permittedRoutes]);
82
73
  useEffect(() => {
83
74
  const root = window.document.documentElement;
84
75
  root.classList.remove('light', 'dark');
@@ -0,0 +1,21 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Routes } from '@deenruv/react-ui-devkit';
3
+ import { Navigate } from 'react-router';
4
+ export const createAdminRouterRoutes = ({ permittedRoutes, defaultRoute, rootElement, errorElement, }) => {
5
+ const children = permittedRoutes.map(({ id, path, element }) => ({ id, path, element }));
6
+ if (defaultRoute && !permittedRoutes.some((route) => route.path === Routes.dashboard)) {
7
+ children.push({
8
+ id: 'admin.fallback.dashboard',
9
+ path: Routes.dashboard,
10
+ element: _jsx(Navigate, { to: defaultRoute.path, replace: true }),
11
+ });
12
+ }
13
+ if (defaultRoute) {
14
+ children.push({
15
+ id: 'admin.fallback.wildcard',
16
+ path: '*',
17
+ element: _jsx(Navigate, { to: defaultRoute.path, replace: true }),
18
+ });
19
+ }
20
+ return [{ id: 'admin.root', element: rootElement, errorElement, children }];
21
+ };
@@ -5,6 +5,7 @@ import { OptionsTab } from "./_components/OptionsTab";
5
5
  import { ProductDetailView } from './_components/ProductDetailView';
6
6
  import { ProductDetailSidebar } from './_components/ProductDetailSidebar';
7
7
  import { ProductStorefrontAction } from './_components/productStorefrontAction';
8
+ import { getProductInitialVariantFormConfig } from './ProductInitialVariantFormConfig';
8
9
  import { DEFAULT_CHANNEL_CODE, useTranslation, createDeenruvForm, DetailView, useMutation, useSettings, } from '@deenruv/react-ui-devkit';
9
10
  import { $, Permission, scalars, typedGql } from '@deenruv/admin-types';
10
11
  import { useMemo } from 'react';
@@ -58,19 +59,7 @@ export const ProductsDetailPage = () => {
58
59
  return [t('validation.nameSlugRequired')];
59
60
  },
60
61
  },
61
- ...{
62
- initialVariantSku: {
63
- validate: (v) => {
64
- if (!id && (!v || typeof v !== 'string' || !v.trim())) {
65
- return [t('validation.initialVariantSkuRequired')];
66
- }
67
- },
68
- },
69
- initialVariantPrice: {
70
- initialValue: 0,
71
- },
72
- initialVariantName: {},
73
- },
62
+ ...getProductInitialVariantFormConfig(!id, t('validation.initialVariantSkuRequired')),
74
63
  },
75
64
  onSubmitted: async (data) => {
76
65
  if (!data.translations)
@@ -0,0 +1,17 @@
1
+ export const getProductInitialVariantFormConfig = (isCreating, initialVariantSkuRequiredError) => {
2
+ if (!isCreating)
3
+ return {};
4
+ return {
5
+ initialVariantSku: {
6
+ validate: (value) => {
7
+ if (!value || typeof value !== 'string' || !value.trim()) {
8
+ return [initialVariantSkuRequiredError];
9
+ }
10
+ },
11
+ },
12
+ initialVariantPrice: {
13
+ initialValue: 0,
14
+ },
15
+ initialVariantName: {},
16
+ };
17
+ };
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const ADMIN_DASHBOARD_VERSION = '1.0.17-dev.15';
1
+ export const ADMIN_DASHBOARD_VERSION = '1.0.17-dev.17';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deenruv/admin-dashboard",
3
- "version": "1.0.17-dev.15",
3
+ "version": "1.0.17-dev.17",
4
4
  "main": "dist/index.js",
5
5
  "style": "dist/index.css",
6
6
  "types": "dist/index.d.ts",
@@ -80,10 +80,10 @@
80
80
  "yup": "^1.7.1",
81
81
  "zod": "^4.4.3",
82
82
  "zustand": "^5.0.14",
83
- "@deenruv/admin-dashboard": "1.0.17-dev.15",
84
- "@deenruv/admin-types": "1.0.17-dev.15",
85
- "@deenruv/deenruv-examples-plugin": "1.0.17-dev.15",
86
- "@deenruv/react-ui-devkit": "1.0.17-dev.15"
83
+ "@deenruv/admin-dashboard": "1.0.17-dev.17",
84
+ "@deenruv/admin-types": "1.0.17-dev.17",
85
+ "@deenruv/deenruv-examples-plugin": "1.0.17-dev.17",
86
+ "@deenruv/react-ui-devkit": "1.0.17-dev.17"
87
87
  },
88
88
  "devDependencies": {
89
89
  "@tailwindcss/typography": "^0.5.20",