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. 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.