add theming changes for onprem

This commit is contained in:
lalitdeore12@gmail.com
2025-05-20 13:51:36 +05:30
parent e92c2817b2
commit 4942387bab
3 changed files with 43 additions and 2 deletions
+5
View File
@@ -192,6 +192,11 @@ const App = (message, props) => {
{ path: "/" }
);
}
if (responseJson?.theme?.length > 0) {
handleThemeChange(responseJson.theme)
}else{
handleThemeChange("dark")
}
}
// Handling Ethereum update
+36 -2
View File
@@ -449,6 +449,36 @@ const LeftSideBar = ({ userdata, serverside, globalUrl, notifications, }) => {
});
};
const handleUpdateTheme = (newTheme) => {
const data = {
"theme": newTheme,
}
const url = globalUrl + `/api/v1/users/${userdata?.id}/theme`;
fetch(url, {
mode: "cors",
method: "POST",
body: JSON.stringify(data),
credentials: "include",
crossDomain: true,
withCredentials: true,
headers: {
"Content-Type": "application/json; charset=utf-8",
},
}).then((response) =>
response.json().then((responseJson) => {
if (responseJson["success"] === false) {
toast("Failed updating theme: ", responseJson.reason);
} else {
handleThemeChange(newTheme);
setCurrentSelectedTheme(newTheme);
}
})
).catch((error) => {
console.log("Error changing theme: ", error);
});
};
const removeCookie = (name, path = "/") => {
@@ -543,7 +573,7 @@ const LeftSideBar = ({ userdata, serverside, globalUrl, notifications, }) => {
},
}}
>
{userdata && (
{userdata && (userdata?.org_status?.includes("integration_partner") && userdata?.org_status?.includes("sub_org")) ? null : (
<>
<ToggleButtonGroup
value={currentSelectedTheme}
@@ -555,7 +585,11 @@ const LeftSideBar = ({ userdata, serverside, globalUrl, notifications, }) => {
if (newTheme === currentSelectedTheme) {
return;
}
handleChangeTheme(newTheme);
if (userdata?.org_status?.includes("integration_partner")){
handleChangeTheme(newTheme);
}else {
handleUpdateTheme(newTheme);
}
}}
aria-label="theme"
style={{display: 'flex', justifyContent: "center", marginBottom: 10, }}