added change translation button to sidebar and implemented translation functionality

This commit is contained in:
2026-05-30 11:19:52 +02:00
parent b435b5f638
commit 137a9204df
4 changed files with 29 additions and 18 deletions
+15 -17
View File
@@ -6,25 +6,9 @@ import type {
SettingsIntf,
Storage,
} from "../misc/interfaces";
import i18n from "./i18n";
export const getProducts = async () => {
const result = await fetch(`${API_BASE}/products/all-products`, {
headers: {
Authorization: `Bearer ${Cookies.get("token") || ""}`,
"Content-Type": "application/json",
Accept: "application/json",
},
});
const response = await result.json();
if (response.code === "ep002") {
return { success: false, code: response.code };
}
if (response.code === "sp002") {
return response.data;
}
};
export const getProductDetails = async (uuid: string) => {
const result = await fetch(`${API_BASE}/products/view?uuid=${uuid}`, {
@@ -289,3 +273,17 @@ export const deleteSelectedProducts = async (uuids: string[]) => {
console.log(response);
};
export const changeTranslation = () => {
const clientLng = i18n.language;
if (clientLng === "en") {
i18n.changeLanguage("de");
Cookies.set("language", "de");
} else if (clientLng === "de") {
i18n.changeLanguage("en");
Cookies.set("language", "en");
} else {
alert("Cannot change language.");
}
};