feat: sharable payment link dialog

This commit is contained in:
Ahmed Bouhuolia
2024-09-15 19:28:43 +02:00
parent 9517b4e279
commit 542e61dbfc
17 changed files with 476 additions and 19 deletions

View File

@@ -1,22 +1,37 @@
import React, { createContext, useContext, ReactNode } from 'react';
import {
GetSharableLinkMetaResponse,
useGetSharableLinkMeta,
} from '@/hooks/query/payment-link';
interface PaymentPortalContextType {
// Define the context type here
paymentAmount: number;
setPaymentAmount: (amount: number) => void;
sharableLinkMeta: GetSharableLinkMetaResponse | undefined;
isSharableLinkMetaLoading: boolean;
}
const PaymentPortalContext = createContext<PaymentPortalContextType>(
{} as PaymentPortalContextType,
);
export const PaymentPortalBoot: React.FC<{ children: ReactNode }> = ({
interface PaymentPortalBootProps {
linkId: string;
children: ReactNode;
}
export const PaymentPortalBoot: React.FC<PaymentPortalBootProps> = ({
linkId,
children,
}) => {
const [paymentAmount, setPaymentAmount] = React.useState<number>(0);
const { data: sharableLinkMeta, isLoading: isSharableLinkMetaLoading } =
useGetSharableLinkMeta(linkId);
const value = {
sharableLinkMeta,
isSharableLinkMetaLoading,
};
return (
<PaymentPortalContext.Provider value={{ paymentAmount, setPaymentAmount }}>
<PaymentPortalContext.Provider value={value}>
{children}
</PaymentPortalContext.Provider>
);