Skip to content

Instantly share code, notes, and snippets.

@brdsio
Created October 7, 2024 20:16
Show Gist options
  • Save brdsio/42ede3cbf883df8ec5485cd73559a6f0 to your computer and use it in GitHub Desktop.
Save brdsio/42ede3cbf883df8ec5485cd73559a6f0 to your computer and use it in GitHub Desktop.
import { Button, Form, Table } from "react-bootstrap";
import { Vaccines } from "@/types/vaccines";
interface VaccineTableProps {
vaccineRows: Vaccines[];
handleVaccineChange: (index: number, field: keyof Vaccines, value: string) => void;
handleAddVaccineRow: () => void;
}
export default function VaccineTable({
vaccineRows,
handleVaccineChange,
handleAddVaccineRow
}: VaccineTableProps) {
return (
<>
<Table striped bordered hover size="sm">
<thead>
<tr>
<th></th>
<th>Aplicada em</th>
<th>Replicar em</th>
</tr>
</thead>
<tbody>
{vaccineRows.map((row, index) => (
<tr key={index}>
<td>
<Form.Control
placeholder={row.vaccine}
onChange={(e) => handleVaccineChange(index, 'vaccine', e.target.value)}
/>
</td>
<td>
<Form.Control
placeholder="dd/mm/aaaa"
defaultValue={row.appliedDate}
onChange={(e) => handleVaccineChange(index, 'appliedDate', e.target.value)}
/>
</td>
<td>
<Form.Control
placeholder="dd/mm/aaaa"
defaultValue={row.replicateDate}
onChange={(e) => handleVaccineChange(index, 'replicateDate', e.target.value)}
/>
</td>
</tr>
))}
</tbody>
</Table>
<Button variant="outline-dark" onClick={handleAddVaccineRow}>
Adicionar nova vacina
</Button>
</>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment