From 5ab379feaf5e004b801d06813343c01a5089731e Mon Sep 17 00:00:00 2001 From: Arjun Patel Date: Tue, 18 Jan 2022 19:18:32 -0800 Subject: [PATCH] nice flow almost done --- components/LinkCard.tsx | 162 +++++++++++++++++++++++++++++++++------- components/RoomCard.tsx | 2 +- models/link.ts | 5 +- 3 files changed, 140 insertions(+), 29 deletions(-) diff --git a/components/LinkCard.tsx b/components/LinkCard.tsx index 116620d..14b06ed 100644 --- a/components/LinkCard.tsx +++ b/components/LinkCard.tsx @@ -1,21 +1,113 @@ -import { FaArchive, FaExternalLinkAlt, FaFilePdf } from "react-icons/fa"; +import { + FaAngleDoubleRight, + FaArchive, + FaExternalLinkAlt, + FaFilePdf, + FaTrash, +} from "react-icons/fa"; import Link, { LinkType } from "../models/link"; import Image from "next/image"; import { BsThreeDots } from "react-icons/bs"; import LinkIcon from "./LinkIcon"; +import { useTeamDashboardContext } from "../contexts/teamDashboardContext"; +import { useAuth } from "../contexts/authContext"; +import { User } from "../models/user"; +import { Avatar, Dropdown, Menu, Tooltip } from "antd"; +import { useState } from "react"; +import SkeletonLoader from "./Loading/skeletonLoader"; +import moment from "moment"; interface ILinkCardProps { link: Link; } export default function LinkCard(props: ILinkCardProps) { + const { currUser } = useAuth(); + const { teamUsersMap, user } = useTeamDashboardContext(); + const [loading, setLoading] = useState(false); + + var sender: User; + + if (props.link.createdByUserId == currUser.uid) { + sender = user; + } else { + } + + var receivers: User[] = props.link.recipients?.reduce((results, userId) => { + if (userId in teamUsersMap) { + results.push(teamUsersMap[userId]); + } + + // if I am the receiver still add me to the receivers + if (userId == currUser.uid) { + results.push(user); + } + + return results; + }, [] as User[]); + + function handleDeleteLink() { + if ( + confirm( + "Are you sure you want to delete link? It will disappear for all recipients." + ) + ) { + console.log("deleting link"); + try { + } catch (error) {} + } + } + + function handleArchivingLink() { + if ( + confirm( + "Are you sure you want to archive link? It will be in the archive tab." + ) + ) { + console.log("archiving link"); + try { + } catch (error) {} + } + } + + if (loading) { + return ; + } + + const LinkOptionsMenu = ( + + }> + + + } + > + + + + ); + + const relativeDateTime: string = moment( + props.link.createdDate.toDate() + ).fromNow(); + + var receiversNames = ""; + if (receivers) { + receiversNames = receivers.map((receiver) => receiver.firstName).join(", "); + } + + console.log(receiversNames); + return ( - window.open(props.link.link, "_blank")} - className="flex flex-col rounded-lg hover:cursor-pointer" - > + {/* attmnt header */} - + window.open(props.link.link, "_blank")} + className="flex flex-row bg-gray-300 bg-opacity-25 py-5 px-3 items-center justify-start hover:cursor-pointer" + > @@ -40,29 +132,45 @@ export default function LinkCard(props: ILinkCardProps) { {/* attmnt footer */} - - - - - profile + " + receiversNames + ": " + relativeDateTime + } + > + + + + + + + {receivers ? ( + receivers.map((receiverUser, i) => { + return ( + + ); + }) + ) : ( + + team + + )} + + + + + + - - - Adriana - - 5 minutes ago - - - - - + ); } diff --git a/components/RoomCard.tsx b/components/RoomCard.tsx index 2c8cc6f..b094ba2 100644 --- a/components/RoomCard.tsx +++ b/components/RoomCard.tsx @@ -282,7 +282,7 @@ export default function RoomCard(props: IRoomCardProps) { isUserInRoom ? " bg-gray-400 bg-opacity-25 text-gray-400" : "bg-gray-300 bg-opacity-25 text-white" - } bg-gray-400 bg-opacity-25 p-2 ml-auto rounded hover:bg-opacity-40`} + } bg-gray-400 bg-opacity-25 p-2 ml-auto rounded hover:bg-opacity-40`} > diff --git a/models/link.ts b/models/link.ts index c84ec99..c52ef7c 100644 --- a/models/link.ts +++ b/models/link.ts @@ -45,7 +45,10 @@ export default class Link { return LinkType.github; } else if (url.includes(LinkType.atlassian)) { return LinkType.atlassian; - } else if (url.includes(LinkType.googleDrive)) { + } else if ( + url.includes(LinkType.googleDrive) || + url.includes("docs.google") + ) { return LinkType.googleDrive; } else if ( url.includes(".png") ||