import { Dialog, Transition } from "@headlessui/react"; import { Fragment, useState } from "react"; import { ModernSwitch } from "~/components/ModernSwitch"; import { api, type RouterOutputs } from "~/utils/api"; interface Props { video: RouterOutputs["video"]["get"]; } export function ShareModal({ video }: Props) { const utils = api.useContext(); const [open, setOpen] = useState(false); const setSharingMutation = api.video.setSharing.useMutation({ onMutate: async ({ videoId, sharing }) => { await utils.video.get.cancel(); const previousValue = utils.video.get.getData({ videoId }); if (previousValue) { utils.video.get.setData({ videoId }, { ...previousValue, sharing }); } return { previousValue }; }, }); const [linkCopied, setLinkCopied] = useState(false); const handleCopy = () => { void navigator.clipboard.writeText(window.location.href); setLinkCopied(true); setTimeout(() => { setLinkCopied(false); }, 5000); }; return ( <> setOpen(true)} className="cursor-pointer rounded border border-[#0000001a] px-2 py-2 text-sm text-[#292d34] hover:bg-[#fafbfc]" > Share setOpen(false)} >
Share this recording
Share link with anyone setSharingMutation.mutate({ videoId: video.id, sharing: !video.sharing, }) } />
{video.sharing ? ( <>
{/*
*/} {/* Expire link*/} {/* */} {/*
*/} {/*
*/} {/* Delete video when expired*/} {/* */} {/*
*/}
Share link with search engines console.log("test")} />
{/*
*/} {/* Embed code*/} {/* */} {/*
*/}
) : null}
); }