Added invite link to estimation session

This commit is contained in:
Pijus Kamandulis 2024-10-12 10:24:52 +03:00
parent 3abbbc7808
commit e34c8524b7
2 changed files with 46 additions and 0 deletions

View File

@ -0,0 +1,39 @@
import { useState } from 'react';
interface CopyInputProps {
value: string;
}
const CopyInput: React.FC<CopyInputProps> = ({ value }) => {
const [copied, setCopied] = useState(false);
const handleCopy = async () => {
try {
await navigator.clipboard.writeText(value);
setCopied(true);
setTimeout(() => setCopied(false), 2000);
} catch (error) {
console.error('Failed to copy text:', error);
}
};
return (
<div className="flex items-center space-x-2">
<input
type="text"
value={value}
readOnly
className="w-full rounded-md border border-gray-300 bg-gray-100 px-4 py-2 text-gray-900 dark:border-gray-600 dark:bg-nero-800 dark:text-gray-100"
/>
<button
onClick={handleCopy}
className="rounded-md bg-indigo-600 px-4 py-2 text-sm font-semibold text-white shadow-sm transition-colors hover:bg-indigo-500"
>
{copied ? 'Copied!' : 'Copy'}
</button>
</div>
);
};
export default CopyInput;

View File

@ -6,6 +6,7 @@ import VoteSelection from './components/VoteSelection';
import VoteList from './components/VoteList'; import VoteList from './components/VoteList';
import { Button, ButtonColor, Drawer } from '../../components'; import { Button, ButtonColor, Drawer } from '../../components';
import CreateTicketForm from './components/CreateTicketForm'; import CreateTicketForm from './components/CreateTicketForm';
import CopyInput from '../../components/CopyInput';
const fibonacciSequence = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 100]; const fibonacciSequence = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 100];
@ -47,6 +48,12 @@ const Estimation: React.FC = () => {
/> />
<div className="flex w-full flex-grow flex-col p-6"> <div className="flex w-full flex-grow flex-col p-6">
<div className="flex items-center justify-center gap-2">
<span className="align-middle text-xl font-semibold">
Invite others to join your session
</span>
<CopyInput value={`${window.location.origin}/join/${sessionId}`} />
</div>
{currentTicket ? ( {currentTicket ? (
<> <>
<h1 className="mb-4 text-2xl font-bold">{currentTicket.name}</h1> <h1 className="mb-4 text-2xl font-bold">{currentTicket.name}</h1>