Skip to content

Commit

Permalink
Move some logic to named functions
Browse files Browse the repository at this point in the history
  • Loading branch information
arbulu89 committed Jul 11, 2023
1 parent 3c1dd36 commit 3614c2e
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions assets/js/components/HostsList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,16 @@ function HostsList() {

const dispatch = useDispatch();

const openDeregistrationModal = (host) => {
setHostToDeregister(host);
setCleanUpModalOpen(true);
};

const cleanUpHost = (host) => {
setCleanUpModalOpen(false);
dispatch(deregisterHost(host));
};

const config = {
pagination: true,
usePadding: false,
Expand Down Expand Up @@ -191,8 +201,7 @@ function HostsList() {
<CleanUpButton
cleaning={item.deregistering}
onClick={() => {
setHostToDeregister(item);
setCleanUpModalOpen(true);
openDeregistrationModal(item);
}}
/>
),
Expand Down Expand Up @@ -232,8 +241,7 @@ function HostsList() {
hostname={hostToDeregister?.hostname}
isOpen={!!cleanUpModalOpen}
onCleanUp={() => {
setCleanUpModalOpen(false);
dispatch(deregisterHost(hostToDeregister));
cleanUpHost(hostToDeregister);
}}
onCancel={() => {
setCleanUpModalOpen(false);
Expand Down

0 comments on commit 3614c2e

Please sign in to comment.