import { useState } from 'react';
import DataClientRender from './DataClientRender';
import { Client } from './DataClientInterfaz';

const clientes = [
	{
		id: 1,
		nombreComercial: 'Andres Alvarez',
		razonSocial: 'Andres Alvarez',
		identificacion: '1721529788',
		direccion: 'Calle oe',
		telefono: '0988545102',
		correo: 'andres@test.com'
	},
  {
		id: 2,
		nombreComercial: 'Paul Ruales',
		razonSocial: 'Paul Ruales',
		identificacion: '1721524123',
		direccion: 'Calle lomisima',
		telefono: '0988544772',
		correo: 'poul@test.com'
	}
];
function DataClient() {
	const [clients, setClients] = useState<Client[]>(clientes);
  const [selectClient, setSelectClient] = useState<Client | null>(null);

	const handleSelectClient = (value:Client) => {
		setSelectClient(value)
    if(!clients.includes(value)) setClients([...clients, value])
	};
	return (
		<DataClientRender
			client={clients}
			handleSelectClient={handleSelectClient}
      selectClient={selectClient}
		/>
	);
}

export default DataClient;
