@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.
- package/app.css +457 -0
- package/bitbucket-pipelines.yml +223 -0
- package/package.json +43 -0
- package/public/gif/balloon.gif +0 -0
- package/public/gif/gift.gif +0 -0
- package/public/img/ai-dialog.png +0 -0
- package/public/img/ai-x1-banner.png +0 -0
- package/public/img/ai-x1.png +0 -0
- package/public/img/alert-Icon.png +0 -0
- package/public/img/aleta-payment-kyc-require.png +0 -0
- package/public/img/aleta-payment-pending.png +0 -0
- package/public/img/aleta-payment-rejected.png +0 -0
- package/public/img/aleta-payment-subscription-required.png +0 -0
- package/public/img/boost-banner-bg.png +0 -0
- package/public/img/boost-banner-right.png +0 -0
- package/public/img/boost-banner.png +0 -0
- package/public/img/boost-dialog-bg.png +0 -0
- package/public/img/boostPower.png +0 -0
- package/public/img/boostTooltip.png +0 -0
- package/public/img/brand-icon.svg +23 -0
- package/public/img/brand-text.svg +11 -0
- package/public/img/card-icon.png +0 -0
- package/public/img/cashback-Icon.png +0 -0
- package/public/img/crown.svg +9 -0
- package/public/img/empty-box.png +0 -0
- package/public/img/gen3-dialog.png +0 -0
- package/public/img/gen3-home-banner-bg.png +0 -0
- package/public/img/gen3-image.png +0 -0
- package/public/img/gift.png +0 -0
- package/public/img/img-placeholder-illustration.svg +6 -0
- package/public/img/logo.svg +31 -0
- package/public/img/offerBanner.png +0 -0
- package/public/img/pagenotfound.png +0 -0
- package/public/img/partial-pay-payment-successful.png +0 -0
- package/public/img/phoneShippingBG.png +0 -0
- package/public/img/placeholder-image.jpg +0 -0
- package/public/img/powerIcon.png +0 -0
- package/public/img/product-01.png +0 -0
- package/public/img/product-02.jpg +0 -0
- package/public/img/product-03.jpg +0 -0
- package/public/img/product-04.jpg +0 -0
- package/public/img/product-05.png +0 -0
- package/public/img/product-06.png +0 -0
- package/public/img/profile-avatar.svg +12 -0
- package/public/img/promotion-icon.png +0 -0
- package/public/img/session-expired.png +0 -0
- package/public/img/shipping-alert-icon.png +0 -0
- package/public/img/shippingIcon.png +0 -0
- package/public/img/smart-pay-banner-how.png +0 -0
- package/public/img/smart-pay-banner-own.png +0 -0
- package/public/img/smart-pay-chose.png +0 -0
- package/public/img/smart-pay-easy.png +0 -0
- package/public/img/smart-pay-payment.png +0 -0
- package/public/img/smart-plan-fire.gif +0 -0
- package/public/img/smart-plan-sparkle.gif +0 -0
- package/public/img/special.png +0 -0
- package/public/img/specialOfferBg.png +0 -0
- package/public/img/stop-shipping-banner.png +0 -0
- package/public/img/subscriptionBanner.png +0 -0
- package/public/img/subscriptionIcon.png +0 -0
- package/public/img/successIcon.png +0 -0
- package/public/img/wallet-icon.png +0 -0
- package/public/img/world-wide-shipping.png +0 -0
- package/public/next.svg +1 -0
- package/public/vercel.svg +1 -0
- package/shared/components/AddressFormComponent.tsx +215 -0
- package/shared/components/AddressShippingFormComponent.tsx +223 -0
- package/shared/components/AiPaymentDialog.tsx +95 -0
- package/shared/components/AppLoadingComponent.tsx +15 -0
- package/shared/components/AppLoadingComponentV2.tsx +18 -0
- package/shared/components/Button.tsx +48 -0
- package/shared/components/BuySubscriptionDialog.tsx +75 -0
- package/shared/components/CartDrawerComponent.tsx +324 -0
- package/shared/components/CashbackComponent.tsx +48 -0
- package/shared/components/CashbackMigrationComponent.tsx +41 -0
- package/shared/components/CommissionNonEligibleComponent.tsx +27 -0
- package/shared/components/CustomNextImage.tsx +50 -0
- package/shared/components/CustomNextLink.tsx +46 -0
- package/shared/components/EditAddressFormComponent.tsx +254 -0
- package/shared/components/EmptyCartMessageComponent.tsx +25 -0
- package/shared/components/EmptyCartMessageForCartPage.tsx +61 -0
- package/shared/components/EmptyLegacyOrderMessageForOrdersPage.tsx +52 -0
- package/shared/components/EmptyOrderMessageForOrdersPage.tsx +62 -0
- package/shared/components/EmptyOrderMessageForShippingOrdersPage.tsx +62 -0
- package/shared/components/Footer.tsx +71 -0
- package/shared/components/GreetingDialog.tsx +96 -0
- package/shared/components/Header.tsx +106 -0
- package/shared/components/HoldShippingDialog.tsx +165 -0
- package/shared/components/HomeBanners.tsx +298 -0
- package/shared/components/InactiveCartDialog.tsx +69 -0
- package/shared/components/InputCartQuantity.tsx +342 -0
- package/shared/components/Inputfield.tsx +110 -0
- package/shared/components/ListItemComponent.tsx +82 -0
- package/shared/components/LoadingIconComponent.tsx +284 -0
- package/shared/components/OrderNotFoundComponent.tsx +56 -0
- package/shared/components/PageHeader.tsx +42 -0
- package/shared/components/PhoneNumberCountries.tsx +133 -0
- package/shared/components/PhoneShippingDialog.tsx +77 -0
- package/shared/components/PickupDialog.tsx +92 -0
- package/shared/components/ProductNotFoundComponent.tsx +56 -0
- package/shared/components/ProductPriceComponent.tsx +32 -0
- package/shared/components/ProfileMenu.tsx +120 -0
- package/shared/components/RequestCreditNoteInvoiceDialog.tsx +214 -0
- package/shared/components/RequestInvoiceDialog.tsx +194 -0
- package/shared/components/SelectCities.tsx +133 -0
- package/shared/components/SelectComponent.tsx +334 -0
- package/shared/components/SelectCountries.tsx +179 -0
- package/shared/components/SelectPickUpStore.tsx +131 -0
- package/shared/components/SelectStates.tsx +144 -0
- package/shared/components/ServerTime.tsx +68 -0
- package/shared/components/SessionDialogComponent.tsx +60 -0
- package/shared/components/ShippingAddressFormDialogComponent.tsx +51 -0
- package/shared/components/Sidebar.tsx +281 -0
- package/shared/components/SpecialOfferDialog.tsx +193 -0
- package/shared/components/StatusComponents.tsx +25 -0
- package/shared/components/StepperComponent.tsx +79 -0
- package/shared/components/StepperSmartPayComponent.tsx +97 -0
- package/shared/components/SubscriptionPurchaseDialogComponent.tsx +81 -0
- package/shared/components/TableComponent.tsx +144 -0
- package/shared/components/TablePaginationComponent.tsx +151 -0
- package/shared/components/aleta/AletaManagerComponent.tsx +52 -0
- package/shared/components/aleta/KycPendingStatus.tsx +33 -0
- package/shared/components/aleta/KycRejectedStatus.tsx +53 -0
- package/shared/components/aleta/KycRequiredStatus.tsx +53 -0
- package/shared/components/aleta/SubscriptionRequiredStatus.tsx +45 -0
- package/shared/components/icons/AletaWalletIcon.tsx +21 -0
- package/shared/components/icons/BrandIcon.tsx +97 -0
- package/shared/components/icons/BrandText.tsx +47 -0
- package/shared/components/icons/CartIcon.tsx +21 -0
- package/shared/components/icons/DoneIcon.tsx +27 -0
- package/shared/components/icons/HomnifiIcon.tsx +23 -0
- package/shared/components/icons/InfoIcon.tsx +16 -0
- package/shared/components/icons/SmartPayProductIcon.tsx +31 -0
- package/shared/components/payments/DisclaimerAlertDialog.tsx +205 -0
- package/shared/components/payments/EmptyAssets.tsx +23 -0
- package/shared/components/payments/PaybyWalletItemComponent.tsx +116 -0
- package/shared/components/payments/PaymentAssetItemComponent.tsx +101 -0
- package/shared/components/payments/RequestProcessingDialog.tsx +123 -0
- package/shared/components/payments/WalletSectionManager.tsx +82 -0
- package/shared/components/payments/WalletSliderComponent.tsx +326 -0
- package/shared/components/payments/WalletTermsAndConditionComponent.tsx +88 -0
- package/shared/constants/address-shipping.schema.ts +56 -0
- package/shared/constants/address.schema.ts +56 -0
- package/shared/constants/app.ts +323 -0
- package/shared/constants/environment.ts +23 -0
- package/shared/constants/feature-flags.ts +15 -0
- package/shared/constants/query-keys.ts +106 -0
- package/shared/constants/routes.ts +41 -0
- package/shared/constants/socket.ts +15 -0
- package/shared/contexts/HomeProductsContext.tsx +51 -0
- package/shared/contexts/MainWrapperContext.tsx +289 -0
- package/shared/contexts/WebSocketContext.tsx +155 -0
- package/shared/hooks/useAddressForm.ts +169 -0
- package/shared/hooks/useAddresses.ts +28 -0
- package/shared/hooks/useAppForm.ts +39 -0
- package/shared/hooks/useCart.ts +207 -0
- package/shared/hooks/useCopy.ts +45 -0
- package/shared/hooks/useCountries.ts +27 -0
- package/shared/hooks/useCustomRouter.ts +51 -0
- package/shared/hooks/useDebounce.ts +21 -0
- package/shared/hooks/useInvoice.ts +41 -0
- package/shared/hooks/useOnlineUser.ts +38 -0
- package/shared/hooks/usePayments.ts +101 -0
- package/shared/hooks/useShippingAddressForm.ts +70 -0
- package/shared/hooks/useShippingAddresses.ts +33 -0
- package/shared/hooks/useStores.ts +29 -0
- package/shared/hooks/useUserActivity.ts +43 -0
- package/shared/i18n/client.ts +27 -0
- package/shared/i18n/locales/en.ts +383 -0
- package/shared/i18n/locales/it.ts +373 -0
- package/shared/i18n/server.ts +7 -0
- package/shared/services/addresses.service.ts +27 -0
- package/shared/services/api/core/ApiError.ts +29 -0
- package/shared/services/api/core/ApiRequestOptions.ts +25 -0
- package/shared/services/api/core/ApiResult.ts +11 -0
- package/shared/services/api/core/CancelablePromise.ts +130 -0
- package/shared/services/api/core/OpenAPI.ts +37 -0
- package/shared/services/api/core/request.ts +376 -0
- package/shared/services/api/index.ts +64 -0
- package/shared/services/api/models/AddAllProductToShippingCartDto.ts +7 -0
- package/shared/services/api/models/AddProductToCartDto.ts +8 -0
- package/shared/services/api/models/AddProductToShippingCartDto.ts +8 -0
- package/shared/services/api/models/AdminPlaceOrderDto.ts +16 -0
- package/shared/services/api/models/AssignPickupSerialNumberDto.ts +10 -0
- package/shared/services/api/models/CreateUserAddressDto.ts +19 -0
- package/shared/services/api/models/DeletCartProductsArrayDto.ts +7 -0
- package/shared/services/api/models/GenerateInvoiceDto.ts +7 -0
- package/shared/services/api/models/OrderConfirmationEmailDto.ts +8 -0
- package/shared/services/api/models/PlaceOrderDto.ts +9 -0
- package/shared/services/api/models/PlaceShipmentOrderDto.ts +8 -0
- package/shared/services/api/models/ProductBoostDto.ts +18 -0
- package/shared/services/api/models/RemoveAssignedSerialNumberDto.ts +9 -0
- package/shared/services/api/models/RemoveProductToCartDto.ts +8 -0
- package/shared/services/api/models/ShipmentItem.ts +8 -0
- package/shared/services/api/models/ShippingCartUpdateBillingAddressesDto.ts +7 -0
- package/shared/services/api/models/ShippingCartUpdateShippingMethodDto.ts +7 -0
- package/shared/services/api/models/UnfreezeWalletDto.ts +8 -0
- package/shared/services/api/models/UpdateCartBillingAddressesDto.ts +7 -0
- package/shared/services/api/models/UpdateCartPaymentMethodDto.ts +9 -0
- package/shared/services/api/models/UpdateCartShippingMethodDto.ts +7 -0
- package/shared/services/api/models/UpdateCartStoreDto.ts +7 -0
- package/shared/services/api/models/UpdateProductDto.ts +11 -0
- package/shared/services/api/models/UpdateShipmentItemStatusDto.ts +24 -0
- package/shared/services/api/models/UpdateShippingCartPaymentMethodDto.ts +9 -0
- package/shared/services/api/models/UpdateUserAddressDto.ts +19 -0
- package/shared/services/api/models/ValidateAuthCodeDto.ts +8 -0
- package/shared/services/api/models/WithdrawOrderWalletDto.ts +8 -0
- package/shared/services/api/services/AddressesService.ts +160 -0
- package/shared/services/api/services/AdminsDevicesService.ts +28 -0
- package/shared/services/api/services/AdminsOrdersService.ts +117 -0
- package/shared/services/api/services/AdminsPickupsService.ts +57 -0
- package/shared/services/api/services/AdminsProductsService.ts +86 -0
- package/shared/services/api/services/CartsService.ts +190 -0
- package/shared/services/api/services/CashBackQueueService.ts +39 -0
- package/shared/services/api/services/CategoriesService.ts +65 -0
- package/shared/services/api/services/DefaultService.ts +19 -0
- package/shared/services/api/services/FeaturesFlagsService.ts +20 -0
- package/shared/services/api/services/IossQueueService.ts +39 -0
- package/shared/services/api/services/OrderCallbackService.ts +67 -0
- package/shared/services/api/services/OrderEmailsService.ts +40 -0
- package/shared/services/api/services/OrderImportService.ts +228 -0
- package/shared/services/api/services/OrdersService.ts +183 -0
- package/shared/services/api/services/PaymentGatewayService.ts +19 -0
- package/shared/services/api/services/PaymentsService.ts +88 -0
- package/shared/services/api/services/ProductsService.ts +67 -0
- package/shared/services/api/services/ShipmentOrderCallbackService.ts +67 -0
- package/shared/services/api/services/ShipmentOrdersService.ts +88 -0
- package/shared/services/api/services/ShipmentsService.ts +30 -0
- package/shared/services/api/services/ShippingCartService.ts +247 -0
- package/shared/services/api/services/ShippingMethodsService.ts +20 -0
- package/shared/services/api/services/StoresService.ts +25 -0
- package/shared/services/api/services/SyncServiceQueueService.ts +39 -0
- package/shared/services/api/services/UpgradeOrdersService.ts +26 -0
- package/shared/services/api/services/UsersAuthService.ts +45 -0
- package/shared/services/api/services/UsersService.ts +53 -0
- package/shared/services/api/services/XeraQueueService.ts +39 -0
- package/shared/services/index.ts +0 -0
- package/shared/services/payment-method.service.ts +29 -0
- package/shared/stores/cartStore.ts +108 -0
- package/shared/stores/countriesStore.ts +62 -0
- package/shared/stores/formStore.ts +19 -0
- package/shared/stores/loadingStore.ts +12 -0
- package/shared/stores/userStore.ts +32 -0
- package/shared/types/SelectComponent.types.ts +31 -0
- package/shared/types/addressForm.ts +27 -0
- package/shared/types/cart.ts +208 -0
- package/shared/types/category.ts +6 -0
- package/shared/types/creditNote.ts +0 -0
- package/shared/types/feature-flags.ts +5 -0
- package/shared/types/icon.ts +5 -0
- package/shared/types/index.d.ts +84 -0
- package/shared/types/order.ts +332 -0
- package/shared/types/pagination.ts +5 -0
- package/shared/types/payments.ts +68 -0
- package/shared/types/product.ts +54 -0
- package/shared/types/shoppingCart.ts +219 -0
- package/shared/types/upgradeCart.ts +226 -0
- package/shared/types/user.ts +36 -0
- package/shared/utils/app.util.ts +261 -0
- package/shared/utils/notifications.util.ts +39 -0
- package/shared/utils/user-session.util.ts +171 -0
- package/tailwind.config.ts +234 -0
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import CustomNextImage from "@hms/packages/shared/components/CustomNextImage";
|
|
2
|
+
import {
|
|
3
|
+
Asset,
|
|
4
|
+
Option,
|
|
5
|
+
PaymentsMethod,
|
|
6
|
+
} from "@hms/packages/shared/types/payments";
|
|
7
|
+
import { Tooltip, Typography } from "@material-tailwind/react";
|
|
8
|
+
|
|
9
|
+
import cardIcon from "../../../public/img/card-icon.png";
|
|
10
|
+
|
|
11
|
+
export type PaymentAssetItemComponentProps = {
|
|
12
|
+
paymentMethodData: PaymentsMethod;
|
|
13
|
+
item: Asset;
|
|
14
|
+
selectedItem: number;
|
|
15
|
+
option: Option;
|
|
16
|
+
handleItemClick: () => void;
|
|
17
|
+
haveCommission?: boolean;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export default function PaymentAssetItemComponent({
|
|
21
|
+
paymentMethodData,
|
|
22
|
+
item,
|
|
23
|
+
selectedItem,
|
|
24
|
+
option,
|
|
25
|
+
handleItemClick,
|
|
26
|
+
haveCommission = false,
|
|
27
|
+
}: PaymentAssetItemComponentProps) {
|
|
28
|
+
//
|
|
29
|
+
let isEligible = false;
|
|
30
|
+
let msg = option.restricted.msg;
|
|
31
|
+
|
|
32
|
+
if (option.restricted.status === false) {
|
|
33
|
+
isEligible = true;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<>
|
|
38
|
+
<Tooltip
|
|
39
|
+
placement="top"
|
|
40
|
+
content={`${msg}`}
|
|
41
|
+
animate={{
|
|
42
|
+
mount: { scale: 1, y: 0 },
|
|
43
|
+
unmount: { scale: 0, y: 25 },
|
|
44
|
+
}}
|
|
45
|
+
className={`bg-red-600 ${isEligible ? "hidden" : ""}`}
|
|
46
|
+
interactive={!isEligible}
|
|
47
|
+
>
|
|
48
|
+
<li
|
|
49
|
+
className={`border ${
|
|
50
|
+
selectedItem === item.id
|
|
51
|
+
? "border-purple-500 bg-purple-50" // Selected border color
|
|
52
|
+
: "border-slate-100 bg-gray-50/30" // Default border color
|
|
53
|
+
} ${!isEligible ? "cursor-not-allowed opacity-80" : "cursor-pointer"} rounded-xl p-4 text-center cursor-pointer`}
|
|
54
|
+
onClick={isEligible ? handleItemClick : () => {}}
|
|
55
|
+
>
|
|
56
|
+
<div className="text-center w-fit mx-auto mb-2">
|
|
57
|
+
<Typography
|
|
58
|
+
variant="lead"
|
|
59
|
+
className="text-xs font-medium p-2 rounded-xl bg-[#FEF3C7] text-[#D97706]"
|
|
60
|
+
>
|
|
61
|
+
Uses {option.minPercentage}%
|
|
62
|
+
</Typography>
|
|
63
|
+
</div>
|
|
64
|
+
|
|
65
|
+
<CustomNextImage
|
|
66
|
+
src={cardIcon.src}
|
|
67
|
+
alt="walletIcon"
|
|
68
|
+
className={`mx-auto my-2 ${isEligible ? "" : "grayscale"}`}
|
|
69
|
+
height={80}
|
|
70
|
+
width={80}
|
|
71
|
+
/>
|
|
72
|
+
|
|
73
|
+
<Typography
|
|
74
|
+
variant="lead"
|
|
75
|
+
className="text-sm font-semibold text-black-500 mb-1"
|
|
76
|
+
>
|
|
77
|
+
{option.name}
|
|
78
|
+
</Typography>
|
|
79
|
+
|
|
80
|
+
{paymentMethodData.paymentFees.map((fee, feeIndex) => (
|
|
81
|
+
<Typography
|
|
82
|
+
key={feeIndex}
|
|
83
|
+
variant="lead"
|
|
84
|
+
className="text-xs font-normal text-slate-500 mb-2"
|
|
85
|
+
>
|
|
86
|
+
{fee.name}
|
|
87
|
+
</Typography>
|
|
88
|
+
))}
|
|
89
|
+
{haveCommission && (
|
|
90
|
+
<Typography
|
|
91
|
+
variant="lead"
|
|
92
|
+
className="text-xs font-medium text-slate-500 mb-3"
|
|
93
|
+
>
|
|
94
|
+
CV: {option.commissions.totalCV} VP: {option.commissions.totalVP}
|
|
95
|
+
</Typography>
|
|
96
|
+
)}
|
|
97
|
+
</li>
|
|
98
|
+
</Tooltip>
|
|
99
|
+
</>
|
|
100
|
+
);
|
|
101
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
// import AppLoadingComponent from "@hms/packages/shared/components/AppLoadingComponent";
|
|
2
|
+
import ButtonCustom from "@hms/packages/shared/components/Button";
|
|
3
|
+
import { _useScopedI18n } from "@hms/packages/shared/i18n/client";
|
|
4
|
+
import {
|
|
5
|
+
Dialog,
|
|
6
|
+
DialogBody,
|
|
7
|
+
DialogHeader,
|
|
8
|
+
IconButton,
|
|
9
|
+
Typography,
|
|
10
|
+
} from "@material-tailwind/react";
|
|
11
|
+
import React from "react";
|
|
12
|
+
import { IoRefresh } from "react-icons/io5";
|
|
13
|
+
|
|
14
|
+
import LoadingIconComponent from "../LoadingIconComponent";
|
|
15
|
+
|
|
16
|
+
type RequestProcessingDialogProps = {
|
|
17
|
+
open: boolean;
|
|
18
|
+
orderId: string;
|
|
19
|
+
paymentProcessFailed: boolean;
|
|
20
|
+
onRetry?: () => void;
|
|
21
|
+
setOpen: (value: boolean) => void;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export function RequestProcessingDialog({
|
|
25
|
+
open,
|
|
26
|
+
setOpen,
|
|
27
|
+
orderId,
|
|
28
|
+
paymentProcessFailed,
|
|
29
|
+
onRetry,
|
|
30
|
+
}: RequestProcessingDialogProps) {
|
|
31
|
+
//
|
|
32
|
+
const scopeT = _useScopedI18n("payment.requestProcessingDialog");
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<>
|
|
36
|
+
<Dialog open={open} size="xs" handler={() => {}} className="p-2 md:p-5">
|
|
37
|
+
<DialogHeader className="p-0">
|
|
38
|
+
<div className="text-right size-full">
|
|
39
|
+
<IconButton
|
|
40
|
+
color="blue-gray"
|
|
41
|
+
size="sm"
|
|
42
|
+
variant="text"
|
|
43
|
+
onClick={() => {
|
|
44
|
+
setOpen(false);
|
|
45
|
+
}}
|
|
46
|
+
>
|
|
47
|
+
<svg
|
|
48
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
49
|
+
fill="none"
|
|
50
|
+
viewBox="0 0 24 24"
|
|
51
|
+
stroke="currentColor"
|
|
52
|
+
strokeWidth={2}
|
|
53
|
+
className="h-5 w-5"
|
|
54
|
+
>
|
|
55
|
+
<path
|
|
56
|
+
strokeLinecap="round"
|
|
57
|
+
strokeLinejoin="round"
|
|
58
|
+
d="M6 18L18 6M6 6l12 12"
|
|
59
|
+
/>
|
|
60
|
+
</svg>
|
|
61
|
+
</IconButton>
|
|
62
|
+
</div>
|
|
63
|
+
</DialogHeader>
|
|
64
|
+
<DialogBody className="flex flex-col items-center gap-8 text-center">
|
|
65
|
+
<>
|
|
66
|
+
<LoadingIconComponent />
|
|
67
|
+
<div>
|
|
68
|
+
{/* <AppLoadingComponent /> */}
|
|
69
|
+
<Typography variant="h3" className="text-xl text-black-500">
|
|
70
|
+
{scopeT("title")}...
|
|
71
|
+
</Typography>
|
|
72
|
+
</div>
|
|
73
|
+
|
|
74
|
+
<div className="bg-gray-50 py-4 px-9 border border-slate-100 rounded-lg">
|
|
75
|
+
<Typography
|
|
76
|
+
variant="h6"
|
|
77
|
+
className="text-xs leading-5 font-medium text-black-500"
|
|
78
|
+
>
|
|
79
|
+
{scopeT("orderId")} : {orderId}
|
|
80
|
+
</Typography>
|
|
81
|
+
</div>
|
|
82
|
+
|
|
83
|
+
<div>
|
|
84
|
+
{paymentProcessFailed ? (
|
|
85
|
+
<>
|
|
86
|
+
<Typography
|
|
87
|
+
variant="lead"
|
|
88
|
+
className="text-sm font-medium text-slate-500 mb-3"
|
|
89
|
+
>
|
|
90
|
+
{scopeT("errorMsg")}
|
|
91
|
+
</Typography>
|
|
92
|
+
|
|
93
|
+
<ButtonCustom
|
|
94
|
+
icon={<IoRefresh className="size-4" />}
|
|
95
|
+
onClick={onRetry}
|
|
96
|
+
>
|
|
97
|
+
{scopeT("retryBtn")}
|
|
98
|
+
</ButtonCustom>
|
|
99
|
+
</>
|
|
100
|
+
) : (
|
|
101
|
+
<>
|
|
102
|
+
<Typography
|
|
103
|
+
variant="lead"
|
|
104
|
+
className="text-sm font-medium text-slate-500 mb-3"
|
|
105
|
+
>
|
|
106
|
+
{scopeT("subTitle")}
|
|
107
|
+
</Typography>
|
|
108
|
+
|
|
109
|
+
<Typography
|
|
110
|
+
variant="lead"
|
|
111
|
+
className="text-sm font-medium text-slate-500"
|
|
112
|
+
>
|
|
113
|
+
{scopeT("message")}
|
|
114
|
+
</Typography>
|
|
115
|
+
</>
|
|
116
|
+
)}
|
|
117
|
+
</div>
|
|
118
|
+
</>
|
|
119
|
+
</DialogBody>
|
|
120
|
+
</Dialog>
|
|
121
|
+
</>
|
|
122
|
+
);
|
|
123
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import WalletTermsAndConditionComponent from "@hms/packages/shared/components/payments/WalletTermsAndConditionComponent";
|
|
2
|
+
import { usePayments } from "@hms/packages/shared/hooks/usePayments";
|
|
3
|
+
import { useUserStore } from "@hms/packages/shared/stores/userStore";
|
|
4
|
+
import {
|
|
5
|
+
PaymentsMethod,
|
|
6
|
+
PaymentType,
|
|
7
|
+
} from "@hms/packages/shared/types/payments";
|
|
8
|
+
import React, { useCallback, useEffect, useState } from "react";
|
|
9
|
+
|
|
10
|
+
import { PAYMENTS_TYPE } from "../../constants/app";
|
|
11
|
+
|
|
12
|
+
type WalletSectionManagerProps = {
|
|
13
|
+
paymentMethodData: PaymentsMethod;
|
|
14
|
+
activeTab: boolean;
|
|
15
|
+
setDisablePaymentButton: (status: boolean) => void;
|
|
16
|
+
type?: PaymentType;
|
|
17
|
+
PaybyWalletComponent: React.ComponentType<{
|
|
18
|
+
assets: any;
|
|
19
|
+
paymentMethodData: PaymentsMethod;
|
|
20
|
+
setDisablePaymentButton: (status: boolean) => void;
|
|
21
|
+
}>;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export default function WalletSectionManager({
|
|
25
|
+
paymentMethodData,
|
|
26
|
+
activeTab,
|
|
27
|
+
setDisablePaymentButton,
|
|
28
|
+
type,
|
|
29
|
+
PaybyWalletComponent,
|
|
30
|
+
}: WalletSectionManagerProps) {
|
|
31
|
+
//
|
|
32
|
+
const { user, setUser } = useUserStore();
|
|
33
|
+
const { getAssetsAPI, isLoadingAsset, assets } = usePayments({
|
|
34
|
+
type: type || PAYMENTS_TYPE.NORMAL,
|
|
35
|
+
});
|
|
36
|
+
// State to track if wallet consent is confirmed
|
|
37
|
+
const [walletConsentConfirmed, setWalletConsentConfirmed] = useState(
|
|
38
|
+
user?.walletConsentConfirmed,
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
const handleEnableConsent = useCallback(() => {
|
|
42
|
+
if (user?.id) {
|
|
43
|
+
setUser({
|
|
44
|
+
...user,
|
|
45
|
+
walletConsentConfirmed: true,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
setWalletConsentConfirmed(true);
|
|
49
|
+
}, [user, setUser, setWalletConsentConfirmed]);
|
|
50
|
+
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
if (
|
|
53
|
+
activeTab &&
|
|
54
|
+
paymentMethodData &&
|
|
55
|
+
paymentMethodData.id &&
|
|
56
|
+
walletConsentConfirmed
|
|
57
|
+
) {
|
|
58
|
+
getAssetsAPI({
|
|
59
|
+
methodId: paymentMethodData.id,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}, [activeTab, walletConsentConfirmed, paymentMethodData, getAssetsAPI]);
|
|
63
|
+
|
|
64
|
+
if (isLoadingAsset) return <>Loading ...</>;
|
|
65
|
+
|
|
66
|
+
return (
|
|
67
|
+
<React.Fragment>
|
|
68
|
+
{user && walletConsentConfirmed && (
|
|
69
|
+
<PaybyWalletComponent
|
|
70
|
+
assets={assets}
|
|
71
|
+
paymentMethodData={paymentMethodData}
|
|
72
|
+
setDisablePaymentButton={setDisablePaymentButton}
|
|
73
|
+
/>
|
|
74
|
+
)}
|
|
75
|
+
{user && !walletConsentConfirmed && (
|
|
76
|
+
<WalletTermsAndConditionComponent
|
|
77
|
+
onConsentAccepted={() => handleEnableConsent()}
|
|
78
|
+
/>
|
|
79
|
+
)}
|
|
80
|
+
</React.Fragment>
|
|
81
|
+
);
|
|
82
|
+
}
|
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
import ButtonCustom from "@hms/packages/shared/components/Button";
|
|
2
|
+
import CustomNextLink from "@hms/packages/shared/components/CustomNextLink";
|
|
3
|
+
import { ROUTES } from "@hms/packages/shared/constants/routes";
|
|
4
|
+
import { useGlobalDebounce } from "@hms/packages/shared/hooks/useDebounce";
|
|
5
|
+
import { _useScopedI18n } from "@hms/packages/shared/i18n/client";
|
|
6
|
+
import { Asset, Commission, Option } from "@hms/packages/shared/types/payments";
|
|
7
|
+
import {
|
|
8
|
+
Button,
|
|
9
|
+
Menu,
|
|
10
|
+
MenuHandler,
|
|
11
|
+
MenuItem,
|
|
12
|
+
MenuList,
|
|
13
|
+
Slider,
|
|
14
|
+
Typography,
|
|
15
|
+
} from "@material-tailwind/react";
|
|
16
|
+
import React, { Dispatch, useEffect, useMemo, useState } from "react";
|
|
17
|
+
import { GoChevronDown } from "react-icons/go";
|
|
18
|
+
import { HiOutlineArrowSmLeft } from "react-icons/hi";
|
|
19
|
+
|
|
20
|
+
// Payment method update function type
|
|
21
|
+
type PaymentUpdateFunction = (params: any) => Promise<void> | void;
|
|
22
|
+
|
|
23
|
+
// Configuration for different cart types
|
|
24
|
+
interface CartConfig {
|
|
25
|
+
updatePaymentMethod: PaymentUpdateFunction;
|
|
26
|
+
showCommissions?: boolean;
|
|
27
|
+
additionalParams?: Record<string, any>;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
type WalletSliderComponentProps = {
|
|
31
|
+
asset: Asset;
|
|
32
|
+
selectedOption: Option;
|
|
33
|
+
grandTotal: number;
|
|
34
|
+
baseAmountToPay: number;
|
|
35
|
+
optionAmountToPay: number;
|
|
36
|
+
commission: Commission;
|
|
37
|
+
setSelectedAsset: Dispatch<any>;
|
|
38
|
+
setSelectedOption: (option: Option) => void;
|
|
39
|
+
cartConfig: CartConfig;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export default function WalletSliderComponent({
|
|
43
|
+
asset,
|
|
44
|
+
selectedOption,
|
|
45
|
+
grandTotal,
|
|
46
|
+
baseAmountToPay,
|
|
47
|
+
optionAmountToPay,
|
|
48
|
+
commission,
|
|
49
|
+
setSelectedAsset,
|
|
50
|
+
setSelectedOption,
|
|
51
|
+
cartConfig,
|
|
52
|
+
}: WalletSliderComponentProps) {
|
|
53
|
+
const scopeT = _useScopedI18n("payment.walletSliderComponent");
|
|
54
|
+
|
|
55
|
+
const [openMenu, setOpenMenu] = useState(false);
|
|
56
|
+
const [currentPercentage, setCurrentPercentage] = useState<number>(
|
|
57
|
+
selectedOption.currentPercentage ?? selectedOption.minPercentage,
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
const {
|
|
61
|
+
updatePaymentMethod,
|
|
62
|
+
showCommissions = true,
|
|
63
|
+
additionalParams = {},
|
|
64
|
+
} = cartConfig;
|
|
65
|
+
|
|
66
|
+
const handleChangePercentage = useGlobalDebounce(
|
|
67
|
+
async (percentage: number) => {
|
|
68
|
+
const params = {
|
|
69
|
+
paymentMethodId: asset.paymentMethodId,
|
|
70
|
+
paymentOptionId: selectedOption.id,
|
|
71
|
+
fromAssetSelectedPercentage: percentage,
|
|
72
|
+
...additionalParams,
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
await updatePaymentMethod(params);
|
|
76
|
+
},
|
|
77
|
+
300,
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
const handleSliderChange = (e: any) => {
|
|
81
|
+
let value = +e.target.value;
|
|
82
|
+
|
|
83
|
+
if (value < selectedOption.minPercentage) {
|
|
84
|
+
value = selectedOption.minPercentage;
|
|
85
|
+
} else if (value > 99) {
|
|
86
|
+
value = 99;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
setCurrentPercentage(value);
|
|
90
|
+
|
|
91
|
+
if (selectedOption.currentPercentage == value) return;
|
|
92
|
+
handleChangePercentage(value);
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
useEffect(() => {
|
|
96
|
+
(async () =>
|
|
97
|
+
await setCurrentPercentage(
|
|
98
|
+
selectedOption.currentPercentage ?? selectedOption.minPercentage,
|
|
99
|
+
))();
|
|
100
|
+
}, [selectedOption, setCurrentPercentage]);
|
|
101
|
+
|
|
102
|
+
const canPayWithBase = useMemo(() => {
|
|
103
|
+
if (+asset.balance < baseAmountToPay) return false;
|
|
104
|
+
return true;
|
|
105
|
+
}, [asset, baseAmountToPay]);
|
|
106
|
+
|
|
107
|
+
const canPayWithOption = useMemo(() => {
|
|
108
|
+
if (+selectedOption.balance < optionAmountToPay) return false;
|
|
109
|
+
return true;
|
|
110
|
+
}, [selectedOption, optionAmountToPay]);
|
|
111
|
+
|
|
112
|
+
return (
|
|
113
|
+
<>
|
|
114
|
+
<div className="">
|
|
115
|
+
<ButtonCustom
|
|
116
|
+
variant="text"
|
|
117
|
+
className="text-base mb-2 p-0"
|
|
118
|
+
icon={undefined}
|
|
119
|
+
onClick={() => {
|
|
120
|
+
setSelectedAsset(null);
|
|
121
|
+
}}
|
|
122
|
+
>
|
|
123
|
+
<HiOutlineArrowSmLeft className="text-2xl" />
|
|
124
|
+
{scopeT("backBtn")}
|
|
125
|
+
</ButtonCustom>
|
|
126
|
+
|
|
127
|
+
<div className="overflow-x-auto">
|
|
128
|
+
<div className="flex flex-col md:flex-row md:min-w-[600px] justify-between items-center gap-5 py-4">
|
|
129
|
+
<div
|
|
130
|
+
className={`flex flex-col justify-center items-center border ${canPayWithBase ? "border-slate-100" : "text-orange-500 bg-orange-50 border-orange-300"} rounded-xl p-4 min-w-30`}
|
|
131
|
+
>
|
|
132
|
+
<Typography
|
|
133
|
+
variant="lead"
|
|
134
|
+
className="text-sm font-semibold text-black-500 p-1"
|
|
135
|
+
>
|
|
136
|
+
{asset.name}
|
|
137
|
+
</Typography>
|
|
138
|
+
<Typography
|
|
139
|
+
variant="lead"
|
|
140
|
+
className="text-xs font-semibold text-gray-300 my-2"
|
|
141
|
+
>
|
|
142
|
+
{scopeT("amount")} : {baseAmountToPay}
|
|
143
|
+
</Typography>
|
|
144
|
+
{showCommissions && selectedOption.commissions?.base && (
|
|
145
|
+
<Typography
|
|
146
|
+
variant="lead"
|
|
147
|
+
className="text-xs font-medium text-slate-500"
|
|
148
|
+
>
|
|
149
|
+
CV: {selectedOption.commissions.base.cv} VP:{" "}
|
|
150
|
+
{selectedOption.commissions.base.vp}
|
|
151
|
+
</Typography>
|
|
152
|
+
)}
|
|
153
|
+
</div>
|
|
154
|
+
|
|
155
|
+
<div className="flex flex-1 flex-col items-center gap-5">
|
|
156
|
+
<div className="flex items-center gap-3 w-full">
|
|
157
|
+
<Typography
|
|
158
|
+
variant="lead"
|
|
159
|
+
className="text-sm font-normal text-black-500"
|
|
160
|
+
>
|
|
161
|
+
{currentPercentage}%
|
|
162
|
+
</Typography>
|
|
163
|
+
<Slider
|
|
164
|
+
key={selectedOption.id}
|
|
165
|
+
onChange={handleSliderChange}
|
|
166
|
+
min={0}
|
|
167
|
+
value={currentPercentage}
|
|
168
|
+
max={100}
|
|
169
|
+
step={1}
|
|
170
|
+
color="green"
|
|
171
|
+
className="flex-1 my-4 md:my-0"
|
|
172
|
+
/>
|
|
173
|
+
|
|
174
|
+
<Typography
|
|
175
|
+
variant="lead"
|
|
176
|
+
className="text-sm font-normal text-black-500"
|
|
177
|
+
>
|
|
178
|
+
{100 - currentPercentage}%
|
|
179
|
+
</Typography>
|
|
180
|
+
</div>
|
|
181
|
+
</div>
|
|
182
|
+
|
|
183
|
+
<div
|
|
184
|
+
className={`flex flex-col justify-center items-center border ${canPayWithOption ? "border-slate-100" : "text-orange-500 bg-orange-50 border-orange-300"} rounded-xl p-4 min-w-30`}
|
|
185
|
+
>
|
|
186
|
+
<Menu open={openMenu} handler={setOpenMenu}>
|
|
187
|
+
<MenuHandler>
|
|
188
|
+
<Button
|
|
189
|
+
variant="text"
|
|
190
|
+
size="sm"
|
|
191
|
+
className="flex justify-center items-center gap-1 p-1 text-sm font-semibold text-black-500 "
|
|
192
|
+
>
|
|
193
|
+
{selectedOption.name}
|
|
194
|
+
<GoChevronDown
|
|
195
|
+
strokeWidth={2.5}
|
|
196
|
+
className={`h-3.5 w-3.5 transition-transform ${
|
|
197
|
+
openMenu ? "rotate-180" : ""
|
|
198
|
+
}`}
|
|
199
|
+
/>
|
|
200
|
+
</Button>
|
|
201
|
+
</MenuHandler>
|
|
202
|
+
<MenuList className="p-1">
|
|
203
|
+
{asset.options.map((option, index) => {
|
|
204
|
+
let isEligible = false;
|
|
205
|
+
|
|
206
|
+
if (
|
|
207
|
+
+option.balance > 0 &&
|
|
208
|
+
option.restricted.status === false
|
|
209
|
+
) {
|
|
210
|
+
isEligible = true;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
return (
|
|
214
|
+
<MenuItem
|
|
215
|
+
onClick={() => {
|
|
216
|
+
isEligible && setSelectedOption(option);
|
|
217
|
+
}}
|
|
218
|
+
key={index}
|
|
219
|
+
className=""
|
|
220
|
+
disabled={
|
|
221
|
+
!isEligible || selectedOption.id === option.id
|
|
222
|
+
}
|
|
223
|
+
>
|
|
224
|
+
<div className="flex">
|
|
225
|
+
<div>
|
|
226
|
+
<Typography
|
|
227
|
+
variant="h6"
|
|
228
|
+
className="text-sm font-semibold text-black-500"
|
|
229
|
+
>
|
|
230
|
+
{option.name}
|
|
231
|
+
</Typography>
|
|
232
|
+
<Typography
|
|
233
|
+
variant="lead"
|
|
234
|
+
className="text-xs font-semibold text-gray-400"
|
|
235
|
+
>
|
|
236
|
+
{scopeT("avlBalance")}: {option.balance}
|
|
237
|
+
</Typography>
|
|
238
|
+
</div>
|
|
239
|
+
</div>
|
|
240
|
+
</MenuItem>
|
|
241
|
+
);
|
|
242
|
+
})}{" "}
|
|
243
|
+
</MenuList>
|
|
244
|
+
</Menu>
|
|
245
|
+
<Typography
|
|
246
|
+
variant="lead"
|
|
247
|
+
className="text-xs font-semibold text-gray-300 my-2"
|
|
248
|
+
>
|
|
249
|
+
{scopeT("amount")} : {optionAmountToPay}
|
|
250
|
+
</Typography>
|
|
251
|
+
{showCommissions && selectedOption.commissions?.option && (
|
|
252
|
+
<Typography
|
|
253
|
+
variant="lead"
|
|
254
|
+
className="text-xs font-medium text-slate-500"
|
|
255
|
+
>
|
|
256
|
+
CV: {selectedOption.commissions.option.cv} VP:{" "}
|
|
257
|
+
{selectedOption.commissions.option.vp}
|
|
258
|
+
</Typography>
|
|
259
|
+
)}
|
|
260
|
+
</div>
|
|
261
|
+
</div>
|
|
262
|
+
</div>
|
|
263
|
+
<div className="text-center mt-4">
|
|
264
|
+
<Typography
|
|
265
|
+
variant="lead"
|
|
266
|
+
className="text-base font-normal text-black-500"
|
|
267
|
+
>
|
|
268
|
+
{scopeT("grandTotal")}: <strong> $ {grandTotal} </strong>
|
|
269
|
+
</Typography>
|
|
270
|
+
</div>
|
|
271
|
+
|
|
272
|
+
{showCommissions && (
|
|
273
|
+
<div className="text-center mt-3">
|
|
274
|
+
<Typography
|
|
275
|
+
variant="lead"
|
|
276
|
+
className="text-sm font-normal text-black-500"
|
|
277
|
+
>
|
|
278
|
+
CV: <strong>{commission?.totalCV}</strong> VP:{" "}
|
|
279
|
+
<strong>{commission?.totalVP}</strong>
|
|
280
|
+
</Typography>
|
|
281
|
+
</div>
|
|
282
|
+
)}
|
|
283
|
+
|
|
284
|
+
<div className="w-[70%] mx-auto grid grid-cols-1 md:grid-cols-2 gap-5 mt-6">
|
|
285
|
+
{+selectedOption.balance < optionAmountToPay && (
|
|
286
|
+
<div className="flex flex-col justify-between text-center text-orange-500 bg-orange-50 border border-orange-300 px-3 py-4 rounded-lg">
|
|
287
|
+
<Typography
|
|
288
|
+
variant="lead"
|
|
289
|
+
className="text-xs text-center leading-5 font-medium break-words"
|
|
290
|
+
>
|
|
291
|
+
{scopeT("insufficientBalance")} <br />
|
|
292
|
+
{selectedOption.name}: {selectedOption.balance} <br />
|
|
293
|
+
</Typography>
|
|
294
|
+
<CustomNextLink
|
|
295
|
+
target="_blank"
|
|
296
|
+
className="underline font-semibold text-sm mt-3 block text-purple-500 hover:text-purple-600"
|
|
297
|
+
href={ROUTES.dashboard.nodeLinkDeposit}
|
|
298
|
+
>
|
|
299
|
+
{scopeT("depositBtn")}
|
|
300
|
+
</CustomNextLink>
|
|
301
|
+
</div>
|
|
302
|
+
)}
|
|
303
|
+
|
|
304
|
+
{+asset.balance < baseAmountToPay && (
|
|
305
|
+
<div className="flex flex-col justify-between text-center text-orange-500 bg-orange-50 border border-orange-300 px-3 py-4 rounded-lg">
|
|
306
|
+
<Typography
|
|
307
|
+
variant="lead"
|
|
308
|
+
className="text-xs text-center leading-5 font-medium break-words"
|
|
309
|
+
>
|
|
310
|
+
{scopeT("insufficientBalance")} <br />
|
|
311
|
+
{asset.name}: {asset.balance} <br />
|
|
312
|
+
</Typography>
|
|
313
|
+
<CustomNextLink
|
|
314
|
+
target="_blank"
|
|
315
|
+
className="underline font-semibold text-sm mt-3 block text-purple-500 hover:text-purple-600"
|
|
316
|
+
href={ROUTES.dashboard.nodeLinkDeposit}
|
|
317
|
+
>
|
|
318
|
+
{scopeT("depositBtn")}
|
|
319
|
+
</CustomNextLink>
|
|
320
|
+
</div>
|
|
321
|
+
)}
|
|
322
|
+
</div>
|
|
323
|
+
</div>
|
|
324
|
+
</>
|
|
325
|
+
);
|
|
326
|
+
}
|