@lmnto/h-mall-shared 1.0.1

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 (262) hide show
  1. package/app.css +457 -0
  2. package/bitbucket-pipelines.yml +223 -0
  3. package/package.json +43 -0
  4. package/public/gif/balloon.gif +0 -0
  5. package/public/gif/gift.gif +0 -0
  6. package/public/img/ai-dialog.png +0 -0
  7. package/public/img/ai-x1-banner.png +0 -0
  8. package/public/img/ai-x1.png +0 -0
  9. package/public/img/alert-Icon.png +0 -0
  10. package/public/img/aleta-payment-kyc-require.png +0 -0
  11. package/public/img/aleta-payment-pending.png +0 -0
  12. package/public/img/aleta-payment-rejected.png +0 -0
  13. package/public/img/aleta-payment-subscription-required.png +0 -0
  14. package/public/img/boost-banner-bg.png +0 -0
  15. package/public/img/boost-banner-right.png +0 -0
  16. package/public/img/boost-banner.png +0 -0
  17. package/public/img/boost-dialog-bg.png +0 -0
  18. package/public/img/boostPower.png +0 -0
  19. package/public/img/boostTooltip.png +0 -0
  20. package/public/img/brand-icon.svg +23 -0
  21. package/public/img/brand-text.svg +11 -0
  22. package/public/img/card-icon.png +0 -0
  23. package/public/img/cashback-Icon.png +0 -0
  24. package/public/img/crown.svg +9 -0
  25. package/public/img/empty-box.png +0 -0
  26. package/public/img/gen3-dialog.png +0 -0
  27. package/public/img/gen3-home-banner-bg.png +0 -0
  28. package/public/img/gen3-image.png +0 -0
  29. package/public/img/gift.png +0 -0
  30. package/public/img/img-placeholder-illustration.svg +6 -0
  31. package/public/img/logo.svg +31 -0
  32. package/public/img/offerBanner.png +0 -0
  33. package/public/img/pagenotfound.png +0 -0
  34. package/public/img/partial-pay-payment-successful.png +0 -0
  35. package/public/img/phoneShippingBG.png +0 -0
  36. package/public/img/placeholder-image.jpg +0 -0
  37. package/public/img/powerIcon.png +0 -0
  38. package/public/img/product-01.png +0 -0
  39. package/public/img/product-02.jpg +0 -0
  40. package/public/img/product-03.jpg +0 -0
  41. package/public/img/product-04.jpg +0 -0
  42. package/public/img/product-05.png +0 -0
  43. package/public/img/product-06.png +0 -0
  44. package/public/img/profile-avatar.svg +12 -0
  45. package/public/img/promotion-icon.png +0 -0
  46. package/public/img/session-expired.png +0 -0
  47. package/public/img/shipping-alert-icon.png +0 -0
  48. package/public/img/shippingIcon.png +0 -0
  49. package/public/img/smart-pay-banner-how.png +0 -0
  50. package/public/img/smart-pay-banner-own.png +0 -0
  51. package/public/img/smart-pay-chose.png +0 -0
  52. package/public/img/smart-pay-easy.png +0 -0
  53. package/public/img/smart-pay-payment.png +0 -0
  54. package/public/img/smart-plan-fire.gif +0 -0
  55. package/public/img/smart-plan-sparkle.gif +0 -0
  56. package/public/img/special.png +0 -0
  57. package/public/img/specialOfferBg.png +0 -0
  58. package/public/img/stop-shipping-banner.png +0 -0
  59. package/public/img/subscriptionBanner.png +0 -0
  60. package/public/img/subscriptionIcon.png +0 -0
  61. package/public/img/successIcon.png +0 -0
  62. package/public/img/wallet-icon.png +0 -0
  63. package/public/img/world-wide-shipping.png +0 -0
  64. package/public/next.svg +1 -0
  65. package/public/vercel.svg +1 -0
  66. package/shared/components/AddressFormComponent.tsx +215 -0
  67. package/shared/components/AddressShippingFormComponent.tsx +223 -0
  68. package/shared/components/AiPaymentDialog.tsx +95 -0
  69. package/shared/components/AppLoadingComponent.tsx +15 -0
  70. package/shared/components/AppLoadingComponentV2.tsx +18 -0
  71. package/shared/components/Button.tsx +48 -0
  72. package/shared/components/BuySubscriptionDialog.tsx +75 -0
  73. package/shared/components/CartDrawerComponent.tsx +324 -0
  74. package/shared/components/CashbackComponent.tsx +48 -0
  75. package/shared/components/CashbackMigrationComponent.tsx +41 -0
  76. package/shared/components/CommissionNonEligibleComponent.tsx +27 -0
  77. package/shared/components/CustomNextImage.tsx +50 -0
  78. package/shared/components/CustomNextLink.tsx +46 -0
  79. package/shared/components/EditAddressFormComponent.tsx +254 -0
  80. package/shared/components/EmptyCartMessageComponent.tsx +25 -0
  81. package/shared/components/EmptyCartMessageForCartPage.tsx +61 -0
  82. package/shared/components/EmptyLegacyOrderMessageForOrdersPage.tsx +52 -0
  83. package/shared/components/EmptyOrderMessageForOrdersPage.tsx +62 -0
  84. package/shared/components/EmptyOrderMessageForShippingOrdersPage.tsx +62 -0
  85. package/shared/components/Footer.tsx +71 -0
  86. package/shared/components/GreetingDialog.tsx +96 -0
  87. package/shared/components/Header.tsx +106 -0
  88. package/shared/components/HoldShippingDialog.tsx +165 -0
  89. package/shared/components/HomeBanners.tsx +298 -0
  90. package/shared/components/InactiveCartDialog.tsx +69 -0
  91. package/shared/components/InputCartQuantity.tsx +342 -0
  92. package/shared/components/Inputfield.tsx +110 -0
  93. package/shared/components/ListItemComponent.tsx +82 -0
  94. package/shared/components/LoadingIconComponent.tsx +284 -0
  95. package/shared/components/OrderNotFoundComponent.tsx +56 -0
  96. package/shared/components/PageHeader.tsx +42 -0
  97. package/shared/components/PhoneNumberCountries.tsx +133 -0
  98. package/shared/components/PhoneShippingDialog.tsx +77 -0
  99. package/shared/components/PickupDialog.tsx +92 -0
  100. package/shared/components/ProductNotFoundComponent.tsx +56 -0
  101. package/shared/components/ProductPriceComponent.tsx +32 -0
  102. package/shared/components/ProfileMenu.tsx +120 -0
  103. package/shared/components/RequestCreditNoteInvoiceDialog.tsx +214 -0
  104. package/shared/components/RequestInvoiceDialog.tsx +194 -0
  105. package/shared/components/SelectCities.tsx +133 -0
  106. package/shared/components/SelectComponent.tsx +334 -0
  107. package/shared/components/SelectCountries.tsx +179 -0
  108. package/shared/components/SelectPickUpStore.tsx +131 -0
  109. package/shared/components/SelectStates.tsx +144 -0
  110. package/shared/components/ServerTime.tsx +68 -0
  111. package/shared/components/SessionDialogComponent.tsx +60 -0
  112. package/shared/components/ShippingAddressFormDialogComponent.tsx +51 -0
  113. package/shared/components/Sidebar.tsx +281 -0
  114. package/shared/components/SpecialOfferDialog.tsx +193 -0
  115. package/shared/components/StatusComponents.tsx +25 -0
  116. package/shared/components/StepperComponent.tsx +79 -0
  117. package/shared/components/StepperSmartPayComponent.tsx +97 -0
  118. package/shared/components/SubscriptionPurchaseDialogComponent.tsx +81 -0
  119. package/shared/components/TableComponent.tsx +144 -0
  120. package/shared/components/TablePaginationComponent.tsx +151 -0
  121. package/shared/components/aleta/AletaManagerComponent.tsx +52 -0
  122. package/shared/components/aleta/KycPendingStatus.tsx +33 -0
  123. package/shared/components/aleta/KycRejectedStatus.tsx +53 -0
  124. package/shared/components/aleta/KycRequiredStatus.tsx +53 -0
  125. package/shared/components/aleta/SubscriptionRequiredStatus.tsx +45 -0
  126. package/shared/components/icons/AletaWalletIcon.tsx +21 -0
  127. package/shared/components/icons/BrandIcon.tsx +97 -0
  128. package/shared/components/icons/BrandText.tsx +47 -0
  129. package/shared/components/icons/CartIcon.tsx +21 -0
  130. package/shared/components/icons/DoneIcon.tsx +27 -0
  131. package/shared/components/icons/HomnifiIcon.tsx +23 -0
  132. package/shared/components/icons/InfoIcon.tsx +16 -0
  133. package/shared/components/icons/SmartPayProductIcon.tsx +31 -0
  134. package/shared/components/payments/DisclaimerAlertDialog.tsx +205 -0
  135. package/shared/components/payments/EmptyAssets.tsx +23 -0
  136. package/shared/components/payments/PaybyWalletItemComponent.tsx +116 -0
  137. package/shared/components/payments/PaymentAssetItemComponent.tsx +101 -0
  138. package/shared/components/payments/RequestProcessingDialog.tsx +123 -0
  139. package/shared/components/payments/WalletSectionManager.tsx +82 -0
  140. package/shared/components/payments/WalletSliderComponent.tsx +326 -0
  141. package/shared/components/payments/WalletTermsAndConditionComponent.tsx +88 -0
  142. package/shared/constants/address-shipping.schema.ts +56 -0
  143. package/shared/constants/address.schema.ts +56 -0
  144. package/shared/constants/app.ts +323 -0
  145. package/shared/constants/environment.ts +23 -0
  146. package/shared/constants/feature-flags.ts +15 -0
  147. package/shared/constants/query-keys.ts +106 -0
  148. package/shared/constants/routes.ts +41 -0
  149. package/shared/constants/socket.ts +15 -0
  150. package/shared/contexts/HomeProductsContext.tsx +51 -0
  151. package/shared/contexts/MainWrapperContext.tsx +289 -0
  152. package/shared/contexts/WebSocketContext.tsx +155 -0
  153. package/shared/hooks/useAddressForm.ts +169 -0
  154. package/shared/hooks/useAddresses.ts +28 -0
  155. package/shared/hooks/useAppForm.ts +39 -0
  156. package/shared/hooks/useCart.ts +207 -0
  157. package/shared/hooks/useCopy.ts +45 -0
  158. package/shared/hooks/useCountries.ts +27 -0
  159. package/shared/hooks/useCustomRouter.ts +51 -0
  160. package/shared/hooks/useDebounce.ts +21 -0
  161. package/shared/hooks/useInvoice.ts +41 -0
  162. package/shared/hooks/useOnlineUser.ts +38 -0
  163. package/shared/hooks/usePayments.ts +101 -0
  164. package/shared/hooks/useShippingAddressForm.ts +70 -0
  165. package/shared/hooks/useShippingAddresses.ts +33 -0
  166. package/shared/hooks/useStores.ts +29 -0
  167. package/shared/hooks/useUserActivity.ts +43 -0
  168. package/shared/i18n/client.ts +27 -0
  169. package/shared/i18n/locales/en.ts +383 -0
  170. package/shared/i18n/locales/it.ts +373 -0
  171. package/shared/i18n/server.ts +7 -0
  172. package/shared/services/addresses.service.ts +27 -0
  173. package/shared/services/api/core/ApiError.ts +29 -0
  174. package/shared/services/api/core/ApiRequestOptions.ts +25 -0
  175. package/shared/services/api/core/ApiResult.ts +11 -0
  176. package/shared/services/api/core/CancelablePromise.ts +130 -0
  177. package/shared/services/api/core/OpenAPI.ts +37 -0
  178. package/shared/services/api/core/request.ts +376 -0
  179. package/shared/services/api/index.ts +64 -0
  180. package/shared/services/api/models/AddAllProductToShippingCartDto.ts +7 -0
  181. package/shared/services/api/models/AddProductToCartDto.ts +8 -0
  182. package/shared/services/api/models/AddProductToShippingCartDto.ts +8 -0
  183. package/shared/services/api/models/AdminPlaceOrderDto.ts +16 -0
  184. package/shared/services/api/models/AssignPickupSerialNumberDto.ts +10 -0
  185. package/shared/services/api/models/CreateUserAddressDto.ts +19 -0
  186. package/shared/services/api/models/DeletCartProductsArrayDto.ts +7 -0
  187. package/shared/services/api/models/GenerateInvoiceDto.ts +7 -0
  188. package/shared/services/api/models/OrderConfirmationEmailDto.ts +8 -0
  189. package/shared/services/api/models/PlaceOrderDto.ts +9 -0
  190. package/shared/services/api/models/PlaceShipmentOrderDto.ts +8 -0
  191. package/shared/services/api/models/ProductBoostDto.ts +18 -0
  192. package/shared/services/api/models/RemoveAssignedSerialNumberDto.ts +9 -0
  193. package/shared/services/api/models/RemoveProductToCartDto.ts +8 -0
  194. package/shared/services/api/models/ShipmentItem.ts +8 -0
  195. package/shared/services/api/models/ShippingCartUpdateBillingAddressesDto.ts +7 -0
  196. package/shared/services/api/models/ShippingCartUpdateShippingMethodDto.ts +7 -0
  197. package/shared/services/api/models/UnfreezeWalletDto.ts +8 -0
  198. package/shared/services/api/models/UpdateCartBillingAddressesDto.ts +7 -0
  199. package/shared/services/api/models/UpdateCartPaymentMethodDto.ts +9 -0
  200. package/shared/services/api/models/UpdateCartShippingMethodDto.ts +7 -0
  201. package/shared/services/api/models/UpdateCartStoreDto.ts +7 -0
  202. package/shared/services/api/models/UpdateProductDto.ts +11 -0
  203. package/shared/services/api/models/UpdateShipmentItemStatusDto.ts +24 -0
  204. package/shared/services/api/models/UpdateShippingCartPaymentMethodDto.ts +9 -0
  205. package/shared/services/api/models/UpdateUserAddressDto.ts +19 -0
  206. package/shared/services/api/models/ValidateAuthCodeDto.ts +8 -0
  207. package/shared/services/api/models/WithdrawOrderWalletDto.ts +8 -0
  208. package/shared/services/api/services/AddressesService.ts +160 -0
  209. package/shared/services/api/services/AdminsDevicesService.ts +28 -0
  210. package/shared/services/api/services/AdminsOrdersService.ts +117 -0
  211. package/shared/services/api/services/AdminsPickupsService.ts +57 -0
  212. package/shared/services/api/services/AdminsProductsService.ts +86 -0
  213. package/shared/services/api/services/CartsService.ts +190 -0
  214. package/shared/services/api/services/CashBackQueueService.ts +39 -0
  215. package/shared/services/api/services/CategoriesService.ts +65 -0
  216. package/shared/services/api/services/DefaultService.ts +19 -0
  217. package/shared/services/api/services/FeaturesFlagsService.ts +20 -0
  218. package/shared/services/api/services/IossQueueService.ts +39 -0
  219. package/shared/services/api/services/OrderCallbackService.ts +67 -0
  220. package/shared/services/api/services/OrderEmailsService.ts +40 -0
  221. package/shared/services/api/services/OrderImportService.ts +228 -0
  222. package/shared/services/api/services/OrdersService.ts +183 -0
  223. package/shared/services/api/services/PaymentGatewayService.ts +19 -0
  224. package/shared/services/api/services/PaymentsService.ts +88 -0
  225. package/shared/services/api/services/ProductsService.ts +67 -0
  226. package/shared/services/api/services/ShipmentOrderCallbackService.ts +67 -0
  227. package/shared/services/api/services/ShipmentOrdersService.ts +88 -0
  228. package/shared/services/api/services/ShipmentsService.ts +30 -0
  229. package/shared/services/api/services/ShippingCartService.ts +247 -0
  230. package/shared/services/api/services/ShippingMethodsService.ts +20 -0
  231. package/shared/services/api/services/StoresService.ts +25 -0
  232. package/shared/services/api/services/SyncServiceQueueService.ts +39 -0
  233. package/shared/services/api/services/UpgradeOrdersService.ts +26 -0
  234. package/shared/services/api/services/UsersAuthService.ts +45 -0
  235. package/shared/services/api/services/UsersService.ts +53 -0
  236. package/shared/services/api/services/XeraQueueService.ts +39 -0
  237. package/shared/services/index.ts +0 -0
  238. package/shared/services/payment-method.service.ts +29 -0
  239. package/shared/stores/cartStore.ts +108 -0
  240. package/shared/stores/countriesStore.ts +62 -0
  241. package/shared/stores/formStore.ts +19 -0
  242. package/shared/stores/loadingStore.ts +12 -0
  243. package/shared/stores/userStore.ts +32 -0
  244. package/shared/types/SelectComponent.types.ts +31 -0
  245. package/shared/types/addressForm.ts +27 -0
  246. package/shared/types/cart.ts +208 -0
  247. package/shared/types/category.ts +6 -0
  248. package/shared/types/creditNote.ts +0 -0
  249. package/shared/types/feature-flags.ts +5 -0
  250. package/shared/types/icon.ts +5 -0
  251. package/shared/types/index.d.ts +84 -0
  252. package/shared/types/order.ts +332 -0
  253. package/shared/types/pagination.ts +5 -0
  254. package/shared/types/payments.ts +68 -0
  255. package/shared/types/product.ts +54 -0
  256. package/shared/types/shoppingCart.ts +219 -0
  257. package/shared/types/upgradeCart.ts +226 -0
  258. package/shared/types/user.ts +36 -0
  259. package/shared/utils/app.util.ts +261 -0
  260. package/shared/utils/notifications.util.ts +39 -0
  261. package/shared/utils/user-session.util.ts +171 -0
  262. package/tailwind.config.ts +234 -0
@@ -0,0 +1,56 @@
1
+ "use client";
2
+
3
+ import { Typography } from "@material-tailwind/react";
4
+ import Image from "next/image";
5
+
6
+ import emptyBox from "../../public/img/empty-box.png";
7
+ import { ROUTES } from "../constants/routes";
8
+ import useCustomRouter from "../hooks/useCustomRouter";
9
+ import { _useScopedI18n } from "../i18n/client";
10
+ import ButtonCustom from "./Button";
11
+
12
+ export default function ProductNotFoundComponent() {
13
+ //
14
+ const scopeT = _useScopedI18n("sharedComponents.productNotFoundComponent");
15
+
16
+ const { push } = useCustomRouter();
17
+
18
+ return (
19
+ <>
20
+ <div className="px-3 md:px-5 mr-1 flex cartAutoHeight">
21
+ <div className="">
22
+ <ul className="flex flex-col gap-y-6">{}</ul>
23
+ </div>
24
+ <div className="flex items-center justify-center flex-col w-full">
25
+ <Image
26
+ src={emptyBox.src}
27
+ alt="emptyBox"
28
+ width={100}
29
+ height={100}
30
+ className="mb-5"
31
+ />
32
+ <Typography
33
+ variant="h6"
34
+ className="text-center md:text-lg font-semibold text-black-500 mb-5"
35
+ >
36
+ {scopeT("title")}
37
+ </Typography>
38
+ <Typography
39
+ variant="h6"
40
+ className="text-center font-medium text-slate-400"
41
+ >
42
+ {scopeT("message")}
43
+ </Typography>
44
+
45
+ <ButtonCustom
46
+ onClick={() => push(ROUTES.dashboard.products)}
47
+ className="font-normal mt-7"
48
+ icon={undefined}
49
+ >
50
+ {scopeT("redirectBtn")}
51
+ </ButtonCustom>
52
+ </div>
53
+ </div>
54
+ </>
55
+ );
56
+ }
@@ -0,0 +1,32 @@
1
+ import { DEFAULT_CURRENCY, EURO_CURRENCY } from "../constants/app";
2
+
3
+ export type ProductPriceComponentProps = {
4
+ amount: string | number;
5
+ useEuroCurrency?: boolean;
6
+ };
7
+
8
+ export default function ProductPriceComponent({
9
+ amount,
10
+ useEuroCurrency,
11
+ }: ProductPriceComponentProps) {
12
+ if (amount == null || amount === undefined) {
13
+ return <></>;
14
+ }
15
+
16
+ const numAmount = Number(amount);
17
+
18
+ // Check if the number has decimals
19
+ const hasDecimals = numAmount % 1 !== 0;
20
+
21
+ // Format: show decimals only if they exist, max 2 decimal places
22
+ const formattedAmount = hasDecimals
23
+ ? numAmount.toFixed(2).replace(/\.?0+$/, "")
24
+ : numAmount.toString();
25
+
26
+ return (
27
+ <>
28
+ {useEuroCurrency ? EURO_CURRENCY : DEFAULT_CURRENCY}
29
+ {formattedAmount}
30
+ </>
31
+ );
32
+ }
@@ -0,0 +1,120 @@
1
+ import {
2
+ Avatar,
3
+ Button,
4
+ IconButton,
5
+ Menu,
6
+ MenuHandler,
7
+ MenuList,
8
+ Typography,
9
+ } from "@material-tailwind/react";
10
+ import { useState } from "react";
11
+ import { IoChevronDownOutline } from "react-icons/io5";
12
+ import { MdContentCopy, MdOutlineLogout } from "react-icons/md";
13
+ import { TbExternalLink } from "react-icons/tb";
14
+
15
+ import { PROFILE_PLACEHOLDER_IMAGE } from "../constants/app";
16
+ import { ROUTES } from "../constants/routes";
17
+ import useCopy from "../hooks/useCopy";
18
+ import { _useScopedI18n } from "../i18n/client";
19
+ import ButtonCustom from "./Button";
20
+
21
+ export type ProfileMenuProps = {
22
+ bidNumber?: string;
23
+ userName?: string;
24
+ logout: () => void;
25
+ };
26
+
27
+ export default function ProfileMenu({
28
+ bidNumber = "",
29
+ userName = "",
30
+ logout,
31
+ }: ProfileMenuProps) {
32
+ const scopeT = _useScopedI18n("sharedComponents.profileMenuComponent");
33
+
34
+ const [isMenuOpen, setIsMenuOpen] = useState(false);
35
+ const { handleCopy } = useCopy();
36
+
37
+ return (
38
+ <>
39
+ <div className="hidden lg:block">
40
+ <Menu open={isMenuOpen} handler={setIsMenuOpen} placement="bottom-end">
41
+ <MenuHandler>
42
+ <Button
43
+ variant="text"
44
+ color="blue-gray"
45
+ className="flex items-center gap-2 rounded-full p-1"
46
+ >
47
+ <Avatar
48
+ variant="circular"
49
+ alt="tania andrew"
50
+ className="border border-slate-50 w-9 h-9"
51
+ src={PROFILE_PLACEHOLDER_IMAGE}
52
+ />
53
+ <Typography
54
+ as="a"
55
+ href="#"
56
+ className="text-sm font-medium text-black-500 capitalize"
57
+ >
58
+ {userName}
59
+ </Typography>
60
+ <IoChevronDownOutline className="h-4 w-4 text-black-500" />
61
+ </Button>
62
+ </MenuHandler>
63
+ <MenuList className="p-3 w-48">
64
+ <div
65
+ className="flex items-center justify-start gap-1 rounded pb-2
66
+ hover:bg-white active:bg-white focus:bg-white
67
+ outline-none"
68
+ >
69
+ <IconButton
70
+ variant="outlined"
71
+ className="p-0 rounded-full border-none h-9 w-9"
72
+ onClick={() => handleCopy(bidNumber)}
73
+ >
74
+ <MdContentCopy className="h-4 w-4" />
75
+ </IconButton>
76
+ <Typography
77
+ variant="h6"
78
+ className="text-black-500 text-sm font-semibold"
79
+ >
80
+ Nid : {bidNumber}
81
+ </Typography>
82
+ </div>
83
+
84
+ <div
85
+ className="flex items-center justify-start gap-1 rounded
86
+ hover:bg-white active:bg-white focus:bg-white
87
+ outline-none"
88
+ >
89
+ <IconButton
90
+ variant="outlined"
91
+ className="p-0 rounded-full border-none h-9 w-9"
92
+ onClick={() => window.open(ROUTES.dashboard.nodeLinkProfile)}
93
+ >
94
+ <TbExternalLink className="h-4 w-4" />
95
+ </IconButton>
96
+
97
+ <Typography
98
+ variant="h6"
99
+ className="text-black-500 text-sm font-semibold"
100
+ >
101
+ {scopeT("nodeLinkRedirectionLink")}
102
+ </Typography>
103
+ </div>
104
+ <hr className="my-3 block border-slate-50" />
105
+ <div className="flex justify-start items-center rounded p-0 outline-none">
106
+ <ButtonCustom
107
+ icon={<MdOutlineLogout className="h-5 w-5" />}
108
+ className="!justify-start gap-2 font-normal !text-base !px-4 py-2.5 !text-start"
109
+ onClick={logout}
110
+ fullWidth={true}
111
+ >
112
+ {scopeT("logout")}
113
+ </ButtonCustom>
114
+ </div>
115
+ </MenuList>
116
+ </Menu>
117
+ </div>
118
+ </>
119
+ );
120
+ }
@@ -0,0 +1,214 @@
1
+ import {
2
+ Dialog,
3
+ DialogBody,
4
+ DialogHeader,
5
+ IconButton,
6
+ Typography,
7
+ } from "@material-tailwind/react";
8
+ import React, { useEffect, useState } from "react";
9
+
10
+ import { useInvoice } from "../hooks/useInvoice";
11
+ import { _useScopedI18n } from "../i18n/client";
12
+ import { handleDownload } from "../utils/app.util";
13
+ import { notification } from "../utils/notifications.util";
14
+ import AppLoadingComponent from "./AppLoadingComponent";
15
+
16
+ type CreditNote = {
17
+ id: number;
18
+ identifier: string;
19
+ creditNoteInvoiceUrl?: string;
20
+ type?: string;
21
+ };
22
+
23
+ type RequestCreditNoteInvoiceDialogProps = {
24
+ open: boolean;
25
+ creditNotes: CreditNote[];
26
+ setOpen: (value: boolean) => void;
27
+ };
28
+
29
+ export function RequestCreditNoteInvoiceDialog({
30
+ open,
31
+ creditNotes,
32
+ setOpen,
33
+ }: RequestCreditNoteInvoiceDialogProps) {
34
+ const scopeT = _useScopedI18n("invoice.requestProcessingDialog");
35
+ const { generateCreditNoteInvoiceAPI } = useInvoice();
36
+ const [currentIndex, setCurrentIndex] = useState(0);
37
+ const [, setAttemptCount] = useState(0);
38
+ const [allAttemptsFailed, setAllAttemptsFailed] = useState(false);
39
+
40
+ useEffect(() => {
41
+ let timeoutIds: NodeJS.Timeout[] = [];
42
+
43
+ if (creditNotes[currentIndex]) {
44
+ const firstCallTimeout = setTimeout(() => {
45
+ generateCreditNoteInvoiceAPI.mutate({
46
+ creditNote: creditNotes[currentIndex].identifier,
47
+ type: creditNotes[currentIndex].type,
48
+ });
49
+ setAttemptCount(1);
50
+ }, 2000);
51
+ timeoutIds.push(firstCallTimeout);
52
+
53
+ const secondCallTimeout = setTimeout(() => {
54
+ generateCreditNoteInvoiceAPI.mutate({
55
+ creditNote: creditNotes[currentIndex].identifier,
56
+ type: creditNotes[currentIndex].type,
57
+ });
58
+ setAttemptCount(2);
59
+ }, 5000);
60
+ timeoutIds.push(secondCallTimeout);
61
+
62
+ const thirdCallTimeout = setTimeout(() => {
63
+ generateCreditNoteInvoiceAPI.mutate({
64
+ creditNote: creditNotes[currentIndex].identifier,
65
+ type: creditNotes[currentIndex].type,
66
+ });
67
+ setAttemptCount(3);
68
+ }, 7000);
69
+ timeoutIds.push(thirdCallTimeout);
70
+
71
+ const checkAttemptsTimeout = setTimeout(() => {
72
+ if (
73
+ !generateCreditNoteInvoiceAPI.isSuccess ||
74
+ !generateCreditNoteInvoiceAPI.data?.data?.invoiceUrl
75
+ ) {
76
+ setAllAttemptsFailed(true);
77
+ }
78
+ }, 8000);
79
+ timeoutIds.push(checkAttemptsTimeout);
80
+ }
81
+
82
+ return () => {
83
+ timeoutIds.forEach((id) => clearTimeout(id));
84
+ };
85
+ }, [currentIndex, creditNotes, generateCreditNoteInvoiceAPI]);
86
+
87
+ useEffect(() => {
88
+ if (
89
+ generateCreditNoteInvoiceAPI?.isSuccess &&
90
+ generateCreditNoteInvoiceAPI.data?.link
91
+ ) {
92
+ handleDownload(
93
+ generateCreditNoteInvoiceAPI.data?.link,
94
+ creditNotes[currentIndex]?.identifier?.toString() || "",
95
+ );
96
+
97
+ // Move to next credit note if available
98
+ if (currentIndex < creditNotes.length - 1) {
99
+ setCurrentIndex(currentIndex + 1);
100
+ setAllAttemptsFailed(false);
101
+ setAttemptCount(0);
102
+ } else {
103
+ setOpen(false);
104
+ }
105
+ }
106
+ // eslint-disable-next-line react-hooks/exhaustive-deps
107
+ }, [generateCreditNoteInvoiceAPI?.isSuccess]);
108
+
109
+ useEffect(() => {
110
+ if (generateCreditNoteInvoiceAPI?.isError) {
111
+ notification.notifyError("something went wrong.");
112
+ setOpen(false);
113
+ }
114
+ // eslint-disable-next-line react-hooks/exhaustive-deps
115
+ }, [generateCreditNoteInvoiceAPI?.isError]);
116
+
117
+ return (
118
+ <>
119
+ <Dialog open={open} size="xs" handler={() => {}} className="p-2 md:p-5">
120
+ <DialogHeader className="p-0">
121
+ <div className="text-right size-full">
122
+ <IconButton
123
+ color="blue-gray"
124
+ size="sm"
125
+ variant="text"
126
+ onClick={() => setOpen(false)}
127
+ >
128
+ <svg
129
+ xmlns="http://www.w3.org/2000/svg"
130
+ fill="none"
131
+ viewBox="0 0 24 24"
132
+ stroke="currentColor"
133
+ strokeWidth={2}
134
+ className="h-5 w-5"
135
+ >
136
+ <path
137
+ strokeLinecap="round"
138
+ strokeLinejoin="round"
139
+ d="M6 18L18 6M6 6l12 12"
140
+ />
141
+ </svg>
142
+ </IconButton>
143
+ </div>
144
+ </DialogHeader>
145
+ <DialogBody className="flex flex-col items-center gap-8 text-center">
146
+ {allAttemptsFailed ? (
147
+ <>
148
+ <div>
149
+ <Typography
150
+ variant="h3"
151
+ className="text-xl text-black-500 mb-4"
152
+ >
153
+ {scopeT("failedTitle") ||
154
+ "Unable to Generate Credit Note Invoice"}
155
+ </Typography>
156
+ <Typography
157
+ variant="lead"
158
+ className="text-sm font-medium text-slate-500 mb-6"
159
+ >
160
+ {scopeT("failedMessage") ||
161
+ "We couldn't generate your credit note invoice at this time. Please try again."}
162
+ </Typography>
163
+ </div>
164
+
165
+ <div className="bg-gray-50 py-4 px-9 border border-slate-100 rounded-lg">
166
+ <Typography
167
+ variant="h6"
168
+ className="text-xs leading-5 font-medium text-black-500"
169
+ >
170
+ Credit Note ID: {creditNotes[currentIndex]?.identifier}
171
+ </Typography>
172
+ </div>
173
+ </>
174
+ ) : (
175
+ <>
176
+ <div>
177
+ <AppLoadingComponent />
178
+ <Typography variant="h3" className="text-xl text-black-500">
179
+ Generating Credit Note Invoice {currentIndex + 1} of{" "}
180
+ {creditNotes.length}...
181
+ </Typography>
182
+ </div>
183
+
184
+ <div className="bg-gray-50 py-4 px-9 border border-slate-100 rounded-lg">
185
+ <Typography
186
+ variant="h6"
187
+ className="text-xs leading-5 font-medium text-black-500"
188
+ >
189
+ Credit Note ID: {creditNotes[currentIndex]?.identifier}
190
+ </Typography>
191
+ </div>
192
+
193
+ <div>
194
+ <Typography
195
+ variant="lead"
196
+ className="text-sm font-medium text-slate-500 mb-3"
197
+ >
198
+ {scopeT("subTitle")}
199
+ </Typography>
200
+
201
+ <Typography
202
+ variant="lead"
203
+ className="text-sm font-medium text-slate-500"
204
+ >
205
+ {scopeT("message")}
206
+ </Typography>
207
+ </div>
208
+ </>
209
+ )}
210
+ </DialogBody>
211
+ </Dialog>
212
+ </>
213
+ );
214
+ }
@@ -0,0 +1,194 @@
1
+ import {
2
+ Dialog,
3
+ DialogBody,
4
+ DialogHeader,
5
+ IconButton,
6
+ Typography,
7
+ } from "@material-tailwind/react";
8
+ import React, { useEffect, useState } from "react";
9
+
10
+ import { useInvoice } from "../hooks/useInvoice";
11
+ import { _useScopedI18n } from "../i18n/client";
12
+ import { handleDownload } from "../utils/app.util";
13
+ import { notification } from "../utils/notifications.util";
14
+ import AppLoadingComponent from "./AppLoadingComponent";
15
+
16
+ type RequestInvoiceDialogProps = {
17
+ open: boolean;
18
+ isShipping: boolean;
19
+ orderId: string;
20
+ setOpen: (value: boolean) => void;
21
+ };
22
+
23
+ export function RequestInvoiceDialog({
24
+ open,
25
+ isShipping = false,
26
+ setOpen,
27
+ orderId,
28
+ }: RequestInvoiceDialogProps) {
29
+ const scopeT = _useScopedI18n("invoice.requestProcessingDialog");
30
+ const { generateOrderInvoiceAPI, generateShippingOrderInvoiceAPI } =
31
+ useInvoice();
32
+ const [, setAttemptCount] = useState(0);
33
+ const [allAttemptsFailed, setAllAttemptsFailed] = useState(false);
34
+
35
+ const invoiceAPI = isShipping
36
+ ? generateShippingOrderInvoiceAPI
37
+ : generateOrderInvoiceAPI;
38
+
39
+ useEffect(() => {
40
+ let timeoutIds: NodeJS.Timeout[] = [];
41
+
42
+ if (orderId) {
43
+ const firstCallTimeout = setTimeout(() => {
44
+ invoiceAPI.mutate({
45
+ orderId: orderId,
46
+ });
47
+ setAttemptCount(1);
48
+ }, 2000);
49
+ timeoutIds.push(firstCallTimeout);
50
+
51
+ const secondCallTimeout = setTimeout(() => {
52
+ invoiceAPI.mutate({
53
+ orderId: orderId,
54
+ });
55
+ setAttemptCount(2);
56
+ }, 5000);
57
+ timeoutIds.push(secondCallTimeout);
58
+
59
+ const thirdCallTimeout = setTimeout(() => {
60
+ invoiceAPI.mutate({
61
+ orderId: orderId,
62
+ });
63
+ setAttemptCount(3);
64
+ }, 7000);
65
+ timeoutIds.push(thirdCallTimeout);
66
+
67
+ const checkAttemptsTimeout = setTimeout(() => {
68
+ if (!invoiceAPI.isSuccess || !invoiceAPI.data?.data?.invoiceUrl) {
69
+ setAllAttemptsFailed(true);
70
+ }
71
+ }, 8000);
72
+ timeoutIds.push(checkAttemptsTimeout);
73
+ }
74
+
75
+ return () => {
76
+ timeoutIds.forEach((id) => clearTimeout(id));
77
+ };
78
+ // eslint-disable-next-line react-hooks/exhaustive-deps
79
+ }, [orderId]);
80
+
81
+ useEffect(() => {
82
+ if (invoiceAPI?.isSuccess && invoiceAPI.data?.link) {
83
+ handleDownload(invoiceAPI.data?.link, orderId.toString());
84
+ setOpen(false);
85
+ }
86
+ // eslint-disable-next-line react-hooks/exhaustive-deps
87
+ }, [invoiceAPI?.isSuccess]);
88
+
89
+ useEffect(() => {
90
+ if (generateOrderInvoiceAPI?.isError) {
91
+ notification.notifyError("something went wrong.");
92
+ setOpen(false);
93
+ }
94
+ // eslint-disable-next-line react-hooks/exhaustive-deps
95
+ }, [generateOrderInvoiceAPI?.isError]);
96
+
97
+ return (
98
+ <>
99
+ <Dialog open={open} size="xs" handler={() => {}} className="p-2 md:p-5">
100
+ <DialogHeader className="p-0">
101
+ <div className="text-right size-full">
102
+ <IconButton
103
+ color="blue-gray"
104
+ size="sm"
105
+ variant="text"
106
+ onClick={() => {
107
+ setOpen(false);
108
+ }}
109
+ >
110
+ <svg
111
+ xmlns="http://www.w3.org/2000/svg"
112
+ fill="none"
113
+ viewBox="0 0 24 24"
114
+ stroke="currentColor"
115
+ strokeWidth={2}
116
+ className="h-5 w-5"
117
+ >
118
+ <path
119
+ strokeLinecap="round"
120
+ strokeLinejoin="round"
121
+ d="M6 18L18 6M6 6l12 12"
122
+ />
123
+ </svg>
124
+ </IconButton>
125
+ </div>
126
+ </DialogHeader>
127
+ <DialogBody className="flex flex-col items-center gap-8 text-center">
128
+ {allAttemptsFailed ? (
129
+ <>
130
+ <div>
131
+ <Typography
132
+ variant="h3"
133
+ className="text-xl text-black-500 mb-4"
134
+ >
135
+ {scopeT("failedTitle") || "Unable to Generate Invoice"}
136
+ </Typography>
137
+ <Typography
138
+ variant="lead"
139
+ className="text-sm font-medium text-slate-500 mb-6"
140
+ >
141
+ {scopeT("failedMessage") ||
142
+ "We couldn't generate your invoice at this time. Please try again."}
143
+ </Typography>
144
+ </div>
145
+
146
+ <div className="bg-gray-50 py-4 px-9 border border-slate-100 rounded-lg">
147
+ <Typography
148
+ variant="h6"
149
+ className="text-xs leading-5 font-medium text-black-500"
150
+ >
151
+ {scopeT("orderId")} : {orderId}
152
+ </Typography>
153
+ </div>
154
+ </>
155
+ ) : (
156
+ <>
157
+ <div>
158
+ <AppLoadingComponent />
159
+ <Typography variant="h3" className="text-xl text-black-500">
160
+ {scopeT("title")}...
161
+ </Typography>
162
+ </div>
163
+
164
+ <div className="bg-gray-50 py-4 px-9 border border-slate-100 rounded-lg">
165
+ <Typography
166
+ variant="h6"
167
+ className="text-xs leading-5 font-medium text-black-500"
168
+ >
169
+ {scopeT("orderId")} : {orderId}
170
+ </Typography>
171
+ </div>
172
+
173
+ <div>
174
+ <Typography
175
+ variant="lead"
176
+ className="text-sm font-medium text-slate-500 mb-3"
177
+ >
178
+ {scopeT("subTitle")}
179
+ </Typography>
180
+
181
+ <Typography
182
+ variant="lead"
183
+ className="text-sm font-medium text-slate-500"
184
+ >
185
+ {scopeT("message")}
186
+ </Typography>
187
+ </div>
188
+ </>
189
+ )}
190
+ </DialogBody>
191
+ </Dialog>
192
+ </>
193
+ );
194
+ }