From d338cf5337acc0f18121eede5a2c9b0aa82cb9eb Mon Sep 17 00:00:00 2001
From: xaralis <filip.varecha@fragaria.cz>
Date: Wed, 9 Dec 2020 14:58:43 +0100
Subject: [PATCH] feat: typings polishing, added program

---
 src/components/annoucements/Announcement.jsx  |  6 +--
 .../annoucements/AnnouncementList.jsx         |  2 +-
 src/components/posts/Post.jsx                 | 23 +++++---
 src/components/posts/PostList.jsx             | 30 ++++++-----
 src/containers/AnnoucementsContainer.jsx      | 12 ++---
 src/containers/PostsContainer.jsx             | 52 +++++++++++--------
 typings/cf2021.d.ts                           | 27 ++++++++--
 7 files changed, 97 insertions(+), 55 deletions(-)

diff --git a/src/components/annoucements/Announcement.jsx b/src/components/annoucements/Announcement.jsx
index 03e0c39..39b769b 100644
--- a/src/components/annoucements/Announcement.jsx
+++ b/src/components/annoucements/Announcement.jsx
@@ -11,13 +11,13 @@ const Announcement = ({
   content,
   link,
   relatedPostId,
-  isSeen,
+  seen,
 }) => {
   const wrapperClassName = classNames(
     "bg-opacity-50 border-l-2 px-4 py-2 lg:px-8 lg:py-3",
     {
-      "bg-grey-50": isSeen,
-      "bg-yellow-100": !isSeen,
+      "bg-grey-50": !!seen,
+      "bg-yellow-100": !seen,
       "border-orange-300": type === "rejected-procedure-proposal",
       "border-blue-300": type === "suggested-procedure-proposal",
       "border-green-400": type === "accepted-procedure-proposal",
diff --git a/src/components/annoucements/AnnouncementList.jsx b/src/components/annoucements/AnnouncementList.jsx
index 7d4dbd2..7698f6c 100644
--- a/src/components/annoucements/AnnouncementList.jsx
+++ b/src/components/annoucements/AnnouncementList.jsx
@@ -13,7 +13,7 @@ const AnnouncementList = ({ items, className }) => {
           type={item.type}
           content={item.content}
           link={item.link}
-          isSeen={item.isSeen}
+          seen={item.seen}
         />
       ))}
     </div>
diff --git a/src/components/posts/Post.jsx b/src/components/posts/Post.jsx
index a85ca95..2e8a892 100644
--- a/src/components/posts/Post.jsx
+++ b/src/components/posts/Post.jsx
@@ -11,16 +11,16 @@ const Post = ({
   type,
   ranking,
   content,
-  isSeen,
-  isArchived,
+  seen,
+  archived,
   state,
-  originalContent,
+  historyLog,
 }) => {
   const wrapperClassName = classNames(
     "flex items-start p-4 lg:p-2 lg:py-4 lg:-mx-2",
     {
-      "bg-yellow-100 bg-opacity-50": !isSeen,
-      "opacity-25 hover:opacity-100 transition-opacity duration-200": isArchived,
+      "bg-yellow-100 bg-opacity-50": !seen,
+      "opacity-25 hover:opacity-100 transition-opacity duration-200": !!archived,
     },
     className
   );
@@ -78,7 +78,7 @@ const Post = ({
     );
   }
 
-  if (isArchived) {
+  if (archived) {
     labels.push(
       <Chip
         key="isArchived"
@@ -91,6 +91,12 @@ const Post = ({
     );
   }
 
+  const isModified =
+    (historyLog || []).filter(
+      (logRecord) =>
+        logRecord.attribute === "content" && logRecord.originator === "chairman"
+    ).length > 0;
+
   return (
     <div className={wrapperClassName}>
       <img
@@ -108,6 +114,11 @@ const Post = ({
                   <span className="text-grey-200 text-sm">{author.group}</span>
                   <span className="text-grey-200 ml-1 text-sm">
                     @ {format(datetime, "H:mm")}
+                    {isModified && (
+                      <span className="text-grey-200 text-xs ml-2 underline">
+                        (Upraveno přesdedajícím)
+                      </span>
+                    )}
                   </span>
                 </div>
               </div>
diff --git a/src/components/posts/PostList.jsx b/src/components/posts/PostList.jsx
index 8a2ee97..efdb9cc 100644
--- a/src/components/posts/PostList.jsx
+++ b/src/components/posts/PostList.jsx
@@ -6,20 +6,22 @@ import Post from "./Post";
 const PostList = ({ className, items }) => {
   return (
     <div className={classNames("space-y-px", className)}>
-      {items.map((item) => (
-        <Post
-          key={item.id}
-          datetime={item.datetime}
-          author={item.author}
-          type={item.type}
-          state={item.state}
-          content={item.content}
-          originalContent={item.originalContent}
-          ranking={item.ranking}
-          isSeen={item.isSeen}
-          isArchived={item.isArchived}
-        />
-      ))}
+      {items
+        .filter((item) => !item.hidden)
+        .map((item) => (
+          <Post
+            key={item.id}
+            datetime={item.datetime}
+            author={item.author}
+            type={item.type}
+            state={item.state}
+            content={item.content}
+            ranking={item.ranking}
+            historyLog={item.historyLog}
+            seen={item.seen}
+            archived={item.archived}
+          />
+        ))}
     </div>
   );
 };
diff --git a/src/containers/AnnoucementsContainer.jsx b/src/containers/AnnoucementsContainer.jsx
index 4c592d1..f75e8ff 100644
--- a/src/containers/AnnoucementsContainer.jsx
+++ b/src/containers/AnnoucementsContainer.jsx
@@ -10,7 +10,7 @@ const AnnoucementsContainer = () => {
       content:
         "Shizz fo shizzle mah nizzle fo rizzle, mah home g-dizzle, gravida vizzle, arcu. Pellentesque crunk tortizzle. Sed erizzle. Black izzle sheezy telliv.",
       datetime: new Date(),
-      isSeen: false,
+      seen: false,
       type: "rejected-procedure-proposal",
     },
     {
@@ -18,7 +18,7 @@ const AnnoucementsContainer = () => {
       content:
         "Shizz fo shizzle mah nizzle fo rizzle, mah home g-dizzle, gravida vizzle, arcu. Pellentesque crunk tortizzle. Sed erizzle. Black izzle sheezy telliv.",
       datetime: new Date(),
-      isSeen: false,
+      seen: false,
       type: "accepted-procedure-proposal",
     },
     {
@@ -26,7 +26,7 @@ const AnnoucementsContainer = () => {
       content:
         "Shizz fo shizzle mah nizzle fo rizzle, mah home g-dizzle, gravida vizzle, arcu. Pellentesque crunk tortizzle. Sed erizzle. Black izzle sheezy telliv.",
       datetime: new Date(),
-      isSeen: true,
+      seen: true,
       type: "suggested-procedure-proposal",
     },
     {
@@ -34,7 +34,7 @@ const AnnoucementsContainer = () => {
       content:
         "Shizz fo shizzle mah nizzle fo rizzle, mah home g-dizzle, gravida vizzle, arcu. Pellentesque crunk tortizzle. Sed erizzle. Black izzle sheezy telliv.",
       datetime: new Date(),
-      isSeen: true,
+      seen: true,
       type: "voting",
     },
     {
@@ -42,7 +42,7 @@ const AnnoucementsContainer = () => {
       content:
         "Shizz fo shizzle mah nizzle fo rizzle, mah home g-dizzle, gravida vizzle, arcu. Pellentesque crunk tortizzle. Sed erizzle. Black izzle sheezy telliv.",
       datetime: new Date(),
-      isSeen: true,
+      seen: true,
       type: "announcement",
     },
     {
@@ -50,7 +50,7 @@ const AnnoucementsContainer = () => {
       content:
         "Shizz fo shizzle mah nizzle fo rizzle, mah home g-dizzle, gravida vizzle, arcu. Pellentesque crunk tortizzle. Sed erizzle. Black izzle sheezy telliv.",
       datetime: new Date(),
-      isSeen: true,
+      seen: true,
       type: "user-ban",
     },
   ];
diff --git a/src/containers/PostsContainer.jsx b/src/containers/PostsContainer.jsx
index e7dd22c..caeea17 100644
--- a/src/containers/PostsContainer.jsx
+++ b/src/containers/PostsContainer.jsx
@@ -19,8 +19,8 @@ const PostsContainer = ({ className }) => {
         dislikes: 1,
         score: 4,
       },
-      isSeen: false,
-      isArchived: false,
+      seen: false,
+      archived: false,
       type: "post",
     },
     {
@@ -37,8 +37,8 @@ const PostsContainer = ({ className }) => {
         dislikes: 1,
         score: 4,
       },
-      isSeen: false,
-      isArchived: false,
+      seen: false,
+      archived: false,
       type: "post",
     },
     {
@@ -55,8 +55,8 @@ const PostsContainer = ({ className }) => {
         dislikes: 1,
         score: 4,
       },
-      isSeen: true,
-      isArchived: false,
+      seen: true,
+      archived: false,
       type: "post",
     },
     {
@@ -73,8 +73,8 @@ const PostsContainer = ({ className }) => {
         dislikes: 1,
         score: 4,
       },
-      isSeen: true,
-      isArchived: false,
+      seen: true,
+      archived: false,
       type: "post",
     },
     {
@@ -91,8 +91,8 @@ const PostsContainer = ({ className }) => {
         dislikes: 1,
         score: 4,
       },
-      isSeen: true,
-      isArchived: false,
+      seen: true,
+      archived: false,
       type: "post",
     },
     {
@@ -109,8 +109,8 @@ const PostsContainer = ({ className }) => {
         dislikes: 1,
         score: 4,
       },
-      isSeen: true,
-      isArchived: true,
+      seen: true,
+      archived: true,
       type: "post",
     },
     {
@@ -127,8 +127,8 @@ const PostsContainer = ({ className }) => {
         dislikes: 1,
         score: 4,
       },
-      isSeen: true,
-      isArchived: true,
+      seen: true,
+      archived: true,
       type: "procedure-proposal",
       state: "pending",
     },
@@ -146,10 +146,18 @@ const PostsContainer = ({ className }) => {
         dislikes: 1,
         score: 4,
       },
-      isSeen: true,
-      isArchived: false,
+      seen: true,
+      archived: false,
       type: "procedure-proposal",
       state: "announced",
+      historyLog: [
+        {
+          attribute: "content",
+          datetime: new Date(),
+          newValue: "Lemme know",
+          originator: "chairman",
+        },
+      ],
     },
     {
       id: "9",
@@ -165,8 +173,8 @@ const PostsContainer = ({ className }) => {
         dislikes: 1,
         score: 4,
       },
-      isSeen: true,
-      isArchived: false,
+      seen: true,
+      archived: false,
       type: "procedure-proposal",
       state: "accepted",
     },
@@ -184,8 +192,8 @@ const PostsContainer = ({ className }) => {
         dislikes: 1,
         score: 4,
       },
-      isSeen: true,
-      isArchived: false,
+      seen: true,
+      archived: false,
       type: "procedure-proposal",
       state: "rejected",
     },
@@ -203,8 +211,8 @@ const PostsContainer = ({ className }) => {
         dislikes: 1,
         score: 4,
       },
-      isSeen: true,
-      isArchived: true,
+      seen: true,
+      archived: true,
       type: "procedure-proposal",
       state: "rejected-by-chairman",
     },
diff --git a/typings/cf2021.d.ts b/typings/cf2021.d.ts
index 4dd762b..5df5414 100644
--- a/typings/cf2021.d.ts
+++ b/typings/cf2021.d.ts
@@ -1,4 +1,18 @@
 declare namespace CF2021 {
+    interface ProgramScheduleEntry {
+        id: string;
+        title: string;
+        expectedStartAt: Date;
+        expectedFinishAt: Date;
+    }
+
+    export interface ProgramStorePayload {
+        current: ProgramScheduleEntry & {
+            discussionOpened: boolean;
+        }
+        schedule: ProgramScheduleEntry[];
+    }
+
     interface GroupMapping {
         id: number;
         code: string;
@@ -37,7 +51,7 @@ declare namespace CF2021 {
         content: string;
         link?: string;
         relatedPostId: string;
-        isSeen: boolean;
+        seen: boolean;
     }
 
     export interface AnnouncementStorePayload {
@@ -60,8 +74,15 @@ declare namespace CF2021 {
             likes: number;
             dislikes: number;
         };
-        isArchived: boolean;
-        isSeen: boolean;
+        historyLog: {
+            attribute: string;
+            newValue: string;
+            datetime: Date;
+            originator: "self" | "chairman";
+        }[];
+        archived: boolean;
+        hidden: boolean;
+        seen: boolean;
     }
 
     export interface DiscussionPost extends AbstractPost {
-- 
GitLab