Add invite links
This commit is contained in:
@@ -34,9 +34,14 @@ export function MarathonPage() {
|
||||
}
|
||||
}
|
||||
|
||||
const copyInviteCode = () => {
|
||||
const getInviteLink = () => {
|
||||
if (!marathon) return ''
|
||||
return `${window.location.origin}/invite/${marathon.invite_code}`
|
||||
}
|
||||
|
||||
const copyInviteLink = () => {
|
||||
if (marathon) {
|
||||
navigator.clipboard.writeText(marathon.invite_code)
|
||||
navigator.clipboard.writeText(getInviteLink())
|
||||
setCopied(true)
|
||||
setTimeout(() => setCopied(false), 2000)
|
||||
}
|
||||
@@ -229,16 +234,16 @@ export function MarathonPage() {
|
||||
</Card>
|
||||
</div>
|
||||
|
||||
{/* Invite code */}
|
||||
{/* Invite link */}
|
||||
{marathon.status !== 'finished' && (
|
||||
<Card className="mb-8">
|
||||
<CardContent>
|
||||
<h3 className="font-medium text-white mb-3">Код приглашения</h3>
|
||||
<h3 className="font-medium text-white mb-3">Ссылка для приглашения</h3>
|
||||
<div className="flex items-center gap-3">
|
||||
<code className="flex-1 px-4 py-2 bg-gray-900 rounded-lg text-primary-400 font-mono">
|
||||
{marathon.invite_code}
|
||||
<code className="flex-1 px-4 py-2 bg-gray-900 rounded-lg text-primary-400 font-mono text-sm overflow-hidden text-ellipsis">
|
||||
{getInviteLink()}
|
||||
</code>
|
||||
<Button variant="secondary" onClick={copyInviteCode}>
|
||||
<Button variant="secondary" onClick={copyInviteLink}>
|
||||
{copied ? (
|
||||
<>
|
||||
<Check className="w-4 h-4 mr-2" />
|
||||
@@ -253,7 +258,7 @@ export function MarathonPage() {
|
||||
</Button>
|
||||
</div>
|
||||
<p className="text-sm text-gray-500 mt-2">
|
||||
Поделитесь этим кодом с друзьями, чтобы они могли присоединиться к марафону
|
||||
Поделитесь этой ссылкой с друзьями, чтобы они могли присоединиться к марафону
|
||||
</p>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
Reference in New Issue
Block a user