diff --git a/CHANGELOG.md b/CHANGELOG.md index a3c8b068..47aa8908 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,10 @@ - Webpack V4 to V5 migration. (INDIGO Sprint 230303, [!16](https://github.com/TeskaLabs/seacat-admin-webui/pull/16)) +### Bugfix + +- Fix responses in Clients and Tenant containers causing errors on undefined value. Closing issue [!24](https://github.com/TeskaLabs/seacat-admin-webui/issues/24). (INDIGO Sprint 230317, [!25](https://github.com/TeskaLabs/seacat-admin-webui/pull/25)) + ## v23.5 ### Features diff --git a/src/modules/auth/clients/ClientCreateContainer.js b/src/modules/auth/clients/ClientCreateContainer.js index cc0eb1d6..5373ff35 100644 --- a/src/modules/auth/clients/ClientCreateContainer.js +++ b/src/modules/auth/clients/ClientCreateContainer.js @@ -113,9 +113,6 @@ const ClientCreateContainer = (props) => { const retrieveClientFeatures = async () => { try { let response = await SeaCatAuthAPI.get('/client/features'); - if (response.statusText != 'OK') { - throw new Error("Unable to get clients"); - } setMetaData(response.data["metadata_schema"]); setTemplate(response.data["templates"]); } catch (e) { @@ -127,9 +124,6 @@ const ClientCreateContainer = (props) => { const getClientDetail = async () => { try { let response = await SeaCatAuthAPI.get(`client/${client_id}`); - if (response.statusText != 'OK') { - throw new Error("Unable to get client details"); - } setClient(response.data); } catch (e) { console.error(e); @@ -142,9 +136,6 @@ const ClientCreateContainer = (props) => { let body = refactorSubmitData(values, "create"); try { let response = await SeaCatAuthAPI.post(`/client`, body); - if (response.statusText != 'OK') { - throw new Error("Unable to create client"); - } if (response.data?.client_id) { props.app.addAlert("success", t("ClientCreateContainer|Client has been created")); props.history.push(`/auth/clients/${response.data.client_id}`); @@ -160,7 +151,7 @@ const ClientCreateContainer = (props) => { setDisabled(true); try { let response = await SeaCatAuthAPI.put(`/client/${client_id}`, body); - if (response.statusText != 'OK') { + if (response.data.result !== "OK") { throw new Error("Unable to change client details"); } setDisabled(false); diff --git a/src/modules/auth/clients/ClientDetailContainer.js b/src/modules/auth/clients/ClientDetailContainer.js index 50f7cc44..4d2027ae 100644 --- a/src/modules/auth/clients/ClientDetailContainer.js +++ b/src/modules/auth/clients/ClientDetailContainer.js @@ -30,9 +30,6 @@ const ClientDetailContainer = (props) => { const getClientDetail = async () => { try { let response = await SeaCatAuthAPI.get(`client/${client_id}`); - if (response.statusText != 'OK') { - throw new Error("Unable to get client details"); - } setClient(response.data); } catch (e) { console.error(e); @@ -43,9 +40,6 @@ const ClientDetailContainer = (props) => { const resetSecret = async () => { try { let response = await SeaCatAuthAPI.post(`client/${client_id}/reset_secret`); - if (response.statusText != 'OK') { - throw new Error("Unable to reset client secret"); - } props.app.addAlert("success", t('ClientDetailContainer|Secret has been reset successfully')); getClientDetail(); } catch (e) { @@ -73,7 +67,7 @@ const ClientDetailContainer = (props) => { const removeClient = async () => { try { let response = await SeaCatAuthAPI.delete(`/client/${client_id}`); - if (response.statusText != 'OK') { + if (response.data.result !== "OK") { throw new Error("Unable to delete client"); } props.app.addAlert("success", t('ClientDetailContainer|Client removed successfully')); diff --git a/src/modules/auth/clients/ClientListContainer.js b/src/modules/auth/clients/ClientListContainer.js index bdfb9c95..2304a557 100644 --- a/src/modules/auth/clients/ClientListContainer.js +++ b/src/modules/auth/clients/ClientListContainer.js @@ -77,9 +77,6 @@ function ClientListContainer(props) { const retrieveData = async () => { try { let response = await SeaCatAuthAPI.get("/client", {params: {p:page, i: limit, f: filter}}); - if (response.statusText != 'OK') { - throw new Error("Unable to get clients"); - } setData(response.data.data); setCount(response.data.count); setLoading(false); diff --git a/src/modules/auth/tenant/TenantDetailContainer.js b/src/modules/auth/tenant/TenantDetailContainer.js index 22040386..55d6e3a9 100644 --- a/src/modules/auth/tenant/TenantDetailContainer.js +++ b/src/modules/auth/tenant/TenantDetailContainer.js @@ -127,9 +127,6 @@ function TenantDetailContainer(props) { const retrieveData = async () => { try { let response = await SeaCatAuthAPI.get(`/tenant/${tenant_id}`); - if (response.statusText !== "OK") { - throw new Error(t("TenantDetailContainer|Something went wrong, failed to fetch tenant detail")); - } setData(response.data); response.data?.data && setCustomTenantData(response.data.data); setLoadingCustomData(false);