add button

This commit is contained in:
Eduardo Quiros 2022-09-01 10:01:10 -06:00
parent f6ab828ed4
commit 22dff4fe07
No known key found for this signature in database
GPG Key ID: B77F36C3F12720B4
1 changed files with 25 additions and 8 deletions

View File

@ -41,6 +41,7 @@ const Communities = () => {
const [districtId, setDistrictId] = useState(null);
const [codeHouses, setCodeHouses] = useState('');
const [submitted, setSubmitted] = useState(false);
const [saveButtonLabel, setSaveButtonLabel] = useState('Registrar')
const [selectedCommunities, setSelectedCommunities] = useState(null);
const [globalFilter, setGlobalFilter] = useState(null);
const [deleteCommunityDialog, setDeleteCommunityDialog] = useState(false);
@ -454,6 +455,16 @@ const Communities = () => {
});
};
const updateCommunity = (community) => {
console.log(community);
setCommunity(community);
setSaveButtonLabel('Actualizar');
setHousesList(community.houses);
setProvinciaId(community.provincia);
setCantonId(community.canton);
setDistrictId(community.district);
}
const actionsCommunity = (rowData) => {
let icono = '';
@ -465,6 +476,12 @@ const Communities = () => {
return (
<div className="actions">
<Button
icon="pi pi-pencil"
className="p-button-rounded p-button-success mt-2 mx-2"
onClick={() => updateCommunity(rowData)}
title="Editar"
/>
<Button
icon="pi pi-exclamation-circle"
className="p-button-rounded p-button-info mt-2 mx-2"
@ -1169,7 +1186,7 @@ const Communities = () => {
</div>
<div className="col-12 md:col-12 py-2">
<Button
label="Registrar"
label={saveButtonLabel}
icon="pi pi-check"
onClick={saveCommunity}
></Button>