From 031a68d017812b92d6b2a7419e10ab2858173b84 Mon Sep 17 00:00:00 2001
From: xaralis <filip.varecha@fragaria.cz>
Date: Mon, 21 Dec 2020 21:19:45 +0100
Subject: [PATCH] feat: only display non-pending procedure proposals to
 non-chairmen

---
 src/containers/PostsContainer.jsx | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/containers/PostsContainer.jsx b/src/containers/PostsContainer.jsx
index 0efdc0c..25d968a 100644
--- a/src/containers/PostsContainer.jsx
+++ b/src/containers/PostsContainer.jsx
@@ -146,6 +146,14 @@ const PostsContainer = ({ className }) => {
 
   const sliceStart = (window.page - 1) * window.perPage;
   const sliceEnd = window.page * window.perPage;
+  let windowItems = window.items.map((postId) => items[postId]);
+
+  // Only display proposals verified by chairman to other users.
+  if (!user || user.role !== "chairman") {
+    windowItems = windowItems.filter(
+      (item) => item.type === "post" || item.state !== "pending"
+    );
+  }
 
   return (
     <>
@@ -155,9 +163,7 @@ const PostsContainer = ({ className }) => {
         </ErrorMessage>
       )}
       <PostList
-        items={window.items
-          .slice(sliceStart, sliceEnd)
-          .map((postId) => items[postId])}
+        items={windowItems.slice(sliceStart, sliceEnd)}
         canThumb={isAuthenticated}
         canRunActions={isAuthenticated && user.role === "chairman"}
         onLike={like.run}
-- 
GitLab