Files
reflector/www/app/(app)/transcripts/shareLink.tsx
Igor Monadical 369ecdff13 feat: replace nextjs-config with environment variables (#632)
* chore: remove nextjs-config

* build fix

* update readme

* explicit nextjs env vars + remove feature-unrelated things and obsolete vars from config

* full config removal

* remove force-dynamic from pages

* compile fix

* restore claude-deleted tests

* better .env.example

---------

Co-authored-by: Igor Loskutov <igor.loskutoff@gmail.com>
2025-09-11 11:20:41 -04:00

76 lines
2.0 KiB
TypeScript

import React, { useState, useRef, useEffect, use } from "react";
import { Button, Flex, Input, Text } from "@chakra-ui/react";
import QRCode from "react-qr-code";
import { featureEnabled } from "../../lib/features";
type ShareLinkProps = {
transcriptId: string;
};
const ShareLink = (props: ShareLinkProps) => {
const [isCopied, setIsCopied] = useState(false);
const inputRef = useRef<HTMLInputElement>(null);
const [currentUrl, setCurrentUrl] = useState<string>("");
const requireLogin = featureEnabled("requireLogin");
const privacyEnabled = featureEnabled("privacy");
useEffect(() => {
setCurrentUrl(window.location.href);
}, []);
const handleCopyClick = () => {
if (inputRef.current) {
let text_to_copy = inputRef.current.value;
text_to_copy &&
navigator.clipboard.writeText(text_to_copy).then(() => {
setIsCopied(true);
// Reset the copied state after 2 seconds
setTimeout(() => setIsCopied(false), 2000);
});
}
};
return (
<>
{!requireLogin && (
<>
{privacyEnabled ? (
<Text>
Share this link to grant others access to this page. The link
includes the full audio recording and is valid for the next 7
days.
</Text>
) : (
<Text>
Share this link to allow others to view this page and listen to
the full audio recording.
</Text>
)}
</>
)}
<Flex align={"center"}>
<QRCode
value={`${location.origin}/transcripts/${props.transcriptId}`}
level="L"
size={98}
/>
<Input
type="text"
readOnly
value={currentUrl}
ref={inputRef}
onChange={() => {}}
mx="2"
/>
<Button onClick={handleCopyClick}>
{isCopied ? "Copied!" : "Copy"}
</Button>
</Flex>
</>
);
};
export default ShareLink;