Skip to content

Commit

Permalink
Merge pull request #25 from elpablos/fix/client-statustext
Browse files Browse the repository at this point in the history
fix: rewrite statusText check
  • Loading branch information
Pe5h4 authored Mar 23, 2023
2 parents 8ee0269 + a14f6e1 commit 12a142b
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 23 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 1 addition & 10 deletions src/modules/auth/clients/ClientCreateContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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);
Expand All @@ -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}`);
Expand All @@ -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);
Expand Down
8 changes: 1 addition & 7 deletions src/modules/auth/clients/ClientDetailContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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) {
Expand Down Expand Up @@ -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'));
Expand Down
3 changes: 0 additions & 3 deletions src/modules/auth/clients/ClientListContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 0 additions & 3 deletions src/modules/auth/tenant/TenantDetailContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 12a142b

Please sign in to comment.