Skip to content

Instantly share code, notes, and snippets.

@dersonsena
Created May 6, 2024 21:43
Show Gist options
  • Save dersonsena/ba86e25aa0f9c23c1b4f16684837b1ba to your computer and use it in GitHub Desktop.
Save dersonsena/ba86e25aa0f9c23c1b4f16684837b1ba to your computer and use it in GitHub Desktop.
<ModalCustomerDetails isOpen={isOpenFullDetails} onClose={onCloseFullDetails} id={customerId} />
import { Modal } from '@/components/Common/Modal/Modal'
import { EssentialInformations, PaymentDetail } from './components'
import { useFetchCustomerDetail } from '../../hooks'
import { useEffect } from 'react'
import { useToast } from '@chakra-ui/react'
export const ModalCustomerDetails = ({ isOpen, onClose, id }) => {
const toast = useToast()
const { dataCustomer, errorCustomer, fetchCustomer, loadingCustomer } = useFetchCustomerDetail()
useEffect(() => {
if (!id || !isOpen) return
fetchCustomer(id)
}, [id])
useEffect(() => {
if (!errorCustomer) return
toast({
description: 'Erro ao exibir detalhes do Cliente.',
status: 'error',
duration: 2000,
isClosable: true,
position: 'top-right',
})
onClose()
}, [errorCustomer])
return (
<Modal.Root isOpen={isOpen} onClose={onClose} size='6xl'>
<Modal.Header text={dataCustomer && dataCustomer.customerName} />
<Modal.Body loading={loadingCustomer}>
<main className='px-3 flex flex-col gap-3'>
<EssentialInformations customer={dataCustomer} />
{/* <CareerPath complete={complete} nextGraduation='Titan Sky Black' numberGraduation={3} /> */}
<PaymentDetail customer={dataCustomer} />
{/* <DepositTable /> */}
{/* <Network customers={dataCustomer && dataCustomer.network} /> */}
</main>
</Modal.Body>
</Modal.Root>
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment