diff --git a/typescript/Frontend/src/App.tsx b/typescript/Frontend/src/App.tsx
index 586cf423d..8847fb18a 100644
--- a/typescript/Frontend/src/App.tsx
+++ b/typescript/Frontend/src/App.tsx
@@ -14,12 +14,13 @@ import NavigationButtons from "./components/Layout/NavigationButtons";
import InstallationPage from "./components/Installations/InstallationPage";
import { UserContext } from "./components/Context/UserContextProvider";
import ResetPassword from "./ResetPassword";
+import innovenergyLogo from "./resources/innovenergy_Logo_onOrange.png";
const App = () => {
const { token, setToken, removeToken } = useToken();
const [language, setLanguage] = useState("EN");
- const { currentUser } = useContext(UserContext);
+ const { getCurrentUser } = useContext(UserContext);
const getTranslations = () => {
if (language === "DE") {
@@ -31,7 +32,7 @@ const App = () => {
if (!token) {
return ;
}
- if (token && currentUser?.mustResetPassword) {
+ if (token && getCurrentUser()?.mustResetPassword) {
return ;
}
return (
@@ -42,15 +43,20 @@ const App = () => {
defaultLocale="EN"
>
-
-
-
+
+
+
+
+
+
+
+
{
const [password, setPassword] = useState("");
const [loading, setLoading] = useState(false);
const [error, setError] = useState();
- const { setCurrentUser } = useContext(UserContext);
+ const { saveCurrentUser } = useContext(UserContext);
const verifyToken = async (token: string) => {
axiosConfigWithoutToken.get("/GetAllInstallations", {
@@ -39,7 +39,8 @@ const Login = ({ setToken, setLanguage }: I_LoginProps) => {
verifyToken(data.token)
.then(() => {
setToken(data.token);
- setCurrentUser(data.user);
+ saveCurrentUser(data.user);
+ console.log(data.user);
setLoading(false);
setLanguage(data.user.language);
})
diff --git a/typescript/Frontend/src/ResetPassword.tsx b/typescript/Frontend/src/ResetPassword.tsx
index c43db5d49..3b07db745 100644
--- a/typescript/Frontend/src/ResetPassword.tsx
+++ b/typescript/Frontend/src/ResetPassword.tsx
@@ -12,7 +12,7 @@ import * as Yup from "yup";
const ResetPassword = () => {
const [loading, setLoading] = useState(false);
const [error, setError] = useState();
- const { setCurrentUser } = useContext(UserContext);
+ const { saveCurrentUser } = useContext(UserContext);
const validationSchema = Yup.object().shape({
password: Yup.string().required("*Password is required"),
@@ -33,7 +33,8 @@ const ResetPassword = () => {
params: { newPassword: formikValues.verifyPassword },
})
.then((res) => {
- setCurrentUser(res.data);
+ saveCurrentUser(res.data);
+ console.log(res.data);
setLoading(false);
})
.catch((err) => setError(err));
diff --git a/typescript/Frontend/src/components/Context/UserContextProvider.tsx b/typescript/Frontend/src/components/Context/UserContextProvider.tsx
index 9b18056d2..6b9f35adb 100644
--- a/typescript/Frontend/src/components/Context/UserContextProvider.tsx
+++ b/typescript/Frontend/src/components/Context/UserContextProvider.tsx
@@ -4,18 +4,36 @@ import { I_User } from "../../util/user.util";
interface InstallationContextProviderProps {
currentUser?: I_User;
setCurrentUser: (value: I_User) => void;
+ saveCurrentUser: (user: I_User) => void;
+ getCurrentUser: () => I_User;
}
export const UserContext = createContext({
currentUser: {} as I_User,
setCurrentUser: () => {},
+ saveCurrentUser: () => {},
+ getCurrentUser: () => {
+ return {} as I_User;
+ },
});
const UserContextProvider = ({ children }: { children: ReactNode }) => {
const [currentUser, setCurrentUser] = useState();
+ const saveCurrentUser = (user: I_User) => {
+ localStorage.setItem("currentUser", JSON.stringify(user));
+ setCurrentUser(user);
+ };
+
+ const getCurrentUser = (): I_User => {
+ const tokenString = localStorage.getItem("currentUser");
+ return tokenString !== null ? JSON.parse(tokenString) : "";
+ };
+
return (
-
+
{children}
);
diff --git a/typescript/Frontend/src/components/Context/UsersContextProvider.tsx b/typescript/Frontend/src/components/Context/UsersContextProvider.tsx
index d6150b0e3..af77b5e9c 100644
--- a/typescript/Frontend/src/components/Context/UsersContextProvider.tsx
+++ b/typescript/Frontend/src/components/Context/UsersContextProvider.tsx
@@ -21,6 +21,7 @@ interface UsersContextProviderProps {
getAvailableUsersForResource: () => I_User[];
fetchUsersWithInheritedAccessForResource: () => Promise;
fetchUsersWithDirectAccessForResource: () => Promise;
+ fetchAvailableUsers: () => Promise;
}
export const UsersContext = createContext({
@@ -39,6 +40,9 @@ export const UsersContext = createContext({
fetchUsersWithDirectAccessForResource: () => {
return Promise.resolve();
},
+ fetchAvailableUsers: () => {
+ return Promise.resolve();
+ },
});
const UsersContextProvider = ({ children }: { children: ReactNode }) => {
@@ -51,7 +55,7 @@ const UsersContextProvider = ({ children }: { children: ReactNode }) => {
const { currentType } = useContext(GroupContext);
const { id } = useParams();
- const fetchUsers = useCallback(
+ const fetchUsersWithAccess = useCallback(
async (route: string, setState: (value: any) => void) => {
axiosConfig.get(route + currentType, { params: { id } }).then((res) => {
setState(res.data);
@@ -61,12 +65,15 @@ const UsersContextProvider = ({ children }: { children: ReactNode }) => {
);
const fetchUsersWithInheritedAccessForResource = useCallback(async () => {
- fetchUsers("/GetUsersWithInheritedAccessTo", setInheritedAccessUsers);
- }, [fetchUsers]);
+ fetchUsersWithAccess(
+ "/GetUsersWithInheritedAccessTo",
+ setInheritedAccessUsers
+ );
+ }, [fetchUsersWithAccess]);
const fetchUsersWithDirectAccessForResource = useCallback(async () => {
- fetchUsers("/GetUsersWithDirectAccessTo", setDirectAccessUsers);
- }, [fetchUsers]);
+ fetchUsersWithAccess("/GetUsersWithDirectAccessTo", setDirectAccessUsers);
+ }, [fetchUsersWithAccess]);
const getAvailableUsersForResource = () => {
const inheritedUsers = inheritedAccessUsers.map(
@@ -81,10 +88,15 @@ const UsersContextProvider = ({ children }: { children: ReactNode }) => {
);
};
- useEffect(() => {
- axiosConfig.get("/GetAllChildUsers").then((res) => {
+ const fetchAvailableUsers = async (): Promise => {
+ return axiosConfig.get("/GetAllChildUsers").then((res) => {
+ console.log(res);
setAvailableUsers(res.data);
});
+ };
+
+ useEffect(() => {
+ fetchAvailableUsers();
}, []);
return (
@@ -99,6 +111,7 @@ const UsersContextProvider = ({ children }: { children: ReactNode }) => {
getAvailableUsersForResource,
fetchUsersWithInheritedAccessForResource,
fetchUsersWithDirectAccessForResource,
+ fetchAvailableUsers,
}}
>
{children}
diff --git a/typescript/Frontend/src/components/Groups/AccessManagement/AccessManagement.tsx b/typescript/Frontend/src/components/Groups/AccessManagement/AccessManagement.tsx
index 3cc3c7a98..733784022 100644
--- a/typescript/Frontend/src/components/Groups/AccessManagement/AccessManagement.tsx
+++ b/typescript/Frontend/src/components/Groups/AccessManagement/AccessManagement.tsx
@@ -8,13 +8,13 @@ import { useContext } from "react";
import { UserContext } from "../../Context/UserContextProvider";
const AccessManagement = () => {
- const { currentUser } = useContext(UserContext);
+ const { getCurrentUser } = useContext(UserContext);
return (
- {currentUser?.hasWriteAccess && }
+ {getCurrentUser().hasWriteAccess && }
diff --git a/typescript/Frontend/src/components/Groups/AccessManagement/AvailableUserDialog.tsx b/typescript/Frontend/src/components/Groups/AccessManagement/AvailableUserDialog.tsx
index 96ed26adf..0fa267e85 100644
--- a/typescript/Frontend/src/components/Groups/AccessManagement/AvailableUserDialog.tsx
+++ b/typescript/Frontend/src/components/Groups/AccessManagement/AvailableUserDialog.tsx
@@ -59,15 +59,16 @@ const AvailableUserDialog = () => {
scroll="paper"
>
- Grant access
+
option.name}
+ value={selectedUsers}
renderInput={(params) => (
{
sx={{ height: 40, ml: 2 }}
onClick={handleGrant}
>
-
+
@@ -95,7 +99,7 @@ const AvailableUserDialog = () => {
type="submit"
onClick={() => setOpen(true)}
>
-
+
>
);
diff --git a/typescript/Frontend/src/components/Groups/AccessManagement/UsersWithDirectAccess.tsx b/typescript/Frontend/src/components/Groups/AccessManagement/UsersWithDirectAccess.tsx
index 791d354f5..aba3365f5 100644
--- a/typescript/Frontend/src/components/Groups/AccessManagement/UsersWithDirectAccess.tsx
+++ b/typescript/Frontend/src/components/Groups/AccessManagement/UsersWithDirectAccess.tsx
@@ -20,7 +20,7 @@ const UsersWithDirectAccess = () => {
useContext(UsersContext);
const { currentType } = useContext(GroupContext);
const { id } = useParams();
- const { currentUser } = useContext(UserContext);
+ const { getCurrentUser } = useContext(UserContext);
useEffect(() => {
fetchUsersWithDirectAccessForResource();
@@ -47,7 +47,7 @@ const UsersWithDirectAccess = () => {
handleIconClick(user.id)}
diff --git a/typescript/Frontend/src/components/Groups/FolderForm.tsx b/typescript/Frontend/src/components/Groups/FolderForm.tsx
index 2796612e7..24c11f99e 100644
--- a/typescript/Frontend/src/components/Groups/FolderForm.tsx
+++ b/typescript/Frontend/src/components/Groups/FolderForm.tsx
@@ -23,13 +23,13 @@ const FolderForm = (props: I_CustomerFormProps) => {
const { values, additionalButtons, handleSubmit } = props;
const intl = useIntl();
const { fetchData } = useContext(GroupContext);
- const { currentUser } = useContext(UserContext);
+ const { getCurrentUser } = useContext(UserContext);
const [snackbarOpen, setSnackbarOpen] = useState(false);
const [error, setError] = useState();
const [loading, setLoading] = useState(false);
- const readOnly = !currentUser?.hasWriteAccess;
+ const readOnly = !getCurrentUser().hasWriteAccess;
const formik = useFormik({
initialValues: {
diff --git a/typescript/Frontend/src/components/Installations/InstallationForm.tsx b/typescript/Frontend/src/components/Installations/InstallationForm.tsx
index 52d628278..b8aed2c2a 100644
--- a/typescript/Frontend/src/components/Installations/InstallationForm.tsx
+++ b/typescript/Frontend/src/components/Installations/InstallationForm.tsx
@@ -21,9 +21,9 @@ const InstallationForm = (props: I_InstallationFormProps) => {
const intl = useIntl();
const { fetchData } = useContext(InstallationContext);
- const { currentUser } = useContext(UserContext);
+ const { getCurrentUser } = useContext(UserContext);
- const readOnly = !currentUser?.hasWriteAccess;
+ const readOnly = !getCurrentUser().hasWriteAccess;
const formik = useFormik({
initialValues: {
diff --git a/typescript/Frontend/src/components/Installations/InstallationList.tsx b/typescript/Frontend/src/components/Installations/InstallationList.tsx
index 2988f2849..297e942bd 100644
--- a/typescript/Frontend/src/components/Installations/InstallationList.tsx
+++ b/typescript/Frontend/src/components/Installations/InstallationList.tsx
@@ -64,9 +64,10 @@ const InstallationList = (props: InstallationListProps) => {
bgcolor: "background.paper",
position: "relative",
overflow: "auto",
- maxHeight: 400,
py: 0,
mt: 1,
+ height: "80vh",
+ maxHeight: "70vh",
}}
component="nav"
aria-labelledby="nested-list-subheader"
diff --git a/typescript/Frontend/src/components/Installations/InstallationPage.tsx b/typescript/Frontend/src/components/Installations/InstallationPage.tsx
index 7650d1d67..4203a5d0e 100644
--- a/typescript/Frontend/src/components/Installations/InstallationPage.tsx
+++ b/typescript/Frontend/src/components/Installations/InstallationPage.tsx
@@ -8,7 +8,7 @@ import { Grid } from "@mui/material";
const InstallationPage = () => {
return (
<>
-
+
diff --git a/typescript/Frontend/src/components/Installations/Installations.tsx b/typescript/Frontend/src/components/Installations/Installations.tsx
index 4a09e0221..b79f34d9b 100644
--- a/typescript/Frontend/src/components/Installations/Installations.tsx
+++ b/typescript/Frontend/src/components/Installations/Installations.tsx
@@ -12,7 +12,7 @@ import Installation from "./Installation";
const Installations = () => {
return (
-
+