|
1 | 1 | import { useState, type FormEvent } from "react" |
2 | | -import { CheckCircle2 } from "lucide-react" |
| 2 | +import { ArrowUpRight } from "lucide-react" |
3 | 3 | import { Button } from "@/components/ui/button" |
4 | 4 | import { Input } from "@/components/ui/input" |
5 | 5 | import { Label } from "@/components/ui/label" |
6 | 6 | import { Textarea } from "@/components/ui/textarea" |
7 | 7 |
|
| 8 | +const REPO = "https://github.com/IamCoder18/synapse" |
| 9 | + |
8 | 10 | export function PilotForm() { |
9 | | - const [sent, setSent] = useState(false) |
| 11 | + const [name, setName] = useState("") |
| 12 | + const [team, setTeam] = useState("") |
| 13 | + const [experience, setExperience] = useState("") |
10 | 14 |
|
11 | | - function submit(e: FormEvent) { |
12 | | - e.preventDefault() |
13 | | - setSent(true) |
| 15 | + function issueUrl() { |
| 16 | + const params = new URLSearchParams({ |
| 17 | + template: "website-feedback.yml", |
| 18 | + title: `[Website] Feedback${name ? ` from ${name}` : ""}`, |
| 19 | + experience, |
| 20 | + }) |
| 21 | + if (name) params.set("name", name) |
| 22 | + if (team) params.set("team", team) |
| 23 | + return `${REPO}/issues/new?${params.toString()}` |
14 | 24 | } |
15 | 25 |
|
16 | | - if (sent) { |
17 | | - return ( |
18 | | - <div className="flex h-full min-h-64 flex-col items-center justify-center gap-3 text-center"> |
19 | | - <div className="flex size-12 items-center justify-center rounded-full bg-primary/15"> |
20 | | - <CheckCircle2 className="size-6 text-primary" /> |
21 | | - </div> |
22 | | - <p className="font-display text-lg font-semibold">Feedback received</p> |
23 | | - <p className="max-w-xs text-sm text-muted-foreground"> |
24 | | - Thanks for taking the time — your notes go straight to the |
25 | | - maintainers and into release planning. |
26 | | - </p> |
27 | | - </div> |
28 | | - ) |
| 26 | + function submit(e: FormEvent) { |
| 27 | + e.preventDefault() |
| 28 | + window.open(issueUrl(), "_blank", "noopener") |
29 | 29 | } |
30 | 30 |
|
31 | 31 | return ( |
32 | 32 | <form onSubmit={submit} className="grid gap-5"> |
33 | 33 | <div className="grid gap-5 sm:grid-cols-2"> |
34 | 34 | <div className="grid gap-2.5"> |
35 | | - <Label htmlFor="pilot-name">Name</Label> |
36 | | - <Input id="pilot-name" placeholder="Ada Lovelace" required /> |
| 35 | + <Label htmlFor="pilot-name"> |
| 36 | + Name <span className="text-muted-foreground">(optional)</span> |
| 37 | + </Label> |
| 38 | + <Input |
| 39 | + id="pilot-name" |
| 40 | + placeholder="Ada Lovelace" |
| 41 | + value={name} |
| 42 | + onChange={(e) => setName(e.target.value)} |
| 43 | + /> |
37 | 44 | </div> |
38 | 45 | <div className="grid gap-2.5"> |
39 | 46 | <Label htmlFor="pilot-team"> |
40 | 47 | Team number <span className="text-muted-foreground">(optional)</span> |
41 | 48 | </Label> |
42 | | - <Input id="pilot-team" placeholder="23684" /> |
| 49 | + <Input |
| 50 | + id="pilot-team" |
| 51 | + placeholder="23684" |
| 52 | + value={team} |
| 53 | + onChange={(e) => setTeam(e.target.value)} |
| 54 | + /> |
43 | 55 | </div> |
44 | 56 | </div> |
45 | | - <div className="grid gap-2.5"> |
46 | | - <Label htmlFor="pilot-email">Email</Label> |
47 | | - <Input id="pilot-email" type="email" placeholder="you@team.org" required /> |
48 | | - </div> |
49 | 57 | <div className="grid gap-2.5"> |
50 | 58 | <Label htmlFor="pilot-about">Your experience so far</Label> |
51 | 59 | <Textarea |
52 | 60 | id="pilot-about" |
| 61 | + required |
53 | 62 | placeholder="The good, the broken, and the missing..." |
54 | 63 | className="min-h-24" |
| 64 | + value={experience} |
| 65 | + onChange={(e) => setExperience(e.target.value)} |
55 | 66 | /> |
56 | 67 | </div> |
57 | 68 | <div className="flex flex-wrap items-center gap-3"> |
58 | 69 | <Button type="submit" size="lg"> |
59 | | - Send feedback |
| 70 | + Send feedback on GitHub |
| 71 | + <ArrowUpRight /> |
60 | 72 | </Button> |
61 | 73 | <p className="text-xs text-muted-foreground"> |
62 | | - Read by the maintainers — no newsletter, no spam. |
| 74 | + Opens a public issue on GitHub — read by the maintainers, no email |
| 75 | + needed. |
63 | 76 | </p> |
64 | 77 | </div> |
65 | 78 | </form> |
|
0 commit comments