import { useFormContext } from 'react-hook-form'; // @mui import Stack from '@mui/material/Stack'; import Button from '@mui/material/Button'; import Divider from '@mui/material/Divider'; import IconButton from '@mui/material/IconButton'; import Typography from '@mui/material/Typography'; // hooks import { useGetSettings } from 'src/api/settings'; import { useBoolean } from 'src/hooks/use-boolean'; import { useResponsive } from 'src/hooks/use-responsive'; // components import Iconify from 'src/components/iconify'; // import { createFullAddress } from 'src/utils/create-full-address'; import { useGetCustomers } from 'src/api/customer'; import { CompanyListDialog } from '../company'; // ---------------------------------------------------------------------- export default function InvoiceNewEditAddress() { const { watch, setValue, formState: { errors }, } = useFormContext(); const mdUp = useResponsive('up', 'md'); const values = watch(); const { invoiceFrom, invoiceTo } = values; const { settings } = useGetSettings(); const { customers } = useGetCustomers(); const from = useBoolean(); const to = useBoolean(); return ( <> } sx={{ p: 3 }} > From: {invoiceFrom ? ( {invoiceFrom.name} {createFullAddress(invoiceFrom.address)} {invoiceFrom.phoneNumber} ) : ( {(errors.invoiceFrom as any)?.message} )} To: {invoiceTo ? ( {invoiceTo.name} {createFullAddress(invoiceTo.address)} {invoiceTo.phoneNumber} ) : ( {(errors.invoiceTo as any)?.message} )} {settings && ( invoiceFrom?.id === selectedId} onSelect={(company) => setValue('invoiceFrom', company)} list={[settings?.company, settings?.['company-ee']]} action={ } /> )} invoiceTo?.id === selectedId} onSelect={(company) => setValue('invoiceTo', company)} list={customers} action={ } /> ); }