From a61a1fff430bdac9ad51c63b6dd0c936a872feae Mon Sep 17 00:00:00 2001 From: vanderleik Date: Tue, 19 Mar 2024 13:53:46 -0300 Subject: [PATCH] feat: VIN-366 - adicionado funcionalidade de checkbox --- .../forms/ListAddressComponent.jsx | 2 +- .../forms/ListPersonComponent.jsx | 30 +++++++++++++++++-- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/frontend/src/components/registration/forms/ListAddressComponent.jsx b/frontend/src/components/registration/forms/ListAddressComponent.jsx index 44727aae..6d7a4eb3 100644 --- a/frontend/src/components/registration/forms/ListAddressComponent.jsx +++ b/frontend/src/components/registration/forms/ListAddressComponent.jsx @@ -55,7 +55,7 @@ const ListAddressComponent = () => { setEditingAddress(selectedAddress[0]); setVisibleEditDialog(true); } else { - alert('Selecione um vinho para editar.'); + alert('Selecione um endereço para editar.'); } }; diff --git a/frontend/src/components/registration/forms/ListPersonComponent.jsx b/frontend/src/components/registration/forms/ListPersonComponent.jsx index 7968aac9..c3ce57ce 100644 --- a/frontend/src/components/registration/forms/ListPersonComponent.jsx +++ b/frontend/src/components/registration/forms/ListPersonComponent.jsx @@ -13,6 +13,8 @@ import { createPerson, updatePerson, deletePerson } from '../../../service/regis const ListPersonComponent = () => { const { persons, navigate, fetchPersons } = useListPersonComponentHook(); const [selectedPerson, setSelectedPerson] = useState(null); + const [editingPerson, setEditingPerson] = useState(null); + const [visibleEditDialog, setVisibleEditDialog] = useState(false); const dt = useRef(null); const [filters, setFilters] = useState({ @@ -42,10 +44,32 @@ const ListPersonComponent = () => { return persons.address ? true : false; }; + const onSelectionChange = (e) => { + setSelectedPerson(e.value); + }; + + const onSelectAllChange = (e) => { + const _selectedPerson = e.checked ? persons.map(scale => scale) : null; + if (_selectedPerson) { + setSelectedPerson(_selectedPerson); + } else { + setSelectedPerson(null); + } + }; + const onNewClick = () => { navigate('/registration'); }; + const onEditClick = () => { + if (selectedPerson && selectedPerson.length === 1) { + setEditingPerson(selectedPerson[0]); + setVisibleEditDialog(true); + } else { + alert('Selecione uma pessoa para editar.'); + } + }; + const rightToolbarTemplate = () => { return