mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-21 23:30:32 +00:00
feat: sharable payment link dialog
This commit is contained in:
@@ -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>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user