@deenruv/admin-dashboard 1.0.0
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.
- package/LICENSE +23 -0
- package/README.md +30 -0
- package/dist/@types/resources.js +51 -0
- package/dist/DeenruvAdminPanel.js +118 -0
- package/dist/DeenruvDeveloperIndicator.js +57 -0
- package/dist/components/Aexol.js +4 -0
- package/dist/components/BrandLogo.js +22 -0
- package/dist/components/CanLeaveRouteDialog.js +8 -0
- package/dist/components/DataTable.js +13 -0
- package/dist/components/DeleteDialog.js +6 -0
- package/dist/components/DuplicateEntry.js +46 -0
- package/dist/components/GlobalSearch.js +134 -0
- package/dist/components/History/AddEntryForm.js +29 -0
- package/dist/components/History/DeleteEntryDialog.js +25 -0
- package/dist/components/History/EditEntryDialog.js +32 -0
- package/dist/components/History/History.js +13 -0
- package/dist/components/History/ModifyHistoryInfo.js +6 -0
- package/dist/components/History/Timeline.js +53 -0
- package/dist/components/History/index.js +5 -0
- package/dist/components/Menu/ActiveAdmins.js +24 -0
- package/dist/components/Menu/ChannelSwitcher.js +20 -0
- package/dist/components/Menu/LanguagesDropdown.js +26 -0
- package/dist/components/Menu/Navigation.js +270 -0
- package/dist/components/Menu/NavigationFooter.js +12 -0
- package/dist/components/Menu/Notifications.js +90 -0
- package/dist/components/Menu/index.js +67 -0
- package/dist/components/index.js +6 -0
- package/dist/graphql/base.js +95 -0
- package/dist/graphql/collections.js +94 -0
- package/dist/graphql/draft_order.js +307 -0
- package/dist/graphql/orders.js +157 -0
- package/dist/graphql/products.js +230 -0
- package/dist/graphql/scalars.js +22 -0
- package/dist/i18.js +13 -0
- package/dist/index.css +161 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +1 -0
- package/dist/locales/en/admins.json +57 -0
- package/dist/locales/en/assets.json +69 -0
- package/dist/locales/en/channels.json +66 -0
- package/dist/locales/en/collections.json +145 -0
- package/dist/locales/en/common.json +1127 -0
- package/dist/locales/en/countries.json +50 -0
- package/dist/locales/en/customerGroups.json +6 -0
- package/dist/locales/en/customers.json +109 -0
- package/dist/locales/en/dashboard.json +34 -0
- package/dist/locales/en/facets.json +78 -0
- package/dist/locales/en/globalSettings.json +15 -0
- package/dist/locales/en/index.js +52 -0
- package/dist/locales/en/orders.json +932 -0
- package/dist/locales/en/paymentMethods.json +59 -0
- package/dist/locales/en/permissions.json +94 -0
- package/dist/locales/en/products.json +194 -0
- package/dist/locales/en/promotions.json +65 -0
- package/dist/locales/en/roles.json +59 -0
- package/dist/locales/en/sellers.json +41 -0
- package/dist/locales/en/shippingMethods.json +84 -0
- package/dist/locales/en/stockLocations.json +40 -0
- package/dist/locales/en/system.json +41 -0
- package/dist/locales/en/table.json +201 -0
- package/dist/locales/en/taxCategories.json +47 -0
- package/dist/locales/en/taxRates.json +56 -0
- package/dist/locales/en/zones.json +47 -0
- package/dist/locales/index.js +2 -0
- package/dist/locales/pl/admins.json +57 -0
- package/dist/locales/pl/assets.json +69 -0
- package/dist/locales/pl/channels.json +66 -0
- package/dist/locales/pl/collections.json +145 -0
- package/dist/locales/pl/common.json +1128 -0
- package/dist/locales/pl/countries.json +50 -0
- package/dist/locales/pl/customerGroups.json +6 -0
- package/dist/locales/pl/customers.json +109 -0
- package/dist/locales/pl/dashboard.json +34 -0
- package/dist/locales/pl/facets.json +78 -0
- package/dist/locales/pl/globalSettings.json +15 -0
- package/dist/locales/pl/index.js +52 -0
- package/dist/locales/pl/orders.json +932 -0
- package/dist/locales/pl/paymentMethods.json +59 -0
- package/dist/locales/pl/permissions.json +94 -0
- package/dist/locales/pl/products.json +194 -0
- package/dist/locales/pl/promotions.json +65 -0
- package/dist/locales/pl/roles.json +59 -0
- package/dist/locales/pl/sellers.json +41 -0
- package/dist/locales/pl/shippingMethods.json +84 -0
- package/dist/locales/pl/stockLocations.json +40 -0
- package/dist/locales/pl/system.json +41 -0
- package/dist/locales/pl/table.json +201 -0
- package/dist/locales/pl/taxCategories.json +47 -0
- package/dist/locales/pl/taxRates.json +56 -0
- package/dist/locales/pl/zones.json +47 -0
- package/dist/notifications/OrderStatusNotification.js +47 -0
- package/dist/notifications/SystemStatusNotification.js +19 -0
- package/dist/pages/Custom404.js +5 -0
- package/dist/pages/LoginScreen.js +37 -0
- package/dist/pages/Root.js +252 -0
- package/dist/pages/admins/Detail.js +72 -0
- package/dist/pages/admins/List.js +56 -0
- package/dist/pages/admins/_components/AdminDetailView.js +34 -0
- package/dist/pages/admins/_components/RolesCard.js +31 -0
- package/dist/pages/admins/index.js +2 -0
- package/dist/pages/assets/List.js +82 -0
- package/dist/pages/assets/_components/Asset.js +114 -0
- package/dist/pages/assets/_components/AssetListView.js +29 -0
- package/dist/pages/assets/_components/EditAssetDialog.js +85 -0
- package/dist/pages/assets/_components/UploadAssetDialog.js +133 -0
- package/dist/pages/assets/_components/UploadProgress.js +20 -0
- package/dist/pages/assets/index.js +1 -0
- package/dist/pages/channels/Detail.js +149 -0
- package/dist/pages/channels/List.js +46 -0
- package/dist/pages/channels/_components/ChannelDetailView.js +51 -0
- package/dist/pages/channels/_components/DefaultsCard.js +25 -0
- package/dist/pages/channels/index.js +2 -0
- package/dist/pages/collections/Detail.js +61 -0
- package/dist/pages/collections/List.js +135 -0
- package/dist/pages/collections/_components/CollectionDetailView.js +52 -0
- package/dist/pages/collections/_components/CollectionProductVariantsDrawer.js +28 -0
- package/dist/pages/collections/_components/CombinationMode.js +6 -0
- package/dist/pages/collections/_components/ContentsCard.js +43 -0
- package/dist/pages/collections/_components/ContentsTable.js +102 -0
- package/dist/pages/collections/_components/DeleteCollectionsFromChannel.js +36 -0
- package/dist/pages/collections/_components/FacetsSelector.js +30 -0
- package/dist/pages/collections/_components/FiltersCard.js +101 -0
- package/dist/pages/collections/_components/MoveCollectionsToCollections.js +107 -0
- package/dist/pages/collections/_components/MoveEntityToChannels.js +115 -0
- package/dist/pages/collections/_components/PageHeader.js +11 -0
- package/dist/pages/collections/_components/SelectedCollectionsModal.js +22 -0
- package/dist/pages/collections/_components/VariantsSelector.js +43 -0
- package/dist/pages/collections/consts.js +7 -0
- package/dist/pages/collections/index.js +2 -0
- package/dist/pages/countries/Detail.js +57 -0
- package/dist/pages/countries/List.js +47 -0
- package/dist/pages/countries/_components/CountryDetailView.js +28 -0
- package/dist/pages/countries/index.js +2 -0
- package/dist/pages/customer-groups/Detail.js +76 -0
- package/dist/pages/customer-groups/List.js +41 -0
- package/dist/pages/customer-groups/_components/CustomerGroupsDetailView.js +21 -0
- package/dist/pages/customer-groups/index.js +2 -0
- package/dist/pages/customers/Detail.js +75 -0
- package/dist/pages/customers/List.js +60 -0
- package/dist/pages/customers/_components/Address.js +59 -0
- package/dist/pages/customers/_components/AddressDialog.js +56 -0
- package/dist/pages/customers/_components/AddressForm.js +77 -0
- package/dist/pages/customers/_components/AddressesCard.js +9 -0
- package/dist/pages/customers/_components/CustomerDetailSidebar.js +9 -0
- package/dist/pages/customers/_components/CustomerDetailView.js +41 -0
- package/dist/pages/customers/_components/CustomerGroupsCard.js +46 -0
- package/dist/pages/customers/_components/HistoryTab.js +65 -0
- package/dist/pages/customers/_components/OrdersTab.js +46 -0
- package/dist/pages/customers/_components/PersonalDataCard.js +6 -0
- package/dist/pages/customers/_components/VerifiedCard.js +6 -0
- package/dist/pages/customers/index.js +2 -0
- package/dist/pages/dashboard/Dashboard.js +10 -0
- package/dist/pages/dashboard/index.js +1 -0
- package/dist/pages/extensions/Extensions.js +74 -0
- package/dist/pages/extensions/index.js +1 -0
- package/dist/pages/facets/Detail.js +56 -0
- package/dist/pages/facets/List.js +48 -0
- package/dist/pages/facets/_components/AddFacetValueDialog.js +105 -0
- package/dist/pages/facets/_components/ColorSample.js +18 -0
- package/dist/pages/facets/_components/FacetDetailView.js +98 -0
- package/dist/pages/facets/index.js +2 -0
- package/dist/pages/global-settings/GlobalSettingsComponent.js +30 -0
- package/dist/pages/global-settings/index.js +71 -0
- package/dist/pages/index.js +25 -0
- package/dist/pages/orders/Detail.js +21 -0
- package/dist/pages/orders/List.js +132 -0
- package/dist/pages/orders/_components/AddPaymentDialog.js +50 -0
- package/dist/pages/orders/_components/AddressCard.js +260 -0
- package/dist/pages/orders/_components/CancelAndRefundDialog.js +29 -0
- package/dist/pages/orders/_components/ChangesRegister.js +68 -0
- package/dist/pages/orders/_components/ChangesRegisterTable.js +18 -0
- package/dist/pages/orders/_components/CouponCodesCard.js +85 -0
- package/dist/pages/orders/_components/CustomComponent.js +21 -0
- package/dist/pages/orders/_components/CustomerSelectCard.js +117 -0
- package/dist/pages/orders/_components/EditNoteButton.js +10 -0
- package/dist/pages/orders/_components/FulfillmentModal.js +85 -0
- package/dist/pages/orders/_components/LineItem.js +7 -0
- package/dist/pages/orders/_components/ManualOrderChangeModal.js +47 -0
- package/dist/pages/orders/_components/ModifyAcceptModal.js +22 -0
- package/dist/pages/orders/_components/ModifyingCard.js +77 -0
- package/dist/pages/orders/_components/OrderHistory.js +59 -0
- package/dist/pages/orders/_components/OrderLineActionModal/ActionQuantityPrice.js +58 -0
- package/dist/pages/orders/_components/OrderLineActionModal/index.js +7 -0
- package/dist/pages/orders/_components/OrderLineActionModal/types.js +1 -0
- package/dist/pages/orders/_components/OrderLineCustomFields.js +26 -0
- package/dist/pages/orders/_components/OrderSummary.js +10 -0
- package/dist/pages/orders/_components/PaymentMetadata.js +6 -0
- package/dist/pages/orders/_components/Payments.js +113 -0
- package/dist/pages/orders/_components/PossibleOrderStates.js +54 -0
- package/dist/pages/orders/_components/PriceChangedInfo.js +16 -0
- package/dist/pages/orders/_components/ProductsCard.js +308 -0
- package/dist/pages/orders/_components/ProductsTable.js +29 -0
- package/dist/pages/orders/_components/PromotionsList.js +73 -0
- package/dist/pages/orders/_components/RealizationCard.js +98 -0
- package/dist/pages/orders/_components/RefundCard.js +11 -0
- package/dist/pages/orders/_components/RefundPaymentCard.js +13 -0
- package/dist/pages/orders/_components/ShippingMethod.js +112 -0
- package/dist/pages/orders/_components/SpecialLineItem.js +7 -0
- package/dist/pages/orders/_components/SurchargeCard.js +99 -0
- package/dist/pages/orders/_components/SurchargeTable.js +8 -0
- package/dist/pages/orders/_components/TaxSummary.js +11 -0
- package/dist/pages/orders/_components/ToRealizationForm.js +64 -0
- package/dist/pages/orders/_components/TopActions.js +219 -0
- package/dist/pages/orders/_components/index.js +25 -0
- package/dist/pages/orders/index.js +2 -0
- package/dist/pages/payment-methods/Detail.js +67 -0
- package/dist/pages/payment-methods/List.js +41 -0
- package/dist/pages/payment-methods/_components/OptionsCard.js +60 -0
- package/dist/pages/payment-methods/_components/PaymentMethodDetailView.js +53 -0
- package/dist/pages/payment-methods/index.js +2 -0
- package/dist/pages/product-variants/Detail.js +4 -0
- package/dist/pages/product-variants/List.js +76 -0
- package/dist/pages/product-variants/index.js +2 -0
- package/dist/pages/products/Detail.js +75 -0
- package/dist/pages/products/List.js +79 -0
- package/dist/pages/products/_components/AddOptionGroupDialog.js +65 -0
- package/dist/pages/products/_components/AssetsCard.js +35 -0
- package/dist/pages/products/_components/BasicFieldsCard.js +6 -0
- package/dist/pages/products/_components/ChannelsCard.js +6 -0
- package/dist/pages/products/_components/CollectionsCard.js +6 -0
- package/dist/pages/products/_components/Container.js +4 -0
- package/dist/pages/products/_components/DiscountRatingCard.js +6 -0
- package/dist/pages/products/_components/FacetValuesCard.js +6 -0
- package/dist/pages/products/_components/ImagesCard.js +6 -0
- package/dist/pages/products/_components/OptionGroup.js +93 -0
- package/dist/pages/products/_components/OptionValueCard.js +59 -0
- package/dist/pages/products/_components/OptionsCard.js +38 -0
- package/dist/pages/products/_components/OptionsTab.js +40 -0
- package/dist/pages/products/_components/PriceCard.js +27 -0
- package/dist/pages/products/_components/ProductDetailSidebar.js +30 -0
- package/dist/pages/products/_components/ProductDetailView.js +54 -0
- package/dist/pages/products/_components/SettingsCard.js +6 -0
- package/dist/pages/products/_components/StockCard.js +40 -0
- package/dist/pages/products/_components/Variant.js +149 -0
- package/dist/pages/products/_components/VariantsTab.js +46 -0
- package/dist/pages/products/index.js +2 -0
- package/dist/pages/promotions/Detail.js +80 -0
- package/dist/pages/promotions/List.js +38 -0
- package/dist/pages/promotions/_components/ActionsCard.js +67 -0
- package/dist/pages/promotions/_components/BasicFieldsCard.js +6 -0
- package/dist/pages/promotions/_components/ConditionsCard.js +70 -0
- package/dist/pages/promotions/_components/CustomerGroupsSelector.js +25 -0
- package/dist/pages/promotions/_components/EnabledCard.js +6 -0
- package/dist/pages/promotions/_components/OptionsCard.js +6 -0
- package/dist/pages/promotions/_components/PromotionDetailSidebar.js +15 -0
- package/dist/pages/promotions/_components/PromotionDetailView.js +66 -0
- package/dist/pages/promotions/_components/PromotionFieldRender.js +4 -0
- package/dist/pages/promotions/index.js +2 -0
- package/dist/pages/roles/Detail.js +72 -0
- package/dist/pages/roles/List.js +70 -0
- package/dist/pages/roles/_components/PermissionsCard.js +7 -0
- package/dist/pages/roles/_components/PermissionsTable.js +42 -0
- package/dist/pages/roles/_components/RoleDetailView.js +49 -0
- package/dist/pages/roles/index.js +2 -0
- package/dist/pages/sellers/Detail.js +48 -0
- package/dist/pages/sellers/List.js +37 -0
- package/dist/pages/sellers/_components/SellerDetailView.js +20 -0
- package/dist/pages/sellers/index.js +2 -0
- package/dist/pages/shipping-methods/Detail.js +105 -0
- package/dist/pages/shipping-methods/List.js +40 -0
- package/dist/pages/shipping-methods/_components/CalculatorCard.js +79 -0
- package/dist/pages/shipping-methods/_components/CheckerCard.js +76 -0
- package/dist/pages/shipping-methods/_components/Lines.js +20 -0
- package/dist/pages/shipping-methods/_components/ShippingMethodDetailView.js +67 -0
- package/dist/pages/shipping-methods/_components/TestCard.js +62 -0
- package/dist/pages/shipping-methods/index.js +2 -0
- package/dist/pages/status/Status.js +6 -0
- package/dist/pages/status/_components/FilterToolbar.js +29 -0
- package/dist/pages/status/_components/Health.js +21 -0
- package/dist/pages/status/_components/JobResultPopover.js +8 -0
- package/dist/pages/status/_components/Jobs.js +199 -0
- package/dist/pages/status/_components/JsonExplorer.js +44 -0
- package/dist/pages/status/_components/JsonPopup.js +8 -0
- package/dist/pages/status/index.js +1 -0
- package/dist/pages/stock-locations/Detail.js +77 -0
- package/dist/pages/stock-locations/List.js +38 -0
- package/dist/pages/stock-locations/_components/StockLocationDetailView.js +22 -0
- package/dist/pages/stock-locations/index.js +2 -0
- package/dist/pages/tax-categories/Detail.js +85 -0
- package/dist/pages/tax-categories/List.js +46 -0
- package/dist/pages/tax-categories/_components/TaxCategoryDetailView.js +24 -0
- package/dist/pages/tax-categories/index.js +2 -0
- package/dist/pages/tax-rates/Detail.js +62 -0
- package/dist/pages/tax-rates/List.js +64 -0
- package/dist/pages/tax-rates/_components/TaxRateDetailView.js +64 -0
- package/dist/pages/tax-rates/index.js +2 -0
- package/dist/pages/zones/Detail.js +86 -0
- package/dist/pages/zones/List.js +52 -0
- package/dist/pages/zones/_components/ZoneDetailView.js +49 -0
- package/dist/pages/zones/index.js +2 -0
- package/dist/version.js +1 -0
- package/package.json +122 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { JobState } from '@deenruv/admin-types';
|
|
3
|
+
import { useTranslation, Checkbox, SimpleSelect, useServer } from '@deenruv/react-ui-devkit';
|
|
4
|
+
export const FilterToolbar = ({ Search, stateFilter, setStateFilter, jobQueueFilter, setJobQueueFilter, liveUpdate, setLiveUpdate, }) => {
|
|
5
|
+
const { t } = useTranslation('system');
|
|
6
|
+
const { jobQueues } = useServer();
|
|
7
|
+
const jobStatesOptions = [
|
|
8
|
+
{ label: t('jobs.allStates'), value: 'undefined' },
|
|
9
|
+
...Object.entries(JobState).map(([key, value]) => ({
|
|
10
|
+
label: t('jobs.states.' + key.toLowerCase()),
|
|
11
|
+
value,
|
|
12
|
+
color: value === JobState.COMPLETED
|
|
13
|
+
? 'green'
|
|
14
|
+
: value === JobState.RETRYING
|
|
15
|
+
? 'goldenrod'
|
|
16
|
+
: value === JobState.FAILED
|
|
17
|
+
? 'firebrick'
|
|
18
|
+
: undefined,
|
|
19
|
+
})),
|
|
20
|
+
];
|
|
21
|
+
const jobQueuesOptions = [
|
|
22
|
+
{ label: t('jobs.allNames'), value: 'undefined' },
|
|
23
|
+
...jobQueues.map((q) => ({
|
|
24
|
+
label: q.name,
|
|
25
|
+
value: q.name,
|
|
26
|
+
})),
|
|
27
|
+
];
|
|
28
|
+
return (_jsxs("div", { className: "flex items-center gap-2", children: [_jsxs("div", { className: "flex items-center space-x-2", children: [_jsx(Checkbox, { id: "live-update", checked: liveUpdate, onCheckedChange: setLiveUpdate }), _jsx("label", { htmlFor: "live-update", className: "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70", children: t('jobs.live') })] }), _jsx(SimpleSelect, { placeholder: t('jobs.allStates'), options: jobStatesOptions, value: stateFilter, onValueChange: setStateFilter, wrapperClassName: "w-[160px]", className: "h-8" }), _jsx(SimpleSelect, { placeholder: t('jobs.allNames'), options: jobQueuesOptions, value: jobQueueFilter, onValueChange: setJobQueueFilter, wrapperClassName: "w-[160px]", className: "h-8" })] }));
|
|
29
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useTranslation, Badge, Button, CardIcons, cn, CustomCard, Skeleton, useServer, } from '@deenruv/react-ui-devkit';
|
|
3
|
+
import { RefreshCw, AlertCircle, CheckCircle, XCircle } from 'lucide-react';
|
|
4
|
+
const getStatusBadge = (status) => {
|
|
5
|
+
const statusLower = status.toLowerCase();
|
|
6
|
+
if (statusLower === 'up' || statusLower === 'ok' || statusLower === 'healthy') {
|
|
7
|
+
return (_jsxs(Badge, { variant: "outline", className: "flex select-none items-center gap-1 border-green-200 bg-green-50 text-green-700", children: [_jsx(CheckCircle, { className: "size-3.5" }), status] }));
|
|
8
|
+
}
|
|
9
|
+
else if (statusLower === 'degraded' || statusLower === 'warning') {
|
|
10
|
+
return (_jsxs(Badge, { variant: "outline", className: "flex select-none items-center gap-1 border-amber-200 bg-amber-50 text-amber-700", children: [_jsx(AlertCircle, { className: "size-3.5" }), status] }));
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
return (_jsxs(Badge, { variant: "outline", className: "flex select-none items-center gap-1 border-red-200 bg-red-50 text-red-700", children: [_jsx(XCircle, { className: "size-3.5" }), status] }));
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
export const Health = () => {
|
|
17
|
+
const { t } = useTranslation('system');
|
|
18
|
+
const { data, lastUpdated, loading } = useServer((state) => state.status);
|
|
19
|
+
const fetchStatus = useServer((state) => state.fetchStatus);
|
|
20
|
+
return (_jsx(CustomCard, { title: t('health.title'), ...(lastUpdated && { description: t('health.updated') + '' + lastUpdated.toLocaleTimeString() }), color: data.status ? (data.status === 'up' ? 'green' : 'red') : 'gray', icon: _jsx(CardIcons.action, {}), upperRight: _jsxs(Button, { variant: "outline", size: "sm", onClick: fetchStatus, disabled: loading, className: "h-9", children: [_jsx(RefreshCw, { className: cn('mr-2 h-4 w-4', loading && 'animate-spin') }), loading ? t('health.refreshing') : t('health.refresh')] }), children: loading && !data.status ? (_jsxs("div", { className: "space-y-4", children: [_jsx(Skeleton, { className: "h-6 w-32" }), _jsxs("div", { className: "space-y-2", children: [_jsx(Skeleton, { className: "h-5 w-full" }), _jsx(Skeleton, { className: "h-5 w-full" }), _jsx(Skeleton, { className: "h-5 w-3/4" })] })] })) : data.status ? (_jsxs("div", { className: "space-y-6", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx("h3", { className: "text-base font-medium", children: t('health.status') }), getStatusBadge(data.status)] }), _jsxs("div", { children: [_jsx("h3", { className: "mb-3 text-base font-medium", children: t('health.details') }), _jsx("div", { className: "divide-y rounded-md border", children: Object.entries(data.details).map(([key, detail], index) => (_jsxs("div", { className: cn('flex items-center justify-between px-4 py-3', index % 2 === 0 ? 'bg-muted/20' : 'bg-background'), children: [_jsx("span", { className: "text-sm font-medium", children: key }), getStatusBadge(detail.status)] }, key))) })] })] })) : (_jsxs("div", { className: "flex flex-col items-center justify-center py-8 text-center", children: [_jsx(AlertCircle, { className: "text-muted-foreground mb-3 size-10" }), _jsx("h3", { className: "text-lg font-medium", children: t('health.error.title') }), _jsx("p", { className: "text-muted-foreground mt-1 text-sm", children: t('health.error.description') }), _jsx(Button, { variant: "outline", size: "sm", onClick: fetchStatus, className: "mt-4", children: t('health.error.button') })] })) }));
|
|
21
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { FileText } from 'lucide-react';
|
|
4
|
+
import { useTranslation, Popover, PopoverContent, PopoverTrigger, Button } from '@deenruv/react-ui-devkit';
|
|
5
|
+
export function JobResultPopover({ result }) {
|
|
6
|
+
const { t } = useTranslation('system');
|
|
7
|
+
return (_jsxs(Popover, { children: [_jsx(PopoverTrigger, { asChild: true, children: _jsxs(Button, { variant: "outline", size: 'sm', className: "bg-muted/50 flex h-8 items-center gap-2 rounded-full", children: [_jsx(FileText, { className: "size-4" }), _jsx("span", { children: t('jobs.table.jobResult') })] }) }), _jsx(PopoverContent, { className: "w-[220px] p-4", children: _jsxs("div", { className: "space-y-2 text-sm", children: [_jsxs("div", { className: "flex items-start", children: [_jsx("span", { className: "mr-1", children: "success:" }), _jsx("span", { className: result?.success ? 'font-medium text-green-600' : 'font-medium text-red-600', children: result?.success?.toString() })] }), _jsxs("div", { children: [_jsx("span", { className: "mr-1", children: "indexedItemCount:" }), _jsx("span", { className: "font-medium", children: result?.indexedItemCount })] }), _jsxs("div", { children: [_jsx("span", { className: "mr-1", children: "timeTaken:" }), _jsx("span", { className: "font-medium", children: result?.timeTaken })] })] }) })] }));
|
|
8
|
+
}
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { JsonPopup } from "./JsonPopup.js";
|
|
3
|
+
import { FilterToolbar } from "./FilterToolbar.js";
|
|
4
|
+
import { JobState, Selector } from '@deenruv/admin-types';
|
|
5
|
+
import { apiClient, Badge, Button, CardIcons, ColumnView, CustomCard, DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, formatDate, ListTable, TableLabel, useDetailListHook, useTranslation, } from '@deenruv/react-ui-devkit';
|
|
6
|
+
import { useReactTable, getCoreRowModel } from '@tanstack/react-table';
|
|
7
|
+
import { AlertCircle, CheckCircle, Clock, MoreHorizontal, Play, RefreshCw, XCircle } from 'lucide-react';
|
|
8
|
+
import { useMemo, useState } from 'react';
|
|
9
|
+
import { JobResultPopover } from "./JobResultPopover.js";
|
|
10
|
+
const JobSelector = Selector('Job')({
|
|
11
|
+
id: true,
|
|
12
|
+
data: true,
|
|
13
|
+
attempts: true,
|
|
14
|
+
createdAt: true,
|
|
15
|
+
duration: true,
|
|
16
|
+
error: true,
|
|
17
|
+
isSettled: true,
|
|
18
|
+
progress: true,
|
|
19
|
+
queueName: true,
|
|
20
|
+
result: true,
|
|
21
|
+
retries: true,
|
|
22
|
+
settledAt: true,
|
|
23
|
+
startedAt: true,
|
|
24
|
+
state: true,
|
|
25
|
+
});
|
|
26
|
+
const calculateDuration = (startedAt, settledAt) => {
|
|
27
|
+
if (!startedAt)
|
|
28
|
+
return '—';
|
|
29
|
+
const start = new Date(startedAt);
|
|
30
|
+
const end = settledAt ? new Date(settledAt) : new Date();
|
|
31
|
+
const durationMs = end.getTime() - start.getTime();
|
|
32
|
+
if (durationMs < 1000)
|
|
33
|
+
return `${durationMs}ms`;
|
|
34
|
+
if (durationMs < 60000)
|
|
35
|
+
return `${Math.floor(durationMs / 1000)}s`;
|
|
36
|
+
return `${Math.floor(durationMs / 60000)}m ${Math.floor((durationMs % 60000) / 1000)}s`;
|
|
37
|
+
};
|
|
38
|
+
const JobStateBadge = ({ state }) => {
|
|
39
|
+
const { t } = useTranslation('system');
|
|
40
|
+
switch (state) {
|
|
41
|
+
case JobState.PENDING:
|
|
42
|
+
return (_jsxs(Badge, { variant: "outline", className: "gap-1", children: [_jsx(Clock, { className: "size-3" }), " ", t('jobs.states.pending')] }));
|
|
43
|
+
case JobState.RUNNING:
|
|
44
|
+
return (_jsxs(Badge, { variant: "secondary", className: "gap-1", children: [_jsx(Play, { className: "size-3" }), " ", t('jobs.states.running')] }));
|
|
45
|
+
case JobState.COMPLETED:
|
|
46
|
+
return (_jsxs(Badge, { className: "gap-1 bg-green-100 text-green-800", children: [_jsx(CheckCircle, { className: "size-3" }), " ", t('jobs.states.completed')] }));
|
|
47
|
+
case JobState.RETRYING:
|
|
48
|
+
return (_jsxs(Badge, { className: "gap-1 bg-yellow-100 text-yellow-800", children: [_jsx(RefreshCw, { className: "size-3" }), " ", t('jobs.states.retrying')] }));
|
|
49
|
+
case JobState.FAILED:
|
|
50
|
+
return (_jsxs(Badge, { variant: "destructive", className: "gap-1", children: [_jsx(XCircle, { className: "size-3" }), " ", t('jobs.states.failed')] }));
|
|
51
|
+
case JobState.CANCELLED:
|
|
52
|
+
return (_jsxs(Badge, { variant: "outline", className: "gap-1 bg-gray-100 text-gray-800", children: [_jsx(AlertCircle, { className: "size-3" }), " ", t('jobs.states.cancelled')] }));
|
|
53
|
+
default:
|
|
54
|
+
return _jsx(Badge, { variant: "outline", children: state });
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
export const Jobs = () => {
|
|
58
|
+
const { t } = useTranslation('system');
|
|
59
|
+
const [liveUpdate, setLiveUpdate] = useState(true);
|
|
60
|
+
const [stateFilter, setStateFilter] = useState();
|
|
61
|
+
const [jobQueueFilter, setJobQueueFilter] = useState();
|
|
62
|
+
const filterObj = useMemo(() => ({
|
|
63
|
+
state: { eq: stateFilter },
|
|
64
|
+
queueName: { eq: jobQueueFilter },
|
|
65
|
+
}), [stateFilter, jobQueueFilter]);
|
|
66
|
+
const { objects, refetch, Paginate, Search } = useDetailListHook({
|
|
67
|
+
searchFields: ['queueName'],
|
|
68
|
+
fetch: async ({ page, perPage, filter, filterOperator }) => {
|
|
69
|
+
const { jobs } = await apiClient('query')({
|
|
70
|
+
jobs: [
|
|
71
|
+
{
|
|
72
|
+
options: {
|
|
73
|
+
take: perPage,
|
|
74
|
+
skip: (page - 1) * perPage,
|
|
75
|
+
filter: { ...filter },
|
|
76
|
+
filterOperator,
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
{ items: JobSelector, totalItems: true },
|
|
80
|
+
],
|
|
81
|
+
});
|
|
82
|
+
return jobs;
|
|
83
|
+
},
|
|
84
|
+
});
|
|
85
|
+
//TODO: FIXME (PAGINATION BUG)
|
|
86
|
+
// useEffect(() => {
|
|
87
|
+
// refetch(filterObj);
|
|
88
|
+
// if (!liveUpdate) return () => clearInterval(0);
|
|
89
|
+
// const interval = setInterval(() => {
|
|
90
|
+
// refetch(filterObj);
|
|
91
|
+
// }, 5000);
|
|
92
|
+
// return () => clearInterval(interval);
|
|
93
|
+
// }, [filterObj, liveUpdate]);
|
|
94
|
+
const handleRemoveJob = async (jobId) => {
|
|
95
|
+
await apiClient('mutation')({ cancelJob: [{ jobId }, {}] });
|
|
96
|
+
};
|
|
97
|
+
const columns = useMemo(() => [
|
|
98
|
+
{
|
|
99
|
+
accessorKey: 'id',
|
|
100
|
+
header: () => _jsx(TableLabel, { children: t('jobs.table.id') }),
|
|
101
|
+
cell: ({ row }) => (_jsx("div", { className: "max-w-[120px] truncate font-mono text-xs", title: row.original.id, children: row.original.id })),
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
accessorKey: 'queueName',
|
|
105
|
+
header: () => _jsx(TableLabel, { children: t('jobs.table.queueName') }),
|
|
106
|
+
cell: ({ row }) => _jsx("div", { className: "font-medium", children: row.original.queueName }),
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
accessorKey: 'state',
|
|
110
|
+
header: () => _jsx(TableLabel, { children: t('jobs.table.status') }),
|
|
111
|
+
cell: ({ row }) => {
|
|
112
|
+
const state = row.original.state;
|
|
113
|
+
return _jsx(JobStateBadge, { state: state });
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
accessorKey: 'createdAt',
|
|
118
|
+
header: () => _jsx(TableLabel, { children: t('jobs.table.created') }),
|
|
119
|
+
cell: ({ row }) => formatDate(row.original.createdAt, {
|
|
120
|
+
month: '2-digit',
|
|
121
|
+
day: '2-digit',
|
|
122
|
+
year: '2-digit',
|
|
123
|
+
hour: '2-digit',
|
|
124
|
+
minute: '2-digit',
|
|
125
|
+
second: '2-digit',
|
|
126
|
+
}),
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
accessorKey: 'startedAt',
|
|
130
|
+
header: () => _jsx(TableLabel, { children: t('jobs.table.started') }),
|
|
131
|
+
cell: ({ row }) => formatDate(row.original.startedAt || '', {
|
|
132
|
+
month: '2-digit',
|
|
133
|
+
day: '2-digit',
|
|
134
|
+
year: '2-digit',
|
|
135
|
+
hour: '2-digit',
|
|
136
|
+
minute: '2-digit',
|
|
137
|
+
second: '2-digit',
|
|
138
|
+
}),
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
accessorKey: 'settledAt',
|
|
142
|
+
header: () => _jsx(TableLabel, { children: t('jobs.table.settled') }),
|
|
143
|
+
cell: ({ row }) => formatDate(row.original.settledAt || '', {
|
|
144
|
+
month: '2-digit',
|
|
145
|
+
day: '2-digit',
|
|
146
|
+
year: '2-digit',
|
|
147
|
+
hour: '2-digit',
|
|
148
|
+
minute: '2-digit',
|
|
149
|
+
second: '2-digit',
|
|
150
|
+
}),
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
accessorKey: 'jobData',
|
|
154
|
+
header: () => _jsx(TableLabel, { children: t('jobs.table.jobData') }),
|
|
155
|
+
cell: ({ row }) => {
|
|
156
|
+
return JsonPopup({
|
|
157
|
+
data: row.original.data,
|
|
158
|
+
});
|
|
159
|
+
},
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
accessorKey: 'duration',
|
|
163
|
+
header: () => _jsx(TableLabel, { children: t('jobs.table.duration') }),
|
|
164
|
+
cell: ({ row }) => {
|
|
165
|
+
const duration = calculateDuration(row.original.startedAt, row.original.settledAt);
|
|
166
|
+
return _jsx("div", { children: duration });
|
|
167
|
+
},
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
accessorKey: 'jobResult',
|
|
171
|
+
header: () => _jsx(TableLabel, { children: t('jobs.table.jobResult') }),
|
|
172
|
+
cell: ({ row }) => {
|
|
173
|
+
return JobResultPopover({
|
|
174
|
+
result: row.original.result,
|
|
175
|
+
});
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
id: 'actions',
|
|
180
|
+
cell: ({ row }) => {
|
|
181
|
+
const job = row.original;
|
|
182
|
+
return (_jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsx(Button, { variant: "ghost", className: "size-8 p-0", children: _jsx(MoreHorizontal, { className: "size-4" }) }) }), _jsx(DropdownMenuContent, { align: "end", children: _jsxs(DropdownMenuItem, { onClick: () => handleRemoveJob(job.id), className: "text-red-600", children: [_jsx(XCircle, { className: "mr-2 size-4" }), t('jobs.table.removeJob')] }) })] }));
|
|
183
|
+
},
|
|
184
|
+
size: 28,
|
|
185
|
+
minSize: 28,
|
|
186
|
+
maxSize: 28,
|
|
187
|
+
meta: {
|
|
188
|
+
isFixedWidth: true,
|
|
189
|
+
},
|
|
190
|
+
},
|
|
191
|
+
], []);
|
|
192
|
+
const table = useReactTable({
|
|
193
|
+
columns,
|
|
194
|
+
data: objects || [],
|
|
195
|
+
getRowId: (row) => row.id,
|
|
196
|
+
getCoreRowModel: getCoreRowModel(),
|
|
197
|
+
});
|
|
198
|
+
return (_jsx(CustomCard, { title: t('jobs.title'), color: "orange", icon: _jsx(CardIcons.check, {}), upperRight: _jsxs("div", { className: "flex items-center gap-2", children: [_jsx(FilterToolbar, { Search, setStateFilter, stateFilter, jobQueueFilter, setJobQueueFilter, liveUpdate, setLiveUpdate }), _jsx(ColumnView, { table: table, entityName: "Job" })] }), children: _jsx(ListTable, { columns, isFiltered: false, table, Paginate, tableId: 'jobs-list-view' }) }));
|
|
199
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useState } from 'react';
|
|
4
|
+
import { ChevronDown, ChevronRight } from 'lucide-react';
|
|
5
|
+
import { cn } from '@deenruv/react-ui-devkit';
|
|
6
|
+
const JsonProperty = ({ name, value, depth, isLast }) => {
|
|
7
|
+
const [isExpanded, setIsExpanded] = useState(false);
|
|
8
|
+
const indent = depth * 20;
|
|
9
|
+
const isExpandable = value !== null && (typeof value === 'object' || Array.isArray(value));
|
|
10
|
+
const toggleExpand = () => {
|
|
11
|
+
if (isExpandable) {
|
|
12
|
+
setIsExpanded(!isExpanded);
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
const renderValue = () => {
|
|
16
|
+
if (value === null)
|
|
17
|
+
return _jsx("span", { className: "text-gray-500", children: "null" });
|
|
18
|
+
if (typeof value === 'boolean')
|
|
19
|
+
return _jsx("span", { className: "text-blue-600", children: value.toString() });
|
|
20
|
+
if (typeof value === 'number')
|
|
21
|
+
return _jsx("span", { className: "text-green-600", children: value });
|
|
22
|
+
if (typeof value === 'string')
|
|
23
|
+
return _jsx("span", { className: "text-amber-600", children: value });
|
|
24
|
+
if (Array.isArray(value)) {
|
|
25
|
+
if (!isExpanded) {
|
|
26
|
+
return (_jsx("span", { className: "cursor-pointer text-gray-500", onClick: toggleExpand, children: '>' }));
|
|
27
|
+
}
|
|
28
|
+
return (_jsx("div", { children: value.map((item, index) => (_jsx("div", { style: { marginLeft: 20 }, children: _jsx(JsonProperty, { name: index.toString(), value: item, depth: depth + 1, isLast: index === value.length - 1 }) }, index))) }));
|
|
29
|
+
}
|
|
30
|
+
if (typeof value === 'object') {
|
|
31
|
+
if (!isExpanded) {
|
|
32
|
+
return (_jsx("span", { className: "cursor-pointer text-gray-500", onClick: toggleExpand, children: '>' }));
|
|
33
|
+
}
|
|
34
|
+
const entries = Object.entries(value);
|
|
35
|
+
return (_jsx("div", { children: entries.map(([key, val], index) => (_jsx(JsonProperty, { name: key, value: val, depth: depth + 1, isLast: index === entries.length - 1 }, key))) }));
|
|
36
|
+
}
|
|
37
|
+
return _jsx("span", { children: String(value) });
|
|
38
|
+
};
|
|
39
|
+
return (_jsx("div", { className: cn('py-0.5 font-mono text-sm', !isLast && isExpanded && isExpandable ? 'border-l border-gray-200 dark:border-gray-700' : ''), style: { paddingLeft: indent }, children: _jsxs("div", { className: "flex items-center", children: [isExpandable && (_jsx("button", { onClick: toggleExpand, className: "mr-1 rounded p-0.5 hover:bg-gray-100 dark:hover:bg-gray-800", children: isExpanded ? _jsx(ChevronDown, { className: "size-3" }) : _jsx(ChevronRight, { className: "size-3" }) })), isExpandable && !isExpanded ? (_jsxs("div", { children: [_jsxs("span", { className: "text-gray-600 dark:text-gray-400", children: [name, ": "] }), renderValue()] })) : (_jsxs("div", { children: [_jsxs("span", { className: "text-gray-600 dark:text-gray-400", children: [name, ": "] }), renderValue()] }))] }) }));
|
|
40
|
+
};
|
|
41
|
+
export function JsonExplorer({ data, className }) {
|
|
42
|
+
const entries = Object.entries(data);
|
|
43
|
+
return (_jsx("div", { className: cn('overflow-auto rounded-lg bg-white p-4 dark:bg-gray-950', className), children: entries.map(([key, value], index) => (_jsx(JsonProperty, { name: key, value: value, depth: 0, isLast: index === entries.length - 1 }, key))) }));
|
|
44
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { JsonExplorer } from "./JsonExplorer.js";
|
|
4
|
+
import { useTranslation, Dialog, DialogContent, DialogHeader, DialogTitle, DialogTrigger, Button, } from '@deenruv/react-ui-devkit';
|
|
5
|
+
export function JsonPopup({ data }) {
|
|
6
|
+
const { t } = useTranslation('system');
|
|
7
|
+
return (_jsxs(Dialog, { children: [_jsx(DialogTrigger, { asChild: true, children: _jsx(Button, { size: 'sm', variant: "outline", className: "h-8", children: t('jobs.table.jobData') }) }), _jsxs(DialogContent, { className: "flex max-h-[80vh] flex-col overflow-hidden sm:max-w-[600px]", children: [_jsx(DialogHeader, { children: _jsx(DialogTitle, { children: t('jobs.table.jobData') }) }), _jsx("div", { className: "flex-1 overflow-auto", children: _jsx(JsonExplorer, { data: data }) })] })] }));
|
|
8
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Status.js';
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useParams } from 'react-router-dom';
|
|
3
|
+
import { useValidators, DetailView, createDeenruvForm, useMutation } from '@deenruv/react-ui-devkit';
|
|
4
|
+
import { StockLocationDetailView } from './_components/StockLocationDetailView';
|
|
5
|
+
import { typedGql, scalars, $, Permission } from '@deenruv/admin-types';
|
|
6
|
+
import { useCallback } from 'react';
|
|
7
|
+
const CreateStockLocationMutation = typedGql('mutation', { scalars })({
|
|
8
|
+
createStockLocation: [
|
|
9
|
+
{
|
|
10
|
+
input: $('input', 'CreateStockLocationInput!'),
|
|
11
|
+
},
|
|
12
|
+
{ id: true },
|
|
13
|
+
],
|
|
14
|
+
});
|
|
15
|
+
const EditStockLocationMutation = typedGql('mutation', { scalars })({
|
|
16
|
+
updateStockLocation: [
|
|
17
|
+
{
|
|
18
|
+
input: $('input', 'UpdateStockLocationInput!'),
|
|
19
|
+
},
|
|
20
|
+
{ id: true },
|
|
21
|
+
],
|
|
22
|
+
});
|
|
23
|
+
const DeleteStockLocationMutation = typedGql('mutation', { scalars })({
|
|
24
|
+
deleteStockLocation: [
|
|
25
|
+
{
|
|
26
|
+
input: $('input', 'DeleteStockLocationInput!'),
|
|
27
|
+
},
|
|
28
|
+
{ message: true },
|
|
29
|
+
],
|
|
30
|
+
});
|
|
31
|
+
export const StockLocationsDetailPage = () => {
|
|
32
|
+
const { id } = useParams();
|
|
33
|
+
const [update] = useMutation(EditStockLocationMutation);
|
|
34
|
+
const [create] = useMutation(CreateStockLocationMutation);
|
|
35
|
+
const [remove] = useMutation(DeleteStockLocationMutation);
|
|
36
|
+
const { nameValidator } = useValidators();
|
|
37
|
+
const onSubmitHandler = useCallback((data) => {
|
|
38
|
+
if (!data.name?.validatedValue) {
|
|
39
|
+
throw new Error('Name is required.');
|
|
40
|
+
}
|
|
41
|
+
const inputData = {
|
|
42
|
+
name: data.name.validatedValue,
|
|
43
|
+
description: data.description?.validatedValue,
|
|
44
|
+
...(data.customFields?.validatedValue ? { customFields: data.customFields?.validatedValue } : {}),
|
|
45
|
+
};
|
|
46
|
+
if (id) {
|
|
47
|
+
return update({ input: { id, ...inputData } });
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
return create({ input: inputData });
|
|
51
|
+
}
|
|
52
|
+
}, [id, update, create]);
|
|
53
|
+
const onDeleteHandler = useCallback(() => {
|
|
54
|
+
if (!id) {
|
|
55
|
+
throw new Error('Could not find the id.');
|
|
56
|
+
}
|
|
57
|
+
return remove({ input: { id } });
|
|
58
|
+
}, [remove, id]);
|
|
59
|
+
return (_jsx("div", { className: "relative flex flex-col gap-y-4", children: _jsx(DetailView, { id: id, locationId: "stockLocations-detail-view", main: {
|
|
60
|
+
name: 'stockLocation',
|
|
61
|
+
label: 'Stock location',
|
|
62
|
+
component: _jsx(StockLocationDetailView, {}),
|
|
63
|
+
form: createDeenruvForm({
|
|
64
|
+
key: 'CreateStockLocationInput',
|
|
65
|
+
keys: ['description', 'name'],
|
|
66
|
+
config: {
|
|
67
|
+
name: nameValidator,
|
|
68
|
+
},
|
|
69
|
+
onSubmitted: onSubmitHandler,
|
|
70
|
+
onDeleted: onDeleteHandler,
|
|
71
|
+
}),
|
|
72
|
+
}, permissions: {
|
|
73
|
+
create: Permission.CreateStockLocation,
|
|
74
|
+
edit: Permission.UpdateStockLocation,
|
|
75
|
+
delete: Permission.DeleteStockLocation,
|
|
76
|
+
} }) }));
|
|
77
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Routes, apiClient, DetailList, deepMerge, ListLocations, EntityChannelManagementBulkAction, } from '@deenruv/react-ui-devkit';
|
|
3
|
+
import { Permission, SortOrder } from '@deenruv/admin-types';
|
|
4
|
+
const tableId = 'stockLocations-list-view';
|
|
5
|
+
const { selector } = ListLocations[tableId];
|
|
6
|
+
const fetch = async ({ page, perPage, filter, filterOperator, sort }, additionalSelector) => {
|
|
7
|
+
const response = await apiClient('query')({
|
|
8
|
+
['stockLocations']: [
|
|
9
|
+
{
|
|
10
|
+
options: {
|
|
11
|
+
take: perPage,
|
|
12
|
+
skip: (page - 1) * perPage,
|
|
13
|
+
filterOperator: filterOperator,
|
|
14
|
+
sort: sort ? { [sort.key]: sort.sortDir } : { createdAt: SortOrder.DESC },
|
|
15
|
+
...(filter && { filter }),
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
{ items: deepMerge(selector, additionalSelector ?? {}), totalItems: true },
|
|
19
|
+
],
|
|
20
|
+
});
|
|
21
|
+
return response['stockLocations'];
|
|
22
|
+
};
|
|
23
|
+
const onRemove = async (items) => {
|
|
24
|
+
try {
|
|
25
|
+
const ids = items.map((item) => item.id);
|
|
26
|
+
const { deleteStockLocations } = await apiClient('mutation')({
|
|
27
|
+
deleteStockLocations: [{ input: ids.map((id) => ({ id })) }, { message: true, result: true }],
|
|
28
|
+
});
|
|
29
|
+
return !!deleteStockLocations.length;
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
return error;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
export const StockLocationsListPage = () => (_jsx(DetailList, { filterFields: [
|
|
36
|
+
{ key: 'name', operator: 'StringOperators' },
|
|
37
|
+
{ key: 'description', operator: 'StringOperators' },
|
|
38
|
+
], detailLinkColumn: "id", additionalBulkActions: [...EntityChannelManagementBulkAction(tableId)], searchFields: ['name'], hideColumns: ['customFields', 'translations', 'collections', 'variantList'], entityName: 'StockLocation', route: Routes['stockLocations'], tableId: tableId, fetch: fetch, onRemove: onRemove, createPermissions: [Permission.CreateStockLocation], deletePermissions: [Permission.DeleteStockLocation] }));
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect } from 'react';
|
|
3
|
+
import { Input, Label, useSettings, useDetailView, DetailViewMarker, CustomCard, CardIcons, EntityCustomFields, RichTextEditor, useTranslation, } from '@deenruv/react-ui-devkit';
|
|
4
|
+
const STOCK_LOCATION_FORM_KEYS = ['CreateStockLocationInput', 'name', 'description', 'customFields'];
|
|
5
|
+
export const StockLocationDetailView = () => {
|
|
6
|
+
const contentLng = useSettings((p) => p.translationsLanguage);
|
|
7
|
+
const { t } = useTranslation('stockLocations');
|
|
8
|
+
const { form, entity, fetchEntity, id } = useDetailView('stockLocations-detail-view', ...STOCK_LOCATION_FORM_KEYS);
|
|
9
|
+
const { base: { setField, state }, } = form;
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
(async () => {
|
|
12
|
+
const res = await fetchEntity();
|
|
13
|
+
if (!res)
|
|
14
|
+
return;
|
|
15
|
+
setField('name', res.name);
|
|
16
|
+
setField('description', res['description']);
|
|
17
|
+
})();
|
|
18
|
+
}, [contentLng]);
|
|
19
|
+
return (_jsx("main", { className: "min-h-96", children: _jsxs("div", { className: "flex flex-col gap-3", children: [_jsx(CustomCard, { title: t('details.basic.title'), icon: _jsx(CardIcons.basic, {}), color: "green", children: _jsxs("div", { className: "flex flex-col gap-3", children: [_jsx(Input, { label: t('details.basic.name'), value: state.name?.value, onChange: (e) => setField('name', e.target.value), errors: state.name?.errors, required: true }), _jsxs("div", { className: "flex basis-full flex-col", children: [_jsx(Label, { className: "mb-2", children: t('details.basic.description') }), _jsx(RichTextEditor, { content: state.description?.value ?? undefined, onContentChanged: (e) => setField('description', e) })] })] }) }), _jsx(DetailViewMarker, { position: 'stockLocations-detail-view' }), _jsx(EntityCustomFields, { entityName: "stockLocation", id: id, hideButton: true, onChange: (customFields) => {
|
|
20
|
+
setField('customFields', customFields);
|
|
21
|
+
}, initialValues: entity && 'customFields' in entity ? { customFields: entity.customFields } : { customFields: {} } })] }) }));
|
|
22
|
+
};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useParams } from 'react-router-dom';
|
|
3
|
+
import { useTranslation, DetailView, createDeenruvForm, useMutation } from '@deenruv/react-ui-devkit';
|
|
4
|
+
import { TaxCategoryDetailView } from './_components/TaxCategoryDetailView';
|
|
5
|
+
import { $, Permission, scalars, typedGql } from '@deenruv/admin-types';
|
|
6
|
+
import { useCallback } from 'react';
|
|
7
|
+
const CreateTaxCategoryMutation = typedGql('mutation', { scalars })({
|
|
8
|
+
createTaxCategory: [
|
|
9
|
+
{
|
|
10
|
+
input: $('input', 'CreateTaxCategoryInput!'),
|
|
11
|
+
},
|
|
12
|
+
{ id: true },
|
|
13
|
+
],
|
|
14
|
+
});
|
|
15
|
+
const EditTaxCategoryMutation = typedGql('mutation', { scalars })({
|
|
16
|
+
updateTaxCategory: [
|
|
17
|
+
{
|
|
18
|
+
input: $('input', 'UpdateTaxCategoryInput!'),
|
|
19
|
+
},
|
|
20
|
+
{ id: true },
|
|
21
|
+
],
|
|
22
|
+
});
|
|
23
|
+
const DeleteTaxCategoryMutation = typedGql('mutation', { scalars })({
|
|
24
|
+
deleteTaxCategory: [
|
|
25
|
+
{
|
|
26
|
+
id: $('id', 'ID!'),
|
|
27
|
+
},
|
|
28
|
+
{ message: true, result: true },
|
|
29
|
+
],
|
|
30
|
+
});
|
|
31
|
+
export const TaxCategoriesDetailPage = () => {
|
|
32
|
+
const { id } = useParams();
|
|
33
|
+
const { t } = useTranslation('taxCategories');
|
|
34
|
+
const [update] = useMutation(EditTaxCategoryMutation);
|
|
35
|
+
const [remove] = useMutation(DeleteTaxCategoryMutation);
|
|
36
|
+
const [create] = useMutation(CreateTaxCategoryMutation);
|
|
37
|
+
const onDeleteHandler = useCallback(() => {
|
|
38
|
+
if (!id) {
|
|
39
|
+
throw new Error('Could not find the id.');
|
|
40
|
+
}
|
|
41
|
+
return remove({ id });
|
|
42
|
+
}, [remove, id]);
|
|
43
|
+
return (_jsx("div", { className: "relative flex flex-col gap-y-4", children: _jsx(DetailView, { id: id, locationId: "taxCategories-detail-view", main: {
|
|
44
|
+
name: 'taxCategory',
|
|
45
|
+
label: 'Tax Category',
|
|
46
|
+
component: _jsx(TaxCategoryDetailView, {}),
|
|
47
|
+
form: createDeenruvForm({
|
|
48
|
+
key: 'CreateTaxCategoryInput',
|
|
49
|
+
keys: ['isDefault', 'name', 'customFields'],
|
|
50
|
+
config: {
|
|
51
|
+
name: {
|
|
52
|
+
validate: (v) => {
|
|
53
|
+
if (!v || v === '')
|
|
54
|
+
return [t('validation.nameRequired')];
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
onSubmitted: (data) => {
|
|
59
|
+
if (!data.name?.validatedValue) {
|
|
60
|
+
throw new Error('Name is required.');
|
|
61
|
+
}
|
|
62
|
+
const inputData = {
|
|
63
|
+
name: data.name.validatedValue,
|
|
64
|
+
isDefault: data.isDefault?.validatedValue,
|
|
65
|
+
...(data.customFields?.validatedValue ? { customFields: data.customFields?.validatedValue } : {}),
|
|
66
|
+
};
|
|
67
|
+
return id
|
|
68
|
+
? update({
|
|
69
|
+
input: {
|
|
70
|
+
id: id,
|
|
71
|
+
...inputData,
|
|
72
|
+
},
|
|
73
|
+
})
|
|
74
|
+
: create({
|
|
75
|
+
input: inputData,
|
|
76
|
+
});
|
|
77
|
+
},
|
|
78
|
+
onDeleted: onDeleteHandler,
|
|
79
|
+
}),
|
|
80
|
+
}, permissions: {
|
|
81
|
+
create: Permission.CreateTaxCategory,
|
|
82
|
+
edit: Permission.UpdateTaxCategory,
|
|
83
|
+
delete: Permission.DeleteTaxCategory,
|
|
84
|
+
} }) }));
|
|
85
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Routes, apiClient, DetailList, deepMerge, ListLocations } from '@deenruv/react-ui-devkit';
|
|
3
|
+
import { Permission, SortOrder } from '@deenruv/admin-types';
|
|
4
|
+
const tableId = 'taxCategories-list-view';
|
|
5
|
+
const { selector } = ListLocations[tableId];
|
|
6
|
+
const fetch = async ({ page, perPage, filter, filterOperator, sort }, additionalSelector) => {
|
|
7
|
+
const response = await apiClient('query')({
|
|
8
|
+
['taxCategories']: [
|
|
9
|
+
{
|
|
10
|
+
options: {
|
|
11
|
+
take: perPage,
|
|
12
|
+
skip: (page - 1) * perPage,
|
|
13
|
+
filterOperator: filterOperator,
|
|
14
|
+
sort: sort ? { [sort.key]: sort.sortDir } : { createdAt: SortOrder.DESC },
|
|
15
|
+
...(filter && { filter }),
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
{ items: deepMerge(selector, additionalSelector ?? {}), totalItems: true },
|
|
19
|
+
],
|
|
20
|
+
});
|
|
21
|
+
return response['taxCategories'];
|
|
22
|
+
};
|
|
23
|
+
const onRemove = async (items) => {
|
|
24
|
+
try {
|
|
25
|
+
const ids = items.map((item) => item.id);
|
|
26
|
+
const { deleteTaxCategories } = await apiClient('mutation')({
|
|
27
|
+
deleteTaxCategories: [
|
|
28
|
+
{ ids },
|
|
29
|
+
{
|
|
30
|
+
message: true,
|
|
31
|
+
result: true,
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
});
|
|
35
|
+
return !!deleteTaxCategories.length;
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
return error;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
export const TaxCategoriesListPage = () => {
|
|
42
|
+
return (_jsx(DetailList, { filterFields: [
|
|
43
|
+
{ key: 'name', operator: 'StringOperators' },
|
|
44
|
+
{ key: 'isDefault', operator: 'BooleanOperators' },
|
|
45
|
+
], detailLinkColumn: "id", searchFields: ['name'], hideColumns: ['customFields', 'translations'], entityName: 'TaxCategory', route: Routes['taxCategories'], tableId: tableId, fetch: fetch, onRemove: onRemove, createPermissions: [Permission.CreateTaxCategory], deletePermissions: [Permission.DeleteTaxCategory] }));
|
|
46
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useDetailView, DetailViewMarker, useSettings, Input, Switch, Label, CustomCard, CardIcons, EntityCustomFields, useTranslation, } from '@deenruv/react-ui-devkit';
|
|
3
|
+
import { useEffect } from 'react';
|
|
4
|
+
const TAX_CATEGORY_FORM_KEYS = ['CreateTaxCategoryInput', 'name', 'isDefault', 'customFields'];
|
|
5
|
+
export const TaxCategoryDetailView = () => {
|
|
6
|
+
const contentLng = useSettings((p) => p.translationsLanguage);
|
|
7
|
+
const { id, form, entity, fetchEntity } = useDetailView('taxCategories-detail-view', ...TAX_CATEGORY_FORM_KEYS);
|
|
8
|
+
const { t } = useTranslation('taxCategories');
|
|
9
|
+
const { base: { setField, state }, } = form;
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
(async () => {
|
|
12
|
+
const res = await fetchEntity();
|
|
13
|
+
if (!res)
|
|
14
|
+
return;
|
|
15
|
+
setField('name', res.name);
|
|
16
|
+
setField('isDefault', res['isDefault']);
|
|
17
|
+
})();
|
|
18
|
+
}, [contentLng]);
|
|
19
|
+
return (_jsx("div", { children: _jsxs("div", { className: "flex w-full flex-col gap-4", children: [_jsx(CustomCard, { title: t('details.basic.title'), icon: _jsx(CardIcons.basic, {}), color: "green", children: _jsxs("div", { className: "flex items-start gap-4", children: [_jsx("div", { className: "flex basis-full md:basis-1/2", children: _jsx(Input, { label: t('details.basic.name'), value: state.name?.value, required: true, onChange: (e) => {
|
|
20
|
+
setField('name', e.target.value);
|
|
21
|
+
}, errors: state.name?.errors }) }), _jsxs("div", { className: "mt-7 flex basis-full items-center gap-3 md:basis-1/2", children: [_jsx(Switch, { checked: state.isDefault?.value ?? undefined, onCheckedChange: (e) => setField('isDefault', e) }), _jsx(Label, { children: t('details.basic.isDefault') })] })] }) }), _jsx(DetailViewMarker, { position: 'taxCategories-detail-view' }), _jsx(EntityCustomFields, { entityName: "taxCategory", id: id, hideButton: true, onChange: (customFields) => {
|
|
22
|
+
setField('customFields', customFields);
|
|
23
|
+
}, initialValues: entity && 'customFields' in entity ? { customFields: entity.customFields } : { customFields: {} } })] }) }));
|
|
24
|
+
};
|