-
+
+
);
})}
@@ -615,12 +626,16 @@ const PaginatedPortfolio: React.FC
> = ({
type Props = {
hankkeet: HankeData[];
+ signedInUserByHanke: SignedInUserByHanke;
};
-const HankePortfolio: React.FC> = ({ hankkeet }) => {
+const HankePortfolio: React.FC> = ({
+ hankkeet,
+ signedInUserByHanke,
+}) => {
return (
);
};
diff --git a/src/domain/hanke/portfolio/HankePortfolioContainer.tsx b/src/domain/hanke/portfolio/HankePortfolioContainer.tsx
index fe2c9201b..db57f233d 100644
--- a/src/domain/hanke/portfolio/HankePortfolioContainer.tsx
+++ b/src/domain/hanke/portfolio/HankePortfolioContainer.tsx
@@ -3,6 +3,7 @@ import { useQuery } from 'react-query';
import api from '../../api/api';
import { HankeData } from '../../types/hanke';
import HankePortfolioComponent from './HankePortfolioComponent';
+import { usePermissionsByHanke } from '../hankeUsers/hooks/useUserRightsForHanke';
const getHankkeet = async () => {
const { data } = await api.get(`/hankkeet`, {
@@ -16,10 +17,16 @@ const getHankkeet = async () => {
const useHankeList = () => useQuery(['project'], getHankkeet);
const HankePortfolioContainer: React.FC> = () => {
- const { data } = useHankeList();
+ const { data: hankkeet } = useHankeList();
+ const { data: signedInUserByHanke } = usePermissionsByHanke();
+ const userData = signedInUserByHanke ?? {};
// Add header to fix Axe "page-has-heading-one"-error
- return data ? : <>>;
+ return hankkeet ? (
+
+ ) : (
+ <>>
+ );
};
export default HankePortfolioContainer;
diff --git a/src/domain/mocks/signedInUser.ts b/src/domain/mocks/signedInUser.ts
new file mode 100644
index 000000000..571ee69c1
--- /dev/null
+++ b/src/domain/mocks/signedInUser.ts
@@ -0,0 +1,67 @@
+import {
+ AccessRightLevel,
+ Rights,
+ SignedInUser,
+ SignedInUserByHanke,
+} from '../hanke/hankeUsers/hankeUser';
+
+export const USER_ALL: SignedInUser = {
+ hankeKayttajaId: 'cc0376be-9609-4b2b-bb10-5a385bdea1d8',
+ kayttooikeustaso: AccessRightLevel.KAIKKI_OIKEUDET,
+ kayttooikeudet: Object.values(Rights),
+};
+
+export const USER_EDIT_ALL: SignedInUser = {
+ hankeKayttajaId: '79284308-d532-4f90-bae7-ea45f947a9c1',
+ kayttooikeustaso: AccessRightLevel.KAIKKIEN_MUOKKAUS,
+ kayttooikeudet: [
+ Rights.VIEW,
+ Rights.MODIFY_VIEW_PERMISSIONS,
+ Rights.EDIT,
+ Rights.MODIFY_EDIT_PERMISSIONS,
+ Rights.EDIT_APPLICATIONS,
+ Rights.MODIFY_APPLICATION_PERMISSIONS,
+ Rights.RESEND_INVITATION,
+ ],
+};
+
+export const USER_EDIT_HANKE: SignedInUser = {
+ hankeKayttajaId: '678585e0-11c5-4675-8847-46132ab0e60c',
+ kayttooikeustaso: AccessRightLevel.HANKEMUOKKAUS,
+ kayttooikeudet: [Rights.VIEW, Rights.EDIT, Rights.RESEND_INVITATION],
+};
+
+export const USER_HAKEMUSASIOINTI: SignedInUser = {
+ hankeKayttajaId: '448ef74f-bf6e-4011-b924-8f559f716a4c',
+ kayttooikeustaso: AccessRightLevel.HAKEMUSASIOINTI,
+ kayttooikeudet: [Rights.VIEW, Rights.EDIT_APPLICATIONS, Rights.RESEND_INVITATION],
+};
+
+export const USER_VIEW: SignedInUser = {
+ hankeKayttajaId: 'ecd6027f-a66f-4ee4-854e-20f0a66c40f8',
+ kayttooikeustaso: AccessRightLevel.KATSELUOIKEUS,
+ kayttooikeudet: [Rights.VIEW],
+};
+
+export const signedInUsers: SignedInUser[] = [
+ USER_ALL,
+ USER_EDIT_ALL,
+ USER_EDIT_HANKE,
+ USER_HAKEMUSASIOINTI,
+ USER_VIEW,
+];
+
+export const signedInUser = (accessLevel: AccessRightLevel) =>
+ signedInUsers.find((user) => user.kayttooikeustaso === accessLevel) ?? USER_VIEW;
+
+export const signedInUserByHanke = (
+ hankeTunnusList: string[],
+ access: AccessRightLevel = AccessRightLevel.KAIKKI_OIKEUDET,
+): SignedInUserByHanke =>
+ hankeTunnusList.reduce(
+ (data: SignedInUserByHanke, tunnus: string) => ({
+ ...data,
+ [tunnus]: signedInUser(access),
+ }),
+ {},
+ );