@vindhq/sloud-payment-sdk 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +398 -0
- package/dist/index.cjs.js +51442 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.esm.js +51440 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.umd.js +51448 -0
- package/dist/index.umd.js.map +1 -0
- package/dist/react/index.esm.js +51440 -0
- package/dist/react/index.esm.js.map +1 -0
- package/dist/react/rollup.config.d.ts +8 -0
- package/dist/react/rollup.config.dts.d.ts +3 -0
- package/dist/react/src/components/Button/Button.types.d.ts +6 -0
- package/dist/react/src/components/Button/index.d.ts +3 -0
- package/dist/react/src/components/CopyToClipboardSpan/CopyToClipboard.types.d.ts +4 -0
- package/dist/react/src/components/CopyToClipboardSpan/index.d.ts +3 -0
- package/dist/react/src/components/Input/Input.types.d.ts +17 -0
- package/dist/react/src/components/Input/index.d.ts +3 -0
- package/dist/react/src/components/Skeleton/PaymentOptionSkeletons.d.ts +6 -0
- package/dist/react/src/components/TextArea/TextArea.types.d.ts +19 -0
- package/dist/react/src/components/TextArea/index.d.ts +3 -0
- package/dist/react/src/components/Widget.d.ts +6 -0
- package/dist/react/src/components/modals/AwaitingPaymentModal/AwaitingPaymentModal.d.ts +2 -0
- package/dist/react/src/components/modals/AwaitingPaymentTimeoutModal/AwaitingPaymentTimeoutModal.d.ts +2 -0
- package/dist/react/src/components/modals/Modal.d.ts +10 -0
- package/dist/react/src/components/modals/PaymentDetailsModal/PaymentDetailsModal.d.ts +2 -0
- package/dist/react/src/components/modals/PaymentDetailsModal/hooks/useTimer.d.ts +7 -0
- package/dist/react/src/components/modals/PaymentOptionsModal/PaymentOptionsModal.d.ts +2 -0
- package/dist/react/src/components/modals/PaymentOptionsModal/RadioButton.d.ts +11 -0
- package/dist/react/src/components/modals/PaymentOptionsModal/paymentOptionsMap.d.ts +5 -0
- package/dist/react/src/components/modals/SuccessModal/SuccessModal.d.ts +2 -0
- package/dist/react/src/components/modals/state/actions/data.d.ts +10 -0
- package/dist/react/src/components/modals/state/actions/index.d.ts +5 -0
- package/dist/react/src/components/modals/state/actions/modal.d.ts +5 -0
- package/dist/react/src/components/modals/state/actions/payment.d.ts +7 -0
- package/dist/react/src/components/modals/state/constants/actionTypes.d.ts +24 -0
- package/dist/react/src/components/modals/state/constants/index.d.ts +2 -0
- package/dist/react/src/components/modals/state/constants/initialState.d.ts +36 -0
- package/dist/react/src/components/modals/state/reducers/data.d.ts +2 -0
- package/dist/react/src/components/modals/state/reducers/index.d.ts +2 -0
- package/dist/react/src/components/modals/state/reducers/modal.d.ts +2 -0
- package/dist/react/src/components/modals/state/reducers/payment.d.ts +2 -0
- package/dist/react/src/components/modals/state/types/common.d.ts +12 -0
- package/dist/react/src/components/modals/state/types/data.d.ts +34 -0
- package/dist/react/src/components/modals/state/types/index.d.ts +8 -0
- package/dist/react/src/components/modals/state/types/modal.d.ts +12 -0
- package/dist/react/src/components/modals/state/types/payment.d.ts +14 -0
- package/dist/react/src/components/modals/state/utils/index.d.ts +37 -0
- package/dist/react/src/context/ModalProvider.d.ts +4 -0
- package/dist/react/src/context/PaymentInfoContext.d.ts +26 -0
- package/dist/react/src/context/PaymentWidgetContext.d.ts +13 -0
- package/dist/react/src/context/modal.d.ts +4 -0
- package/dist/react/src/context/types.d.ts +28 -0
- package/dist/react/src/hooks/types.d.ts +34 -0
- package/dist/react/src/hooks/useModalControl.d.ts +27 -0
- package/dist/react/src/hooks/usePaymentAPI.d.ts +10 -0
- package/dist/react/src/hooks/useShortPolling.d.ts +4 -0
- package/dist/react/src/index.d.ts +2 -0
- package/dist/react/src/services/config/endpoints.d.ts +9 -0
- package/dist/react/src/services/config/error.d.ts +5 -0
- package/dist/react/src/services/index.d.ts +27 -0
- package/dist/react/src/services/payments/index.d.ts +4 -0
- package/dist/react/src/services/payments/types.d.ts +68 -0
- package/dist/react/src/services/products/index.d.ts +1 -0
- package/dist/react/src/services/products/types.d.ts +124 -0
- package/dist/react/src/services/store/index.d.ts +2 -0
- package/dist/react/src/services/store/types.d.ts +57 -0
- package/dist/react/src/services/utils/widgetConfig.d.ts +20 -0
- package/dist/react/src/svg_components/ArrowLeftIcon.d.ts +3 -0
- package/dist/react/src/svg_components/BankTransferIcon.d.ts +2 -0
- package/dist/react/src/svg_components/CancelIcon.d.ts +7 -0
- package/dist/react/src/svg_components/CardIcon.d.ts +2 -0
- package/dist/react/src/svg_components/CloseIcon.d.ts +3 -0
- package/dist/react/src/svg_components/CopyIcon.d.ts +2 -0
- package/dist/react/src/svg_components/EyeCloseIcon.d.ts +5 -0
- package/dist/react/src/svg_components/EyeOpenIcon.d.ts +5 -0
- package/dist/react/src/svg_components/SloudIcon.d.ts +2 -0
- package/dist/react/src/utils/enums/AxiosErrorCodes.d.ts +7 -0
- package/dist/react/src/utils/enums/AxiosMethods.d.ts +7 -0
- package/dist/react/src/utils/helpers/classNames.d.ts +7 -0
- package/dist/react/src/utils/helpers/formatCurrency.d.ts +10 -0
- package/dist/react/src/utils/helpers/phoneDefaults.d.ts +3 -0
- package/dist/react/src/utils/helpers/validatePhone.d.ts +7 -0
- package/dist/react/src/utils/image_utils/index.d.ts +9 -0
- package/dist/react/src/utils/storage/index.d.ts +9 -0
- package/dist/react/src/widget.d.ts +27 -0
- package/dist/rollup.config.d.ts +8 -0
- package/dist/rollup.config.dts.d.ts +3 -0
- package/dist/src/components/Button/Button.types.d.ts +6 -0
- package/dist/src/components/Button/index.d.ts +3 -0
- package/dist/src/components/CopyToClipboardSpan/CopyToClipboard.types.d.ts +4 -0
- package/dist/src/components/CopyToClipboardSpan/index.d.ts +3 -0
- package/dist/src/components/Input/Input.types.d.ts +17 -0
- package/dist/src/components/Input/index.d.ts +3 -0
- package/dist/src/components/Skeleton/PaymentOptionSkeletons.d.ts +6 -0
- package/dist/src/components/TextArea/TextArea.types.d.ts +19 -0
- package/dist/src/components/TextArea/index.d.ts +3 -0
- package/dist/src/components/Widget.d.ts +6 -0
- package/dist/src/components/modals/AwaitingPaymentModal/AwaitingPaymentModal.d.ts +2 -0
- package/dist/src/components/modals/AwaitingPaymentTimeoutModal/AwaitingPaymentTimeoutModal.d.ts +2 -0
- package/dist/src/components/modals/Modal.d.ts +10 -0
- package/dist/src/components/modals/PaymentDetailsModal/PaymentDetailsModal.d.ts +2 -0
- package/dist/src/components/modals/PaymentDetailsModal/hooks/useTimer.d.ts +7 -0
- package/dist/src/components/modals/PaymentOptionsModal/PaymentOptionsModal.d.ts +2 -0
- package/dist/src/components/modals/PaymentOptionsModal/RadioButton.d.ts +11 -0
- package/dist/src/components/modals/PaymentOptionsModal/paymentOptionsMap.d.ts +5 -0
- package/dist/src/components/modals/SuccessModal/SuccessModal.d.ts +2 -0
- package/dist/src/components/modals/state/actions/data.d.ts +10 -0
- package/dist/src/components/modals/state/actions/index.d.ts +5 -0
- package/dist/src/components/modals/state/actions/modal.d.ts +5 -0
- package/dist/src/components/modals/state/actions/payment.d.ts +7 -0
- package/dist/src/components/modals/state/constants/actionTypes.d.ts +24 -0
- package/dist/src/components/modals/state/constants/index.d.ts +2 -0
- package/dist/src/components/modals/state/constants/initialState.d.ts +36 -0
- package/dist/src/components/modals/state/reducers/data.d.ts +2 -0
- package/dist/src/components/modals/state/reducers/index.d.ts +2 -0
- package/dist/src/components/modals/state/reducers/modal.d.ts +2 -0
- package/dist/src/components/modals/state/reducers/payment.d.ts +2 -0
- package/dist/src/components/modals/state/types/common.d.ts +12 -0
- package/dist/src/components/modals/state/types/data.d.ts +34 -0
- package/dist/src/components/modals/state/types/index.d.ts +8 -0
- package/dist/src/components/modals/state/types/modal.d.ts +12 -0
- package/dist/src/components/modals/state/types/payment.d.ts +14 -0
- package/dist/src/components/modals/state/utils/index.d.ts +37 -0
- package/dist/src/context/ModalProvider.d.ts +4 -0
- package/dist/src/context/PaymentInfoContext.d.ts +26 -0
- package/dist/src/context/PaymentWidgetContext.d.ts +13 -0
- package/dist/src/context/modal.d.ts +4 -0
- package/dist/src/context/types.d.ts +28 -0
- package/dist/src/hooks/types.d.ts +34 -0
- package/dist/src/hooks/useModalControl.d.ts +27 -0
- package/dist/src/hooks/usePaymentAPI.d.ts +10 -0
- package/dist/src/hooks/useShortPolling.d.ts +4 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/services/config/endpoints.d.ts +9 -0
- package/dist/src/services/config/error.d.ts +5 -0
- package/dist/src/services/index.d.ts +27 -0
- package/dist/src/services/payments/index.d.ts +4 -0
- package/dist/src/services/payments/types.d.ts +68 -0
- package/dist/src/services/products/index.d.ts +1 -0
- package/dist/src/services/products/types.d.ts +124 -0
- package/dist/src/services/store/index.d.ts +2 -0
- package/dist/src/services/store/types.d.ts +57 -0
- package/dist/src/services/utils/widgetConfig.d.ts +20 -0
- package/dist/src/svg_components/ArrowLeftIcon.d.ts +3 -0
- package/dist/src/svg_components/BankTransferIcon.d.ts +2 -0
- package/dist/src/svg_components/CancelIcon.d.ts +7 -0
- package/dist/src/svg_components/CardIcon.d.ts +2 -0
- package/dist/src/svg_components/CloseIcon.d.ts +3 -0
- package/dist/src/svg_components/CopyIcon.d.ts +2 -0
- package/dist/src/svg_components/EyeCloseIcon.d.ts +5 -0
- package/dist/src/svg_components/EyeOpenIcon.d.ts +5 -0
- package/dist/src/svg_components/SloudIcon.d.ts +2 -0
- package/dist/src/utils/enums/AxiosErrorCodes.d.ts +7 -0
- package/dist/src/utils/enums/AxiosMethods.d.ts +7 -0
- package/dist/src/utils/helpers/classNames.d.ts +7 -0
- package/dist/src/utils/helpers/formatCurrency.d.ts +10 -0
- package/dist/src/utils/helpers/phoneDefaults.d.ts +3 -0
- package/dist/src/utils/helpers/validatePhone.d.ts +7 -0
- package/dist/src/utils/image_utils/index.d.ts +9 -0
- package/dist/src/utils/storage/index.d.ts +9 -0
- package/dist/src/widget.d.ts +27 -0
- package/package.json +87 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { RollupOptions } from "rollup";
|
|
2
|
+
/**
|
|
3
|
+
* Rollup configuration for bundling the PaymentWidget project.
|
|
4
|
+
* Supports TypeScript, PostCSS, asset imports, and generates
|
|
5
|
+
* ESM, CJS, and UMD bundles with sourcemaps.
|
|
6
|
+
*/
|
|
7
|
+
declare const config: RollupOptions;
|
|
8
|
+
export default config;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type ChangeEvent, type FocusEvent, type HTMLProps } from 'react';
|
|
2
|
+
export interface IInput extends HTMLProps<HTMLInputElement> {
|
|
3
|
+
error?: string | boolean;
|
|
4
|
+
label: string;
|
|
5
|
+
placeholder?: string;
|
|
6
|
+
name?: string;
|
|
7
|
+
onChange?: (e: ChangeEvent<HTMLInputElement>) => void;
|
|
8
|
+
onFocus?: (e: FocusEvent<HTMLInputElement>) => void;
|
|
9
|
+
onDelete?: () => void;
|
|
10
|
+
type?: string;
|
|
11
|
+
value?: string | number;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
autoComplete?: string;
|
|
14
|
+
title?: string;
|
|
15
|
+
required?: boolean;
|
|
16
|
+
inputClass?: string;
|
|
17
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import "react-loading-skeleton/dist/skeleton.css";
|
|
2
|
+
interface PaymentOptionsSkeletonProps {
|
|
3
|
+
numberOfSkeletons?: number;
|
|
4
|
+
}
|
|
5
|
+
declare const PaymentOptionsSkeleton: ({ numberOfSkeletons, }: PaymentOptionsSkeletonProps) => import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export default PaymentOptionsSkeleton;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type ChangeEvent, type FocusEvent, type HTMLProps } from 'react';
|
|
2
|
+
export interface ITextArea extends HTMLProps<HTMLTextAreaElement> {
|
|
3
|
+
error?: string | boolean;
|
|
4
|
+
label: string;
|
|
5
|
+
placeholder?: string;
|
|
6
|
+
name?: string;
|
|
7
|
+
onChange?: (e: ChangeEvent<HTMLTextAreaElement>) => void;
|
|
8
|
+
onFocus?: (e: FocusEvent<HTMLTextAreaElement>) => void;
|
|
9
|
+
onDelete?: () => void;
|
|
10
|
+
value?: string;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
autoComplete?: string;
|
|
13
|
+
title?: string;
|
|
14
|
+
required?: boolean;
|
|
15
|
+
inputClass?: string;
|
|
16
|
+
rows?: number;
|
|
17
|
+
cols?: number;
|
|
18
|
+
showCancelIcon?: boolean;
|
|
19
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { ITextArea } from "./TextArea.types";
|
|
2
|
+
declare const TextArea: ({ error, name, onChange, onFocus, onDelete, label, placeholder, value, disabled, autoComplete, title, required, inputClass, rows, cols, showCancelIcon, }: ITextArea) => JSX.Element;
|
|
3
|
+
export default TextArea;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
interface ModalProps {
|
|
3
|
+
title: string;
|
|
4
|
+
children: React.JSX.Element;
|
|
5
|
+
isControllable?: boolean;
|
|
6
|
+
isOpen?: boolean;
|
|
7
|
+
isCentralizedHeader?: boolean;
|
|
8
|
+
}
|
|
9
|
+
declare const Modal: ({ title, children, isControllable, isOpen, isCentralizedHeader, }: ModalProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
10
|
+
export default Modal;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
declare const RadioButton: ({ label, name, value, id, disabled, onChange, checked, }: {
|
|
3
|
+
label: string;
|
|
4
|
+
name: string;
|
|
5
|
+
value: string;
|
|
6
|
+
id: string;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
checked?: boolean;
|
|
9
|
+
onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
10
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export default RadioButton;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ProductItem } from '../../../../hooks/types';
|
|
2
|
+
import { IGetStoreData } from '../../../../services';
|
|
3
|
+
import { DeliveryDetails, EditItemAction, RemoveItemAction, ResetDataAction, SetDataAction, SetDeliveryDetailsAction, SetLoadingAction, SetStoreAction } from '../types';
|
|
4
|
+
export declare const setData: (data: ProductItem[]) => SetDataAction;
|
|
5
|
+
export declare const setStore: (store: IGetStoreData) => SetStoreAction;
|
|
6
|
+
export declare const setLoading: (isLoading: boolean) => SetLoadingAction;
|
|
7
|
+
export declare const setDeliveryDetails: (details: Partial<DeliveryDetails>) => SetDeliveryDetailsAction;
|
|
8
|
+
export declare const editItemQuantity: (index: number, quantity?: number) => EditItemAction;
|
|
9
|
+
export declare const removeItem: (index: number) => RemoveItemAction;
|
|
10
|
+
export declare const resetData: () => ResetDataAction;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ResetModalAction, SetAboutModalAction, SetCurrentIndexAction, SetOpenAction } from '../types';
|
|
2
|
+
export declare const setOpen: (isOpen: boolean) => SetOpenAction;
|
|
3
|
+
export declare const setCurrentIndex: (index: number) => SetCurrentIndexAction;
|
|
4
|
+
export declare const setAboutModal: (isOpen: boolean) => SetAboutModalAction;
|
|
5
|
+
export declare const resetModal: () => ResetModalAction;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { PaymentStatus } from "../../../../hooks/types";
|
|
2
|
+
import { IPaymentDetails } from "../../../../services/products/types";
|
|
3
|
+
import { ResetPaymentAction, SetAdditionalAmountAction, SetPaymentDetailsAction, SetPaymentStatusAction } from "../types";
|
|
4
|
+
export declare const setPaymentStatus: (status: PaymentStatus) => SetPaymentStatusAction;
|
|
5
|
+
export declare const setPaymentDetails: (details: IPaymentDetails) => SetPaymentDetailsAction;
|
|
6
|
+
export declare const setAdditionalAmount: (amount: number) => SetAdditionalAmountAction;
|
|
7
|
+
export declare const resetPayment: () => ResetPaymentAction;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export declare const PAYMENT_ACTIONS: {
|
|
2
|
+
readonly SET_PAYMENT_STATUS: "SET_PAYMENT_STATUS";
|
|
3
|
+
readonly SET_PAYMENT_DETAILS: "SET_PAYMENT_DETAILS";
|
|
4
|
+
readonly SET_ADDITIONAL_AMOUNT: "SET_ADDITIONAL_AMOUNT";
|
|
5
|
+
readonly RESET_PAYMENT: "RESET_PAYMENT";
|
|
6
|
+
};
|
|
7
|
+
export declare const MODAL_ACTIONS: {
|
|
8
|
+
readonly SET_OPEN: "SET_OPEN";
|
|
9
|
+
readonly SET_CURRENT_INDEX: "SET_CURRENT_INDEX";
|
|
10
|
+
readonly SET_ABOUT_MODAL: "SET_ABOUT_MODAL";
|
|
11
|
+
readonly RESET_MODAL: "RESET_MODAL";
|
|
12
|
+
};
|
|
13
|
+
export declare const DATA_ACTIONS: {
|
|
14
|
+
readonly SET_DATA: "SET_DATA";
|
|
15
|
+
readonly SET_STORE: "SET_STORE";
|
|
16
|
+
readonly SET_LOADING: "SET_LOADING";
|
|
17
|
+
readonly SET_DELIVERY_DETAILS: "SET_DELIVERY_DETAILS";
|
|
18
|
+
readonly EDIT_ITEM: "EDIT_ITEM";
|
|
19
|
+
readonly REMOVE_ITEM: "REMOVE_ITEM";
|
|
20
|
+
readonly RESET_DATA: "RESET_DATA";
|
|
21
|
+
};
|
|
22
|
+
export declare const GLOBAL_ACTIONS: {
|
|
23
|
+
readonly RESET_ALL: "RESET_ALL";
|
|
24
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { PaymentStatus } from "../../../../hooks/types";
|
|
2
|
+
export declare const initialPaymentState: {
|
|
3
|
+
paymentStatus: PaymentStatus;
|
|
4
|
+
additionalAmount: number;
|
|
5
|
+
paymentDetails: {
|
|
6
|
+
reference: string;
|
|
7
|
+
account_name: string;
|
|
8
|
+
account_number: string;
|
|
9
|
+
bank: string;
|
|
10
|
+
expiry: string;
|
|
11
|
+
amount: number;
|
|
12
|
+
currency: string;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
export declare const initialModalState: {
|
|
16
|
+
open: boolean;
|
|
17
|
+
currentIndex: number;
|
|
18
|
+
isOpenAboutModal: boolean;
|
|
19
|
+
};
|
|
20
|
+
export declare const initialDataState: {
|
|
21
|
+
data: import("../../../../hooks/types").ProductItem[];
|
|
22
|
+
store: undefined;
|
|
23
|
+
isLoading: boolean;
|
|
24
|
+
deliveryDetails: {
|
|
25
|
+
channel: "pickup";
|
|
26
|
+
first_name: string;
|
|
27
|
+
last_name: string;
|
|
28
|
+
email: string;
|
|
29
|
+
phone_number: string;
|
|
30
|
+
street: string;
|
|
31
|
+
country: string;
|
|
32
|
+
state: string;
|
|
33
|
+
city: string;
|
|
34
|
+
note: string;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { DataState } from './data';
|
|
2
|
+
import { ModalState } from './modal';
|
|
3
|
+
import { PaymentState } from './payment';
|
|
4
|
+
export interface ActionType<Type, Payload = unknown> {
|
|
5
|
+
type: Type;
|
|
6
|
+
payload: Payload;
|
|
7
|
+
}
|
|
8
|
+
export interface RootState {
|
|
9
|
+
payment: PaymentState;
|
|
10
|
+
modal: ModalState;
|
|
11
|
+
data: DataState;
|
|
12
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ProductItem } from '../../../../hooks/types';
|
|
2
|
+
import { IGetStoreData } from '../../../../services';
|
|
3
|
+
import { DATA_ACTIONS } from '../constants/actionTypes';
|
|
4
|
+
import { ActionType } from './common';
|
|
5
|
+
export interface DeliveryDetails {
|
|
6
|
+
channel: 'pickup' | 'delivery';
|
|
7
|
+
first_name: string;
|
|
8
|
+
last_name: string;
|
|
9
|
+
email: string;
|
|
10
|
+
phone_number: string;
|
|
11
|
+
street: string;
|
|
12
|
+
country: string;
|
|
13
|
+
state: string;
|
|
14
|
+
city: string;
|
|
15
|
+
note: string;
|
|
16
|
+
}
|
|
17
|
+
export interface EditItemPayload {
|
|
18
|
+
index: number;
|
|
19
|
+
quantity?: number;
|
|
20
|
+
}
|
|
21
|
+
export interface DataState {
|
|
22
|
+
data: ProductItem[];
|
|
23
|
+
store?: IGetStoreData;
|
|
24
|
+
isLoading: boolean;
|
|
25
|
+
deliveryDetails: DeliveryDetails;
|
|
26
|
+
}
|
|
27
|
+
export type SetDataAction = ActionType<typeof DATA_ACTIONS.SET_DATA, ProductItem[]>;
|
|
28
|
+
export type SetStoreAction = ActionType<typeof DATA_ACTIONS.SET_STORE, IGetStoreData>;
|
|
29
|
+
export type SetLoadingAction = ActionType<typeof DATA_ACTIONS.SET_LOADING, boolean>;
|
|
30
|
+
export type SetDeliveryDetailsAction = ActionType<typeof DATA_ACTIONS.SET_DELIVERY_DETAILS, Partial<DeliveryDetails>>;
|
|
31
|
+
export type EditItemAction = ActionType<typeof DATA_ACTIONS.EDIT_ITEM, EditItemPayload>;
|
|
32
|
+
export type RemoveItemAction = ActionType<typeof DATA_ACTIONS.REMOVE_ITEM, number>;
|
|
33
|
+
export type ResetDataAction = ActionType<typeof DATA_ACTIONS.RESET_DATA>;
|
|
34
|
+
export type DataAction = SetDataAction | SetStoreAction | SetLoadingAction | SetDeliveryDetailsAction | EditItemAction | RemoveItemAction | ResetDataAction;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './common';
|
|
2
|
+
export * from './data';
|
|
3
|
+
export * from './modal';
|
|
4
|
+
export * from './payment';
|
|
5
|
+
import { GLOBAL_ACTIONS } from '../constants/actionTypes';
|
|
6
|
+
import { ActionType } from './common';
|
|
7
|
+
export type ResetAllAction = ActionType<typeof GLOBAL_ACTIONS.RESET_ALL>;
|
|
8
|
+
export type RootAction = import('./payment').PaymentAction | import('./modal').ModalAction | import('./data').DataAction | ResetAllAction;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { MODAL_ACTIONS } from '../constants';
|
|
2
|
+
import { ActionType } from './common';
|
|
3
|
+
export interface ModalState {
|
|
4
|
+
open: boolean;
|
|
5
|
+
currentIndex: number;
|
|
6
|
+
isOpenAboutModal: boolean;
|
|
7
|
+
}
|
|
8
|
+
export type SetOpenAction = ActionType<typeof MODAL_ACTIONS.SET_OPEN, boolean>;
|
|
9
|
+
export type SetCurrentIndexAction = ActionType<typeof MODAL_ACTIONS.SET_CURRENT_INDEX, number>;
|
|
10
|
+
export type SetAboutModalAction = ActionType<typeof MODAL_ACTIONS.SET_ABOUT_MODAL, boolean>;
|
|
11
|
+
export type ResetModalAction = ActionType<typeof MODAL_ACTIONS.RESET_MODAL>;
|
|
12
|
+
export type ModalAction = SetOpenAction | SetCurrentIndexAction | SetAboutModalAction | ResetModalAction;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { PaymentStatus } from '../../../../hooks/types';
|
|
2
|
+
import { IPaymentDetails } from '../../../../services/products/types';
|
|
3
|
+
import { PAYMENT_ACTIONS } from '../constants/actionTypes';
|
|
4
|
+
import { ActionType } from './common';
|
|
5
|
+
export interface PaymentState {
|
|
6
|
+
paymentStatus: PaymentStatus;
|
|
7
|
+
additionalAmount: number;
|
|
8
|
+
paymentDetails: IPaymentDetails;
|
|
9
|
+
}
|
|
10
|
+
export type SetPaymentStatusAction = ActionType<typeof PAYMENT_ACTIONS.SET_PAYMENT_STATUS, PaymentStatus>;
|
|
11
|
+
export type SetPaymentDetailsAction = ActionType<typeof PAYMENT_ACTIONS.SET_PAYMENT_DETAILS, IPaymentDetails>;
|
|
12
|
+
export type SetAdditionalAmountAction = ActionType<typeof PAYMENT_ACTIONS.SET_ADDITIONAL_AMOUNT, number>;
|
|
13
|
+
export type ResetPaymentAction = ActionType<typeof PAYMENT_ACTIONS.RESET_PAYMENT>;
|
|
14
|
+
export type PaymentAction = SetPaymentStatusAction | SetPaymentDetailsAction | SetAdditionalAmountAction | ResetPaymentAction;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { DeliveryDetails } from "../types";
|
|
2
|
+
import { ProductItem } from "../../../../hooks/types";
|
|
3
|
+
export declare const calculateTotalPrice: (data: ProductItem[]) => number;
|
|
4
|
+
export declare const formatItemsForOrder: (data: ProductItem[]) => {
|
|
5
|
+
product_id: string;
|
|
6
|
+
discount: number;
|
|
7
|
+
quantity: number;
|
|
8
|
+
variation: string[];
|
|
9
|
+
}[];
|
|
10
|
+
export declare const createOrderPayload: (data: ProductItem[], deliveryDetails: DeliveryDetails, additionalAmount: number) => {
|
|
11
|
+
additional_amount: number;
|
|
12
|
+
discount: number;
|
|
13
|
+
payment_method: string;
|
|
14
|
+
buyer_details: DeliveryDetails;
|
|
15
|
+
channel: "pickup" | "delivery";
|
|
16
|
+
delivery_details: {
|
|
17
|
+
channel: "pickup" | "delivery";
|
|
18
|
+
first_name: string;
|
|
19
|
+
last_name: string;
|
|
20
|
+
email: string;
|
|
21
|
+
phone_number: string;
|
|
22
|
+
street: string;
|
|
23
|
+
country: string;
|
|
24
|
+
state: string;
|
|
25
|
+
city: string;
|
|
26
|
+
note: string;
|
|
27
|
+
};
|
|
28
|
+
items: {
|
|
29
|
+
product_id: string;
|
|
30
|
+
discount: number;
|
|
31
|
+
quantity: number;
|
|
32
|
+
variation: string[];
|
|
33
|
+
}[];
|
|
34
|
+
};
|
|
35
|
+
export declare const loadCartFromStorage: () => ProductItem[];
|
|
36
|
+
export declare const saveCartToStorage: (data: ProductItem[]) => void;
|
|
37
|
+
export declare const clearCartFromStorage: () => void;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React, { ReactNode } from "react";
|
|
2
|
+
interface BankAccount {
|
|
3
|
+
accountName: string;
|
|
4
|
+
accountNumber: string;
|
|
5
|
+
bank: string;
|
|
6
|
+
}
|
|
7
|
+
interface TransactionDetails {
|
|
8
|
+
reference: string;
|
|
9
|
+
amount: number;
|
|
10
|
+
charge: number;
|
|
11
|
+
currency: string;
|
|
12
|
+
expiry: string;
|
|
13
|
+
}
|
|
14
|
+
interface PaymentInfoContextProp {
|
|
15
|
+
collectionAccount: BankAccount;
|
|
16
|
+
transactionDetails: TransactionDetails;
|
|
17
|
+
updateCollectionAccount: (bankAccount: BankAccount) => void;
|
|
18
|
+
updateTransactionDetails: (transactionDetails: TransactionDetails) => void;
|
|
19
|
+
}
|
|
20
|
+
declare const PaymentInfoContext: React.Context<PaymentInfoContextProp | undefined>;
|
|
21
|
+
interface PaymentWidgetProviderProps {
|
|
22
|
+
children: ReactNode;
|
|
23
|
+
}
|
|
24
|
+
export declare const PaymentInfoProvider: React.FC<PaymentWidgetProviderProps>;
|
|
25
|
+
export default PaymentInfoContext;
|
|
26
|
+
export declare const usePaymentInfoContext: () => PaymentInfoContextProp;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React, { ReactNode } from "react";
|
|
2
|
+
import { PaymentWidgetOptions } from "../widget";
|
|
3
|
+
interface PaymentWidgetContextType {
|
|
4
|
+
options: PaymentWidgetOptions;
|
|
5
|
+
}
|
|
6
|
+
declare const PaymentWidgetContext: React.Context<PaymentWidgetContextType | undefined>;
|
|
7
|
+
export declare const usePaymentWidgetContext: () => PaymentWidgetContextType;
|
|
8
|
+
interface PaymentWidgetProviderProps {
|
|
9
|
+
children: ReactNode;
|
|
10
|
+
options: PaymentWidgetOptions;
|
|
11
|
+
}
|
|
12
|
+
export declare const PaymentWidgetProvider: React.FC<PaymentWidgetProviderProps>;
|
|
13
|
+
export default PaymentWidgetContext;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { DeliveryDetails, PaymentStatus, ProductItem } from "../hooks/types";
|
|
2
|
+
import { IGetStoreData } from "../services";
|
|
3
|
+
import { IPaymentDetails } from "../services/products/types";
|
|
4
|
+
export interface ModalContextTypes {
|
|
5
|
+
open: boolean;
|
|
6
|
+
data: ProductItem[];
|
|
7
|
+
totalPrice: number;
|
|
8
|
+
currentModal: string;
|
|
9
|
+
movePrev: () => void;
|
|
10
|
+
moveNext: () => void;
|
|
11
|
+
openModal: () => void;
|
|
12
|
+
closeModal: () => void;
|
|
13
|
+
store: IGetStoreData | undefined;
|
|
14
|
+
editItemQuantity: (index: number, quantity?: number) => void;
|
|
15
|
+
removeItem: (index: number) => void;
|
|
16
|
+
isLoading: boolean;
|
|
17
|
+
paymentStatus: PaymentStatus;
|
|
18
|
+
setPaymentStatus: (status: PaymentStatus) => void;
|
|
19
|
+
deliveryDetails: DeliveryDetails;
|
|
20
|
+
paymentDetails: IPaymentDetails;
|
|
21
|
+
additionalAmount: number;
|
|
22
|
+
setAdditionalAmount: (amount: number) => void;
|
|
23
|
+
setDeliveryDetails: (details: DeliveryDetails) => void;
|
|
24
|
+
setData: (newData: ProductItem[]) => void;
|
|
25
|
+
orderProducts: () => Promise<void>;
|
|
26
|
+
isOpenAboutModal: boolean;
|
|
27
|
+
completeOperation: () => void;
|
|
28
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export declare enum ModalNames {
|
|
2
|
+
Payment = "Payment",
|
|
3
|
+
PaymentDetails = "PaymentDetails",
|
|
4
|
+
AwaitingPayment = "AwaitingPayment",
|
|
5
|
+
AwaitingPaymentTimeout = "AwaitingPaymentTimeout",
|
|
6
|
+
Success = "Success"
|
|
7
|
+
}
|
|
8
|
+
export interface DeliveryDetails {
|
|
9
|
+
channel: "pickup" | "delivery";
|
|
10
|
+
first_name: string;
|
|
11
|
+
last_name: string;
|
|
12
|
+
email: string;
|
|
13
|
+
phone_number: string;
|
|
14
|
+
street: string;
|
|
15
|
+
country: string;
|
|
16
|
+
state: string;
|
|
17
|
+
city: string;
|
|
18
|
+
note: string;
|
|
19
|
+
}
|
|
20
|
+
export interface ProductItem {
|
|
21
|
+
id: string;
|
|
22
|
+
image_url: string;
|
|
23
|
+
name: string;
|
|
24
|
+
variations: string[];
|
|
25
|
+
quantity: number;
|
|
26
|
+
price: number;
|
|
27
|
+
in_stock: number;
|
|
28
|
+
}
|
|
29
|
+
export declare enum PaymentStatus {
|
|
30
|
+
PENDING = "pending",
|
|
31
|
+
SUCCESS = "success",
|
|
32
|
+
FAILED = "failed",
|
|
33
|
+
CANCELLED = "cancelled"
|
|
34
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { DeliveryDetails, ModalNames, PaymentStatus, ProductItem } from "./types";
|
|
2
|
+
declare const useModalControl: () => {
|
|
3
|
+
open: boolean;
|
|
4
|
+
data: ProductItem[];
|
|
5
|
+
store: import("../services").IGetStoreData | undefined;
|
|
6
|
+
currentModal: ModalNames;
|
|
7
|
+
totalPrice: number;
|
|
8
|
+
isLoading: boolean;
|
|
9
|
+
moveNext: () => void;
|
|
10
|
+
movePrev: () => void;
|
|
11
|
+
openModal: () => void;
|
|
12
|
+
closeModal: () => void;
|
|
13
|
+
orderProducts: () => Promise<void>;
|
|
14
|
+
deliveryDetails: import("../components/modals/state/types").DeliveryDetails;
|
|
15
|
+
setDeliveryDetails: (details: DeliveryDetails) => void;
|
|
16
|
+
paymentDetails: import("../services/products/types").IPaymentDetails;
|
|
17
|
+
paymentStatus: PaymentStatus;
|
|
18
|
+
setPaymentStatus: (status: PaymentStatus) => void;
|
|
19
|
+
additionalAmount: number;
|
|
20
|
+
setAdditionalAmount: (amount: number) => void;
|
|
21
|
+
editItemQuantity: (index: number, quantity?: number) => void;
|
|
22
|
+
removeItem: (index: number) => void;
|
|
23
|
+
setData: (newData: ProductItem[]) => void;
|
|
24
|
+
isOpenAboutModal: boolean;
|
|
25
|
+
completeOperation: () => void;
|
|
26
|
+
};
|
|
27
|
+
export default useModalControl;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const usePaymentAPI: () => {
|
|
2
|
+
generatePaymentInstrument: () => Promise<void>;
|
|
3
|
+
paymentMethods: Record<string, boolean>;
|
|
4
|
+
publicKey: string;
|
|
5
|
+
isLocalEnv: boolean | undefined;
|
|
6
|
+
isFetchingMethods: boolean;
|
|
7
|
+
isLoading: boolean;
|
|
8
|
+
isSuccess: boolean;
|
|
9
|
+
};
|
|
10
|
+
export default usePaymentAPI;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const Endpoints: {
|
|
2
|
+
getPaymentMethods: (public_key: string) => string;
|
|
3
|
+
generatePaymentInstrument: (public_key: string) => string;
|
|
4
|
+
getPaymentStatus: (payment_reference: string) => string;
|
|
5
|
+
};
|
|
6
|
+
export interface BaseAPIResponse {
|
|
7
|
+
status: string;
|
|
8
|
+
message: string;
|
|
9
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { AxiosError, InternalAxiosRequestConfig } from "axios";
|
|
2
|
+
export * from "./store/types";
|
|
3
|
+
export interface WidgetOptions {
|
|
4
|
+
public_key: string;
|
|
5
|
+
isLocalEnv?: boolean;
|
|
6
|
+
amount: number;
|
|
7
|
+
first_name: string;
|
|
8
|
+
last_name: string;
|
|
9
|
+
phone_number: string;
|
|
10
|
+
email: string;
|
|
11
|
+
}
|
|
12
|
+
export declare const setWidgetOptions: (options: WidgetOptions) => void;
|
|
13
|
+
export declare const getWidgetOptions: () => WidgetOptions;
|
|
14
|
+
interface APIError {
|
|
15
|
+
status: string;
|
|
16
|
+
message: string;
|
|
17
|
+
}
|
|
18
|
+
export interface IApiResponse<T> {
|
|
19
|
+
response?: T;
|
|
20
|
+
error?: AxiosError<APIError>;
|
|
21
|
+
}
|
|
22
|
+
export type ApiRequest = Pick<InternalAxiosRequestConfig<unknown>, "method" | "url" | "params" | "data">;
|
|
23
|
+
export declare const makeApiCall: <T>(request: ApiRequest) => Promise<IApiResponse<T>>;
|
|
24
|
+
export declare const errors: {
|
|
25
|
+
403: string;
|
|
26
|
+
404: string;
|
|
27
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { IGeneratePaymentInstrumentPayload, IGetPaymentMethodsResponse, IPaymentInstrumentResponse, IPaymentStatusResponse } from "./types";
|
|
2
|
+
export declare const fetchPaymentMethods: (public_key: string) => Promise<import("..").IApiResponse<IGetPaymentMethodsResponse>>;
|
|
3
|
+
export declare const generatePaymentInstrumentService: (public_key: string, payload: IGeneratePaymentInstrumentPayload) => Promise<import("..").IApiResponse<IPaymentInstrumentResponse>>;
|
|
4
|
+
export declare const fetchPaymentStatusService: (payment_reference: string) => Promise<import("..").IApiResponse<IPaymentStatusResponse>>;
|