From 2f610eb9555647c08faa8c85922d9b897c532eb6 Mon Sep 17 00:00:00 2001 From: tobi Date: Mon, 18 Nov 2024 14:38:47 +0100 Subject: [PATCH] fix typescript complaining --- .../domain-permissions/excludes/detail.tsx | 47 +++++++++++-------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/web/source/settings/views/moderation/domain-permissions/excludes/detail.tsx b/web/source/settings/views/moderation/domain-permissions/excludes/detail.tsx index a3f9d2e4b..4e14ec3ad 100644 --- a/web/source/settings/views/moderation/domain-permissions/excludes/detail.tsx +++ b/web/source/settings/views/moderation/domain-permissions/excludes/detail.tsx @@ -30,8 +30,6 @@ import MutationButton from "../../../../components/form/mutation-button"; export default function DomainPermissionExcludeDetail() { const baseUrl = useBaseUrl(); const backLocation: string = history.state?.backLocation ?? `~${baseUrl}`; - const [_location, setLocation] = useLocation(); - const [ deleteExclude, deleteResult ] = useDeleteDomainPermissionExcludeMutation(); const params = useParams(); let id = params.excludeId as string | undefined; @@ -86,25 +84,36 @@ export default function DomainPermissionExcludeDetail() {
{privateComment}
- { - e.preventDefault(); - e.stopPropagation(); - deleteExclude(id).then(res => { - if ("data" in res) { - setLocation(backLocation); - } - }); - }} - disabled={false} - showError={true} - result={deleteResult} + ); } +function HandleExclude({ id, backLocation}: {id: string, backLocation: string}) { + const [_location, setLocation] = useLocation(); + const [ deleteExclude, deleteResult ] = useDeleteDomainPermissionExcludeMutation(); + + return ( + { + e.preventDefault(); + e.stopPropagation(); + deleteExclude(id).then(res => { + if ("data" in res) { + setLocation(backLocation); + } + }); + }} + disabled={false} + showError={true} + result={deleteResult} + /> + ); +}