import React from 'react';
import { useQuery } from '@apollo/client';
import { myManager } from '../../types/api';
import { GET_SMS_MANAGER } from '../../apollo/queries';
import client from "../../apollo/apolloClient"
import { queryDataFormater } from '@janda-com/front';
import { SenderList } from './SenderList';
import { ISmsConfig } from '../../app';
interface IProp {
    config: ISmsConfig;
}

export const SenderListWrap: React.FC<IProp> = () => {
    const { data, loading } = useQuery<myManager>(GET_SMS_MANAGER, {
        client,
        onError: e => {
            console.error(e);
        },
    });

    const manager = queryDataFormater(data, 'MyManager', 'data', undefined) || undefined;

    return <SenderList loading={loading} onDeleteClick={() => { }} senders={manager?.senders || []} />;
};
