add theming changes for onprem
This commit is contained in:
@@ -192,6 +192,11 @@ const App = (message, props) => {
|
||||
{ path: "/" }
|
||||
);
|
||||
}
|
||||
if (responseJson?.theme?.length > 0) {
|
||||
handleThemeChange(responseJson.theme)
|
||||
}else{
|
||||
handleThemeChange("dark")
|
||||
}
|
||||
}
|
||||
|
||||
// Handling Ethereum update
|
||||
|
||||
@@ -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, }}
|
||||
|
||||
Reference in New Issue
Block a user