Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: rewrite statusText check to status value #25

Merged
merged 3 commits into from
Mar 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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