From 59877d9fea821f42e47831ed99303a79f5044143 Mon Sep 17 00:00:00 2001 From: Diana Nanyanzi Date: Sat, 7 Dec 2024 01:41:20 +0300 Subject: [PATCH] refactor: error handling in editing panel --- src/components/panel/EditPanel.tsx | 40 +++++++++--------------- src/components/panel/NamespacesPanel.tsx | 2 -- 2 files changed, 15 insertions(+), 27 deletions(-) diff --git a/src/components/panel/EditPanel.tsx b/src/components/panel/EditPanel.tsx index b7883c9..ef74ceb 100644 --- a/src/components/panel/EditPanel.tsx +++ b/src/components/panel/EditPanel.tsx @@ -24,24 +24,6 @@ const keyValuesQuery = ({ store }: { store: string }) => ({ }, }) -// const useKeyValuesQuery = ({ store, key, namespace }) => { -// if (key && namespace) { -// return useDataQuery(keyValuesQuery({ store }), { -// variables: { -// key, -// namespace, -// }, -// }) -// } else { -// return { -// data: null, -// loading: false, -// error: null, -// refetch: () => Promise.resolve(), -// } -// } -// } - const PanelEdit = () => { const { key, namespace, store } = useParams() const { showSuccess, showError } = useCustomAlert() @@ -81,6 +63,20 @@ const PanelEdit = () => { setValue(value) } + const handleUpdate = async () => { + try { + await updateKey({ + key, + namespace, + value, + }) + } catch (error) { + const message = i18n.t('There was an error updating the key') + showError(message) + } + + } + useEffect(() => { setValue(JSON.stringify(data?.results, null, 4)) }, [data]) @@ -110,13 +106,7 @@ const PanelEdit = () => {