@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,67 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback } from 'react';
|
|
3
|
+
import { useParams } from 'react-router-dom';
|
|
4
|
+
import { useValidators, DetailView, createDeenruvForm, useMutation, getMutation, useTranslation, } from '@deenruv/react-ui-devkit';
|
|
5
|
+
import { PaymentMethodDetailView } from "./_components/PaymentMethodDetailView.js";
|
|
6
|
+
const CreatePaymentMethodMutation = getMutation('createPaymentMethod');
|
|
7
|
+
const EditPaymentMethodMutation = getMutation('updatePaymentMethod');
|
|
8
|
+
const DeletePaymentMethodMutation = getMutation('deletePaymentMethod');
|
|
9
|
+
export const PaymentMethodsDetailPage = () => {
|
|
10
|
+
const { id } = useParams();
|
|
11
|
+
const [update] = useMutation(EditPaymentMethodMutation);
|
|
12
|
+
const [create] = useMutation(CreatePaymentMethodMutation);
|
|
13
|
+
const [remove] = useMutation(DeletePaymentMethodMutation);
|
|
14
|
+
const { t } = useTranslation('paymentMethods');
|
|
15
|
+
const { translationsValidator, stringValidator, configurableOperationValidator } = useValidators();
|
|
16
|
+
const onSubmitHandler = useCallback((data) => {
|
|
17
|
+
if (!data.code?.validatedValue) {
|
|
18
|
+
throw new Error('Name is required.');
|
|
19
|
+
}
|
|
20
|
+
const inputData = {
|
|
21
|
+
code: data.code?.validatedValue,
|
|
22
|
+
handler: data.handler?.validatedValue,
|
|
23
|
+
enabled: data.enabled?.validatedValue || data.enabled?.initialValue,
|
|
24
|
+
translations: data.translations?.validatedValue,
|
|
25
|
+
...(data.customFields?.validatedValue ? { customFields: data.customFields?.validatedValue } : {}),
|
|
26
|
+
};
|
|
27
|
+
if (id) {
|
|
28
|
+
return update({
|
|
29
|
+
input: {
|
|
30
|
+
id,
|
|
31
|
+
...inputData,
|
|
32
|
+
checker: data.checker?.validatedValue?.code !== '' ? data.checker?.validatedValue : undefined,
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
return create({
|
|
38
|
+
input: inputData,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}, [id, update, create]);
|
|
42
|
+
const onDeleteHandler = useCallback(() => {
|
|
43
|
+
if (!id) {
|
|
44
|
+
throw new Error('Could not find the id.');
|
|
45
|
+
}
|
|
46
|
+
return remove({ input: { id } });
|
|
47
|
+
}, [remove, id]);
|
|
48
|
+
return (_jsx("div", { className: "relative flex flex-col gap-y-4", children: _jsx(DetailView, { id: id, locationId: "paymentMethods-detail-view", main: {
|
|
49
|
+
name: 'paymentMethod',
|
|
50
|
+
label: 'Payment method',
|
|
51
|
+
component: _jsx(PaymentMethodDetailView, {}),
|
|
52
|
+
form: createDeenruvForm({
|
|
53
|
+
key: 'CreatePaymentMethodInput',
|
|
54
|
+
keys: ['code', 'enabled', 'translations', 'handler', 'checker', 'customFields'],
|
|
55
|
+
config: {
|
|
56
|
+
enabled: {
|
|
57
|
+
initialValue: false,
|
|
58
|
+
},
|
|
59
|
+
translations: translationsValidator,
|
|
60
|
+
code: stringValidator(t('validation.codeRequired')),
|
|
61
|
+
handler: configurableOperationValidator(t('validation.handlerCodeRequired'), t('validation.handlerArgsRequired')),
|
|
62
|
+
},
|
|
63
|
+
onSubmitted: onSubmitHandler,
|
|
64
|
+
onDeleted: onDeleteHandler,
|
|
65
|
+
}),
|
|
66
|
+
} }) }));
|
|
67
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Permission, SortOrder } from '@deenruv/admin-types';
|
|
3
|
+
import { Routes, apiClient, DetailList, deepMerge, ListLocations, EntityChannelManagementBulkAction, } from '@deenruv/react-ui-devkit';
|
|
4
|
+
const tableId = 'paymentMethods-list-view';
|
|
5
|
+
const { selector } = ListLocations[tableId];
|
|
6
|
+
const fetch = async ({ page, perPage, filter, filterOperator, sort }, additionalSelector) => {
|
|
7
|
+
const response = await apiClient('query')({
|
|
8
|
+
paymentMethods: [
|
|
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['paymentMethods'];
|
|
22
|
+
};
|
|
23
|
+
const onRemove = async (items) => {
|
|
24
|
+
try {
|
|
25
|
+
const ids = items.map((item) => item.id);
|
|
26
|
+
const { deletePaymentMethods } = await apiClient('mutation')({
|
|
27
|
+
deletePaymentMethods: [{ ids }, { message: true, result: true }],
|
|
28
|
+
});
|
|
29
|
+
return !!deletePaymentMethods.length;
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
return error;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
export const PaymentMethodsListPage = () => {
|
|
36
|
+
return (_jsx(DetailList, { filterFields: [
|
|
37
|
+
{ key: 'name', operator: 'StringOperators' },
|
|
38
|
+
{ key: 'code', operator: 'StringOperators' },
|
|
39
|
+
{ key: 'enabled', operator: 'BooleanOperators' },
|
|
40
|
+
], additionalBulkActions: [...EntityChannelManagementBulkAction(tableId)], detailLinkColumn: "id", searchFields: ['name', 'code'], hideColumns: ['customFields', 'translations', 'collections', 'variantList'], entityName: 'PaymentMethod', route: Routes['paymentMethods'], tableId: tableId, fetch: fetch, onRemove: onRemove, createPermissions: [Permission.CreatePaymentMethod], deletePermissions: [Permission.DeletePaymentMethod] }));
|
|
41
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
3
|
+
import { useTranslation, Checkbox, Label, apiClient, ErrorMessage, CustomCard, CardIcons, SimpleSelect, PaymentMethodHandlerSelector, } from '@deenruv/react-ui-devkit';
|
|
4
|
+
export const OptionsCard = ({ currentHandlerValue, currentCheckerValue, onHandlerValueChange, onCheckerValueChange, handlerErrors, }) => {
|
|
5
|
+
const { t } = useTranslation('paymentMethods');
|
|
6
|
+
const [handlers, setHandlers] = useState([]);
|
|
7
|
+
const [checkers, setCheckers] = useState([]);
|
|
8
|
+
const [allHandlersOptions, setAllHandlersOptions] = useState([]);
|
|
9
|
+
const [allCheckersOptions, setAllCheckersOptions] = useState([]);
|
|
10
|
+
const fetchOptions = useCallback(async () => {
|
|
11
|
+
const response = await apiClient('query')({
|
|
12
|
+
paymentMethodHandlers: PaymentMethodHandlerSelector,
|
|
13
|
+
paymentMethodEligibilityCheckers: PaymentMethodHandlerSelector,
|
|
14
|
+
});
|
|
15
|
+
setHandlers(response.paymentMethodHandlers);
|
|
16
|
+
setAllHandlersOptions(response.paymentMethodHandlers.map((h) => ({
|
|
17
|
+
value: h.code,
|
|
18
|
+
label: h.code,
|
|
19
|
+
})));
|
|
20
|
+
setAllCheckersOptions(response.paymentMethodEligibilityCheckers.map((h) => ({
|
|
21
|
+
value: h.code,
|
|
22
|
+
label: h.code,
|
|
23
|
+
})));
|
|
24
|
+
setCheckers(response.paymentMethodEligibilityCheckers);
|
|
25
|
+
}, [setAllHandlersOptions, setAllCheckersOptions]);
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
fetchOptions();
|
|
28
|
+
}, [fetchOptions]);
|
|
29
|
+
const handleHandlerValueChange = useCallback((code, args) => {
|
|
30
|
+
const correspondingHandler = handlers.find((h) => h.code === code);
|
|
31
|
+
if (correspondingHandler)
|
|
32
|
+
onHandlerValueChange({
|
|
33
|
+
code: correspondingHandler.code,
|
|
34
|
+
arguments: args ||
|
|
35
|
+
correspondingHandler.args.map((a) => ({
|
|
36
|
+
name: a.name,
|
|
37
|
+
value: 'false',
|
|
38
|
+
})),
|
|
39
|
+
});
|
|
40
|
+
}, [handlers, onHandlerValueChange]);
|
|
41
|
+
const handleCheckerValueChange = useCallback((code, args) => {
|
|
42
|
+
const correspondingChecker = checkers.find((h) => h.code === code);
|
|
43
|
+
if (correspondingChecker)
|
|
44
|
+
onCheckerValueChange({
|
|
45
|
+
code: correspondingChecker.code,
|
|
46
|
+
arguments: args ||
|
|
47
|
+
correspondingChecker.args.map((a) => ({
|
|
48
|
+
name: a.name,
|
|
49
|
+
value: 'false',
|
|
50
|
+
})),
|
|
51
|
+
});
|
|
52
|
+
}, [checkers, onCheckerValueChange]);
|
|
53
|
+
return (_jsx(CustomCard, { title: t('details.options.title'), icon: _jsx(CardIcons.options, {}), color: "teal", children: _jsxs("div", { className: "flex flex-wrap gap-4 xl:flex-nowrap", children: [_jsxs("div", { className: "flex basis-full flex-col gap-3 md:basis-1/2", children: [_jsx(SimpleSelect, { label: t('details.options.handler'), value: currentHandlerValue?.code, onValueChange: handleHandlerValueChange, options: allHandlersOptions }), _jsx("div", { className: "flex", children: currentHandlerValue?.arguments.map((e, i) => {
|
|
54
|
+
const handler = handlers?.find((h) => h.code === currentHandlerValue.code);
|
|
55
|
+
const argument = handler?.args.find((a) => a.name === a.name);
|
|
56
|
+
return (_jsxs("div", { className: "mb-2 flex basis-full items-center gap-3", children: [_jsx(Checkbox, { checked: currentHandlerValue?.arguments[i].value === 'true' ? true : false, onCheckedChange: (e) => handleHandlerValueChange(currentHandlerValue?.code, [
|
|
57
|
+
{ name: argument?.name || '', value: e ? 'true' : 'false' },
|
|
58
|
+
]) }), _jsx(Label, { children: argument?.label })] }, e.name));
|
|
59
|
+
}) }), _jsx(ErrorMessage, { errors: handlerErrors })] }), _jsx("div", { className: "flex basis-full md:basis-1/2", children: _jsx(SimpleSelect, { label: t('details.options.checker'), value: currentCheckerValue?.code, onValueChange: handleCheckerValueChange, options: allCheckersOptions }) })] }) }));
|
|
60
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback, useEffect } from 'react';
|
|
3
|
+
import { useTranslation, CardIcons, CustomCard, DetailViewMarker, Input, Label, setInArrayBy, Switch, useDetailView, useSettings, EntityCustomFields, RichTextEditor, } from '@deenruv/react-ui-devkit';
|
|
4
|
+
import { OptionsCard } from "./OptionsCard";
|
|
5
|
+
const PAYMENT_METHOD_FORM_KEYS = [
|
|
6
|
+
'CreatePaymentMethodInput',
|
|
7
|
+
'code',
|
|
8
|
+
'enabled',
|
|
9
|
+
'translations',
|
|
10
|
+
'handler',
|
|
11
|
+
'checker',
|
|
12
|
+
'customFields',
|
|
13
|
+
];
|
|
14
|
+
export const PaymentMethodDetailView = () => {
|
|
15
|
+
const { form, fetchEntity, entity, id } = useDetailView('paymentMethods-detail-view', ...PAYMENT_METHOD_FORM_KEYS);
|
|
16
|
+
const { base: { setField, state }, } = form;
|
|
17
|
+
// const editMode = useMemo(() => !!id, [id]);
|
|
18
|
+
const { t } = useTranslation('paymentMethods');
|
|
19
|
+
const { translationsLanguage: currentTranslationLng } = useSettings();
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
(async () => {
|
|
22
|
+
const res = await fetchEntity();
|
|
23
|
+
if (!res)
|
|
24
|
+
return;
|
|
25
|
+
setField('code', res.code);
|
|
26
|
+
setField('enabled', res.enabled);
|
|
27
|
+
setField('translations', res.translations);
|
|
28
|
+
setField('handler', {
|
|
29
|
+
arguments: res.handler.args,
|
|
30
|
+
code: res.handler.code,
|
|
31
|
+
});
|
|
32
|
+
setField('checker', {
|
|
33
|
+
arguments: res.checker?.args || [],
|
|
34
|
+
code: res.checker?.code || '',
|
|
35
|
+
});
|
|
36
|
+
})();
|
|
37
|
+
}, []);
|
|
38
|
+
const translations = state?.translations?.value || [];
|
|
39
|
+
const currentTranslationValue = translations.find((v) => v.languageCode === currentTranslationLng);
|
|
40
|
+
const setTranslationField = useCallback((field, e) => {
|
|
41
|
+
setField('translations', setInArrayBy(translations, (t) => t.languageCode !== currentTranslationLng, {
|
|
42
|
+
[field]: e,
|
|
43
|
+
languageCode: currentTranslationLng,
|
|
44
|
+
}));
|
|
45
|
+
}, [currentTranslationLng, translations]);
|
|
46
|
+
return (_jsx("main", { className: "my-4", 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-wrap items-start gap-4 p-0 pt-4", children: [_jsxs("div", { className: "flex w-full flex-wrap items-start gap-4 p-0 pt-4 xl:flex-nowrap", children: [_jsx("div", { className: "flex basis-full md:basis-1/3", children: _jsx(Input, { label: t('details.basic.name'), value: currentTranslationValue?.name ?? undefined, onChange: (e) => setTranslationField('name', e.target.value), errors: state.translations?.errors, required: true }) }), _jsx("div", { className: "flex basis-full md:basis-1/3", children: _jsx(Input, { label: t('details.basic.code'), value: state.code?.value ?? undefined, onChange: (e) => setField('code', e.target.value), errors: state.code?.errors, required: true }) }), _jsxs("div", { className: "mt-7 flex basis-full items-center gap-3 md:basis-1/3", children: [_jsx(Switch, { checked: state.enabled?.value ?? undefined, onCheckedChange: (e) => setField('enabled', e) }), _jsx(Label, { children: t('details.basic.enabled') })] })] }), _jsxs("div", { className: "flex basis-full flex-col", children: [_jsx(Label, { className: "mb-2", children: t('details.basic.description') }), _jsx(RichTextEditor, { content: currentTranslationValue?.description ?? undefined, onContentChanged: (e) => setTranslationField('description', e) })] })] }) }), _jsx(DetailViewMarker, { position: 'paymentMethods-detail-view' }), _jsx(EntityCustomFields, { entityName: "paymentMethod", id: id, hideButton: true, onChange: (customFields, translations) => {
|
|
47
|
+
setField('customFields', customFields);
|
|
48
|
+
if (translations)
|
|
49
|
+
setField('translations', translations);
|
|
50
|
+
}, initialValues: entity && 'customFields' in entity
|
|
51
|
+
? { customFields: entity.customFields, translations: entity.translations }
|
|
52
|
+
: { customFields: {} } }), _jsx(OptionsCard, { currentHandlerValue: state.handler?.value ?? undefined, currentCheckerValue: state.checker?.value ?? undefined, onHandlerValueChange: (handler) => setField('handler', handler), onCheckerValueChange: (checker) => setField('checker', checker), handlerErrors: state.handler?.errors })] }) }));
|
|
53
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Permission, SortOrder } from '@deenruv/admin-types';
|
|
3
|
+
import { useTranslation, apiClient, Badge, deepMerge, DetailList, ListLocations, Routes, TableLabel, FacetIdsSelector, EntityChannelManagementBulkAction, EntityFacetManagementBulkAction, } from '@deenruv/react-ui-devkit';
|
|
4
|
+
import { useNavigate } from 'react-router-dom';
|
|
5
|
+
const tableId = 'productVariants-list-view';
|
|
6
|
+
const { selector } = ListLocations[tableId];
|
|
7
|
+
const fetch = async ({ page, perPage, filter, filterOperator, sort }, additionalSelector) => {
|
|
8
|
+
const response = await apiClient('query')({
|
|
9
|
+
productVariants: [
|
|
10
|
+
{
|
|
11
|
+
options: {
|
|
12
|
+
take: perPage,
|
|
13
|
+
skip: (page - 1) * perPage,
|
|
14
|
+
filterOperator: filterOperator,
|
|
15
|
+
sort: sort ? { [sort.key]: sort.sortDir } : { createdAt: SortOrder.DESC },
|
|
16
|
+
...(filter && { filter }),
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
{ items: deepMerge(selector, additionalSelector ?? {}), totalItems: true },
|
|
20
|
+
],
|
|
21
|
+
});
|
|
22
|
+
return response.productVariants;
|
|
23
|
+
};
|
|
24
|
+
const onRemove = async (items) => {
|
|
25
|
+
try {
|
|
26
|
+
const ids = items.map((item) => item.id);
|
|
27
|
+
const { deleteProducts } = await apiClient('mutation')({
|
|
28
|
+
deleteProducts: [{ ids }, { message: true, result: true }],
|
|
29
|
+
});
|
|
30
|
+
return !!deleteProducts.length;
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
return error;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
export const ProductVariantsListPage = () => {
|
|
37
|
+
const navigate = useNavigate();
|
|
38
|
+
const { t } = useTranslation('products');
|
|
39
|
+
return (_jsx(DetailList, { additionalBulkActions: [...EntityChannelManagementBulkAction(tableId), EntityFacetManagementBulkAction(tableId)], filterFields: [
|
|
40
|
+
{ key: 'sku', operator: 'StringOperators' },
|
|
41
|
+
{ key: 'name', operator: 'StringOperators' },
|
|
42
|
+
{ key: 'enabled', operator: 'BooleanOperators' },
|
|
43
|
+
{ key: 'price', operator: 'NumberOperators' },
|
|
44
|
+
{ key: 'priceWithTax', operator: 'NumberOperators' },
|
|
45
|
+
{ key: 'stockOnHand', operator: 'NumberOperators' },
|
|
46
|
+
{ key: 'stockAllocated', operator: 'NumberOperators' },
|
|
47
|
+
{
|
|
48
|
+
key: 'facetValueId',
|
|
49
|
+
component: (props) => {
|
|
50
|
+
return (_jsx(FacetIdsSelector, { onChange: (facetValuesId) => {
|
|
51
|
+
if (facetValuesId.length === 0) {
|
|
52
|
+
props.onChange(undefined);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
props.onChange({ in: facetValuesId.map((o) => o) });
|
|
56
|
+
}, facetValuesIds: props.value.in }));
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
], detailLinkColumn: "id", searchFields: ['name', 'sku'], hideColumns: ['customFields', 'productId', 'stockOnHand', 'stockAllocated'], entityName: 'ProductVariant', route: {
|
|
60
|
+
...Routes.productVariants,
|
|
61
|
+
edit: (variantId, row) => {
|
|
62
|
+
navigate(`/admin-ui/products/${row.original['productId']}?tab=variants&variantId=${variantId}`, {
|
|
63
|
+
viewTransition: true,
|
|
64
|
+
});
|
|
65
|
+
},
|
|
66
|
+
}, noCreateButton: true, tableId: tableId, fetch: fetch, onRemove: onRemove, createPermissions: [Permission.CreateProduct], deletePermissions: [Permission.DeleteProduct], additionalColumns: [
|
|
67
|
+
{
|
|
68
|
+
id: 'stock',
|
|
69
|
+
accessorKey: 'stock',
|
|
70
|
+
header: () => _jsx(TableLabel, { children: t('table.stock') }),
|
|
71
|
+
cell: ({ row }) => {
|
|
72
|
+
return (_jsxs("div", { className: "flex flex-col gap-1", children: [_jsxs(Badge, { className: "flex justify-between gap-1", variant: row.original.stockOnHand <= 0 ? 'destructive' : 'outline', children: [_jsx("span", { children: t('table.stockOnHand') }), _jsx("span", { children: row.original.stockOnHand })] }), _jsxs(Badge, { className: "flex justify-between gap-1", variant: 'outline', children: [_jsx("span", { children: t('table.stockAllocated') }), _jsx("span", { children: row.original.stockAllocated })] })] }));
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
] }));
|
|
76
|
+
};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useParams } from 'react-router-dom';
|
|
3
|
+
import { VariantsTab } from "./_components/VariantsTab";
|
|
4
|
+
import { OptionsTab } from "./_components/OptionsTab";
|
|
5
|
+
import { ProductDetailView } from './_components/ProductDetailView';
|
|
6
|
+
import { ProductDetailSidebar } from './_components/ProductDetailSidebar';
|
|
7
|
+
import { useTranslation, createDeenruvForm, DetailView, useMutation } from '@deenruv/react-ui-devkit';
|
|
8
|
+
import { $, Permission, scalars, typedGql } from '@deenruv/admin-types';
|
|
9
|
+
import { useMemo } from 'react';
|
|
10
|
+
const EditProductMutation = typedGql('mutation', { scalars })({
|
|
11
|
+
updateProduct: [{ input: $('input', 'UpdateProductInput!') }, { id: true }],
|
|
12
|
+
});
|
|
13
|
+
const CreateProductMutation = typedGql('mutation', { scalars })({
|
|
14
|
+
createProduct: [{ input: $('input', 'CreateProductInput!') }, { id: true }],
|
|
15
|
+
});
|
|
16
|
+
const DeleteProductMutation = typedGql('mutation', { scalars })({
|
|
17
|
+
deleteProduct: [{ id: $('id', 'ID!') }, { result: true }],
|
|
18
|
+
});
|
|
19
|
+
export const ProductsDetailPage = () => {
|
|
20
|
+
const { id } = useParams();
|
|
21
|
+
const { t } = useTranslation('products');
|
|
22
|
+
const [update] = useMutation(EditProductMutation);
|
|
23
|
+
const [create] = useMutation(CreateProductMutation);
|
|
24
|
+
const [remove] = useMutation(DeleteProductMutation);
|
|
25
|
+
const defaultTabs = useMemo(() => {
|
|
26
|
+
const tabs = [];
|
|
27
|
+
if (id) {
|
|
28
|
+
tabs.push({ label: t('options'), name: 'options', component: _jsx(OptionsTab, {}), hideSidebar: true });
|
|
29
|
+
tabs.push({ label: t('variants'), name: 'variants', component: _jsx(VariantsTab, {}), hideSidebar: true });
|
|
30
|
+
}
|
|
31
|
+
return tabs;
|
|
32
|
+
}, [id]);
|
|
33
|
+
return (_jsx("div", { className: "relative flex flex-col gap-y-4", children: _jsx(DetailView, { id: id, locationId: "products-detail-view", main: {
|
|
34
|
+
name: 'product',
|
|
35
|
+
label: t('product'),
|
|
36
|
+
component: _jsx(ProductDetailView, {}),
|
|
37
|
+
sidebar: _jsx(ProductDetailSidebar, {}),
|
|
38
|
+
form: createDeenruvForm({
|
|
39
|
+
key: 'CreateProductInput',
|
|
40
|
+
keys: ['translations', 'featuredAssetId', 'enabled', 'assetIds', 'facetValueIds', 'customFields'],
|
|
41
|
+
config: {
|
|
42
|
+
translations: {
|
|
43
|
+
validate: (v) => {
|
|
44
|
+
const { name, slug } = v[0];
|
|
45
|
+
if (!name || !slug)
|
|
46
|
+
return [t('validation.nameSlugRequired')];
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
onSubmitted: (data) => {
|
|
51
|
+
if (!data.translations)
|
|
52
|
+
throw new Error('Name is required.');
|
|
53
|
+
const input = {
|
|
54
|
+
translations: data.translations?.validatedValue,
|
|
55
|
+
assetIds: data.assetIds?.validatedValue,
|
|
56
|
+
featuredAssetId: data.featuredAssetId?.validatedValue,
|
|
57
|
+
facetValueIds: data.facetValueIds?.validatedValue,
|
|
58
|
+
enabled: data.enabled?.validatedValue,
|
|
59
|
+
...(data.customFields?.validatedValue ? { customFields: data.customFields?.validatedValue } : {}),
|
|
60
|
+
};
|
|
61
|
+
return id ? update({ input: { id, ...input } }) : create({ input });
|
|
62
|
+
},
|
|
63
|
+
onDeleted: () => {
|
|
64
|
+
if (id)
|
|
65
|
+
return remove({ id });
|
|
66
|
+
else
|
|
67
|
+
throw new Error('No id');
|
|
68
|
+
},
|
|
69
|
+
}),
|
|
70
|
+
}, defaultTabs: defaultTabs, permissions: {
|
|
71
|
+
create: Permission.CreateProduct,
|
|
72
|
+
edit: Permission.UpdateProduct,
|
|
73
|
+
delete: Permission.DeleteProduct,
|
|
74
|
+
} }) }));
|
|
75
|
+
};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Permission, SortOrder } from '@deenruv/admin-types';
|
|
3
|
+
import { apiClient, deepMerge, DetailList, ListBadge, ListLocations, Routes, TableLabel, useTranslation, FacetIdsSelector, EntityChannelManagementBulkAction, EntityFacetManagementBulkAction, } from '@deenruv/react-ui-devkit';
|
|
4
|
+
// import { FacetValueSelector } from '@deenruv/react-ui-devkit/FacetValueSelector.js';
|
|
5
|
+
const tableId = 'products-list-view';
|
|
6
|
+
const { selector } = ListLocations[tableId];
|
|
7
|
+
const fetch = async ({ page, perPage, filter, filterOperator, sort }, customFieldsSelector, additionalSelector) => {
|
|
8
|
+
const response = await apiClient('query')({
|
|
9
|
+
['products']: [
|
|
10
|
+
{
|
|
11
|
+
options: {
|
|
12
|
+
take: perPage,
|
|
13
|
+
skip: (page - 1) * perPage,
|
|
14
|
+
filterOperator: filterOperator,
|
|
15
|
+
sort: sort ? { [sort.key]: sort.sortDir } : { createdAt: SortOrder.DESC },
|
|
16
|
+
...(filter && { filter }),
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
{ items: deepMerge(selector, additionalSelector ?? {}), totalItems: true },
|
|
20
|
+
],
|
|
21
|
+
});
|
|
22
|
+
return response['products'];
|
|
23
|
+
};
|
|
24
|
+
const onRemove = async (items) => {
|
|
25
|
+
try {
|
|
26
|
+
const ids = items.map((item) => item.id);
|
|
27
|
+
const { deleteProducts } = await apiClient('mutation')({
|
|
28
|
+
deleteProducts: [{ ids }, { message: true, result: true }],
|
|
29
|
+
});
|
|
30
|
+
return !!deleteProducts.length;
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
return error;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
export const ProductsListPage = () => {
|
|
37
|
+
const { t } = useTranslation('products');
|
|
38
|
+
return (_jsx(DetailList, { filterFields: [
|
|
39
|
+
{ key: 'slug', operator: 'StringOperators' },
|
|
40
|
+
{ key: 'enabled', operator: 'BooleanOperators' },
|
|
41
|
+
{ key: 'sku', operator: 'StringOperators' },
|
|
42
|
+
{ key: 'name', operator: 'StringOperators' },
|
|
43
|
+
{
|
|
44
|
+
key: 'facetValueId',
|
|
45
|
+
component: (props) => {
|
|
46
|
+
return (_jsx(FacetIdsSelector, { onChange: (facetValuesId) => {
|
|
47
|
+
if (facetValuesId.length === 0) {
|
|
48
|
+
props.onChange({});
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
props.onChange({ in: facetValuesId.map((o) => o) });
|
|
52
|
+
}, facetValuesIds: props.value.in }));
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
], additionalBulkActions: [...EntityChannelManagementBulkAction(tableId), EntityFacetManagementBulkAction(tableId)], detailLinkColumn: "id", searchFields: ['name', 'slug', 'sku'], hideColumns: ['customFields', 'translations', 'collections', 'variantList'], entityName: 'Product', route: Routes['products'], tableId: tableId, fetch: fetch, onRemove: onRemove, createPermissions: [Permission.CreateProduct], deletePermissions: [Permission.DeleteProduct], suggestedOrderColumns: {
|
|
56
|
+
featuredAsset: 4,
|
|
57
|
+
variants: 99,
|
|
58
|
+
}, additionalColumns: [
|
|
59
|
+
{
|
|
60
|
+
id: 'variants',
|
|
61
|
+
accessorKey: 'variants',
|
|
62
|
+
header: () => _jsx(TableLabel, { children: t('table.variants') }),
|
|
63
|
+
cell: ({ row }) => row.original.variantList.totalItems,
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
id: 'allVariantsStock',
|
|
67
|
+
accessorKey: 'allVariantsStock',
|
|
68
|
+
header: () => _jsx(TableLabel, { children: t('table.allVariantsStock') }),
|
|
69
|
+
cell: ({ row }) => {
|
|
70
|
+
const { stockOnHandTotal, stockAllocatedTotal } = row.original.variantList.items.reduce((totals, item) => {
|
|
71
|
+
totals.stockOnHandTotal += item.stockOnHand;
|
|
72
|
+
totals.stockAllocatedTotal += item.stockAllocated;
|
|
73
|
+
return totals;
|
|
74
|
+
}, { stockOnHandTotal: 0, stockAllocatedTotal: 0 });
|
|
75
|
+
return (_jsxs(ListBadge, { children: [stockOnHandTotal, " (", stockAllocatedTotal, " ", t('table.allocated'), ")"] }));
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
] }));
|
|
79
|
+
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Button, DialogHeader, DialogTitle, Input, Dialog, DialogContent, DialogTrigger, Label, DialogFooter, apiClient, useGFFLP, setInArrayBy, EntityCustomFields, useTranslation, } from '@deenruv/react-ui-devkit';
|
|
3
|
+
import { useCallback, useState } from 'react';
|
|
4
|
+
import { toast } from 'sonner';
|
|
5
|
+
export const AddOptionGroupDialog = ({ currentTranslationLng, productId, onSuccess, }) => {
|
|
6
|
+
const { t } = useTranslation('products');
|
|
7
|
+
const [open, setOpen] = useState(false);
|
|
8
|
+
const { state, setField } = useGFFLP('CreateProductOptionGroupInput', 'code', 'translations', 'customFields')({});
|
|
9
|
+
const translations = state?.translations?.value || [];
|
|
10
|
+
const [codeEditedManually, setCodeEditedManually] = useState(false);
|
|
11
|
+
const createGroup = useCallback(() => {
|
|
12
|
+
if (state.code?.validatedValue && state.translations?.validatedValue)
|
|
13
|
+
return apiClient('mutation')({
|
|
14
|
+
createProductOptionGroup: [
|
|
15
|
+
{
|
|
16
|
+
input: {
|
|
17
|
+
code: state.code?.validatedValue,
|
|
18
|
+
options: [],
|
|
19
|
+
translations: state.translations.validatedValue,
|
|
20
|
+
...(state.customFields?.validatedValue ? { customFields: state.customFields?.validatedValue } : {}),
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
id: true,
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
})
|
|
28
|
+
.then((res) => {
|
|
29
|
+
if (productId)
|
|
30
|
+
return apiClient('mutation')({
|
|
31
|
+
addOptionGroupToProduct: [
|
|
32
|
+
{
|
|
33
|
+
productId,
|
|
34
|
+
optionGroupId: res.createProductOptionGroup.id,
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
id: true,
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
});
|
|
41
|
+
})
|
|
42
|
+
.then(() => {
|
|
43
|
+
toast(t('toasts.createOptionGroupSuccessToast'));
|
|
44
|
+
setOpen(false);
|
|
45
|
+
onSuccess();
|
|
46
|
+
})
|
|
47
|
+
.catch(() => {
|
|
48
|
+
toast(t('toasts.createOptionGroupErrorToast'));
|
|
49
|
+
});
|
|
50
|
+
}, [state.code, state.translations, productId, onSuccess, t]);
|
|
51
|
+
return (_jsxs(Dialog, { open: open, onOpenChange: setOpen, children: [_jsx(DialogTrigger, { asChild: true, children: _jsx(Button, { className: "self-end", children: t('addOptionGroupDialog.title') }) }), _jsxs(DialogContent, { children: [_jsx(DialogHeader, { children: _jsx(DialogTitle, { children: t('addOptionGroupDialog.title') }) }), _jsxs("div", { className: "flex flex-col gap-3", children: [_jsxs("div", { children: [_jsx(Label, { children: t('addOptionGroupDialog.name') }), _jsx(Input, { className: "mt-1", value: state.translations?.value[0].name ?? undefined, onChange: (e) => {
|
|
52
|
+
setField('translations', setInArrayBy(translations, (t) => t.languageCode !== currentTranslationLng, {
|
|
53
|
+
name: e.target.value,
|
|
54
|
+
languageCode: currentTranslationLng,
|
|
55
|
+
}));
|
|
56
|
+
if (!codeEditedManually) {
|
|
57
|
+
setField('code', e.target.value.replace(/\s+/g, '-'));
|
|
58
|
+
}
|
|
59
|
+
} })] }), _jsxs("div", { children: [_jsx(Label, { children: t('addOptionGroupDialog.code') }), _jsx(Input, { className: "mt-1", value: state.code?.value, onChange: (e) => {
|
|
60
|
+
setCodeEditedManually(true);
|
|
61
|
+
setField('code', e.target.value);
|
|
62
|
+
} })] }), _jsx(EntityCustomFields, { id: undefined, entityName: "productOptionGroup", hideButton: true, onChange: (cf) => {
|
|
63
|
+
setField('customFields', cf);
|
|
64
|
+
}, additionalData: {}, withoutBorder: true })] }), _jsxs(DialogFooter, { className: "mt-2", children: [_jsx(Button, { onClick: () => setOpen(false), children: t('addOptionGroupDialog.cancel') }), _jsx(Button, { onClick: createGroup, children: t('addOptionGroupDialog.add') })] })] })] }));
|
|
65
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { DropdownMenuItem, Label, DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuTrigger, apiClient, cn, CustomCard, CardIcons, AssetsModalInput, useTranslation, createDialogFromComponent, } from '@deenruv/react-ui-devkit';
|
|
3
|
+
import { assetsSelector } from "../../../graphql/base";
|
|
4
|
+
import { ImageOff } from 'lucide-react';
|
|
5
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
6
|
+
import { EditAssetDialog } from "../../assets/_components/EditAssetDialog.js";
|
|
7
|
+
export const AssetsCard = ({ featuredAssetId, assetsIds, onAddAsset, onFeaturedAssetChange, onAssetsChange, }) => {
|
|
8
|
+
const { t } = useTranslation('products');
|
|
9
|
+
const [featureAsset, setFeatureAsset] = useState();
|
|
10
|
+
const [assets, setAssets] = useState([]);
|
|
11
|
+
const getAsset = useCallback(async (id) => {
|
|
12
|
+
const response = await apiClient('query')({
|
|
13
|
+
asset: [{ id: id }, assetsSelector],
|
|
14
|
+
});
|
|
15
|
+
return response.asset;
|
|
16
|
+
}, [assetsIds]);
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
if (featuredAssetId)
|
|
19
|
+
getAsset(featuredAssetId).then((a) => setFeatureAsset(a));
|
|
20
|
+
}, [featuredAssetId]);
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
const promises = [];
|
|
23
|
+
if (assetsIds)
|
|
24
|
+
assetsIds.forEach((id) => promises.push(getAsset(id)));
|
|
25
|
+
Promise.all(promises).then((assets) => {
|
|
26
|
+
const existingAssets = assets.filter((item) => item !== undefined);
|
|
27
|
+
setAssets(existingAssets);
|
|
28
|
+
});
|
|
29
|
+
}, [assetsIds?.toString()]);
|
|
30
|
+
const handleRemoveAsset = useCallback((id) => {
|
|
31
|
+
const newAssets = assetsIds?.filter((aId) => aId !== id);
|
|
32
|
+
onAssetsChange(newAssets || []);
|
|
33
|
+
}, [assetsIds, onAssetsChange]);
|
|
34
|
+
return (_jsx(CustomCard, { title: t('assets'), color: "green", icon: _jsx(CardIcons.asset, {}), children: _jsx("div", { className: "flex flex-col gap-6", children: _jsxs("div", { className: "flex gap-6", children: [_jsxs("div", { children: [_jsx(Label, { children: t('details.featuredAsset') }), _jsxs("div", { className: "flex flex-col pt-3", children: [_jsx("div", { className: "mb-4 flex h-36 min-w-36 items-center justify-center border border-solid border-gray-300 p-2 shadow", children: featureAsset?.preview ? (_jsx("img", { src: featureAsset.preview, className: "h-32", alt: "Main image preview" })) : (_jsxs("div", { className: "flex size-full flex-col items-center justify-center gap-2 bg-gray-200 p-3", children: [_jsx(ImageOff, { size: 32 }), t('details.noFeaturedAsset')] })) }), _jsx(AssetsModalInput, { setValue: (a) => onAddAsset(a?.id) })] })] }), _jsxs("div", { children: [_jsx(Label, { children: t('details.otherAssets') }), _jsx("div", { className: "flex gap-3 pt-3", children: assets?.length ? (assets.map((asset) => (_jsxs(DropdownMenu, { modal: false, children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsx("div", { className: cn('flex h-20 min-w-20 cursor-pointer items-center justify-center border border-solid border-gray-300 p-2 shadow', asset.id === featuredAssetId && 'border-2 border-blue-500'), children: asset?.preview && _jsx("img", { src: asset.preview, className: "h-16" }) }) }), _jsx(DropdownMenuContent, { className: "w-56", side: "bottom", align: "end", children: _jsxs(DropdownMenuGroup, { children: [_jsx(DropdownMenuItem, { onClick: () => createDialogFromComponent(EditAssetDialog, asset, { className: 'max-w-4xl' }), children: t('details.editAsset') }), _jsx(DropdownMenuItem, { onClick: () => onFeaturedAssetChange(asset.id), children: t('details.setAsFeatured') }), _jsx(DropdownMenuItem, { onClick: () => handleRemoveAsset(asset.id), children: t('details.removeAsset') })] }) })] }, asset.id)))) : (_jsx("p", { children: t('details.noAssets') })) })] })] }) }) }));
|
|
35
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useTranslation, Input, CustomCard, CardIcons, RichTextEditor } from '@deenruv/react-ui-devkit';
|
|
3
|
+
export const BasicFieldsCard = ({ currentTranslationValue, onChange, errors }) => {
|
|
4
|
+
const { t } = useTranslation('products');
|
|
5
|
+
return (_jsx(CustomCard, { title: t('details.basicInfo'), icon: _jsx(CardIcons.basic, {}), color: "blue", children: _jsxs("div", { className: "flex flex-1 flex-col gap-y-4", children: [_jsxs("div", { className: "flex items-start gap-3", children: [_jsx(Input, { label: t('name'), placeholder: t('name'), value: currentTranslationValue?.name ?? '', onChange: (e) => onChange('name', e.target.value), errors: errors }), _jsx(Input, { value: currentTranslationValue?.slug ?? '', label: t('slug'), placeholder: t('slug'), onChange: (e) => onChange('slug', e.target.value) })] }), _jsx(RichTextEditor, { content: currentTranslationValue?.description ?? '', onContentChanged: (value) => onChange('description', value) })] }) }));
|
|
6
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useTranslation, Badge, CardIcons, CustomCard, DEFAULT_CHANNEL_CODE } from '@deenruv/react-ui-devkit';
|
|
3
|
+
export const ChannelsCard = ({ channels }) => {
|
|
4
|
+
const { t } = useTranslation(['products', 'channels']);
|
|
5
|
+
return (_jsx(CustomCard, { title: t('products:channels'), color: "orange", icon: _jsx(CardIcons.default, {}), children: _jsx("div", { className: "flex flex-wrap gap-2", children: channels.map((p) => (_jsx(Badge, { children: p.code === DEFAULT_CHANNEL_CODE ? t('channels:defaultChannel') : p.code }, p.id))) }) }));
|
|
6
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useTranslation, Badge, CardIcons, CustomCard } from '@deenruv/react-ui-devkit';
|
|
3
|
+
export const CollectionsCard = ({ collections }) => {
|
|
4
|
+
const { t } = useTranslation('products');
|
|
5
|
+
return (_jsx(CustomCard, { title: t('collections'), color: "teal", icon: _jsx(CardIcons.group, {}), children: _jsx("div", { className: "flex flex-wrap gap-2", children: collections.map((c) => (_jsx(Badge, { variant: "secondary", children: c.name }, c.slug))) }) }));
|
|
6
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useTranslation, Input, Card, CardHeader, CardTitle, CardContent } from '@deenruv/react-ui-devkit';
|
|
3
|
+
export const DiscountRatingCard = ({ discountByValue, onDiscountByChange, searchMetricsScoreValue, onSearchMetricsScoreChange, }) => {
|
|
4
|
+
const { t } = useTranslation('products');
|
|
5
|
+
return (_jsxs(Card, { children: [_jsx(CardHeader, { children: _jsx(CardTitle, { className: "flex flex-row justify-between text-base", children: t('customFields.discountRating.title') }) }), _jsx(CardContent, { children: _jsxs("div", { className: "flex flex-col gap-4", children: [_jsx(Input, { type: "number", step: 0.01, label: t('customFields.discountRating.discountedBy'), placeholder: t('customFields.discountRating.discountedBy'), value: discountByValue, onChange: onDiscountByChange }), _jsx(Input, { type: "number", label: t('customFields.discountRating.rating'), placeholder: t('customFields.discountRating.rating'), value: searchMetricsScoreValue, onChange: onSearchMetricsScoreChange })] }) })] }));
|
|
6
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useTranslation, CardIcons, CustomCard, FacetIdsSelector } from '@deenruv/react-ui-devkit';
|
|
3
|
+
export const FacetValuesCard = ({ facetValuesIds, onChange }) => {
|
|
4
|
+
const { t } = useTranslation('products');
|
|
5
|
+
return (_jsx(CustomCard, { title: t('facets'), color: "indigo", icon: _jsx(CardIcons.tag, {}), children: _jsx(FacetIdsSelector, { fixedDropdown: true, facetValuesIds: facetValuesIds, onChange: (options) => onChange(options) }) }));
|
|
6
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useTranslation, Card, CardHeader, CardTitle, CardContent, } from '@deenruv/react-ui-devkit';
|
|
3
|
+
export const ImagesCard = ({ customFields, onMainImageChange, onHoverImageChange }) => {
|
|
4
|
+
const { t } = useTranslation('products');
|
|
5
|
+
return (_jsxs(Card, { children: [_jsx(CardHeader, { children: _jsx(CardTitle, { className: "flex flex-row justify-between text-base", children: t('details.image') }) }), _jsx(CardContent, { children: _jsx("div", { className: "flex flex-col gap-6" }) })] }));
|
|
6
|
+
};
|