@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.
Files changed (292) hide show
  1. package/LICENSE +23 -0
  2. package/README.md +30 -0
  3. package/dist/@types/resources.js +51 -0
  4. package/dist/DeenruvAdminPanel.js +118 -0
  5. package/dist/DeenruvDeveloperIndicator.js +57 -0
  6. package/dist/components/Aexol.js +4 -0
  7. package/dist/components/BrandLogo.js +22 -0
  8. package/dist/components/CanLeaveRouteDialog.js +8 -0
  9. package/dist/components/DataTable.js +13 -0
  10. package/dist/components/DeleteDialog.js +6 -0
  11. package/dist/components/DuplicateEntry.js +46 -0
  12. package/dist/components/GlobalSearch.js +134 -0
  13. package/dist/components/History/AddEntryForm.js +29 -0
  14. package/dist/components/History/DeleteEntryDialog.js +25 -0
  15. package/dist/components/History/EditEntryDialog.js +32 -0
  16. package/dist/components/History/History.js +13 -0
  17. package/dist/components/History/ModifyHistoryInfo.js +6 -0
  18. package/dist/components/History/Timeline.js +53 -0
  19. package/dist/components/History/index.js +5 -0
  20. package/dist/components/Menu/ActiveAdmins.js +24 -0
  21. package/dist/components/Menu/ChannelSwitcher.js +20 -0
  22. package/dist/components/Menu/LanguagesDropdown.js +26 -0
  23. package/dist/components/Menu/Navigation.js +270 -0
  24. package/dist/components/Menu/NavigationFooter.js +12 -0
  25. package/dist/components/Menu/Notifications.js +90 -0
  26. package/dist/components/Menu/index.js +67 -0
  27. package/dist/components/index.js +6 -0
  28. package/dist/graphql/base.js +95 -0
  29. package/dist/graphql/collections.js +94 -0
  30. package/dist/graphql/draft_order.js +307 -0
  31. package/dist/graphql/orders.js +157 -0
  32. package/dist/graphql/products.js +230 -0
  33. package/dist/graphql/scalars.js +22 -0
  34. package/dist/i18.js +13 -0
  35. package/dist/index.css +161 -0
  36. package/dist/index.d.ts +11 -0
  37. package/dist/index.js +1 -0
  38. package/dist/locales/en/admins.json +57 -0
  39. package/dist/locales/en/assets.json +69 -0
  40. package/dist/locales/en/channels.json +66 -0
  41. package/dist/locales/en/collections.json +145 -0
  42. package/dist/locales/en/common.json +1127 -0
  43. package/dist/locales/en/countries.json +50 -0
  44. package/dist/locales/en/customerGroups.json +6 -0
  45. package/dist/locales/en/customers.json +109 -0
  46. package/dist/locales/en/dashboard.json +34 -0
  47. package/dist/locales/en/facets.json +78 -0
  48. package/dist/locales/en/globalSettings.json +15 -0
  49. package/dist/locales/en/index.js +52 -0
  50. package/dist/locales/en/orders.json +932 -0
  51. package/dist/locales/en/paymentMethods.json +59 -0
  52. package/dist/locales/en/permissions.json +94 -0
  53. package/dist/locales/en/products.json +194 -0
  54. package/dist/locales/en/promotions.json +65 -0
  55. package/dist/locales/en/roles.json +59 -0
  56. package/dist/locales/en/sellers.json +41 -0
  57. package/dist/locales/en/shippingMethods.json +84 -0
  58. package/dist/locales/en/stockLocations.json +40 -0
  59. package/dist/locales/en/system.json +41 -0
  60. package/dist/locales/en/table.json +201 -0
  61. package/dist/locales/en/taxCategories.json +47 -0
  62. package/dist/locales/en/taxRates.json +56 -0
  63. package/dist/locales/en/zones.json +47 -0
  64. package/dist/locales/index.js +2 -0
  65. package/dist/locales/pl/admins.json +57 -0
  66. package/dist/locales/pl/assets.json +69 -0
  67. package/dist/locales/pl/channels.json +66 -0
  68. package/dist/locales/pl/collections.json +145 -0
  69. package/dist/locales/pl/common.json +1128 -0
  70. package/dist/locales/pl/countries.json +50 -0
  71. package/dist/locales/pl/customerGroups.json +6 -0
  72. package/dist/locales/pl/customers.json +109 -0
  73. package/dist/locales/pl/dashboard.json +34 -0
  74. package/dist/locales/pl/facets.json +78 -0
  75. package/dist/locales/pl/globalSettings.json +15 -0
  76. package/dist/locales/pl/index.js +52 -0
  77. package/dist/locales/pl/orders.json +932 -0
  78. package/dist/locales/pl/paymentMethods.json +59 -0
  79. package/dist/locales/pl/permissions.json +94 -0
  80. package/dist/locales/pl/products.json +194 -0
  81. package/dist/locales/pl/promotions.json +65 -0
  82. package/dist/locales/pl/roles.json +59 -0
  83. package/dist/locales/pl/sellers.json +41 -0
  84. package/dist/locales/pl/shippingMethods.json +84 -0
  85. package/dist/locales/pl/stockLocations.json +40 -0
  86. package/dist/locales/pl/system.json +41 -0
  87. package/dist/locales/pl/table.json +201 -0
  88. package/dist/locales/pl/taxCategories.json +47 -0
  89. package/dist/locales/pl/taxRates.json +56 -0
  90. package/dist/locales/pl/zones.json +47 -0
  91. package/dist/notifications/OrderStatusNotification.js +47 -0
  92. package/dist/notifications/SystemStatusNotification.js +19 -0
  93. package/dist/pages/Custom404.js +5 -0
  94. package/dist/pages/LoginScreen.js +37 -0
  95. package/dist/pages/Root.js +252 -0
  96. package/dist/pages/admins/Detail.js +72 -0
  97. package/dist/pages/admins/List.js +56 -0
  98. package/dist/pages/admins/_components/AdminDetailView.js +34 -0
  99. package/dist/pages/admins/_components/RolesCard.js +31 -0
  100. package/dist/pages/admins/index.js +2 -0
  101. package/dist/pages/assets/List.js +82 -0
  102. package/dist/pages/assets/_components/Asset.js +114 -0
  103. package/dist/pages/assets/_components/AssetListView.js +29 -0
  104. package/dist/pages/assets/_components/EditAssetDialog.js +85 -0
  105. package/dist/pages/assets/_components/UploadAssetDialog.js +133 -0
  106. package/dist/pages/assets/_components/UploadProgress.js +20 -0
  107. package/dist/pages/assets/index.js +1 -0
  108. package/dist/pages/channels/Detail.js +149 -0
  109. package/dist/pages/channels/List.js +46 -0
  110. package/dist/pages/channels/_components/ChannelDetailView.js +51 -0
  111. package/dist/pages/channels/_components/DefaultsCard.js +25 -0
  112. package/dist/pages/channels/index.js +2 -0
  113. package/dist/pages/collections/Detail.js +61 -0
  114. package/dist/pages/collections/List.js +135 -0
  115. package/dist/pages/collections/_components/CollectionDetailView.js +52 -0
  116. package/dist/pages/collections/_components/CollectionProductVariantsDrawer.js +28 -0
  117. package/dist/pages/collections/_components/CombinationMode.js +6 -0
  118. package/dist/pages/collections/_components/ContentsCard.js +43 -0
  119. package/dist/pages/collections/_components/ContentsTable.js +102 -0
  120. package/dist/pages/collections/_components/DeleteCollectionsFromChannel.js +36 -0
  121. package/dist/pages/collections/_components/FacetsSelector.js +30 -0
  122. package/dist/pages/collections/_components/FiltersCard.js +101 -0
  123. package/dist/pages/collections/_components/MoveCollectionsToCollections.js +107 -0
  124. package/dist/pages/collections/_components/MoveEntityToChannels.js +115 -0
  125. package/dist/pages/collections/_components/PageHeader.js +11 -0
  126. package/dist/pages/collections/_components/SelectedCollectionsModal.js +22 -0
  127. package/dist/pages/collections/_components/VariantsSelector.js +43 -0
  128. package/dist/pages/collections/consts.js +7 -0
  129. package/dist/pages/collections/index.js +2 -0
  130. package/dist/pages/countries/Detail.js +57 -0
  131. package/dist/pages/countries/List.js +47 -0
  132. package/dist/pages/countries/_components/CountryDetailView.js +28 -0
  133. package/dist/pages/countries/index.js +2 -0
  134. package/dist/pages/customer-groups/Detail.js +76 -0
  135. package/dist/pages/customer-groups/List.js +41 -0
  136. package/dist/pages/customer-groups/_components/CustomerGroupsDetailView.js +21 -0
  137. package/dist/pages/customer-groups/index.js +2 -0
  138. package/dist/pages/customers/Detail.js +75 -0
  139. package/dist/pages/customers/List.js +60 -0
  140. package/dist/pages/customers/_components/Address.js +59 -0
  141. package/dist/pages/customers/_components/AddressDialog.js +56 -0
  142. package/dist/pages/customers/_components/AddressForm.js +77 -0
  143. package/dist/pages/customers/_components/AddressesCard.js +9 -0
  144. package/dist/pages/customers/_components/CustomerDetailSidebar.js +9 -0
  145. package/dist/pages/customers/_components/CustomerDetailView.js +41 -0
  146. package/dist/pages/customers/_components/CustomerGroupsCard.js +46 -0
  147. package/dist/pages/customers/_components/HistoryTab.js +65 -0
  148. package/dist/pages/customers/_components/OrdersTab.js +46 -0
  149. package/dist/pages/customers/_components/PersonalDataCard.js +6 -0
  150. package/dist/pages/customers/_components/VerifiedCard.js +6 -0
  151. package/dist/pages/customers/index.js +2 -0
  152. package/dist/pages/dashboard/Dashboard.js +10 -0
  153. package/dist/pages/dashboard/index.js +1 -0
  154. package/dist/pages/extensions/Extensions.js +74 -0
  155. package/dist/pages/extensions/index.js +1 -0
  156. package/dist/pages/facets/Detail.js +56 -0
  157. package/dist/pages/facets/List.js +48 -0
  158. package/dist/pages/facets/_components/AddFacetValueDialog.js +105 -0
  159. package/dist/pages/facets/_components/ColorSample.js +18 -0
  160. package/dist/pages/facets/_components/FacetDetailView.js +98 -0
  161. package/dist/pages/facets/index.js +2 -0
  162. package/dist/pages/global-settings/GlobalSettingsComponent.js +30 -0
  163. package/dist/pages/global-settings/index.js +71 -0
  164. package/dist/pages/index.js +25 -0
  165. package/dist/pages/orders/Detail.js +21 -0
  166. package/dist/pages/orders/List.js +132 -0
  167. package/dist/pages/orders/_components/AddPaymentDialog.js +50 -0
  168. package/dist/pages/orders/_components/AddressCard.js +260 -0
  169. package/dist/pages/orders/_components/CancelAndRefundDialog.js +29 -0
  170. package/dist/pages/orders/_components/ChangesRegister.js +68 -0
  171. package/dist/pages/orders/_components/ChangesRegisterTable.js +18 -0
  172. package/dist/pages/orders/_components/CouponCodesCard.js +85 -0
  173. package/dist/pages/orders/_components/CustomComponent.js +21 -0
  174. package/dist/pages/orders/_components/CustomerSelectCard.js +117 -0
  175. package/dist/pages/orders/_components/EditNoteButton.js +10 -0
  176. package/dist/pages/orders/_components/FulfillmentModal.js +85 -0
  177. package/dist/pages/orders/_components/LineItem.js +7 -0
  178. package/dist/pages/orders/_components/ManualOrderChangeModal.js +47 -0
  179. package/dist/pages/orders/_components/ModifyAcceptModal.js +22 -0
  180. package/dist/pages/orders/_components/ModifyingCard.js +77 -0
  181. package/dist/pages/orders/_components/OrderHistory.js +59 -0
  182. package/dist/pages/orders/_components/OrderLineActionModal/ActionQuantityPrice.js +58 -0
  183. package/dist/pages/orders/_components/OrderLineActionModal/index.js +7 -0
  184. package/dist/pages/orders/_components/OrderLineActionModal/types.js +1 -0
  185. package/dist/pages/orders/_components/OrderLineCustomFields.js +26 -0
  186. package/dist/pages/orders/_components/OrderSummary.js +10 -0
  187. package/dist/pages/orders/_components/PaymentMetadata.js +6 -0
  188. package/dist/pages/orders/_components/Payments.js +113 -0
  189. package/dist/pages/orders/_components/PossibleOrderStates.js +54 -0
  190. package/dist/pages/orders/_components/PriceChangedInfo.js +16 -0
  191. package/dist/pages/orders/_components/ProductsCard.js +308 -0
  192. package/dist/pages/orders/_components/ProductsTable.js +29 -0
  193. package/dist/pages/orders/_components/PromotionsList.js +73 -0
  194. package/dist/pages/orders/_components/RealizationCard.js +98 -0
  195. package/dist/pages/orders/_components/RefundCard.js +11 -0
  196. package/dist/pages/orders/_components/RefundPaymentCard.js +13 -0
  197. package/dist/pages/orders/_components/ShippingMethod.js +112 -0
  198. package/dist/pages/orders/_components/SpecialLineItem.js +7 -0
  199. package/dist/pages/orders/_components/SurchargeCard.js +99 -0
  200. package/dist/pages/orders/_components/SurchargeTable.js +8 -0
  201. package/dist/pages/orders/_components/TaxSummary.js +11 -0
  202. package/dist/pages/orders/_components/ToRealizationForm.js +64 -0
  203. package/dist/pages/orders/_components/TopActions.js +219 -0
  204. package/dist/pages/orders/_components/index.js +25 -0
  205. package/dist/pages/orders/index.js +2 -0
  206. package/dist/pages/payment-methods/Detail.js +67 -0
  207. package/dist/pages/payment-methods/List.js +41 -0
  208. package/dist/pages/payment-methods/_components/OptionsCard.js +60 -0
  209. package/dist/pages/payment-methods/_components/PaymentMethodDetailView.js +53 -0
  210. package/dist/pages/payment-methods/index.js +2 -0
  211. package/dist/pages/product-variants/Detail.js +4 -0
  212. package/dist/pages/product-variants/List.js +76 -0
  213. package/dist/pages/product-variants/index.js +2 -0
  214. package/dist/pages/products/Detail.js +75 -0
  215. package/dist/pages/products/List.js +79 -0
  216. package/dist/pages/products/_components/AddOptionGroupDialog.js +65 -0
  217. package/dist/pages/products/_components/AssetsCard.js +35 -0
  218. package/dist/pages/products/_components/BasicFieldsCard.js +6 -0
  219. package/dist/pages/products/_components/ChannelsCard.js +6 -0
  220. package/dist/pages/products/_components/CollectionsCard.js +6 -0
  221. package/dist/pages/products/_components/Container.js +4 -0
  222. package/dist/pages/products/_components/DiscountRatingCard.js +6 -0
  223. package/dist/pages/products/_components/FacetValuesCard.js +6 -0
  224. package/dist/pages/products/_components/ImagesCard.js +6 -0
  225. package/dist/pages/products/_components/OptionGroup.js +93 -0
  226. package/dist/pages/products/_components/OptionValueCard.js +59 -0
  227. package/dist/pages/products/_components/OptionsCard.js +38 -0
  228. package/dist/pages/products/_components/OptionsTab.js +40 -0
  229. package/dist/pages/products/_components/PriceCard.js +27 -0
  230. package/dist/pages/products/_components/ProductDetailSidebar.js +30 -0
  231. package/dist/pages/products/_components/ProductDetailView.js +54 -0
  232. package/dist/pages/products/_components/SettingsCard.js +6 -0
  233. package/dist/pages/products/_components/StockCard.js +40 -0
  234. package/dist/pages/products/_components/Variant.js +149 -0
  235. package/dist/pages/products/_components/VariantsTab.js +46 -0
  236. package/dist/pages/products/index.js +2 -0
  237. package/dist/pages/promotions/Detail.js +80 -0
  238. package/dist/pages/promotions/List.js +38 -0
  239. package/dist/pages/promotions/_components/ActionsCard.js +67 -0
  240. package/dist/pages/promotions/_components/BasicFieldsCard.js +6 -0
  241. package/dist/pages/promotions/_components/ConditionsCard.js +70 -0
  242. package/dist/pages/promotions/_components/CustomerGroupsSelector.js +25 -0
  243. package/dist/pages/promotions/_components/EnabledCard.js +6 -0
  244. package/dist/pages/promotions/_components/OptionsCard.js +6 -0
  245. package/dist/pages/promotions/_components/PromotionDetailSidebar.js +15 -0
  246. package/dist/pages/promotions/_components/PromotionDetailView.js +66 -0
  247. package/dist/pages/promotions/_components/PromotionFieldRender.js +4 -0
  248. package/dist/pages/promotions/index.js +2 -0
  249. package/dist/pages/roles/Detail.js +72 -0
  250. package/dist/pages/roles/List.js +70 -0
  251. package/dist/pages/roles/_components/PermissionsCard.js +7 -0
  252. package/dist/pages/roles/_components/PermissionsTable.js +42 -0
  253. package/dist/pages/roles/_components/RoleDetailView.js +49 -0
  254. package/dist/pages/roles/index.js +2 -0
  255. package/dist/pages/sellers/Detail.js +48 -0
  256. package/dist/pages/sellers/List.js +37 -0
  257. package/dist/pages/sellers/_components/SellerDetailView.js +20 -0
  258. package/dist/pages/sellers/index.js +2 -0
  259. package/dist/pages/shipping-methods/Detail.js +105 -0
  260. package/dist/pages/shipping-methods/List.js +40 -0
  261. package/dist/pages/shipping-methods/_components/CalculatorCard.js +79 -0
  262. package/dist/pages/shipping-methods/_components/CheckerCard.js +76 -0
  263. package/dist/pages/shipping-methods/_components/Lines.js +20 -0
  264. package/dist/pages/shipping-methods/_components/ShippingMethodDetailView.js +67 -0
  265. package/dist/pages/shipping-methods/_components/TestCard.js +62 -0
  266. package/dist/pages/shipping-methods/index.js +2 -0
  267. package/dist/pages/status/Status.js +6 -0
  268. package/dist/pages/status/_components/FilterToolbar.js +29 -0
  269. package/dist/pages/status/_components/Health.js +21 -0
  270. package/dist/pages/status/_components/JobResultPopover.js +8 -0
  271. package/dist/pages/status/_components/Jobs.js +199 -0
  272. package/dist/pages/status/_components/JsonExplorer.js +44 -0
  273. package/dist/pages/status/_components/JsonPopup.js +8 -0
  274. package/dist/pages/status/index.js +1 -0
  275. package/dist/pages/stock-locations/Detail.js +77 -0
  276. package/dist/pages/stock-locations/List.js +38 -0
  277. package/dist/pages/stock-locations/_components/StockLocationDetailView.js +22 -0
  278. package/dist/pages/stock-locations/index.js +2 -0
  279. package/dist/pages/tax-categories/Detail.js +85 -0
  280. package/dist/pages/tax-categories/List.js +46 -0
  281. package/dist/pages/tax-categories/_components/TaxCategoryDetailView.js +24 -0
  282. package/dist/pages/tax-categories/index.js +2 -0
  283. package/dist/pages/tax-rates/Detail.js +62 -0
  284. package/dist/pages/tax-rates/List.js +64 -0
  285. package/dist/pages/tax-rates/_components/TaxRateDetailView.js +64 -0
  286. package/dist/pages/tax-rates/index.js +2 -0
  287. package/dist/pages/zones/Detail.js +86 -0
  288. package/dist/pages/zones/List.js +52 -0
  289. package/dist/pages/zones/_components/ZoneDetailView.js +49 -0
  290. package/dist/pages/zones/index.js +2 -0
  291. package/dist/version.js +1 -0
  292. package/package.json +122 -0
@@ -0,0 +1,49 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useCallback, useEffect, useMemo, useState } from 'react';
3
+ import { Input, Label, MultipleSelector, DEFAULT_CHANNEL_CODE, apiClient, useDetailView, DetailViewMarker, CustomCard, CardIcons, useTranslation, } from '@deenruv/react-ui-devkit';
4
+ import { PermissionsCard } from "./PermissionsCard";
5
+ const ROLE_FORM_KEYS = ['CreateRoleInput', 'code', 'description', 'channelIds', 'permissions'];
6
+ export const RoleDetailView = () => {
7
+ const { form, fetchEntity, id } = useDetailView('roles-detail-view', ...ROLE_FORM_KEYS);
8
+ const { base: { setField, state }, } = form;
9
+ const { t } = useTranslation('roles');
10
+ const [allChannelOptions, setAllChannelOptions] = useState([]);
11
+ const currentChannelOptions = useMemo(() => {
12
+ if (!allChannelOptions)
13
+ return undefined;
14
+ else
15
+ return state.channelIds?.value?.map((id) => allChannelOptions.find((o) => o.value === id) || { value: id, label: id });
16
+ }, [allChannelOptions, state.channelIds?.value]);
17
+ const fetchChannels = useCallback(async () => {
18
+ const response = await apiClient('query')({
19
+ channels: [
20
+ {},
21
+ {
22
+ items: {
23
+ code: true,
24
+ id: true,
25
+ },
26
+ },
27
+ ],
28
+ });
29
+ setAllChannelOptions(response.channels.items.map((ch) => ({
30
+ value: ch.id,
31
+ label: ch.code === DEFAULT_CHANNEL_CODE ? t('defaultChannel') : ch.code,
32
+ })));
33
+ }, [setAllChannelOptions, t]);
34
+ useEffect(() => {
35
+ fetchChannels();
36
+ }, [id, fetchChannels]);
37
+ useEffect(() => {
38
+ (async () => {
39
+ const res = await fetchEntity();
40
+ if (!res)
41
+ return;
42
+ setField('code', res.code);
43
+ setField('description', res.description);
44
+ setField('channelIds', res.channels.map((ch) => ch.id));
45
+ setField('permissions', res.permissions);
46
+ })();
47
+ }, []);
48
+ 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 xl:flex-nowrap", children: [_jsx("div", { className: "flex basis-full md:basis-1/2 xl:basis-1/4", children: _jsx(Input, { label: t('details.basic.description'), value: state.description?.value ?? undefined, onChange: (e) => setField('description', e.target.value), errors: state.description?.errors, required: true }) }), _jsx("div", { className: "flex basis-full md:basis-1/2 xl:basis-1/4", 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: "flex basis-full flex-col gap-[6px] xl:basis-1/2", children: [_jsx(Label, { children: t('details.basic.channels') }), _jsx(MultipleSelector, { options: allChannelOptions, value: currentChannelOptions, placeholder: t('details.basic.channelsPlaceholder'), onChange: (channelsOptions) => setField('channelIds', channelsOptions.map((o) => o.value)), hideClearAllButton: true })] })] }) }), _jsx(DetailViewMarker, { position: 'roles-detail-view' }), _jsx(PermissionsCard, { currentPermissions: state.permissions?.value ?? undefined, onPermissionsChange: (e) => setField('permissions', e), errors: state.permissions?.errors })] }) }));
49
+ };
@@ -0,0 +1,2 @@
1
+ export * from './Detail.js';
2
+ export * from './List.js';
@@ -0,0 +1,48 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useCallback } from 'react';
3
+ import { useParams } from 'react-router-dom';
4
+ import { useValidators, getMutation, useMutation, DetailView, createDeenruvForm, } from '@deenruv/react-ui-devkit';
5
+ import { SellerDetailView } from "./_components/SellerDetailView.js";
6
+ const CreateSellerMutation = getMutation('createSeller');
7
+ const EditSellerMutation = getMutation('updateSeller');
8
+ const DeleteSellerMutation = getMutation('deleteSeller');
9
+ export const SellersDetailPage = () => {
10
+ const { id } = useParams();
11
+ const [update] = useMutation(EditSellerMutation);
12
+ const [create] = useMutation(CreateSellerMutation);
13
+ const [remove] = useMutation(DeleteSellerMutation);
14
+ const { nameValidator } = useValidators();
15
+ const onSubmitHandler = useCallback((data) => {
16
+ if (!data.name?.validatedValue) {
17
+ throw new Error('Name is required.');
18
+ }
19
+ const inputData = {
20
+ name: data.name.validatedValue,
21
+ ...(data.customFields?.validatedValue ? { customFields: data.customFields?.validatedValue } : {}),
22
+ };
23
+ if (id) {
24
+ return update({ input: { id, ...inputData } });
25
+ }
26
+ else {
27
+ return create({ input: inputData });
28
+ }
29
+ }, [id, update, create]);
30
+ const onDeleteHandler = useCallback(() => {
31
+ if (!id) {
32
+ throw new Error('Could not find the id.');
33
+ }
34
+ return remove({ input: { id } });
35
+ }, [remove, id]);
36
+ return (_jsx("div", { className: "relative flex flex-col gap-y-4", children: _jsx(DetailView, { id: id, locationId: "sellers-detail-view", main: {
37
+ name: 'seller',
38
+ label: 'Seller',
39
+ component: _jsx(SellerDetailView, {}),
40
+ form: createDeenruvForm({
41
+ key: 'CreateSellerInput',
42
+ keys: ['name', 'customFields'],
43
+ config: { name: nameValidator },
44
+ onSubmitted: onSubmitHandler,
45
+ onDeleted: onDeleteHandler,
46
+ }),
47
+ } }) }));
48
+ };
@@ -0,0 +1,37 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Routes, apiClient, DetailList, deepMerge, ListLocations } from '@deenruv/react-ui-devkit';
3
+ import { Permission, SortOrder } from '@deenruv/admin-types';
4
+ const tableId = 'sellers-list-view';
5
+ const { selector } = ListLocations[tableId];
6
+ const fetch = async ({ page, perPage, filter, filterOperator, sort }, additionalSelector) => {
7
+ const response = await apiClient('query')({
8
+ sellers: [
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['sellers'];
22
+ };
23
+ const onRemove = async (items) => {
24
+ try {
25
+ const ids = items.map((item) => item.id);
26
+ const { deleteSellers } = await apiClient('mutation')({
27
+ deleteSellers: [{ ids }, { message: true, result: true }],
28
+ });
29
+ return !!deleteSellers.length;
30
+ }
31
+ catch (error) {
32
+ return error;
33
+ }
34
+ };
35
+ export const SellersListPage = () => {
36
+ return (_jsx(DetailList, { filterFields: [{ key: 'name', operator: 'StringOperators' }], detailLinkColumn: "id", searchFields: ['name'], hideColumns: ['customFields', 'translations', 'collections', 'variantList'], entityName: 'Seller', route: Routes['sellers'], tableId: tableId, fetch: fetch, onRemove: onRemove, createPermissions: [Permission.CreateSeller], deletePermissions: [Permission.DeleteSeller] }));
37
+ };
@@ -0,0 +1,20 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect } from 'react';
3
+ import { Card, CardContent, CardHeader, CardTitle, DetailViewMarker, Input, useDetailView, EntityCustomFields, useTranslation, } from '@deenruv/react-ui-devkit';
4
+ export const SELLER_FORM_KEYS = ['CreateSellerInput', 'name', 'customFields'];
5
+ export const SellerDetailView = () => {
6
+ const { form, fetchEntity, entity, id } = useDetailView('sellers-detail-view', ...SELLER_FORM_KEYS);
7
+ const { base: { setField, state }, } = form;
8
+ const { t } = useTranslation('sellers');
9
+ useEffect(() => {
10
+ (async () => {
11
+ const res = await fetchEntity();
12
+ if (!res)
13
+ return;
14
+ setField('name', res.name);
15
+ })();
16
+ }, []);
17
+ return (_jsx("main", { className: "my-4 min-h-96", children: _jsxs("div", { className: "flex flex-col gap-3", children: [_jsx(Card, { children: _jsxs(CardHeader, { children: [_jsx(CardTitle, { className: "flex flex-row justify-between text-base", children: t('details.basic.title') }), _jsx(CardContent, { className: "flex flex-col gap-4 p-0 pt-4", children: _jsx("div", { className: "flex flex-col gap-3", children: _jsx(Input, { className: "w-1/2", label: t('details.basic.name'), value: state.name?.value, onChange: (e) => setField('name', e.target.value), errors: state.name?.errors, required: true }) }) })] }) }), _jsx(DetailViewMarker, { position: 'sellers-detail-view' }), _jsx(EntityCustomFields, { entityName: "seller", id: id, hideButton: true, onChange: (customFields) => {
18
+ setField('customFields', customFields);
19
+ }, initialValues: entity && 'customFields' in entity ? { customFields: entity.customFields } : { customFields: {} } })] }) }));
20
+ };
@@ -0,0 +1,2 @@
1
+ export * from './Detail.js';
2
+ export * from './List.js';
@@ -0,0 +1,105 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useCallback } from 'react';
3
+ import { useParams } from 'react-router-dom';
4
+ import { useTranslation, DetailView, createDeenruvForm, getMutation, useMutation, } from '@deenruv/react-ui-devkit';
5
+ import { ShippingMethodDetailView } from "./_components/ShippingMethodDetailView.js";
6
+ const CreateShippingMethodMutation = getMutation('createShippingMethod');
7
+ const EditShippingMethodMutation = getMutation('updateShippingMethod');
8
+ const DeleteShippingMethodMutation = getMutation('deleteShippingMethod');
9
+ export const ShippingMethodsDetailPage = () => {
10
+ const { id } = useParams();
11
+ const [update] = useMutation(EditShippingMethodMutation);
12
+ const [create] = useMutation(CreateShippingMethodMutation);
13
+ const [remove] = useMutation(DeleteShippingMethodMutation);
14
+ const { t } = useTranslation('shippingMethods');
15
+ const onSubmitHandler = useCallback((data) => {
16
+ if (!data.code?.validatedValue) {
17
+ throw new Error('Name is required.');
18
+ }
19
+ const inputData = {
20
+ code: data.code?.validatedValue,
21
+ calculator: data.calculator?.validatedValue,
22
+ fulfillmentHandler: data.fulfillmentHandler?.validatedValue,
23
+ translations: data.translations.validatedValue,
24
+ checker: data.checker?.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: "shippingMethods-detail-view", main: {
49
+ name: 'shippingMethod',
50
+ label: 'Shipping method',
51
+ component: _jsx(ShippingMethodDetailView, {}),
52
+ form: createDeenruvForm({
53
+ key: 'CreateShippingMethodInput',
54
+ keys: ['code', 'translations', 'checker', 'calculator', 'fulfillmentHandler', 'customFields'],
55
+ config: {
56
+ fulfillmentHandler: {
57
+ validate: (v) => {
58
+ if (!v)
59
+ return [t('validation.fulfillmentHandlerRequired')];
60
+ },
61
+ },
62
+ checker: {
63
+ validate: (v) => {
64
+ const hasCode = !!v?.code;
65
+ const hasArguments = v?.arguments.filter((a) => a.value).length;
66
+ const errors = [];
67
+ if (!hasCode)
68
+ errors.push(t('validation.checkerCodeRequired'));
69
+ if (!hasArguments)
70
+ errors.push(t('validation.checkerArgsRequired'));
71
+ return errors;
72
+ },
73
+ },
74
+ calculator: {
75
+ validate: (v) => {
76
+ const hasCode = !!v?.code;
77
+ const hasInvalidArguments = v?.arguments.filter((a) => !a.value || a.value === 'false').length; // args have 'false' value by default
78
+ const errors = [];
79
+ console.log(v?.arguments);
80
+ if (!hasCode)
81
+ errors.push(t('validation.checkerCodeRequired'));
82
+ if (hasInvalidArguments)
83
+ errors.push(t('validation.checkerArgsRequired'));
84
+ return errors;
85
+ },
86
+ },
87
+ code: {
88
+ validate: (v) => {
89
+ if (!v || v === '')
90
+ return [t('validation.required')];
91
+ },
92
+ },
93
+ translations: {
94
+ validate: (v) => {
95
+ const { name } = v[0];
96
+ if (!name)
97
+ return [t('validation.nameRequired')];
98
+ },
99
+ },
100
+ },
101
+ onSubmitted: onSubmitHandler,
102
+ onDeleted: onDeleteHandler,
103
+ }),
104
+ } }) }));
105
+ };
@@ -0,0 +1,40 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Routes, apiClient, DetailList, deepMerge, ListLocations, EntityChannelManagementBulkAction, } from '@deenruv/react-ui-devkit';
3
+ import { Permission, SortOrder } from '@deenruv/admin-types';
4
+ const tableId = 'shippingMethods-list-view';
5
+ const { selector } = ListLocations[tableId];
6
+ const fetch = async ({ page, perPage, filter, filterOperator, sort }, additionalSelector) => {
7
+ const response = await apiClient('query')({
8
+ shippingMethods: [
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['shippingMethods'];
22
+ };
23
+ const onRemove = async (items) => {
24
+ try {
25
+ const ids = items.map((item) => item.id);
26
+ const { deleteShippingMethods } = await apiClient('mutation')({
27
+ deleteShippingMethods: [{ ids }, { message: true, result: true }],
28
+ });
29
+ return !!deleteShippingMethods.length;
30
+ }
31
+ catch (error) {
32
+ return error;
33
+ }
34
+ };
35
+ export const ShippingMethodsListPage = () => {
36
+ return (_jsx(DetailList, { filterFields: [
37
+ { key: 'name', operator: 'StringOperators' },
38
+ { key: 'code', operator: 'StringOperators' },
39
+ ], additionalBulkActions: [...EntityChannelManagementBulkAction(tableId)], detailLinkColumn: "id", searchFields: ['name', 'code'], hideColumns: ['customFields', 'translations', 'collections', 'variantList'], entityName: 'ShippingMethod', route: Routes['shippingMethods'], tableId: tableId, fetch: fetch, onRemove: onRemove, createPermissions: [Permission.CreateShippingMethod], deletePermissions: [Permission.DeleteShippingMethod] }));
40
+ };
@@ -0,0 +1,79 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useCallback, useEffect, useState } from 'react';
3
+ import { Button, Label, apiClient, ErrorMessage, generateInputComponents, usePluginStore, CustomFieldsProvider, CardIcons, CustomCard, SimpleSelect, useTranslation, PaymentMethodHandlerSelector, } from '@deenruv/react-ui-devkit';
4
+ import { X } from 'lucide-react';
5
+ export const CalculatorCard = ({ currentCalculatorValue, onCalculatorValueChange, errors, }) => {
6
+ const { t } = useTranslation('shippingMethods');
7
+ const [calculators, setCalculators] = useState([]);
8
+ const [allCalculatorsOptions, setAllCalculatorsOptions] = useState([]);
9
+ const { getInputComponent } = usePluginStore();
10
+ const fetchOptions = useCallback(async () => {
11
+ const response = await apiClient('query')({
12
+ shippingCalculators: PaymentMethodHandlerSelector,
13
+ });
14
+ setAllCalculatorsOptions(response.shippingCalculators.map((c) => ({
15
+ value: c.code,
16
+ label: c.code,
17
+ })));
18
+ setCalculators(response.shippingCalculators);
19
+ }, [setAllCalculatorsOptions]);
20
+ useEffect(() => {
21
+ fetchOptions();
22
+ }, [fetchOptions]);
23
+ const handleCalculatorValueChange = useCallback((code, args) => {
24
+ const correspondingCalculator = calculators.find((h) => h.code === code);
25
+ console.log('args', args);
26
+ if (correspondingCalculator)
27
+ onCalculatorValueChange({
28
+ code: correspondingCalculator.code,
29
+ arguments: args ||
30
+ correspondingCalculator.args.map((a) => ({
31
+ name: a.name,
32
+ value: 'false',
33
+ })),
34
+ });
35
+ }, [calculators, onCalculatorValueChange]);
36
+ const clearInput = useCallback(() => {
37
+ onCalculatorValueChange(undefined);
38
+ }, [onCalculatorValueChange]);
39
+ return (_jsx(CustomCard, { title: t('details.calculator.title'), icon: _jsx(CardIcons.calc, {}), color: "indigo", children: _jsxs("div", { className: "flex basis-full flex-col gap-3 md:basis-1/2", children: [_jsxs("div", { className: "flex items-end gap-1", children: [_jsx(SimpleSelect, { label: t('details.calculator.type'), value: currentCalculatorValue ? currentCalculatorValue.code : '', onValueChange: handleCalculatorValueChange, options: allCalculatorsOptions }), currentCalculatorValue?.code && (_jsx(Button, { variant: 'secondary', className: "p-2", onClick: clearInput, children: _jsx(X, { size: 20 }) }))] }), _jsx("div", { className: "flex gap-3", children: currentCalculatorValue?.arguments.map((e, i) => {
40
+ const calculator = calculators?.find((ch) => ch.code === currentCalculatorValue.code);
41
+ const argument = calculator?.args.find((a) => a.name === e.name);
42
+ if (!argument)
43
+ return null;
44
+ return generateInputComponents([
45
+ {
46
+ ...argument,
47
+ label: [{ languageCode: 'en', value: argument.label || argument.name }],
48
+ description: [{ languageCode: 'en', value: argument.description || '' }],
49
+ },
50
+ ], getInputComponent).map((field) => {
51
+ const value = e.value;
52
+ const setValue = (data) => {
53
+ try {
54
+ onCalculatorValueChange({
55
+ code: currentCalculatorValue.code,
56
+ arguments: currentCalculatorValue.arguments.map((a) => {
57
+ try {
58
+ if (a.name === field.name) {
59
+ return {
60
+ name: a.name,
61
+ value: JSON.stringify(data),
62
+ };
63
+ }
64
+ }
65
+ catch {
66
+ return a;
67
+ }
68
+ return a;
69
+ }),
70
+ });
71
+ }
72
+ catch {
73
+ console.error('Error setting value');
74
+ }
75
+ };
76
+ return (_jsx(CustomFieldsProvider, { field: field, value: value, setValue: setValue, additionalData: {}, children: _jsxs("div", { children: [_jsx("div", { children: _jsx(Label, { children: field.name }) }), field.component] }, field.name) }, field.name));
77
+ });
78
+ }) }), _jsx(ErrorMessage, { errors: errors })] }) }));
79
+ };
@@ -0,0 +1,76 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useCallback, useEffect, useState } from 'react';
3
+ import { Button, Label, apiClient, ErrorMessage, generateInputComponents, usePluginStore, CustomFieldsProvider, CustomCard, CardIcons, SimpleSelect, useTranslation, PaymentMethodHandlerSelector, } from '@deenruv/react-ui-devkit';
4
+ import { X } from 'lucide-react';
5
+ export const CheckerCard = ({ currentCheckerValue, onCheckerValueChange, errors }) => {
6
+ const { t } = useTranslation('shippingMethods');
7
+ const [checkers, setCheckers] = useState([]);
8
+ const [allCheckersOptions, setAllCheckersOptions] = useState([]);
9
+ const { getInputComponent } = usePluginStore();
10
+ const fetchOptions = useCallback(async () => {
11
+ const response = await apiClient('query')({
12
+ shippingEligibilityCheckers: PaymentMethodHandlerSelector,
13
+ });
14
+ setAllCheckersOptions(response.shippingEligibilityCheckers.map((h) => ({
15
+ value: h.code,
16
+ label: h.code,
17
+ })));
18
+ setCheckers(response.shippingEligibilityCheckers);
19
+ }, [setAllCheckersOptions]);
20
+ useEffect(() => {
21
+ fetchOptions();
22
+ }, [fetchOptions]);
23
+ const handleCheckerValueChange = useCallback((code, args) => {
24
+ const correspondingChecker = checkers.find((h) => h.code === code);
25
+ if (correspondingChecker)
26
+ onCheckerValueChange({
27
+ code: correspondingChecker.code,
28
+ arguments: args ||
29
+ correspondingChecker.args.map((a) => ({
30
+ name: a.name,
31
+ value: 'false',
32
+ })),
33
+ });
34
+ }, [checkers, onCheckerValueChange]);
35
+ const clearInput = useCallback(() => {
36
+ console.log('CLICK');
37
+ onCheckerValueChange(undefined);
38
+ }, [onCheckerValueChange]);
39
+ return (_jsx(CustomCard, { title: t('details.options.title'), icon: _jsx(CardIcons.check, {}), color: "teal", upperRight: _jsx(ErrorMessage, { errors: errors }), children: _jsxs("div", { className: "flex basis-full flex-col gap-3 md:basis-1/2", children: [_jsxs("div", { className: "flex items-end gap-1", children: [_jsx(SimpleSelect, { label: t('details.options.checker'), value: currentCheckerValue ? currentCheckerValue.code : '', onValueChange: handleCheckerValueChange, options: allCheckersOptions }), currentCheckerValue?.code && (_jsx(Button, { variant: 'secondary', className: "p-2", onClick: clearInput, children: _jsx(X, { size: 20 }) }))] }), _jsx("div", { className: "flex", children: currentCheckerValue?.arguments.map((e, i) => {
40
+ const checker = checkers?.find((ch) => ch.code === currentCheckerValue.code);
41
+ const argument = checker?.args.find((a) => a.name === a.name);
42
+ if (!argument)
43
+ return null;
44
+ return generateInputComponents([
45
+ {
46
+ ...argument,
47
+ label: [{ languageCode: 'en', value: argument.label || argument.name }],
48
+ description: [{ languageCode: 'en', value: argument.description || '' }],
49
+ },
50
+ ], getInputComponent).map((field) => {
51
+ const value = e.value;
52
+ const setValue = (data) => {
53
+ try {
54
+ onCheckerValueChange({
55
+ code: currentCheckerValue.code,
56
+ arguments: currentCheckerValue.arguments.map((a) => {
57
+ try {
58
+ if (a.name === field.name) {
59
+ return { name: field.name, value: JSON.stringify(data) };
60
+ }
61
+ }
62
+ catch {
63
+ return a;
64
+ }
65
+ return a;
66
+ }),
67
+ });
68
+ }
69
+ catch {
70
+ console.error('Error setting value');
71
+ }
72
+ };
73
+ return (_jsx(CustomFieldsProvider, { field: field, value: value, setValue: setValue, additionalData: {}, children: _jsxs("div", { children: [_jsx("div", { children: _jsx(Label, { children: field.name }) }), field.component] }, field.name) }, field.name));
74
+ });
75
+ }) })] }) }));
76
+ };
@@ -0,0 +1,20 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { ImageWithPreview, TableHeader, TableRow, TableHead, TableBody, TableCell, Table, Label, useTranslation, DialogProductPicker, } from '@deenruv/react-ui-devkit';
3
+ import { useEffect, useState } from 'react';
4
+ export const Lines = ({ onLinesChange }) => {
5
+ const { t } = useTranslation('shippingMethods');
6
+ const [currentProducts, setCurrentProducts] = useState([]);
7
+ useEffect(() => {
8
+ onLinesChange(currentProducts.map((p) => ({ productVariantId: p.id, quantity: 1 })));
9
+ }, [currentProducts, onLinesChange]);
10
+ return (_jsxs("div", { className: "grid gap-6", children: [_jsx(Label, { htmlFor: "product", children: t('details.lines.placeholder') }), _jsx(DialogProductPicker, { initialValue: currentProducts.map((p) => p.id), multiple: true, mode: "variant", onSubmit: (selectedProducts) => {
11
+ const products = selectedProducts.map((product) => ({
12
+ id: product.productVariantId,
13
+ featuredAsset: product.productVariantAsset,
14
+ product: { name: product.productName, featuredAsset: product.productAsset },
15
+ price: product.price.__typename === 'SinglePrice' ? product.price.value : product.price.min,
16
+ priceWithTax: product.priceWithTax.__typename === 'SinglePrice' ? product.priceWithTax.value : product.priceWithTax.min,
17
+ }));
18
+ setCurrentProducts(products);
19
+ } }), _jsxs(Table, { children: [_jsx(TableHeader, { className: "text-nowrap", children: _jsxs(TableRow, { noHover: true, children: [_jsx(TableHead, { children: t('details.lines.product') }), _jsx(TableHead, { children: t('details.lines.price') }), _jsx(TableHead, { children: t('details.lines.total') })] }) }), _jsx(TableBody, { children: currentProducts.length ? (currentProducts.map((line) => (_jsxs(TableRow, { children: [_jsx(TableCell, { children: _jsxs("div", { className: "flex w-max items-center gap-2", children: [_jsx(ImageWithPreview, { imageClassName: "aspect-square w-10 rounded-md object-cover w-[40px] h-[40px]", src: line.featuredAsset?.preview || line.product?.featuredAsset?.preview }), _jsx("div", { className: "font-semibold", children: line.product.name })] }) }), _jsx(TableCell, { children: line.price }), _jsx(TableCell, { children: line.priceWithTax })] }, line.id)))) : (_jsx(TableCell, { colSpan: 8, children: _jsx("div", { className: "mt-4 flex items-center justify-center", children: _jsx("span", { children: t('details.lines.noItems') }) }) })) })] })] }));
20
+ };
@@ -0,0 +1,67 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useCallback, useEffect, useState } from 'react';
3
+ import { Input, Label, apiClient, SimpleSelect, RichTextEditor, useSettings, useDetailView, DetailViewMarker, CustomCard, CardIcons, setInArrayBy, EntityCustomFields, useTranslation, } from '@deenruv/react-ui-devkit';
4
+ import { CheckerCard } from "./CheckerCard";
5
+ import { CalculatorCard } from "./CalculatorCard";
6
+ import { TestCard } from "./TestCard";
7
+ const SHIPPING_METHOD_FORM_KEYS = [
8
+ 'CreateShippingMethodInput',
9
+ 'code',
10
+ 'translations',
11
+ 'checker',
12
+ 'calculator',
13
+ 'fulfillmentHandler',
14
+ 'customFields',
15
+ ];
16
+ export const ShippingMethodDetailView = () => {
17
+ const { form, entity, fetchEntity, id } = useDetailView('shippingMethods-detail-view', ...SHIPPING_METHOD_FORM_KEYS);
18
+ const { base: { setField, state }, } = form;
19
+ const { t } = useTranslation('shippingMethods');
20
+ const [fulfillmentHandlersOptions, setFulfillmentHandlersOptions] = useState();
21
+ const { translationsLanguage: currentTranslationLng } = useSettings();
22
+ useEffect(() => {
23
+ (async () => {
24
+ const res = await fetchEntity();
25
+ if (!res)
26
+ return;
27
+ setField('code', res.code);
28
+ setField('translations', res.translations);
29
+ setField('checker', {
30
+ arguments: res.checker?.args || [],
31
+ code: res.checker?.code || '',
32
+ });
33
+ setField('calculator', {
34
+ arguments: res.calculator?.args || [],
35
+ code: res.calculator?.code || '',
36
+ });
37
+ setField('fulfillmentHandler', res.fulfillmentHandlerCode);
38
+ })();
39
+ }, []);
40
+ const fetchFulfillmentHandlers = useCallback(async () => {
41
+ const response = await apiClient('query')({
42
+ fulfillmentHandlers: { code: true, description: true },
43
+ });
44
+ setFulfillmentHandlersOptions(response.fulfillmentHandlers.map((h) => ({
45
+ label: h.description,
46
+ value: h.code,
47
+ })));
48
+ }, []);
49
+ useEffect(() => {
50
+ fetchFulfillmentHandlers();
51
+ }, [id, fetchFulfillmentHandlers]);
52
+ const translations = state?.translations?.value || [];
53
+ const currentTranslationValue = translations.find((v) => v.languageCode === currentTranslationLng);
54
+ const setTranslationField = useCallback((field, e) => {
55
+ setField('translations', setInArrayBy(translations, (t) => t.languageCode !== currentTranslationLng, {
56
+ [field]: e,
57
+ languageCode: currentTranslationLng,
58
+ }));
59
+ }, [currentTranslationLng, translations]);
60
+ 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: "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("div", { className: "flex basis-full", children: _jsx(SimpleSelect, { label: t('details.basic.fulfillmentHandler'), value: state.fulfillmentHandler?.value ?? undefined, onValueChange: (e) => setField('fulfillmentHandler', e), options: fulfillmentHandlersOptions, errors: state.fulfillmentHandler?.errors }) })] }) }), _jsx(DetailViewMarker, { position: 'shippingMethods-detail-view' }), _jsx(EntityCustomFields, { entityName: "shippingMethod", id: id, hideButton: true, onChange: (customFields, translations) => {
61
+ setField('customFields', customFields);
62
+ if (translations)
63
+ setField('translations', translations);
64
+ }, initialValues: entity && 'customFields' in entity
65
+ ? { customFields: entity.customFields, translations: entity.translations }
66
+ : { customFields: {} } }), _jsx(CheckerCard, { currentCheckerValue: state.checker?.value ?? undefined, onCheckerValueChange: (checker) => checker && setField('checker', checker), errors: state.checker?.errors }), _jsx(CalculatorCard, { currentCalculatorValue: state.calculator?.value ?? undefined, onCalculatorValueChange: (calculator) => calculator && setField('calculator', calculator), errors: state.calculator?.errors }), _jsx(TestCard, { calculator: state.calculator?.value ?? undefined, checker: state.checker?.value ?? undefined })] }) }));
67
+ };
@@ -0,0 +1,62 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { Button, Input, Separator, useServer, apiClient, CustomCard, CardIcons, useGFFLP, SimpleSelect, priceFormatter, useTranslation, } from '@deenruv/react-ui-devkit';
3
+ import { useCallback, useEffect, useState } from 'react';
4
+ import { CircleCheck, CircleX } from 'lucide-react';
5
+ import { Lines } from "./Lines";
6
+ export const TestCard = ({ calculator, checker }) => {
7
+ const { t } = useTranslation('shippingMethods');
8
+ const [testResult, setTestResult] = useState();
9
+ const { countries } = useServer();
10
+ const { state, setField } = useGFFLP('TestShippingMethodInput', 'shippingAddress', 'calculator', 'checker', 'lines')({
11
+ shippingAddress: {
12
+ initialValue: {
13
+ countryCode: '',
14
+ city: '',
15
+ streetLine1: 'test',
16
+ postalCode: '',
17
+ province: '',
18
+ },
19
+ },
20
+ });
21
+ useEffect(() => {
22
+ if (calculator)
23
+ setField('calculator', calculator);
24
+ if (checker)
25
+ setField('checker', checker);
26
+ }, [calculator, checker, setField]);
27
+ const setAddressField = useCallback((addressField, e) => {
28
+ setField('shippingAddress', {
29
+ ...state.shippingAddress.value,
30
+ [addressField]: e,
31
+ });
32
+ }, [state.shippingAddress]);
33
+ const testShippingMethod = useCallback(async () => {
34
+ if (state.calculator && state.checker && state.shippingAddress && state.lines?.validatedValue) {
35
+ const resp = await apiClient('query')({
36
+ testShippingMethod: [
37
+ {
38
+ input: {
39
+ calculator: state.calculator.validatedValue,
40
+ checker: state.checker.validatedValue,
41
+ lines: state.lines.validatedValue,
42
+ shippingAddress: state.shippingAddress.validatedValue,
43
+ },
44
+ },
45
+ {
46
+ eligible: true,
47
+ quote: {
48
+ metadata: true,
49
+ price: true,
50
+ priceWithTax: true,
51
+ },
52
+ },
53
+ ],
54
+ });
55
+ setTestResult(resp.testShippingMethod);
56
+ }
57
+ }, [state]);
58
+ return (_jsx(CustomCard, { title: t('details.test.title'), icon: _jsx(CardIcons.shipping, {}), color: "cyan", bottomRight: _jsx(Button, { className: "w-48", onClick: testShippingMethod, children: t('details.test.button') }), children: _jsxs("div", { className: "flex flex-col gap-4", children: [_jsxs("div", { className: "flex flex-wrap gap-3", children: [_jsx("div", { className: "flex flex-1 basis-full md:basis-1/3", children: _jsx(Input, { label: t('details.test.city'), value: state.shippingAddress?.value.city ?? undefined, onChange: (e) => setAddressField('city', e.target.value), required: true }) }), _jsx("div", { className: "flex flex-1 basis-full md:basis-1/3", children: _jsx(Input, { label: t('details.test.province'), value: state.shippingAddress?.value.province ?? undefined, onChange: (e) => setAddressField('province', e.target.value), required: true }) }), _jsx("div", { className: "flex flex-1 basis-full md:basis-1/3", children: _jsx(Input, { label: t('details.test.postalCode'), value: state.shippingAddress?.value.postalCode ?? undefined, onChange: (e) => setAddressField('postalCode', e.target.value), required: true }) }), _jsx("div", { className: "flex flex-1 basis-full md:basis-1/3", children: _jsx(SimpleSelect, { label: t('details.test.country'), value: state.shippingAddress?.value.countryCode, onValueChange: (e) => setAddressField('countryCode', e), options: countries.map((c) => ({
59
+ label: c.name,
60
+ value: c.code,
61
+ })) }) })] }), _jsx(Separator, {}), _jsx(Lines, { onLinesChange: (e) => setField('lines', e) }), testResult && (_jsxs("div", { className: "flex flex-col gap-3", children: [_jsx("div", { className: "flex gap-3", children: testResult.eligible ? (_jsxs(_Fragment, { children: [_jsx(CircleCheck, { color: "green" }), t('details.test.eligible')] })) : (_jsxs(_Fragment, { children: [_jsx(CircleX, { color: "red" }), t('details.test.notEligible')] })) }), _jsxs("div", { children: [_jsxs("span", { className: "font-semibold", children: [t('details.lines.price'), ":"] }), ' ', priceFormatter(testResult.quote?.price)] }), _jsxs("div", { children: [_jsxs("span", { className: "font-semibold", children: [t('details.lines.total'), ":"] }), ' ', priceFormatter(testResult.quote?.priceWithTax)] })] }))] }) }));
62
+ };
@@ -0,0 +1,2 @@
1
+ export * from './Detail.js';
2
+ export * from './List.js';
@@ -0,0 +1,6 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Health } from './_components/Health.js';
3
+ import { Jobs } from './_components/Jobs.js';
4
+ export const Status = () => {
5
+ return (_jsx("div", { className: "w-full p-4 md:p-6", children: _jsxs("div", { className: "flex flex-col gap-4", children: [_jsx(Health, {}), _jsx(Jobs, {})] }) }));
6
+ };