feat: fix GetDashboard() page

This commit is contained in:
Yang Luo
2024-03-15 19:52:19 +08:00
parent 2cb6ff69ae
commit 88a4736520
2 changed files with 18 additions and 6 deletions

View File

@ -42,11 +42,21 @@ const Dashboard = (props) => {
}
}, [props.account]);
const getOrganizationName = () => {
let organization = localStorage.getItem("organization") === "All" ? "" : localStorage.getItem("organization");
if (!Setting.isAdminUser(props.account) && Setting.isLocalAdminUser(props.account)) {
organization = props.account.owner;
}
return organization;
};
React.useEffect(() => {
if (!Setting.isLocalAdminUser(props.account)) {
return;
}
DashboardBackend.getDashboard(props.account.owner).then((res) => {
const organization = getOrganizationName();
DashboardBackend.getDashboard(organization).then((res) => {
if (res.status === "ok") {
setDashboardData(res.data);
} else {
@ -64,9 +74,8 @@ const Dashboard = (props) => {
return;
}
const newOrganization = localStorage.getItem("organization") === "All" ? "" : localStorage.getItem("organization");
DashboardBackend.getDashboard(newOrganization).then((res) => {
const organization = getOrganizationName();
DashboardBackend.getDashboard(organization).then((res) => {
if (res.status === "ok") {
setDashboardData(res.data);
} else {