@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,108 @@
|
|
|
1
|
+
// user store
|
|
2
|
+
import { create } from "zustand";
|
|
3
|
+
import { createJSONStorage, persist } from "zustand/middleware";
|
|
4
|
+
|
|
5
|
+
import { CATEGORY_FOR_SMART_PAY } from "../constants/app";
|
|
6
|
+
import { ICart, UserAddress } from "../types/cart";
|
|
7
|
+
|
|
8
|
+
interface ICommissionEligibilityFound {
|
|
9
|
+
status: boolean;
|
|
10
|
+
data?: Array<string>;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export type StoreType = {
|
|
14
|
+
cart: ICart | null;
|
|
15
|
+
cartQty: number;
|
|
16
|
+
haveSmartPay?: boolean;
|
|
17
|
+
loading: boolean;
|
|
18
|
+
userBillingAddress: UserAddress[];
|
|
19
|
+
userShippingAddress: UserAddress[];
|
|
20
|
+
commissionNonEligibleFound: ICommissionEligibilityFound;
|
|
21
|
+
paymentMethods: any;
|
|
22
|
+
setPaymentMethods: (methods: any) => void;
|
|
23
|
+
setUserBillingAddress: (address: UserAddress[]) => void;
|
|
24
|
+
setUserShippingAddress: (address: UserAddress[]) => void;
|
|
25
|
+
setCart: (cartData: ICart | null) => void;
|
|
26
|
+
setLoading: (newLoading: boolean) => void;
|
|
27
|
+
refechCart?: () => void | null;
|
|
28
|
+
setRefechCart: (fn: () => void) => void;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const checkSmartPayCategory = (cartProducts: any[]): boolean => {
|
|
32
|
+
return cartProducts?.some(
|
|
33
|
+
(item) => item.product?.category?.code === CATEGORY_FOR_SMART_PAY,
|
|
34
|
+
);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const getTotalProductQuantity = (cartProducts: any[]): number => {
|
|
38
|
+
if (!cartProducts || cartProducts?.length === 0) return 0;
|
|
39
|
+
let totalQuantity = 0;
|
|
40
|
+
cartProducts.forEach((item) => {
|
|
41
|
+
const itemQuantity = Number(item.quantity);
|
|
42
|
+
if (!isNaN(itemQuantity)) {
|
|
43
|
+
totalQuantity += itemQuantity;
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
return totalQuantity;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const checkNonEligibleProductForCommission = (
|
|
50
|
+
cartProducts: any[],
|
|
51
|
+
): ICommissionEligibilityFound => {
|
|
52
|
+
let status = false;
|
|
53
|
+
let data = [];
|
|
54
|
+
|
|
55
|
+
if (cartProducts) {
|
|
56
|
+
cartProducts.forEach((item) => {
|
|
57
|
+
if (item.isEligibleForCommission === false) {
|
|
58
|
+
status = true;
|
|
59
|
+
data.push(`${item.product.category.name}`);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return {
|
|
65
|
+
status,
|
|
66
|
+
data,
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export const useCartStore = create<StoreType>()(
|
|
71
|
+
persist(
|
|
72
|
+
(set, get) => ({
|
|
73
|
+
cart: get()?.cart ?? null, // Initial state for cart info
|
|
74
|
+
cartQty: get()?.cartQty ?? 0,
|
|
75
|
+
loading: true, // Tracks if cart data is loading
|
|
76
|
+
userBillingAddress: get()?.userBillingAddress ?? null,
|
|
77
|
+
userShippingAddress: get()?.userShippingAddress ?? null,
|
|
78
|
+
commissionNonEligibleFound: get()?.commissionNonEligibleFound ?? {
|
|
79
|
+
status: false,
|
|
80
|
+
},
|
|
81
|
+
refechCart: undefined,
|
|
82
|
+
paymentMethods: get()?.paymentMethods ?? null,
|
|
83
|
+
setCart: (data: ICart | null) =>
|
|
84
|
+
set({
|
|
85
|
+
cart: data,
|
|
86
|
+
haveSmartPay: data
|
|
87
|
+
? checkSmartPayCategory(data?.cartProducts)
|
|
88
|
+
: false,
|
|
89
|
+
cartQty: data ? getTotalProductQuantity(data?.cartProducts) : 0,
|
|
90
|
+
commissionNonEligibleFound: checkNonEligibleProductForCommission(
|
|
91
|
+
data?.cartProducts,
|
|
92
|
+
),
|
|
93
|
+
loading: false,
|
|
94
|
+
}), // Action to update
|
|
95
|
+
setLoading: (state: boolean) => set({ loading: state }), // Action to update loading state
|
|
96
|
+
setUserBillingAddress: (address: UserAddress[]) =>
|
|
97
|
+
set({ userBillingAddress: address }),
|
|
98
|
+
setUserShippingAddress: (address: UserAddress[]) =>
|
|
99
|
+
set({ userShippingAddress: address }),
|
|
100
|
+
setRefechCart: (fn: () => void) => set({ refechCart: fn }),
|
|
101
|
+
setPaymentMethods: (methods: any) => set({ paymentMethods: methods }),
|
|
102
|
+
}),
|
|
103
|
+
{
|
|
104
|
+
name: "cartStore",
|
|
105
|
+
storage: createJSONStorage(() => localStorage),
|
|
106
|
+
},
|
|
107
|
+
),
|
|
108
|
+
);
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// user store
|
|
2
|
+
import { create } from "zustand";
|
|
3
|
+
import { createJSONStorage, persist } from "zustand/middleware";
|
|
4
|
+
|
|
5
|
+
import { ICountries } from "../types/addressForm";
|
|
6
|
+
|
|
7
|
+
export type StoreType = {
|
|
8
|
+
countries: ICountries[] | null;
|
|
9
|
+
shippingCountries: ICountries[] | null;
|
|
10
|
+
states: any[] | null;
|
|
11
|
+
shippingStates: any[] | null;
|
|
12
|
+
stores: any[] | null;
|
|
13
|
+
cities: any[] | null;
|
|
14
|
+
shippingCities: any[] | null;
|
|
15
|
+
loading: boolean;
|
|
16
|
+
loadingCities: boolean;
|
|
17
|
+
loadingShippingCities: boolean;
|
|
18
|
+
setCountries: (countries: ICountries[] | null) => void;
|
|
19
|
+
setShippingCountries: (countries: ICountries[] | null) => void;
|
|
20
|
+
setStates: (states: any[] | null) => void;
|
|
21
|
+
setShippingStates: (shippingStates: any[] | null) => void;
|
|
22
|
+
setStores: (stores: any[] | null) => void;
|
|
23
|
+
setCities: (cities: any[] | null) => void;
|
|
24
|
+
setShippingCities: (shippingCities: any[] | null) => void;
|
|
25
|
+
setLoading: (newLoading: boolean) => void;
|
|
26
|
+
setLoadingCities: (newLoading: boolean) => void;
|
|
27
|
+
setShippingLoadingCities: (loadingShippingCities: boolean) => void;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export const countriesStore = create<StoreType>()(
|
|
31
|
+
persist(
|
|
32
|
+
(set, get) => ({
|
|
33
|
+
countries: get()?.countries ?? null,
|
|
34
|
+
shippingCountries: get()?.shippingCountries ?? null,
|
|
35
|
+
states: [],
|
|
36
|
+
shippingStates: [],
|
|
37
|
+
cities: [],
|
|
38
|
+
shippingCities: [],
|
|
39
|
+
stores: [],
|
|
40
|
+
loading: true,
|
|
41
|
+
loadingCities: true,
|
|
42
|
+
loadingShippingCities: true,
|
|
43
|
+
setCountries: (newCountries: ICountries[]) =>
|
|
44
|
+
set({ countries: newCountries }),
|
|
45
|
+
setShippingCountries: (newCountries: ICountries[]) =>
|
|
46
|
+
set({ shippingCountries: newCountries }),
|
|
47
|
+
setStates: (newStates: any) => set({ states: newStates }),
|
|
48
|
+
setShippingStates: (newStates: any) => set({ shippingStates: newStates }),
|
|
49
|
+
setStores: (newStores: any) => set({ stores: newStores }),
|
|
50
|
+
setCities: (newCities: any) => set({ cities: newCities }),
|
|
51
|
+
setShippingCities: (newCities: any) => set({ shippingCities: newCities }),
|
|
52
|
+
setLoading: (newLoading: any) => set({ loading: newLoading }),
|
|
53
|
+
setLoadingCities: (newLoading: any) => set({ loadingCities: newLoading }),
|
|
54
|
+
setShippingLoadingCities: (newLoading: any) =>
|
|
55
|
+
set({ loadingShippingCities: newLoading }),
|
|
56
|
+
}),
|
|
57
|
+
{
|
|
58
|
+
name: "countriesStore",
|
|
59
|
+
storage: createJSONStorage(() => localStorage),
|
|
60
|
+
},
|
|
61
|
+
),
|
|
62
|
+
);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { FieldValues, UseFormReturn } from "react-hook-form";
|
|
2
|
+
import { create } from "zustand";
|
|
3
|
+
|
|
4
|
+
export interface FormStoreType<T extends FieldValues> {
|
|
5
|
+
reactHookUseForm: { [key: string]: UseFormReturn<T> };
|
|
6
|
+
setReactHookUseForm: (data: { [key: string]: UseFormReturn<any> }) => void;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const useFormStore = create<FormStoreType<any>>()((set) => ({
|
|
10
|
+
reactHookUseForm: {}, // Initial state
|
|
11
|
+
setReactHookUseForm: (data: { [key: string]: UseFormReturn<any> }) => {
|
|
12
|
+
set((state) => ({
|
|
13
|
+
reactHookUseForm: {
|
|
14
|
+
...state.reactHookUseForm,
|
|
15
|
+
...data,
|
|
16
|
+
},
|
|
17
|
+
}));
|
|
18
|
+
}, // Action to update
|
|
19
|
+
}));
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// app loading store
|
|
2
|
+
import { create } from "zustand";
|
|
3
|
+
|
|
4
|
+
export type StoreType = {
|
|
5
|
+
loading: boolean;
|
|
6
|
+
setLoading: (newLoading: boolean) => void;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export const useLoadingStore = create<StoreType>()((set) => ({
|
|
10
|
+
loading: false,
|
|
11
|
+
setLoading: (status: boolean) => set({ loading: status }),
|
|
12
|
+
}));
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// user store
|
|
2
|
+
import { create } from "zustand";
|
|
3
|
+
import { createJSONStorage, persist } from "zustand/middleware";
|
|
4
|
+
|
|
5
|
+
import { IUserProfile } from "../types/user";
|
|
6
|
+
|
|
7
|
+
export type StoreType = {
|
|
8
|
+
user: IUserProfile | null;
|
|
9
|
+
loading: boolean;
|
|
10
|
+
userConnected: boolean;
|
|
11
|
+
setUser: (userData: IUserProfile | null) => void;
|
|
12
|
+
setLoading: (newLoading: boolean) => void;
|
|
13
|
+
setUserConnected: (connectedStatus: boolean) => void;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const useUserStore = create<StoreType>()(
|
|
17
|
+
persist(
|
|
18
|
+
(set, get) => ({
|
|
19
|
+
user: get()?.user ?? null, // Initial state for user info
|
|
20
|
+
loading: true, // Tracks if user data is loading
|
|
21
|
+
userConnected: get()?.userConnected ?? false, // initial user auth status
|
|
22
|
+
setUser: (newUser: any) => set({ user: newUser, userConnected: true }), // Action to update user info
|
|
23
|
+
setLoading: (newLoading: any) => set({ loading: newLoading }), // Action to update loading state
|
|
24
|
+
setUserConnected: (connectedStatus: boolean) =>
|
|
25
|
+
set({ userConnected: connectedStatus }), // Action to update the user auth status
|
|
26
|
+
}),
|
|
27
|
+
{
|
|
28
|
+
name: "userStore",
|
|
29
|
+
storage: createJSONStorage(() => sessionStorage),
|
|
30
|
+
},
|
|
31
|
+
),
|
|
32
|
+
);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { JSX } from "react";
|
|
2
|
+
|
|
3
|
+
export type SelectComponentProps = {
|
|
4
|
+
id?: string;
|
|
5
|
+
style?: React.CSSProperties;
|
|
6
|
+
className?: string;
|
|
7
|
+
classNameLabel?: string;
|
|
8
|
+
classNameOpened?: string;
|
|
9
|
+
classNameOption?: string;
|
|
10
|
+
classNamePlaceholder?: string;
|
|
11
|
+
classNameSearchInput?: string;
|
|
12
|
+
label?: string;
|
|
13
|
+
placeholder?: string;
|
|
14
|
+
value: any;
|
|
15
|
+
setValue: (value: any) => void;
|
|
16
|
+
items: any[];
|
|
17
|
+
labelKey?: string;
|
|
18
|
+
searchKey?: string;
|
|
19
|
+
icon?: JSX.Element;
|
|
20
|
+
iconTransitionSpeed?: number;
|
|
21
|
+
scrollToTopOnClose?: boolean;
|
|
22
|
+
disabled?: boolean;
|
|
23
|
+
maxHeightOpened?: number;
|
|
24
|
+
styleOpened?: React.CSSProperties;
|
|
25
|
+
styleClosed?: React.CSSProperties;
|
|
26
|
+
onSelectOpen?: () => void;
|
|
27
|
+
onSelectClose?: () => void;
|
|
28
|
+
onSelectChange?: (value: any) => void;
|
|
29
|
+
renderOption?: (item: any, fullItem: any) => React.ReactNode;
|
|
30
|
+
renderPlaceholder?: (item: any) => React.ReactNode;
|
|
31
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export type AddressForm = {
|
|
2
|
+
firstName: string;
|
|
3
|
+
lastName: string;
|
|
4
|
+
address: string;
|
|
5
|
+
buildingInfo: string;
|
|
6
|
+
countryId: number;
|
|
7
|
+
state: {
|
|
8
|
+
id: number;
|
|
9
|
+
name: string;
|
|
10
|
+
};
|
|
11
|
+
city: {
|
|
12
|
+
id: number;
|
|
13
|
+
name: string;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export interface ICountries {
|
|
18
|
+
id: number;
|
|
19
|
+
name: string;
|
|
20
|
+
code: string;
|
|
21
|
+
callingCode: string;
|
|
22
|
+
flag: string;
|
|
23
|
+
minPhoneLength: string;
|
|
24
|
+
zipCodeExists: boolean;
|
|
25
|
+
zipCodeRegex: string;
|
|
26
|
+
zipCodeExample: string;
|
|
27
|
+
}
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import { Commission } from "./payments";
|
|
2
|
+
|
|
3
|
+
export interface ICart {
|
|
4
|
+
userBID: string;
|
|
5
|
+
reference: string;
|
|
6
|
+
cartProducts: any[]; // Replace 'any' with a specific type if known
|
|
7
|
+
billingAddressId: number | null;
|
|
8
|
+
shippingAddressId: number | null;
|
|
9
|
+
paymentMethodId: number | null;
|
|
10
|
+
id: number;
|
|
11
|
+
cartState: "shopping" | "checkout" | "completed"; // Define more states as needed
|
|
12
|
+
subTotal: string;
|
|
13
|
+
shippingTotal: string;
|
|
14
|
+
feeTotal: string;
|
|
15
|
+
taxTotal: string;
|
|
16
|
+
grandTotal: string;
|
|
17
|
+
utilityToken?: string;
|
|
18
|
+
smartPayPercentage?: string;
|
|
19
|
+
commissionSubTotal?: string;
|
|
20
|
+
isActive: boolean;
|
|
21
|
+
createdAt: string; // You could use Date if you plan to parse it
|
|
22
|
+
updatedAt: string;
|
|
23
|
+
fees: Fee[];
|
|
24
|
+
taxes: Tax[];
|
|
25
|
+
cartAsset: CartAsset;
|
|
26
|
+
isSmartPay: boolean;
|
|
27
|
+
isShippingApplicable?: boolean;
|
|
28
|
+
billingAddress: UserAddress;
|
|
29
|
+
paymentMethod: {
|
|
30
|
+
code: string;
|
|
31
|
+
id: number;
|
|
32
|
+
name: string;
|
|
33
|
+
};
|
|
34
|
+
shippingMethod: {
|
|
35
|
+
id: number;
|
|
36
|
+
name: string;
|
|
37
|
+
displayName: string;
|
|
38
|
+
code: string;
|
|
39
|
+
description: string;
|
|
40
|
+
isActive: boolean;
|
|
41
|
+
isDisplay: boolean;
|
|
42
|
+
isDeleted: boolean;
|
|
43
|
+
createdAt: string;
|
|
44
|
+
updatedAt: string;
|
|
45
|
+
deletedAt: string;
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
type CartAsset = {
|
|
49
|
+
id: number;
|
|
50
|
+
cartId: number;
|
|
51
|
+
assetOption: {
|
|
52
|
+
id: number;
|
|
53
|
+
name: string;
|
|
54
|
+
symbol: string;
|
|
55
|
+
isActive: boolean;
|
|
56
|
+
optionId: number;
|
|
57
|
+
provider: string;
|
|
58
|
+
createdAt: string;
|
|
59
|
+
deletedAt: string;
|
|
60
|
+
isDeleted: boolean;
|
|
61
|
+
updatedAt: string;
|
|
62
|
+
isVariable: boolean;
|
|
63
|
+
optionName: string;
|
|
64
|
+
displayOrder: number;
|
|
65
|
+
optionSymbol: string;
|
|
66
|
+
isAssetActive: boolean;
|
|
67
|
+
minPercentage: number;
|
|
68
|
+
optionIsActive: boolean;
|
|
69
|
+
paymentMethodId: number;
|
|
70
|
+
isCommissionEnabled: boolean;
|
|
71
|
+
commissionMultiplier: {
|
|
72
|
+
base: {
|
|
73
|
+
cv: number;
|
|
74
|
+
vp: number;
|
|
75
|
+
};
|
|
76
|
+
option: {
|
|
77
|
+
cv: number;
|
|
78
|
+
vp: number;
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
calculatedCommision: Commission;
|
|
83
|
+
baseAssetName: string;
|
|
84
|
+
baseAssetSymbol: string;
|
|
85
|
+
baseAssetAmount: number;
|
|
86
|
+
baseAssetPercentage: number;
|
|
87
|
+
optionAssetName: string;
|
|
88
|
+
optionAssetSymbol: string;
|
|
89
|
+
optionAssetAmount: number;
|
|
90
|
+
optionAssetPercentage: string;
|
|
91
|
+
createdAt: string;
|
|
92
|
+
updatedAt: string;
|
|
93
|
+
};
|
|
94
|
+
type Fee = {
|
|
95
|
+
amount: string;
|
|
96
|
+
cartId: number;
|
|
97
|
+
feeCategory: string;
|
|
98
|
+
feeName: string;
|
|
99
|
+
id: number;
|
|
100
|
+
type: string;
|
|
101
|
+
value: string;
|
|
102
|
+
};
|
|
103
|
+
type Tax = {
|
|
104
|
+
amount: string;
|
|
105
|
+
cartId: number;
|
|
106
|
+
id: number;
|
|
107
|
+
taxCategory: string;
|
|
108
|
+
taxName: string;
|
|
109
|
+
type: string;
|
|
110
|
+
value: string;
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
export type cartProduct = {
|
|
114
|
+
id: number;
|
|
115
|
+
sku: string;
|
|
116
|
+
name: string;
|
|
117
|
+
featureImage: string;
|
|
118
|
+
category: cartProductCategory;
|
|
119
|
+
price: number;
|
|
120
|
+
canProductBeRemoved: boolean;
|
|
121
|
+
canUserPurchaseTheProduct: boolean;
|
|
122
|
+
feedBackMessage: string;
|
|
123
|
+
maximumUserCanPurchase: number | null;
|
|
124
|
+
totalOrderExistsForProduct: number | null;
|
|
125
|
+
userPurchaseLimit: number | null;
|
|
126
|
+
maxCartQuantity: number | null;
|
|
127
|
+
quantityStepper: number | null;
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
export type cartProductCategory = {
|
|
131
|
+
id: number;
|
|
132
|
+
code: string;
|
|
133
|
+
name: string;
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
export type CartTableItemComponentProps = {
|
|
137
|
+
id: number;
|
|
138
|
+
product: cartProduct;
|
|
139
|
+
quantity: number;
|
|
140
|
+
cartProducts: number;
|
|
141
|
+
userPurchaseLimit: number | null;
|
|
142
|
+
maximumUserCanPurchase: number | null;
|
|
143
|
+
totalOrderExistsForProduct: number | null;
|
|
144
|
+
feedBackMessage: string;
|
|
145
|
+
canUserPurchaseTheProduct: boolean;
|
|
146
|
+
canProductBeRemoved: boolean;
|
|
147
|
+
unitOriginalPrice: number;
|
|
148
|
+
unitDiscount: number;
|
|
149
|
+
unitPrice: number;
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
export type BillingAddress = {
|
|
153
|
+
address: string;
|
|
154
|
+
buildingInfo: string;
|
|
155
|
+
city: string;
|
|
156
|
+
country: string;
|
|
157
|
+
countryId: number;
|
|
158
|
+
createdAt: string;
|
|
159
|
+
deletedAt: string;
|
|
160
|
+
id: number;
|
|
161
|
+
isActive: boolean;
|
|
162
|
+
isDefault: boolean;
|
|
163
|
+
isDeleted: boolean;
|
|
164
|
+
latitude: string;
|
|
165
|
+
longitude: string;
|
|
166
|
+
state: string;
|
|
167
|
+
type: string;
|
|
168
|
+
updatedAt: string;
|
|
169
|
+
userId: number;
|
|
170
|
+
};
|
|
171
|
+
export type UserAddress = {
|
|
172
|
+
id: number;
|
|
173
|
+
userBID: string;
|
|
174
|
+
firstName: string;
|
|
175
|
+
lastName: string;
|
|
176
|
+
phone: string;
|
|
177
|
+
email: string;
|
|
178
|
+
countryId: 3;
|
|
179
|
+
countryCode: string;
|
|
180
|
+
city: string;
|
|
181
|
+
state: string;
|
|
182
|
+
postalCode: string;
|
|
183
|
+
address: string;
|
|
184
|
+
buildingInfo: string;
|
|
185
|
+
latitude: string;
|
|
186
|
+
longitude: string;
|
|
187
|
+
type: string;
|
|
188
|
+
isDefault: boolean;
|
|
189
|
+
isActive: boolean;
|
|
190
|
+
isDeleted: boolean;
|
|
191
|
+
createdAt: string;
|
|
192
|
+
updatedAt: string;
|
|
193
|
+
deletedAt: string;
|
|
194
|
+
country: {
|
|
195
|
+
id: 3;
|
|
196
|
+
name: string;
|
|
197
|
+
code: string;
|
|
198
|
+
alphaCode: string;
|
|
199
|
+
callingCode: string;
|
|
200
|
+
zipCodeExists: boolean;
|
|
201
|
+
zipCodeRegex: string;
|
|
202
|
+
isActive: boolean;
|
|
203
|
+
isDeleted: boolean;
|
|
204
|
+
createdAt: string;
|
|
205
|
+
updatedAt: string;
|
|
206
|
+
deletedAt: string;
|
|
207
|
+
};
|
|
208
|
+
};
|
|
File without changes
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import "react";
|
|
2
|
+
|
|
3
|
+
declare module "react" {
|
|
4
|
+
interface HTMLAttributes<T> {
|
|
5
|
+
onPointerEnterCapture?: (e: React.PointerEvent<T | null>) => void;
|
|
6
|
+
onPointerLeaveCapture?: (e: React.PointerEvent<T | null>) => void;
|
|
7
|
+
placeholder?: string;
|
|
8
|
+
onResize?: any;
|
|
9
|
+
onResizeCapture?: any;
|
|
10
|
+
}
|
|
11
|
+
interface RefAttributes<T> {
|
|
12
|
+
onPointerEnterCapture?: (e: React.PointerEvent<T | null>) => void;
|
|
13
|
+
onPointerLeaveCapture?: (e: React.PointerEvent<T | null>) => void;
|
|
14
|
+
placeholder?: string;
|
|
15
|
+
onResize?: any;
|
|
16
|
+
onResizeCapture?: any;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
type ObjectTypeDto = { [key: string]: string | number | unknown | Array<any> };
|
|
21
|
+
|
|
22
|
+
interface DebounceFunction {
|
|
23
|
+
(...args: string[] | ObjectTypeDto[] | number[]): void;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export type RequestMethod = "POST" | "GET" | "DELETE" | "PUT" | "PATCH";
|
|
27
|
+
|
|
28
|
+
export interface ApiResponseDto<T> {
|
|
29
|
+
status: boolean;
|
|
30
|
+
message: string;
|
|
31
|
+
msg?: string;
|
|
32
|
+
error?: any;
|
|
33
|
+
data?: T;
|
|
34
|
+
statusCode?: number;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface BooleanResultDto<T> {
|
|
38
|
+
status: boolean;
|
|
39
|
+
message: string;
|
|
40
|
+
data?: Array<T> | object | string | number | undefined | T | any;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface ResultPaginate<T> {
|
|
44
|
+
data: T;
|
|
45
|
+
page: number;
|
|
46
|
+
limit: number;
|
|
47
|
+
total: number;
|
|
48
|
+
sort: string;
|
|
49
|
+
totalPage: number;
|
|
50
|
+
nextPage: number;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface ITableComponentHeadersType {
|
|
54
|
+
name: string;
|
|
55
|
+
key: string;
|
|
56
|
+
canSort?: boolean;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface ITableComponentItemsType {
|
|
60
|
+
lineItems: {
|
|
61
|
+
key: string | "actions";
|
|
62
|
+
value: any;
|
|
63
|
+
}[];
|
|
64
|
+
isLast: boolean;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export interface IOrderTableComponentItemsType {
|
|
68
|
+
lineHeader: any;
|
|
69
|
+
lineItems: Array<
|
|
70
|
+
{
|
|
71
|
+
key: string | "actions";
|
|
72
|
+
value: any;
|
|
73
|
+
}[]
|
|
74
|
+
>;
|
|
75
|
+
isLast: boolean;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export interface ITableComponentItemActionsType {
|
|
79
|
+
name: string;
|
|
80
|
+
key: string;
|
|
81
|
+
isActive: boolean;
|
|
82
|
+
icon: any;
|
|
83
|
+
callback: () => void;
|
|
84
|
+
}
|