import React from 'react';
import ChargeModal, { IWrapChain } from './ChargeModal';
import { ISmsConfig } from '../../app';
import { queryDataFormater } from '@janda-com/front';
import { useQuery } from '@apollo/client';
import { getPoint } from "../../types/api";
import { GET_POINT } from '../../apollo/queries';
import client from '../../apollo/apolloClient';


export interface IChargeModalWrapProp extends IWrapChain { }
export interface IProp extends IChargeModalWrapProp {
    config: ISmsConfig
}

export const ChargeModalWrap: React.FC<IProp> = ({ config, modalHook, onClickCharge }) => {

    const { data, loading } = useQuery<getPoint>(GET_POINT, {
        client
    })

    const pointData = queryDataFormater(data, "MyManager", "data", undefined) || undefined;
    if (!pointData) return <div />


    return <ChargeModal loading={loading} onClickCharge={onClickCharge} pointData={pointData.point} config={config} modalHook={modalHook} />;
};


export default ChargeModalWrap;