@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,61 @@
|
|
|
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, getMutation, useMutation, } from '@deenruv/react-ui-devkit';
|
|
5
|
+
import { CollectionsDetailView } from "./_components/CollectionDetailView.js";
|
|
6
|
+
const CreateCollectionMutation = getMutation('createCollection');
|
|
7
|
+
const EditCollectionMutation = getMutation('updateCollection');
|
|
8
|
+
const DeleteCollectionMutation = getMutation('deleteCollection');
|
|
9
|
+
export const CollectionsDetailPage = () => {
|
|
10
|
+
const { id } = useParams();
|
|
11
|
+
const [update] = useMutation(EditCollectionMutation);
|
|
12
|
+
const [create] = useMutation(CreateCollectionMutation);
|
|
13
|
+
const [remove] = useMutation(DeleteCollectionMutation);
|
|
14
|
+
const { configurableOperationArrayValidator, translationsValidator } = useValidators();
|
|
15
|
+
const onSubmitHandler = useCallback((data) => {
|
|
16
|
+
const inputData = {
|
|
17
|
+
assetIds: data.assetIds?.validatedValue,
|
|
18
|
+
featuredAssetId: data.featuredAssetId?.validatedValue,
|
|
19
|
+
isPrivate: data.isPrivate?.validatedValue,
|
|
20
|
+
inheritFilters: data.inheritFilters?.validatedValue,
|
|
21
|
+
filters: data.filters.validatedValue,
|
|
22
|
+
translations: data.translations.validatedValue.map((t) => ({
|
|
23
|
+
description: t.description || '',
|
|
24
|
+
name: t.name || '',
|
|
25
|
+
languageCode: t.languageCode,
|
|
26
|
+
slug: t.slug || '',
|
|
27
|
+
})),
|
|
28
|
+
};
|
|
29
|
+
if (id)
|
|
30
|
+
return update({ input: { id, ...inputData } });
|
|
31
|
+
else
|
|
32
|
+
return create({ input: inputData });
|
|
33
|
+
}, [id, update, create]);
|
|
34
|
+
const onDeleteHandler = useCallback(() => {
|
|
35
|
+
if (!id) {
|
|
36
|
+
throw new Error('Could not find the id.');
|
|
37
|
+
}
|
|
38
|
+
return remove({ input: { id } });
|
|
39
|
+
}, [remove, id]);
|
|
40
|
+
return (_jsx("div", { className: "relative flex flex-col gap-y-4", children: _jsx(DetailView, { id: id, locationId: "collections-detail-view", main: {
|
|
41
|
+
name: 'collection',
|
|
42
|
+
label: 'Collection',
|
|
43
|
+
component: _jsx(CollectionsDetailView, {}),
|
|
44
|
+
form: createDeenruvForm({
|
|
45
|
+
key: 'CreateCollectionInput',
|
|
46
|
+
keys: ['assetIds', 'featuredAssetId', 'filters', 'inheritFilters', 'isPrivate', 'parentId', 'translations'],
|
|
47
|
+
config: {
|
|
48
|
+
isPrivate: {
|
|
49
|
+
initialValue: false,
|
|
50
|
+
},
|
|
51
|
+
inheritFilters: {
|
|
52
|
+
initialValue: true,
|
|
53
|
+
},
|
|
54
|
+
translations: translationsValidator,
|
|
55
|
+
filters: configurableOperationArrayValidator(),
|
|
56
|
+
},
|
|
57
|
+
onSubmitted: onSubmitHandler,
|
|
58
|
+
onDeleted: onDeleteHandler,
|
|
59
|
+
}),
|
|
60
|
+
} }) }));
|
|
61
|
+
};
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { ArrowDownSquareIcon, ArrowUpSquareIcon, Folder, FolderOpen, XSquareIcon } from 'lucide-react';
|
|
3
|
+
import { Permission, SortOrder } from '@deenruv/admin-types';
|
|
4
|
+
import { CollectionProductVariantsDrawer } from './_components/CollectionProductVariantsDrawer.js';
|
|
5
|
+
import { DrawerTrigger, Routes, apiClient, ListBadge, DetailList, deepMerge, ListLocations, EntityChannelManagementBulkAction, EntityFacetManagementBulkAction, } from '@deenruv/react-ui-devkit';
|
|
6
|
+
import { ArrowRight } from 'lucide-react';
|
|
7
|
+
const tableId = 'collections-list-view';
|
|
8
|
+
const { selector } = ListLocations[tableId];
|
|
9
|
+
const fetch = async ({ page, perPage, filter, filterOperator, sort }, additionalSelector) => {
|
|
10
|
+
const response = await apiClient('query')({
|
|
11
|
+
['collections']: [
|
|
12
|
+
{
|
|
13
|
+
options: {
|
|
14
|
+
take: perPage,
|
|
15
|
+
skip: (page - 1) * perPage,
|
|
16
|
+
filterOperator: filterOperator,
|
|
17
|
+
sort: sort ? { [sort.key]: sort.sortDir } : { createdAt: SortOrder.DESC },
|
|
18
|
+
...(filter && { filter }),
|
|
19
|
+
topLevelOnly: true,
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
{ items: deepMerge(selector, additionalSelector ?? {}), totalItems: true },
|
|
23
|
+
],
|
|
24
|
+
});
|
|
25
|
+
return response['collections'];
|
|
26
|
+
};
|
|
27
|
+
export const CollectionsListPage = () => {
|
|
28
|
+
return (_jsx(DetailList, { filterFields: [], detailLinkColumn: "id", searchFields: ['name', 'code'], hideColumns: ['translations', 'breadcrumbs', 'description'], getSubRows: (row) => row.children, additionalColumns: [
|
|
29
|
+
{
|
|
30
|
+
accessorKey: 'children',
|
|
31
|
+
header: 'Children',
|
|
32
|
+
cell: ({ row, getValue }) => {
|
|
33
|
+
const value = getValue();
|
|
34
|
+
const isExpanded = row.getIsExpanded();
|
|
35
|
+
return (_jsx("div", { style: { paddingLeft: `${row.depth * 2}rem` }, children: _jsx(ListBadge, { paddingLeft: `${row.depth * 2}rem`,
|
|
36
|
+
onClick: row.getToggleExpandedHandler(),
|
|
37
|
+
style: { cursor: 'pointer' }, children: isExpanded ? (_jsx(FolderOpen, { size: 16 })) : value?.length > 0 ? (_jsx(Folder, { size: 16 })) : (_jsx(XSquareIcon, { size: 16 })) }) }));
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
accessorKey: 'productVariants',
|
|
42
|
+
header: 'Products',
|
|
43
|
+
cell: ({ row, getValue }) => {
|
|
44
|
+
const value = getValue();
|
|
45
|
+
return value?.totalItems > 0 ? (_jsx(CollectionProductVariantsDrawer, { collectionId: row.original.id, collectionName: row.original.name, count: row.original.productVariants.totalItems, children: _jsx(DrawerTrigger, { className: "w-full", children: _jsxs(ListBadge, { children: [value.totalItems, _jsx(ArrowRight, { className: "pl-1", size: 16 })] }) }) })) : (_jsx(ListBadge, { children: value?.totalItems || 0 }));
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
], additionalBulkActions: [
|
|
49
|
+
...EntityChannelManagementBulkAction(tableId),
|
|
50
|
+
EntityFacetManagementBulkAction(tableId),
|
|
51
|
+
{
|
|
52
|
+
icon: _jsx(FolderOpen, { size: 16 }),
|
|
53
|
+
label: 'Przenieś zaznaczone kolekcje',
|
|
54
|
+
onClick: async ({ table, data, refetch }) => {
|
|
55
|
+
const selectedRows = table.getSelectedRowModel().flatRows.map((row) => row);
|
|
56
|
+
if (selectedRows.length === 0) {
|
|
57
|
+
return { error: 'Nie zaznaczono żadnej kolekcji' };
|
|
58
|
+
}
|
|
59
|
+
try {
|
|
60
|
+
// const result = await createDialogFromComponent(MoveCollectionsToCollections, selectedRows);
|
|
61
|
+
}
|
|
62
|
+
catch (e) {
|
|
63
|
+
console.log(e);
|
|
64
|
+
}
|
|
65
|
+
return { success: '' };
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
], additionalRowActions: [
|
|
69
|
+
{
|
|
70
|
+
icon: _jsx(ArrowUpSquareIcon, { size: 16 }),
|
|
71
|
+
label: 'Przenieś kolekcje',
|
|
72
|
+
onClick: async ({ row, refetch }) => {
|
|
73
|
+
try {
|
|
74
|
+
await apiClient('mutation')({
|
|
75
|
+
moveCollection: [
|
|
76
|
+
{
|
|
77
|
+
input: {
|
|
78
|
+
collectionId: row.original.id,
|
|
79
|
+
index: row.original.position - 1,
|
|
80
|
+
parentId: row.original.parentId,
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
{ id: true },
|
|
84
|
+
],
|
|
85
|
+
});
|
|
86
|
+
refetch();
|
|
87
|
+
return { success: '' };
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
return { error: '' };
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
icon: _jsx(ArrowDownSquareIcon, { size: 16 }),
|
|
96
|
+
label: 'Przenieś kolekcje',
|
|
97
|
+
onClick: async ({ row, refetch }) => {
|
|
98
|
+
try {
|
|
99
|
+
await apiClient('mutation')({
|
|
100
|
+
moveCollection: [
|
|
101
|
+
{
|
|
102
|
+
input: {
|
|
103
|
+
collectionId: row.original.id,
|
|
104
|
+
index: row.original.position + 1,
|
|
105
|
+
parentId: row.original.parentId,
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
{ id: true },
|
|
109
|
+
],
|
|
110
|
+
});
|
|
111
|
+
refetch();
|
|
112
|
+
return { success: '' };
|
|
113
|
+
}
|
|
114
|
+
catch {
|
|
115
|
+
return { error: '' };
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
icon: _jsx(FolderOpen, { size: 16 }),
|
|
121
|
+
label: 'Przenieś kolekcje',
|
|
122
|
+
onClick: async ({ row, refetch }) => {
|
|
123
|
+
try {
|
|
124
|
+
// const result = await createDialogFromComponent(MoveCollectionsToCollections, [row]);
|
|
125
|
+
}
|
|
126
|
+
catch (e) {
|
|
127
|
+
console.log(e);
|
|
128
|
+
}
|
|
129
|
+
return { success: '' };
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
], entityName: 'Collection', route: Routes['collections'], tableId: tableId, fetch: fetch, onRemove: async () => {
|
|
133
|
+
return true;
|
|
134
|
+
}, createPermissions: [Permission.CreateCollection], deletePermissions: [Permission.DeleteCollection] }));
|
|
135
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback, useEffect } from 'react';
|
|
3
|
+
import { EntityCustomFields, Input, Label, Switch, CustomCard, CardIcons, useDetailView, useSettings, RichTextEditor, useTranslation, setInArrayBy, EntityChannelManager, Routes, } from '@deenruv/react-ui-devkit';
|
|
4
|
+
import { FiltersCard } from "./FiltersCard";
|
|
5
|
+
import { ContentsCard } from "./ContentsCard";
|
|
6
|
+
import { AssetsCard } from "../../products/_components/AssetsCard.js";
|
|
7
|
+
import { useNavigate } from 'react-router-dom';
|
|
8
|
+
export const CollectionsDetailView = () => {
|
|
9
|
+
const { t } = useTranslation('collections');
|
|
10
|
+
const contentLng = useSettings((p) => p.translationsLanguage);
|
|
11
|
+
const selectedChannel = useSettings((p) => p.selectedChannel);
|
|
12
|
+
const navigate = useNavigate();
|
|
13
|
+
const { form, fetchEntity, entity, id } = useDetailView('collections-detail-view', 'CreateCollectionInput', 'translations', 'assetIds', 'featuredAssetId', 'isPrivate', 'inheritFilters', 'filters', 'customFields');
|
|
14
|
+
const { base: { setField, state }, } = form;
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
(async () => {
|
|
17
|
+
const resp = await fetchEntity();
|
|
18
|
+
if (!resp)
|
|
19
|
+
return;
|
|
20
|
+
setField('translations', resp.translations);
|
|
21
|
+
setField('assetIds', resp.assets.map((a) => a.id));
|
|
22
|
+
setField('featuredAssetId', resp.featuredAsset?.id);
|
|
23
|
+
setField('isPrivate', resp.isPrivate);
|
|
24
|
+
setField('inheritFilters', resp.inheritFilters);
|
|
25
|
+
setField('filters', resp.filters.map((f) => ({ code: f.code, arguments: f.args })));
|
|
26
|
+
})();
|
|
27
|
+
}, [contentLng, selectedChannel?.id]);
|
|
28
|
+
const translations = state?.translations?.value || [];
|
|
29
|
+
const currentTranslationValue = translations.find((v) => v.languageCode === contentLng);
|
|
30
|
+
const handleAddAsset = useCallback((newId) => {
|
|
31
|
+
if (!newId)
|
|
32
|
+
return;
|
|
33
|
+
const currentIds = state.assetIds?.value || [];
|
|
34
|
+
setField('assetIds', [...currentIds, newId]);
|
|
35
|
+
}, [state.assetIds?.value, setField]);
|
|
36
|
+
const setTranslationField = useCallback((field, e) => {
|
|
37
|
+
if (!currentTranslationValue)
|
|
38
|
+
return;
|
|
39
|
+
setField('translations', setInArrayBy(translations, (t) => t.languageCode !== contentLng, {
|
|
40
|
+
...currentTranslationValue,
|
|
41
|
+
[field]: e,
|
|
42
|
+
languageCode: contentLng,
|
|
43
|
+
}));
|
|
44
|
+
}, [contentLng, translations]);
|
|
45
|
+
return (_jsx("main", { children: _jsxs("div", { className: "flex flex-col gap-3", children: [_jsx(CustomCard, { title: t('details.basic.title'), icon: _jsx(CardIcons.basic, {}), color: "blue", 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.slug'), value: currentTranslationValue?.slug ?? undefined, onChange: (e) => setTranslationField('slug', e.target.value), required: true }) }), _jsxs("div", { className: "mt-7 flex basis-full items-center gap-3 md:basis-1/3", children: [_jsx(Switch, { checked: state.isPrivate?.value ?? undefined, onCheckedChange: (e) => setField('isPrivate', e) }), _jsx(Label, { children: t('details.basic.isPrivate') })] })] }), _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(AssetsCard, { onAddAsset: handleAddAsset, featuredAssetId: state.featuredAssetId?.value ?? undefined, assetsIds: state.assetIds?.value ?? undefined, onFeaturedAssetChange: (id) => setField('featuredAssetId', id), onAssetsChange: (ids) => setField('assetIds', ids) }), _jsx(EntityChannelManager, { entity: "collection", entityId: id, entityChannels: [{ id: selectedChannel?.id, code: selectedChannel?.code }], onRemoveSuccess: () => navigate(Routes.collections.list) }), _jsx(FiltersCard, { currentFiltersValue: state.filters?.value ?? undefined, onFiltersValueChange: (filters) => setField('filters', filters ?? []), inheritValue: state.inheritFilters?.value ?? undefined, onInheritChange: (e) => setField('inheritFilters', e), errors: state.filters?.errors }), _jsx(EntityCustomFields, { entityName: "collection", id: id, hideButton: true, onChange: (customFields, translations) => {
|
|
46
|
+
setField('customFields', customFields);
|
|
47
|
+
if (translations)
|
|
48
|
+
setField('translations', translations);
|
|
49
|
+
}, initialValues: entity && 'customFields' in entity
|
|
50
|
+
? { customFields: entity.customFields, translations: entity.translations }
|
|
51
|
+
: { customFields: {} } }), id && _jsx(ContentsCard, { collectionId: id })] }) }));
|
|
52
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Button, Input, SelectContent, SelectTrigger, SelectValue, Select, SelectItem, Drawer, DrawerClose, DrawerContent, DrawerDescription, DrawerHeader, DrawerTitle, useTranslation, } from '@deenruv/react-ui-devkit';
|
|
3
|
+
import { useMemo, useState } from 'react';
|
|
4
|
+
import { ContentsTable } from "./ContentsTable";
|
|
5
|
+
const filterOptions = ['name', 'sku', 'id'];
|
|
6
|
+
export const CollectionProductVariantsDrawer = ({ collectionId, collectionName, children, count, }) => {
|
|
7
|
+
const [filter, setFilter] = useState({});
|
|
8
|
+
const { t } = useTranslation(['collections', 'common']);
|
|
9
|
+
const firstFilterKey = useMemo(() => Object.keys(filter ?? {})[0], [filter]);
|
|
10
|
+
const handleFilterValue = (key) => {
|
|
11
|
+
switch (key) {
|
|
12
|
+
case 'name': {
|
|
13
|
+
return (_jsx(Input, { placeholder: `${t('drawer.filter.name')}..`, onChange: (e) => setFilter({ [key]: e.target.value ? { contains: e.target.value } : {} }) }, key));
|
|
14
|
+
}
|
|
15
|
+
case 'sku': {
|
|
16
|
+
return (_jsx(Input, { placeholder: `${t('drawer.filter.sku')}..`, onChange: (e) => setFilter({ [key]: e.target.value ? { contains: e.target.value } : {} }) }, key));
|
|
17
|
+
}
|
|
18
|
+
case 'id': {
|
|
19
|
+
return (_jsx(Input, { placeholder: `${t('drawer.filter.id')}..`, onChange: (e) => setFilter({ [key]: e.target.value ? { eq: e.target.value } : {} }) }, key));
|
|
20
|
+
}
|
|
21
|
+
default:
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
return (_jsx("div", { children: _jsxs(Drawer, { direction: "right", children: [children, _jsxs(DrawerContent, { className: "left-auto right-0 top-0 mt-0 w-[85vw]", children: [_jsxs(DrawerHeader, { className: "flex items-center justify-between", children: [_jsxs("div", { className: "flex items-center gap-4", children: [_jsxs("div", { className: "shrink-0", children: [_jsx(DrawerTitle, { children: t('drawer.title', { collectionName, interpolation: { escapeValue: false } }) }), _jsx(DrawerDescription, { children: t('drawer.count', { count }) }), ' '] }), _jsxs(Select, { value: firstFilterKey, onValueChange: (e) => {
|
|
26
|
+
setFilter({ [e]: {} });
|
|
27
|
+
}, children: [_jsx(SelectTrigger, { className: "w-[280px]", children: _jsx(SelectValue, { placeholder: t('drawer.filter.title') }) }), _jsx(SelectContent, { children: filterOptions.map((i) => (_jsx(SelectItem, { className: "cursor-pointer", value: i, children: t(`drawer.filter.labels.${i}`) }, i))) })] }), filter && handleFilterValue(firstFilterKey)] }), _jsx(DrawerClose, { children: _jsx(Button, { children: t('drawer.close') }) })] }), _jsx(ContentsTable, { collectionId: collectionId, filter: filter })] })] }) }));
|
|
28
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useTranslation, Label, ToggleGroup, ToggleGroupItem } from '@deenruv/react-ui-devkit';
|
|
3
|
+
export const CombinationMode = ({ label, value, onChange }) => {
|
|
4
|
+
const { t } = useTranslation('collections');
|
|
5
|
+
return (_jsxs("div", { className: "flex basis-full flex-col gap-3", children: [_jsx(Label, { children: label }), _jsxs(ToggleGroup, { type: "single", value: value, onValueChange: onChange, className: " justify-start", children: [_jsx(ToggleGroupItem, { variant: 'outline', size: 'sm', value: 'true', children: t('details.filters.labels.arguments.and') }), _jsx(ToggleGroupItem, { variant: 'outline', size: 'sm', value: 'false', children: t('details.filters.labels.arguments.or') })] })] }));
|
|
6
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { CustomCard, CardIcons, DetailList, Routes, apiClient, deepMerge, useTranslation, TableLabel, } from '@deenruv/react-ui-devkit';
|
|
3
|
+
import { useCallback } from 'react';
|
|
4
|
+
import { Permission, SortOrder } from '@deenruv/admin-types';
|
|
5
|
+
import { CollectionProductVariantsSelector } from "../../../graphql/collections.js";
|
|
6
|
+
export const ContentsCard = ({ collectionId }) => {
|
|
7
|
+
const { t } = useTranslation('collections');
|
|
8
|
+
const fetch = useCallback(async ({ page, perPage, filter, filterOperator, sort }, customFieldsSelector, additionalSelector) => {
|
|
9
|
+
const selector = deepMerge(CollectionProductVariantsSelector, additionalSelector ?? {});
|
|
10
|
+
const response = await apiClient('query')({
|
|
11
|
+
collection: [
|
|
12
|
+
{ id: collectionId },
|
|
13
|
+
{
|
|
14
|
+
productVariants: [
|
|
15
|
+
{
|
|
16
|
+
options: {
|
|
17
|
+
take: perPage,
|
|
18
|
+
skip: (page - 1) * perPage,
|
|
19
|
+
filterOperator: filterOperator,
|
|
20
|
+
sort: sort ? { [sort.key]: sort.sortDir } : { createdAt: SortOrder.DESC },
|
|
21
|
+
...(filter && { filter }),
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
{ totalItems: true, items: selector },
|
|
25
|
+
],
|
|
26
|
+
},
|
|
27
|
+
],
|
|
28
|
+
});
|
|
29
|
+
return (response['collection']?.productVariants ?? {
|
|
30
|
+
items: [],
|
|
31
|
+
totalItems: 0,
|
|
32
|
+
});
|
|
33
|
+
}, [collectionId]);
|
|
34
|
+
return (_jsx(CustomCard, { title: t('details.contents.title'), color: "green", icon: _jsx(CardIcons.group, {}), children: _jsx(DetailList, { noPaddings: true, detailLinkColumn: "id", filterFields: [{ key: 'id', operator: 'IDOperators' }], searchFields: ['code', 'name'], hideColumns: ['customFields', 'product', 'updatedAt', 'createdAt'], entityName: 'Product', route: Routes['products'], tableId: "products-list-view", fetch: fetch, noCreateButton: true, createPermissions: [Permission.CreateProduct], deletePermissions: [Permission.DeleteProduct], additionalColumns: [
|
|
35
|
+
{
|
|
36
|
+
accessorKey: 'product',
|
|
37
|
+
enableSorting: false,
|
|
38
|
+
enableColumnFilter: false,
|
|
39
|
+
header: () => _jsx(TableLabel, { children: t('table.product') }),
|
|
40
|
+
cell: ({ row }) => _jsx("div", { className: "flex gap-1", children: row.original.product.name }),
|
|
41
|
+
},
|
|
42
|
+
] }) }));
|
|
43
|
+
};
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { Badge, Table, TableBody, TableCell, TableHead, TableHeader, TableRow, Skeleton, Routes, EmptyState, apiClient, useDetailListHook, deepMerge, ImageWithPreview, useTranslation, TableLabel, } from '@deenruv/react-ui-devkit';
|
|
3
|
+
import { CollectionProductVariantsSelector } from "../../../graphql/collections";
|
|
4
|
+
import { SortOrder } from '@deenruv/admin-types';
|
|
5
|
+
import { flexRender, getCoreRowModel, getFilteredRowModel, getPaginationRowModel, getSortedRowModel, useReactTable, } from '@tanstack/react-table';
|
|
6
|
+
import { ArrowRight } from 'lucide-react';
|
|
7
|
+
import React, { useMemo, useState } from 'react';
|
|
8
|
+
import { Link } from 'react-router-dom';
|
|
9
|
+
import { useDebounce } from 'use-debounce';
|
|
10
|
+
export const ContentsTable = ({ collectionId, filter }) => {
|
|
11
|
+
const { objects, Paginate, Search, SortButton } = useDetailListHook({
|
|
12
|
+
fakeURLParams: true,
|
|
13
|
+
fetch: async ({ page, perPage, filter: filterValue, filterOperator, sort }, customFieldsSelector, additionalSelector) => {
|
|
14
|
+
const selector = deepMerge(CollectionProductVariantsSelector, additionalSelector ?? {});
|
|
15
|
+
const response = await apiClient('query')({
|
|
16
|
+
collection: [
|
|
17
|
+
{ id: collectionId },
|
|
18
|
+
{
|
|
19
|
+
productVariants: [
|
|
20
|
+
{
|
|
21
|
+
options: {
|
|
22
|
+
take: perPage,
|
|
23
|
+
skip: (page - 1) * perPage,
|
|
24
|
+
filterOperator: filterOperator,
|
|
25
|
+
sort: sort ? { [sort.key]: sort.sortDir } : { createdAt: SortOrder.DESC },
|
|
26
|
+
...(filterValue && { filter: filterValue }),
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
{ totalItems: true, items: selector },
|
|
30
|
+
],
|
|
31
|
+
},
|
|
32
|
+
],
|
|
33
|
+
});
|
|
34
|
+
return (response['collection']?.productVariants ?? {
|
|
35
|
+
items: [],
|
|
36
|
+
totalItems: 0,
|
|
37
|
+
});
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
const [tableLoading, setTableLoading] = useState(false);
|
|
41
|
+
const [debouncedFilter] = useDebounce(filter, 500);
|
|
42
|
+
const [columnFilters, setColumnFilters] = useState([]);
|
|
43
|
+
const [columnsVisibilityState, setColumnsVisibilityState] = useState({});
|
|
44
|
+
const [pagination, setPagination] = React.useState({
|
|
45
|
+
pageIndex: 0,
|
|
46
|
+
pageSize: 10,
|
|
47
|
+
});
|
|
48
|
+
const { t } = useTranslation(['collections', 'common']);
|
|
49
|
+
const columns = useMemo(() => [
|
|
50
|
+
{
|
|
51
|
+
accessorKey: 'id',
|
|
52
|
+
enableHiding: false,
|
|
53
|
+
enableColumnFilter: false,
|
|
54
|
+
header: () => _jsx(TableLabel, { children: t('table.id') }),
|
|
55
|
+
cell: ({ row }) => (_jsx(Link, { to: Routes.products.to(`${row.original.product.id}?tab=variants`), className: "text-primary-600", children: _jsxs(Badge, { variant: "outline", className: "flex w-full items-center justify-center", children: [row.original.id, _jsx(ArrowRight, { className: "pl-1", size: 16 })] }) })),
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
accessorKey: 'featuredAsset',
|
|
59
|
+
header: () => _jsx(TableLabel, { children: t('table.featuredAsset') }),
|
|
60
|
+
cell: ({ row }) => _jsx(ImageWithPreview, { src: row.original.featuredAsset?.preview, alt: row.original.name }),
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
accessorKey: 'product.name',
|
|
64
|
+
header: () => _jsx(TableLabel, { children: t('drawer.product') }),
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
accessorKey: 'name',
|
|
68
|
+
header: () => _jsx(TableLabel, { children: t('drawer.variant') }),
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
accessorKey: 'sku',
|
|
72
|
+
header: () => _jsx(TableLabel, { children: t('drawer.sku') }),
|
|
73
|
+
},
|
|
74
|
+
], [t]);
|
|
75
|
+
const tableColumns = useMemo(() => tableLoading
|
|
76
|
+
? columns.map((column) => ({
|
|
77
|
+
...column,
|
|
78
|
+
cell: () => _jsx(Skeleton, { className: "h-12 w-full rounded-sm" }),
|
|
79
|
+
}))
|
|
80
|
+
: columns, [tableLoading]);
|
|
81
|
+
const tableData = useMemo(() => (tableLoading ? Array(10).fill({}) : objects || []), [tableLoading, objects]);
|
|
82
|
+
const table = useReactTable({
|
|
83
|
+
data: tableData || [],
|
|
84
|
+
manualPagination: true,
|
|
85
|
+
enableExpanding: true,
|
|
86
|
+
columns: tableColumns,
|
|
87
|
+
onColumnFiltersChange: setColumnFilters,
|
|
88
|
+
getCoreRowModel: getCoreRowModel(),
|
|
89
|
+
getPaginationRowModel: getPaginationRowModel(),
|
|
90
|
+
getSortedRowModel: getSortedRowModel(),
|
|
91
|
+
getFilteredRowModel: getFilteredRowModel(),
|
|
92
|
+
onColumnVisibilityChange: setColumnsVisibilityState,
|
|
93
|
+
state: {
|
|
94
|
+
columnFilters,
|
|
95
|
+
columnVisibility: columnsVisibilityState,
|
|
96
|
+
pagination,
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
return (_jsxs(_Fragment, { children: [Search, _jsxs(Table, { className: "w-full", ...(!table.getRowModel().rows?.length && { containerClassName: 'flex' }), children: [_jsx(TableHeader, { className: "bg-primary-foreground sticky top-0", children: table.getHeaderGroups().map((headerGroup) => (_jsx(TableRow, { children: headerGroup.headers.map((header) => {
|
|
100
|
+
return (_jsx(TableHead, { children: header.isPlaceholder ? null : flexRender(header.column.columnDef.header, header.getContext()) }, header.id));
|
|
101
|
+
}) }, headerGroup.id))) }), _jsx(TableBody, { children: table.getRowModel().rows?.length ? (table.getRowModel().rows.map((row) => (_jsx(_Fragment, { children: _jsx(TableRow, { "data-state": row.getIsSelected() && 'selected', children: row.getVisibleCells().map((cell) => (_jsx(TableCell, { children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id))) }, row.id) })))) : (_jsx(EmptyState, { columnsLength: columns.length, filtered: false, title: t(`common:emptyState.default.empty.title`), description: t(`common:emptyState.default.empty.text`) })) })] }), Paginate] }));
|
|
102
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Button, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, apiClient, useSettings, useTranslation, } from '@deenruv/react-ui-devkit';
|
|
3
|
+
import { toast } from 'sonner';
|
|
4
|
+
export const DeleteCollectionsFromChannel = ({ refetchCollections, collectionsToRemove, onClose, }) => {
|
|
5
|
+
const { t } = useTranslation('collections');
|
|
6
|
+
const { selectedChannel } = useSettings();
|
|
7
|
+
const removeCollectionsFromChannel = async () => {
|
|
8
|
+
try {
|
|
9
|
+
if (selectedChannel?.id) {
|
|
10
|
+
await apiClient('mutation')({
|
|
11
|
+
removeCollectionsFromChannel: [
|
|
12
|
+
{
|
|
13
|
+
input: {
|
|
14
|
+
collectionIds: collectionsToRemove.map((c) => c.id),
|
|
15
|
+
channelId: selectedChannel.id,
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
{ __typename: true },
|
|
19
|
+
],
|
|
20
|
+
});
|
|
21
|
+
toast.success(t('deleteCollectionsFromChannel.removeSuccess'));
|
|
22
|
+
refetchCollections();
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
toast.error(t('deleteCollectionsFromChannel.removeError'));
|
|
26
|
+
}
|
|
27
|
+
catch (e) {
|
|
28
|
+
console.log(e);
|
|
29
|
+
toast.error(t('deleteCollectionsFromChannel.removeError'));
|
|
30
|
+
}
|
|
31
|
+
finally {
|
|
32
|
+
onClose();
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
return (_jsxs(DialogContent, { className: "", children: [_jsxs(DialogHeader, { className: "pt-6", children: [_jsx(DialogTitle, { children: t('deleteCollectionsFromChannel.areYouSure', { channel: selectedChannel?.code }) }), _jsx(DialogDescription, { children: collectionsToRemove.map((i) => (_jsxs("div", { children: ["- ", i.name] }, i.id))) })] }), _jsxs(DialogFooter, { children: [_jsx(DialogClose, { asChild: true, children: _jsx(Button, { onClick: onClose, variant: "ghost", children: t('deleteCollectionsFromChannel.cancel') }) }), _jsx(Button, { onClick: removeCollectionsFromChannel, variant: "destructive", children: t('deleteCollectionsFromChannel.removeCollection') })] })] }));
|
|
36
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useTranslation, Label, MultipleSelector, apiClient } from '@deenruv/react-ui-devkit';
|
|
3
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
4
|
+
export const FacetsSelector = ({ value, onChange }) => {
|
|
5
|
+
const { t } = useTranslation('collections');
|
|
6
|
+
const [facetsOptions, setFacetsOptions] = useState();
|
|
7
|
+
const fetchFacets = useCallback(async () => {
|
|
8
|
+
const response = await apiClient('query')({
|
|
9
|
+
facetValues: [
|
|
10
|
+
{},
|
|
11
|
+
{
|
|
12
|
+
items: {
|
|
13
|
+
name: true,
|
|
14
|
+
id: true,
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
],
|
|
18
|
+
});
|
|
19
|
+
setFacetsOptions(response.facetValues.items.map((f) => ({ label: f.name, value: f.id })));
|
|
20
|
+
}, []);
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
fetchFacets();
|
|
23
|
+
}, [fetchFacets]);
|
|
24
|
+
return (_jsxs("div", { className: "flex basis-full flex-col gap-2", children: [_jsx(Label, { children: t('details.filters.addFacets') }), _jsx(MultipleSelector, { options: facetsOptions, value: !value
|
|
25
|
+
? []
|
|
26
|
+
: value.map((id) => ({
|
|
27
|
+
label: facetsOptions?.find((o) => o.value === id)?.label || id,
|
|
28
|
+
value: id,
|
|
29
|
+
})), placeholder: t('details.filters.addFacets'), onChange: (e) => onChange(e.map((e) => e.value)), hideClearAllButton: true })] }));
|
|
30
|
+
};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
3
|
+
import { Button, Checkbox, Input, Label, Switch, Separator, apiClient, ErrorMessage, CustomCard, CardIcons, SimpleSelect, useTranslation, PaymentMethodHandlerSelector, } from '@deenruv/react-ui-devkit';
|
|
4
|
+
import { X } from 'lucide-react';
|
|
5
|
+
import { FacetsSelector } from "./FacetsSelector";
|
|
6
|
+
import { CombinationMode } from "./CombinationMode";
|
|
7
|
+
import { VariantsSelector } from "./VariantsSelector";
|
|
8
|
+
export const FiltersCard = ({ currentFiltersValue, onFiltersValueChange, inheritValue, onInheritChange, errors, }) => {
|
|
9
|
+
const { t } = useTranslation('collections');
|
|
10
|
+
const codesTranslations = t('details.filters.labels.codes', { returnObjects: true });
|
|
11
|
+
const [filters, setFilters] = useState([]);
|
|
12
|
+
const [allFiltersOptions, setAllFiltersOptions] = useState([]);
|
|
13
|
+
const fetchOptions = useCallback(async () => {
|
|
14
|
+
const response = await apiClient('query')({
|
|
15
|
+
collectionFilters: PaymentMethodHandlerSelector,
|
|
16
|
+
});
|
|
17
|
+
setAllFiltersOptions(response.collectionFilters.map((c) => ({
|
|
18
|
+
value: c.code,
|
|
19
|
+
label: codesTranslations[c.code]
|
|
20
|
+
? t('details.filters.labels.codes.' + c.code)
|
|
21
|
+
: c.description,
|
|
22
|
+
})));
|
|
23
|
+
setFilters(response.collectionFilters);
|
|
24
|
+
}, [setAllFiltersOptions]);
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
fetchOptions();
|
|
27
|
+
}, [fetchOptions]);
|
|
28
|
+
const handleFiltersValueChange = useCallback((index, code, args) => {
|
|
29
|
+
const correspondingFilter = filters.find((h) => h?.code === code);
|
|
30
|
+
if (correspondingFilter && currentFiltersValue) {
|
|
31
|
+
const newFiltersValue = [...currentFiltersValue];
|
|
32
|
+
newFiltersValue[index] = {
|
|
33
|
+
code: correspondingFilter.code,
|
|
34
|
+
arguments: args ||
|
|
35
|
+
correspondingFilter.args.map((a) => ({
|
|
36
|
+
name: a.name,
|
|
37
|
+
value: 'false',
|
|
38
|
+
})),
|
|
39
|
+
};
|
|
40
|
+
onFiltersValueChange(newFiltersValue);
|
|
41
|
+
}
|
|
42
|
+
}, [filters, onFiltersValueChange, currentFiltersValue]);
|
|
43
|
+
const handleRemoveFilter = useCallback((code) => {
|
|
44
|
+
if (currentFiltersValue) {
|
|
45
|
+
let newValue = [...currentFiltersValue];
|
|
46
|
+
newValue = newValue.filter((v) => v.code !== code);
|
|
47
|
+
onFiltersValueChange(newValue);
|
|
48
|
+
}
|
|
49
|
+
}, [onFiltersValueChange, currentFiltersValue]);
|
|
50
|
+
const handleAddFilter = useCallback(() => {
|
|
51
|
+
const defaultFilter = filters[0];
|
|
52
|
+
const newFiltersValue = [
|
|
53
|
+
...(currentFiltersValue || []),
|
|
54
|
+
{
|
|
55
|
+
code: defaultFilter.code,
|
|
56
|
+
arguments: defaultFilter.args.map((a) => ({
|
|
57
|
+
name: a.name,
|
|
58
|
+
value: 'false',
|
|
59
|
+
})),
|
|
60
|
+
},
|
|
61
|
+
];
|
|
62
|
+
onFiltersValueChange(newFiltersValue);
|
|
63
|
+
}, [onFiltersValueChange, currentFiltersValue]);
|
|
64
|
+
return (_jsx(CustomCard, { title: t('details.filters.title'), upperRight: _jsx(ErrorMessage, { errors: errors }), color: "orange", icon: _jsx(CardIcons.filter, {}), children: _jsx("div", { className: "flex- flex flex-wrap gap-4 xl:flex-nowrap", children: _jsxs("div", { className: "flex basis-full flex-col gap-4", children: [_jsxs("div", { className: "mb-2 flex basis-full", children: [_jsxs("div", { className: "flex items-center gap-3", children: [_jsx(Switch, { checked: inheritValue, onCheckedChange: onInheritChange }), _jsx(Label, { children: t('details.filters.inherit') })] }), _jsx(Button, { className: "ml-auto", onClick: handleAddFilter, children: t('details.filters.addCondition') })] }), currentFiltersValue?.map((filter, index) => {
|
|
65
|
+
return (_jsxs("div", { className: "flex flex-col gap-4", children: [_jsx(Separator, {}), _jsxs("div", { className: "flex w-1/2 items-end gap-1", children: [_jsx(SimpleSelect, { label: t('details.filters.condition'), value: filter ? filter.code : '', onValueChange: (e) => handleFiltersValueChange(index, e), options: allFiltersOptions }), filter?.code && (_jsx(Button, { variant: 'secondary', className: "p-2", onClick: (e) => {
|
|
66
|
+
e.preventDefault();
|
|
67
|
+
handleRemoveFilter(filter.code);
|
|
68
|
+
}, children: _jsx(X, { size: 20 }) }))] }), _jsx("div", { className: "flex items-start justify-center gap-4", children: filter?.arguments.map((e, i) => {
|
|
69
|
+
const _filter = filters?.find((f) => f.code === filter.code);
|
|
70
|
+
const argument = _filter?.args.find((a) => a.name === e.name);
|
|
71
|
+
return argument?.ui?.component === 'facet-value-form-input' ? (_jsx(FacetsSelector, { value: JSON.parse(filter?.arguments[i].value), onChange: (e) => {
|
|
72
|
+
filter.arguments[i] = { name: argument?.name || '', value: JSON.stringify(e) };
|
|
73
|
+
handleFiltersValueChange(index, filter?.code, filter.arguments);
|
|
74
|
+
} })) : argument?.ui?.component === 'select-form-input' ? (_jsx(SimpleSelect, { label: argument?.label || argument.name, value: filter?.arguments[i].value, onValueChange: (e) => {
|
|
75
|
+
filter.arguments[i] = { name: argument?.name || '', value: e };
|
|
76
|
+
handleFiltersValueChange(index, filter?.code, filter.arguments);
|
|
77
|
+
}, options: (argument?.ui?.options).map((o) => ({
|
|
78
|
+
label: o.value,
|
|
79
|
+
value: o.value,
|
|
80
|
+
})) || [] }, i)) : argument?.ui?.component === 'combination-mode-form-input' ? (_jsx(CombinationMode, { label: t('details.filters.labels.arguments.combination-mode'), value: filter?.arguments[i].value, onChange: (e) => {
|
|
81
|
+
filter.arguments[i] = { name: argument?.name || '', value: e };
|
|
82
|
+
handleFiltersValueChange(index, filter?.code, filter.arguments);
|
|
83
|
+
} })) : argument?.ui?.component === 'product-multi-form-input' ? (_jsx(VariantsSelector, { type: argument?.ui?.selectionMode, label: argument?.label || argument.name, value: JSON.parse(filter?.arguments[i].value), onChange: (e) => {
|
|
84
|
+
filter.arguments[i] = { name: argument?.name || '', value: JSON.stringify(e) };
|
|
85
|
+
handleFiltersValueChange(index, filter?.code, filter.arguments);
|
|
86
|
+
} })) : argument?.type === 'int' ? (_jsx("div", { className: "flex basis-full", children: _jsx(Input, { type: "number", step: 0.01, label: argument?.label || argument.name, value: filter?.arguments[i].value, onChange: (e) => {
|
|
87
|
+
filter.arguments[i] = { name: argument?.name || '', value: e.target.value };
|
|
88
|
+
handleFiltersValueChange(index, filter?.code, filter.arguments);
|
|
89
|
+
}, required: true }) }, i)) : argument?.type === 'string' ? (_jsx("div", { className: "flex basis-full", children: _jsx(Input, { label: argument?.label || argument.name, value: filter?.arguments[i].value, onChange: (e) => {
|
|
90
|
+
filter.arguments[i] = { name: argument?.name || '', value: e.target.value };
|
|
91
|
+
handleFiltersValueChange(index, filter?.code, filter.arguments);
|
|
92
|
+
}, required: true }) }, i)) : argument?.type === 'boolean' ? (_jsxs("div", { className: "flex basis-full flex-col gap-3", children: [_jsx(Label, { children: argument?.label }), _jsx(Checkbox, { checked: filter?.arguments[i].value === 'true' ? true : false, onCheckedChange: (e) => {
|
|
93
|
+
filter.arguments[i] = { name: argument?.name || '', value: e ? 'true' : 'false' };
|
|
94
|
+
handleFiltersValueChange(index, filter?.code, filter.arguments);
|
|
95
|
+
} })] }, e.name)) : (_jsx("div", { className: "flex basis-full", children: _jsx(Input, { type: "number", step: 0.01, label: argument?.label ?? undefined, value: filter?.arguments[i].value, onChange: (e) => {
|
|
96
|
+
filter.arguments[i] = { name: argument?.name || '', value: e.target.value };
|
|
97
|
+
handleFiltersValueChange(index, filter?.code, filter.arguments);
|
|
98
|
+
}, required: true }) }, i));
|
|
99
|
+
}) })] }, index));
|
|
100
|
+
})] }) }) }));
|
|
101
|
+
};
|