fix: frontend error codes and translations

This commit is contained in:
2026-07-08 11:57:38 +02:00
parent 87bed4e1c7
commit c6bba8a40c
6 changed files with 403 additions and 357 deletions
+30 -30
View File
@@ -1,43 +1,43 @@
import { API_BASE } from "../../config/api.config";
import {API_BASE} from "../../config/api.config";
import Cookies from "js-cookie";
import type { SettingsIntf } from "../../misc/interfaces";
import { createApiError } from "./apiError";
import type {SettingsIntf} from "../../misc/interfaces";
import {createApiError} from "./apiError";
export const fetchSettings = async () => {
const result = await fetch(`${API_BASE}/users/settings`, {
method: "GET",
headers: {
Authorization: `Bearer ${Cookies.get("token") || ""}`,
"Content-Type": "application/json",
Accept: "application/json",
},
});
const result = await fetch(`${API_BASE}/users/settings`, {
method: "GET",
headers: {
Authorization: `Bearer ${Cookies.get("token") || ""}`,
"Content-Type": "application/json",
Accept: "application/json",
},
});
const response = await result.json();
const response = await result.json();
if (response.code === "su004") {
return { success: true, data: response.data, code: response.code };
}
if (response.code === "SU004") {
return {success: true, data: response.data, code: response.code};
}
throw createApiError(response.code, "Fetch settings failed");
throw createApiError(response.code, "Fetch settings failed");
};
export const mutateSettings = async (payload: SettingsIntf) => {
const result = await fetch(`${API_BASE}/users/update-app-settings`, {
method: "POST",
body: JSON.stringify(payload),
headers: {
Authorization: `Bearer ${Cookies.get("token") || ""}`,
"Content-Type": "application/json",
Accept: "application/json",
},
});
const result = await fetch(`${API_BASE}/users/update-app-settings`, {
method: "POST",
body: JSON.stringify(payload),
headers: {
Authorization: `Bearer ${Cookies.get("token") || ""}`,
"Content-Type": "application/json",
Accept: "application/json",
},
});
const response = await result.json();
const response = await result.json();
if (response.code === "su003") {
return { success: true, code: response.code };
}
if (response.code === "SU003") {
return {success: true, code: response.code};
}
throw createApiError(response.code, "Update settings failed");
throw createApiError(response.code, "Update settings failed");
};