From bbe2e5a7cda0c4037441640da80ce97f60c20058 Mon Sep 17 00:00:00 2001 From: Arjun Patel Date: Tue, 18 Jan 2022 17:57:58 -0800 Subject: [PATCH] way nicer flow and almost ready for fetching and displaying but stay patient --- components/Dashboard/Links.tsx | 11 +- components/Dashboard/Rooms.tsx | 1 - components/LinkCard.tsx | 7 +- components/LinkIcon.tsx | 60 ++++++++ components/Modals/CreateOrUpdateLink.tsx | 172 ++++++++++++++++++++++- components/Modals/CreateOrUpdateRoom.tsx | 1 + models/link.ts | 73 ++++++++-- workspace.code-workspace | 11 ++ 8 files changed, 315 insertions(+), 21 deletions(-) create mode 100644 components/LinkIcon.tsx create mode 100644 workspace.code-workspace diff --git a/components/Dashboard/Links.tsx b/components/Dashboard/Links.tsx index c4070c9..8e99f8d 100644 --- a/components/Dashboard/Links.tsx +++ b/components/Dashboard/Links.tsx @@ -84,8 +84,15 @@ export default function Links() { - - diff --git a/components/Dashboard/Rooms.tsx b/components/Dashboard/Rooms.tsx index 27bd559..0afe572 100644 --- a/components/Dashboard/Rooms.tsx +++ b/components/Dashboard/Rooms.tsx @@ -193,7 +193,6 @@ export default function DashboardRoom() { {teamRooms.length} - {RoomTypeFilter.live}{" "} diff --git a/components/LinkCard.tsx b/components/LinkCard.tsx index 5e5b5b1..e5de282 100644 --- a/components/LinkCard.tsx +++ b/components/LinkCard.tsx @@ -2,13 +2,14 @@ import { FaArchive, FaExternalLinkAlt, FaFilePdf } from "react-icons/fa"; import Link from "../models/link"; import Image from "next/image"; import { BsThreeDots } from "react-icons/bs"; +import LinkIcon from "./LinkIcon"; export default function LinkCard(props: { link?: Link }) { return ( {/* attmnt header */} - + report.pdf @@ -57,7 +58,3 @@ export default function LinkCard(props: { link?: Link }) { ); } - -function RenderFileIcon(props) { - return ; -} diff --git a/components/LinkIcon.tsx b/components/LinkIcon.tsx new file mode 100644 index 0000000..3be8403 --- /dev/null +++ b/components/LinkIcon.tsx @@ -0,0 +1,60 @@ +import { + FaAtlassian, + FaFileAlt, + FaFileCode, + FaFileImage, + FaFilePdf, + FaGithubSquare, + FaGoogleDrive, +} from "react-icons/fa"; +import Link, { LinkType } from "../models/link"; + +export default function LinkIcon(props: { + className?: string; + linkType: LinkType; +}) { + // github + + // atlassian + + // drive + + // onedrive + + // dropbox + + // image + + // pdf + + // https://www.codepile.net/ for code snippets + + const { className, linkType, ...rest } = props; + + switch (linkType) { + case LinkType.default: + return ; + case LinkType.atlassian: + return ; + case LinkType.codePile: + return ; + case LinkType.github: + return ( + + ); + case LinkType.googleDrive: + return ( + + ); + case LinkType.image: + return ( + + ); + case LinkType.pdf: + ; + default: + return ( + + ); + } +} diff --git a/components/Modals/CreateOrUpdateLink.tsx b/components/Modals/CreateOrUpdateLink.tsx index 75d1607..b025071 100644 --- a/components/Modals/CreateOrUpdateLink.tsx +++ b/components/Modals/CreateOrUpdateLink.tsx @@ -1,40 +1,202 @@ +import { Divider, Select, Switch, Tooltip } from "antd"; +const { Option } = Select; + import Modal from "antd/lib/modal/Modal"; import { useState } from "react"; +import toast from "react-hot-toast"; +import { useAuth } from "../../contexts/authContext"; import { ShowModalType, useKeyboardContext, } from "../../contexts/keyboardContext"; +import { useTeamDashboardContext } from "../../contexts/teamDashboardContext"; +import Link, { LinkType } from "../../models/link"; +import LinkIcon from "../LinkIcon"; export default function CreateOrUpdateLink() { + const { currUser } = useAuth(); const { handleModalType, showModalType } = useKeyboardContext(); + const { teamUsers, team } = useTeamDashboardContext(); function closeModal() { handleModalType(ShowModalType.na); } + function handleSelectRecipients(value) { + // passed in array of selections...userIds + + setRecipientsSelected(value); + + console.log(value); + } + + function handleSelectRecipientMode(isChecked) { + // clear the list of recipients if team selected + if (isChecked) { + setRecipientsSelected([]); + setIsTeamLink(true); + } else { + setRecipientsSelected([]); + setIsTeamLink(false); + } + } + + function handleSubmitLink() { + if (!link || !name) { + toast.error("Please add a valid link and name"); + return; + } + + // if it's a team link, make sure recipients is null ... but the model should handle this for us? + + try { + const newLink = new Link( + name, + description, + link, + team.id, + recipientsSelected, + currUser.uid + ); + + console.log(newLink); + + // send to database + } catch (error) { + toast.error("Something went wrong in sending the link."); + console.log(error); + } + } + const [link, setLink] = useState(""); + const [name, setName] = useState(""); + const [description, setDescription] = useState(""); + const [showMoreDetails, setShowMoreDetails] = useState(false); + const [isTeamLink, setIsTeamLink] = useState(true); + const [recipientsSelected, setRecipientsSelected] = useState([]); return ( -
+
Link Please make sure this is valid for others to access. + {/* icon and link input */} + + + + setLink(e.target.value)} + /> + + + + + Name + + Make sure this makes sense to who you are sending it to. + setLink(e.target.value)} + value={name} + placeholder="ex. User Story - Customer Creating Orders" + onChange={(e) => setName(e.target.value)} /> + + + Recipients + + Choose team or individual recipients + + + + Team} + unCheckedChildren={Members} + /> + + + {/* select team members to send to */} + {!isTeamLink ? ( + + ) : ( + <> + )} + + + + + {showMoreDetails ? ( + <> + + + + + + Description + + Optional - Add any pointers about this file. + + +