import { FC } from 'react';
import Button from './Button';
import { useTranslation } from 'react-i18next';
import { useGetInvoiceDetail } from '../pages/receipts/hooks/useReceiptData';
import { useNavigate, useParams } from 'react-router-dom';
import { useGetProfile } from '../pages/profile/hooks/useProfileData';
import { Pages } from '../config/Pages';


const PDFGenerator: FC = () => {
    const { id } = useParams()
    const { t } = useTranslation('global');
    const navigate = useNavigate()
    const getInvoce = useGetInvoiceDetail(id ? id : '')
    const getProfile = useGetProfile()
    const status = getInvoce.data?.data?.invoice?.status
    const financialType = getProfile.data?.data?.user?.financialType

    return (
        <Button
            onClick={() => navigate(Pages.receipts.factor + id)}
            label={status === 'PAID' ? t('receip.get_factor') : t('receip.get_pre_factor')}
            className='bg-[#000]  text-xs '
            disabled={financialType !== 'LEGAL' && financialType !== 'REAL'}
        />
    );
};

export default PDFGenerator; 