-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpage.tsx
76 lines (71 loc) · 2.73 KB
/
page.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
'use client'
import { useState } from 'react'
import { Button } from "@/components/ui/button"
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"
import { Label } from "@/components/ui/label"
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"
export default function QuantumCircuit() {
const [gate1, setGate1] = useState('h')
const [gate2, setGate2] = useState('h')
const [results, setResults] = useState<string | null>(null)
const runCircuit = async () => {
const response = await fetch('/api/quantum', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ gate1, gate2 }),
})
const data = await response.json()
setResults(JSON.stringify(data.results, null, 2))
}
return (
<div className="container mx-auto p-4">
<Card className="w-full max-w-md mx-auto">
<CardHeader>
<CardTitle>Quantum Circuit Simulator</CardTitle>
</CardHeader>
<CardContent>
<div className="grid gap-4">
<div className="grid grid-cols-2 gap-4">
<div>
<Label htmlFor="gate1">Qubit 1 Gate</Label>
<Select value={gate1} onValueChange={setGate1}>
<SelectTrigger id="gate1">
<SelectValue placeholder="Select gate" />
</SelectTrigger>
<SelectContent>
<SelectItem value="h">Hadamard (H)</SelectItem>
<SelectItem value="x">Pauli-X</SelectItem>
<SelectItem value="y">Pauli-Y</SelectItem>
<SelectItem value="z">Pauli-Z</SelectItem>
</SelectContent>
</Select>
</div>
<div>
<Label htmlFor="gate2">Qubit 2 Gate</Label>
<Select value={gate2} onValueChange={setGate2}>
<SelectTrigger id="gate2">
<SelectValue placeholder="Select gate" />
</SelectTrigger>
<SelectContent>
<SelectItem value="h">Hadamard (H)</SelectItem>
<SelectItem value="x">Pauli-X</SelectItem>
<SelectItem value="y">Pauli-Y</SelectItem>
<SelectItem value="z">Pauli-Z</SelectItem>
</SelectContent>
</Select>
</div>
</div>
<Button onClick={runCircuit}>Run Circuit</Button>
{results && (
<pre className="bg-muted p-2 rounded-md overflow-x-auto">
{results}
</pre>
)}
</div>
</CardContent>
</Card>
</div>
)
}