@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,131 @@
|
|
|
1
|
+
import { Typography } from "@material-tailwind/react";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import {
|
|
4
|
+
HTMLInputTypeAttribute,
|
|
5
|
+
useCallback,
|
|
6
|
+
useEffect,
|
|
7
|
+
useState,
|
|
8
|
+
} from "react";
|
|
9
|
+
import { UseFormReturn } from "react-hook-form";
|
|
10
|
+
|
|
11
|
+
import { countriesStore } from "../stores/countriesStore";
|
|
12
|
+
import { useFormStore } from "../stores/formStore";
|
|
13
|
+
import { SelectWithSearch } from "./SelectComponent";
|
|
14
|
+
|
|
15
|
+
export interface InputFieldProps {
|
|
16
|
+
title: string;
|
|
17
|
+
placeholder?: string;
|
|
18
|
+
type?: HTMLInputTypeAttribute;
|
|
19
|
+
name?: string;
|
|
20
|
+
formId: string;
|
|
21
|
+
onStateSelected?: (value: number | string | any) => void;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function SelectPickUpStore({
|
|
25
|
+
className,
|
|
26
|
+
title,
|
|
27
|
+
placeholder,
|
|
28
|
+
name,
|
|
29
|
+
formId,
|
|
30
|
+
onStateSelected,
|
|
31
|
+
}) {
|
|
32
|
+
const { stores, setStores } = countriesStore();
|
|
33
|
+
|
|
34
|
+
const { reactHookUseForm } = useFormStore();
|
|
35
|
+
const { register, formState, setValue, watch } =
|
|
36
|
+
(reactHookUseForm as { [key: string]: UseFormReturn<any> })?.[formId] ?? {};
|
|
37
|
+
const { errors } = formState ?? {};
|
|
38
|
+
const [error, setError] = useState<any>(null);
|
|
39
|
+
const fieldKey = name ?? title?.toLowerCase();
|
|
40
|
+
|
|
41
|
+
const watchField = watch?.(`${fieldKey}`);
|
|
42
|
+
const formValues = watch?.();
|
|
43
|
+
|
|
44
|
+
const checkError = useCallback(() => {
|
|
45
|
+
if (errors?.[fieldKey]) {
|
|
46
|
+
setError(errors[fieldKey]);
|
|
47
|
+
} else {
|
|
48
|
+
setError(null);
|
|
49
|
+
}
|
|
50
|
+
}, [errors, fieldKey]);
|
|
51
|
+
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
setTimeout(() => {
|
|
54
|
+
checkError();
|
|
55
|
+
}, 100);
|
|
56
|
+
}, [watchField, checkError]);
|
|
57
|
+
|
|
58
|
+
const handleOnChange = (value: any) => {
|
|
59
|
+
setValue(`${fieldKey}`, +value.id, {
|
|
60
|
+
shouldValidate: true,
|
|
61
|
+
});
|
|
62
|
+
onStateSelected({
|
|
63
|
+
storeId: value.id,
|
|
64
|
+
countryId: formValues.countryId,
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
setStores([]);
|
|
69
|
+
}, [setStores]);
|
|
70
|
+
|
|
71
|
+
if (!reactHookUseForm || !register) return <></>;
|
|
72
|
+
|
|
73
|
+
return (
|
|
74
|
+
<>
|
|
75
|
+
<Typography
|
|
76
|
+
variant="lead"
|
|
77
|
+
className="text-xs font-medium text-black-400 mb-1"
|
|
78
|
+
>
|
|
79
|
+
{title}
|
|
80
|
+
</Typography>
|
|
81
|
+
|
|
82
|
+
<SelectWithSearch
|
|
83
|
+
maxHeightOpened={235}
|
|
84
|
+
className={`p-3
|
|
85
|
+
w-full min-w-full h-10 text-sm
|
|
86
|
+
bg-white rounded-md
|
|
87
|
+
text-gray-900
|
|
88
|
+
shadow-gray-200/5
|
|
89
|
+
ring-4 ring-transparent
|
|
90
|
+
placeholder:text-gray-300 placeholder:opacity-100
|
|
91
|
+
!border !border-slate-100 !border-t-slate-100
|
|
92
|
+
${error ? "!border-red-500 ring-red-50 bg-red-100/10" : "!border-t-slate-100"}
|
|
93
|
+
focus:!border-slate-300
|
|
94
|
+
focus:ring-gray-300/10
|
|
95
|
+
focus:bg-offWhite
|
|
96
|
+
shadow-none ${className}
|
|
97
|
+
`}
|
|
98
|
+
items={stores}
|
|
99
|
+
searchKey="name"
|
|
100
|
+
placeholder={placeholder}
|
|
101
|
+
renderOption={(_item, state) => {
|
|
102
|
+
if (state)
|
|
103
|
+
return (
|
|
104
|
+
<div
|
|
105
|
+
key={state.id}
|
|
106
|
+
className={
|
|
107
|
+
state.id === watchField
|
|
108
|
+
? "flex items-center gap-2 pointer-events-none text-sm font-medium"
|
|
109
|
+
: "flex items-center gap-2 text-sm font-medium"
|
|
110
|
+
}
|
|
111
|
+
>
|
|
112
|
+
{state.name}
|
|
113
|
+
</div>
|
|
114
|
+
);
|
|
115
|
+
}}
|
|
116
|
+
value={stores?.find((item) => item.id === watchField) || null}
|
|
117
|
+
setValue={(value) => {
|
|
118
|
+
handleOnChange(value);
|
|
119
|
+
}}
|
|
120
|
+
/>
|
|
121
|
+
{error && (
|
|
122
|
+
<Typography
|
|
123
|
+
variant="lead"
|
|
124
|
+
className="text-red-500 font-normal text-xs px-1 block md:absolute -bottom-[1.1rem] left-0"
|
|
125
|
+
>
|
|
126
|
+
{error?.message}
|
|
127
|
+
</Typography>
|
|
128
|
+
)}
|
|
129
|
+
</>
|
|
130
|
+
);
|
|
131
|
+
}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { Typography } from "@material-tailwind/react";
|
|
2
|
+
import React, { useMemo } from "react";
|
|
3
|
+
import {
|
|
4
|
+
HTMLInputTypeAttribute,
|
|
5
|
+
useCallback,
|
|
6
|
+
useEffect,
|
|
7
|
+
useState,
|
|
8
|
+
} from "react";
|
|
9
|
+
import { UseFormReturn } from "react-hook-form";
|
|
10
|
+
|
|
11
|
+
import { countriesStore } from "../stores/countriesStore";
|
|
12
|
+
import { useFormStore } from "../stores/formStore";
|
|
13
|
+
import { renderTitleWithRedAsterisk } from "../utils/app.util";
|
|
14
|
+
import { SelectWithSearch } from "./SelectComponent";
|
|
15
|
+
|
|
16
|
+
export interface InputFieldProps {
|
|
17
|
+
title: string;
|
|
18
|
+
placeholder?: string;
|
|
19
|
+
type?: HTMLInputTypeAttribute;
|
|
20
|
+
name?: string;
|
|
21
|
+
forShipping?: boolean;
|
|
22
|
+
formId: string;
|
|
23
|
+
onStateSelected?: (value: number | string | any) => void;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function SelectStates({
|
|
27
|
+
className,
|
|
28
|
+
title,
|
|
29
|
+
placeholder,
|
|
30
|
+
name,
|
|
31
|
+
formId,
|
|
32
|
+
onStateSelected,
|
|
33
|
+
forShipping = false,
|
|
34
|
+
}) {
|
|
35
|
+
const { states, shippingStates, setCities, setShippingCities } =
|
|
36
|
+
countriesStore();
|
|
37
|
+
const filteredStates = useMemo(() => {
|
|
38
|
+
return forShipping ? shippingStates : states;
|
|
39
|
+
}, [states, shippingStates, forShipping]);
|
|
40
|
+
const { reactHookUseForm } = useFormStore();
|
|
41
|
+
const { register, formState, setValue, watch } =
|
|
42
|
+
(reactHookUseForm as { [key: string]: UseFormReturn<any> })?.[formId] ?? {};
|
|
43
|
+
const { errors } = formState ?? {};
|
|
44
|
+
const [error, setError] = useState<any>(null);
|
|
45
|
+
const fieldKey = name ?? title?.toLowerCase();
|
|
46
|
+
|
|
47
|
+
const watchField = watch?.(`${fieldKey}`);
|
|
48
|
+
const formValues = watch?.();
|
|
49
|
+
|
|
50
|
+
const checkError = useCallback(() => {
|
|
51
|
+
if (errors?.[fieldKey]) {
|
|
52
|
+
setError(errors[fieldKey]);
|
|
53
|
+
} else {
|
|
54
|
+
setError(null);
|
|
55
|
+
}
|
|
56
|
+
}, [errors, fieldKey]);
|
|
57
|
+
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
setTimeout(() => {
|
|
60
|
+
checkError();
|
|
61
|
+
}, 100);
|
|
62
|
+
}, [watchField, checkError]);
|
|
63
|
+
|
|
64
|
+
const handleOnChange = (value: any) => {
|
|
65
|
+
setValue(`${fieldKey}`, +value.id, {
|
|
66
|
+
shouldValidate: true,
|
|
67
|
+
});
|
|
68
|
+
if (forShipping) {
|
|
69
|
+
setShippingCities([]);
|
|
70
|
+
} else {
|
|
71
|
+
setCities([]);
|
|
72
|
+
}
|
|
73
|
+
setValue("city", "");
|
|
74
|
+
onStateSelected({
|
|
75
|
+
stateId: value.id,
|
|
76
|
+
countryId: formValues.countryId,
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
if (!reactHookUseForm || !register) return <></>;
|
|
81
|
+
|
|
82
|
+
return (
|
|
83
|
+
<>
|
|
84
|
+
<Typography
|
|
85
|
+
variant="lead"
|
|
86
|
+
className="text-xs font-medium text-black-400 mb-1"
|
|
87
|
+
>
|
|
88
|
+
{renderTitleWithRedAsterisk(title)}
|
|
89
|
+
</Typography>
|
|
90
|
+
|
|
91
|
+
<SelectWithSearch
|
|
92
|
+
maxHeightOpened={235}
|
|
93
|
+
className={` p-3
|
|
94
|
+
w-full min-w-full h-10 text-base
|
|
95
|
+
bg-white rounded-md
|
|
96
|
+
text-gray-900
|
|
97
|
+
shadow-gray-200/5
|
|
98
|
+
ring-4 ring-transparent
|
|
99
|
+
placeholder:text-gray-300 placeholder:opacity-100
|
|
100
|
+
!border !border-slate-100 !border-t-slate-100
|
|
101
|
+
${error ? "!border-red-500 !border-t-red-500 ring-red-50 bg-red-100/10" : "!border-t-slate-100"}
|
|
102
|
+
focus:!border-slate-300
|
|
103
|
+
focus:ring-gray-300/10
|
|
104
|
+
focus:bg-offWhite
|
|
105
|
+
shadow-none ${className}
|
|
106
|
+
`}
|
|
107
|
+
items={filteredStates}
|
|
108
|
+
searchKey="name"
|
|
109
|
+
placeholder={placeholder}
|
|
110
|
+
renderOption={(_item, state) => {
|
|
111
|
+
if (state)
|
|
112
|
+
return (
|
|
113
|
+
<div
|
|
114
|
+
key={state.id}
|
|
115
|
+
className={
|
|
116
|
+
state.id === watchField
|
|
117
|
+
? "flex items-center gap-2 pointer-events-none text-xs font-normal"
|
|
118
|
+
: "flex items-center gap-2 text-xs font-normal"
|
|
119
|
+
}
|
|
120
|
+
>
|
|
121
|
+
{state.name}
|
|
122
|
+
</div>
|
|
123
|
+
);
|
|
124
|
+
}}
|
|
125
|
+
value={
|
|
126
|
+
filteredStates?.find((item) => item.id === watchField) ||
|
|
127
|
+
filteredStates?.find((item) => item.name === watchField) ||
|
|
128
|
+
null
|
|
129
|
+
}
|
|
130
|
+
setValue={(value) => {
|
|
131
|
+
handleOnChange(value);
|
|
132
|
+
}}
|
|
133
|
+
/>
|
|
134
|
+
{error && (
|
|
135
|
+
<Typography
|
|
136
|
+
variant="lead"
|
|
137
|
+
className="text-red-500 font-normal text-xs px-1 block md:absolute -bottom-[1.1rem] left-0"
|
|
138
|
+
>
|
|
139
|
+
{error?.message}
|
|
140
|
+
</Typography>
|
|
141
|
+
)}
|
|
142
|
+
</>
|
|
143
|
+
);
|
|
144
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { Typography } from "@material-tailwind/react";
|
|
2
|
+
import { useEffect, useRef, useState } from "react";
|
|
3
|
+
|
|
4
|
+
import { _useScopedI18n } from "../i18n/client";
|
|
5
|
+
|
|
6
|
+
export type ServerTimeProps = {
|
|
7
|
+
className?: string;
|
|
8
|
+
overrideClass?: boolean;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export type TimerType = {
|
|
12
|
+
hours: string;
|
|
13
|
+
minutes: string;
|
|
14
|
+
seconds: string;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export default function ServerTime({
|
|
18
|
+
className,
|
|
19
|
+
overrideClass,
|
|
20
|
+
}: ServerTimeProps) {
|
|
21
|
+
//
|
|
22
|
+
const scopeT = _useScopedI18n("sharedComponents.serverTime");
|
|
23
|
+
|
|
24
|
+
const timerInterval = useRef<NodeJS.Timeout | undefined>(undefined);
|
|
25
|
+
|
|
26
|
+
const [time, setTime] = useState<TimerType>({
|
|
27
|
+
hours: `00`,
|
|
28
|
+
minutes: `00`,
|
|
29
|
+
seconds: `00`,
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
timerInterval.current = setInterval(async () => {
|
|
34
|
+
const now = new Date();
|
|
35
|
+
const hours = now.getUTCHours().toString().padStart(2, "0");
|
|
36
|
+
const minutes = now.getUTCMinutes().toString().padStart(2, "0");
|
|
37
|
+
const seconds = now.getUTCSeconds().toString().padStart(2, "0");
|
|
38
|
+
setTime({
|
|
39
|
+
hours,
|
|
40
|
+
minutes,
|
|
41
|
+
seconds,
|
|
42
|
+
});
|
|
43
|
+
}, 1000);
|
|
44
|
+
|
|
45
|
+
return () => timerInterval.current && clearInterval(timerInterval.current);
|
|
46
|
+
}, []);
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<>
|
|
50
|
+
<Typography
|
|
51
|
+
variant="h6"
|
|
52
|
+
className={
|
|
53
|
+
!overrideClass
|
|
54
|
+
? `flex flex-row text-xs font-medium text-center text-black-400 bg-gray-50 py-3 md:py-2.5 px-4 rounded-xl justify-center whitespace-nowrap ${className}`
|
|
55
|
+
: className
|
|
56
|
+
}
|
|
57
|
+
>
|
|
58
|
+
{scopeT("title")} :
|
|
59
|
+
<div className="flex">
|
|
60
|
+
<span className="w-5 text-center">{time.hours}</span>:
|
|
61
|
+
<span className="w-5 text-center">{time.minutes}</span>:
|
|
62
|
+
<span className="w-5 text-center mr-1">{time.seconds}</span>
|
|
63
|
+
</div>{" "}
|
|
64
|
+
UTC
|
|
65
|
+
</Typography>
|
|
66
|
+
</>
|
|
67
|
+
);
|
|
68
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
Dialog,
|
|
5
|
+
DialogBody,
|
|
6
|
+
DialogFooter,
|
|
7
|
+
DialogHeader,
|
|
8
|
+
} from "@material-tailwind/react";
|
|
9
|
+
import React from "react";
|
|
10
|
+
|
|
11
|
+
import SessionIcon from "../../public/img/session-expired.png";
|
|
12
|
+
import { _useScopedI18n } from "../i18n/client";
|
|
13
|
+
import ButtonCustom from "./Button";
|
|
14
|
+
import CustomNextImage from "./CustomNextImage";
|
|
15
|
+
|
|
16
|
+
export type SessionDialogComponentProps = {
|
|
17
|
+
isExpired: boolean;
|
|
18
|
+
callBackFn?: () => void;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export function SessionDialogComponent({
|
|
22
|
+
isExpired,
|
|
23
|
+
callBackFn,
|
|
24
|
+
}: SessionDialogComponentProps) {
|
|
25
|
+
//
|
|
26
|
+
const scopeT = _useScopedI18n("sharedComponents.sessionDialogComponent");
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<>
|
|
30
|
+
<Dialog
|
|
31
|
+
open={isExpired}
|
|
32
|
+
handler={callBackFn}
|
|
33
|
+
size="xs"
|
|
34
|
+
className="md:!max-w-[450px] md:!min-w-[450px] py-8 md:py-4 px-0 md:p-7 flex flex-col items-center justify-center"
|
|
35
|
+
style={{ zIndex: "99999999 !important" }}
|
|
36
|
+
>
|
|
37
|
+
<></>
|
|
38
|
+
<CustomNextImage
|
|
39
|
+
src={SessionIcon.src}
|
|
40
|
+
alt="SessionIcon"
|
|
41
|
+
width={80}
|
|
42
|
+
height={80}
|
|
43
|
+
/>
|
|
44
|
+
<DialogHeader className="text-lg font-semibold text-black-500 pb-0 text-center">
|
|
45
|
+
{" "}
|
|
46
|
+
{scopeT("header")}{" "}
|
|
47
|
+
</DialogHeader>
|
|
48
|
+
<div className="w-24 h-1 mx-auto rounded-full header-underline mt-2"></div>
|
|
49
|
+
<DialogBody className="text-sm text-slate-400 font-medium text-center">
|
|
50
|
+
{scopeT("message")}
|
|
51
|
+
</DialogBody>
|
|
52
|
+
<DialogFooter className="pb-0">
|
|
53
|
+
<ButtonCustom icon={undefined} onClick={callBackFn}>
|
|
54
|
+
{scopeT("redirectBtn")}
|
|
55
|
+
</ButtonCustom>
|
|
56
|
+
</DialogFooter>
|
|
57
|
+
</Dialog>
|
|
58
|
+
</>
|
|
59
|
+
);
|
|
60
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { IconButton, Typography } from "@material-tailwind/react";
|
|
2
|
+
import { Dialog, DialogBody, DialogHeader } from "@material-tailwind/react";
|
|
3
|
+
import { IoIosCloseCircleOutline } from "react-icons/io";
|
|
4
|
+
|
|
5
|
+
import { AddressFormComponentProps } from "../components/AddressFormComponent";
|
|
6
|
+
import AddressShippingFormComponent from "./AddressShippingFormComponent";
|
|
7
|
+
|
|
8
|
+
export function ShippingAddressFormDialogComponent({
|
|
9
|
+
open,
|
|
10
|
+
handleOpen,
|
|
11
|
+
formId,
|
|
12
|
+
isLoading,
|
|
13
|
+
proceedSubmit,
|
|
14
|
+
}: {
|
|
15
|
+
open: boolean;
|
|
16
|
+
handleOpen: any;
|
|
17
|
+
} & AddressFormComponentProps) {
|
|
18
|
+
return (
|
|
19
|
+
<>
|
|
20
|
+
<Dialog
|
|
21
|
+
open={open}
|
|
22
|
+
handler={handleOpen}
|
|
23
|
+
className="lg:min-w-[600px] md:min-w[400px]"
|
|
24
|
+
style={{ maxWidth: "600px", zIndex: 1000 }}
|
|
25
|
+
>
|
|
26
|
+
<DialogHeader className="p-3 md:pb-0 flex items-center justify-between">
|
|
27
|
+
<Typography
|
|
28
|
+
variant="h5"
|
|
29
|
+
className="text-base font-semibold text-black-500"
|
|
30
|
+
>
|
|
31
|
+
Add New Shipping address
|
|
32
|
+
</Typography>
|
|
33
|
+
<IconButton size="sm" variant="text" onClick={handleOpen}>
|
|
34
|
+
<IoIosCloseCircleOutline className="w-6 h-6 text-black-500 cursor-pointer" />
|
|
35
|
+
</IconButton>
|
|
36
|
+
</DialogHeader>
|
|
37
|
+
<DialogBody className="p-3 md:p-4 pb-4 max-h-[80vh] overflow-y-auto overflow-x-hidden">
|
|
38
|
+
<AddressShippingFormComponent
|
|
39
|
+
formId={formId}
|
|
40
|
+
isLoading={isLoading}
|
|
41
|
+
proceedSubmit={proceedSubmit}
|
|
42
|
+
onCancel={() => handleOpen(false)}
|
|
43
|
+
/>
|
|
44
|
+
</DialogBody>
|
|
45
|
+
{/* <DialogFooter>
|
|
46
|
+
<></>
|
|
47
|
+
</DialogFooter> */}
|
|
48
|
+
</Dialog>
|
|
49
|
+
</>
|
|
50
|
+
);
|
|
51
|
+
}
|