macbookpro commited on
Commit
94f5dab
1 Parent(s): 4db208a

alteracoes promptMode

Browse files
web/package-lock.json CHANGED
@@ -8,8 +8,10 @@
8
  "name": "question-generator",
9
  "version": "0.0.0",
10
  "dependencies": {
 
11
  "@radix-ui/react-select": "^2.0.0",
12
  "@radix-ui/react-separator": "^1.0.3",
 
13
  "class-variance-authority": "^0.7.0",
14
  "clsx": "^2.1.1",
15
  "lucide-react": "^0.377.0",
@@ -1230,6 +1232,29 @@
1230
  }
1231
  }
1232
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1233
  "node_modules/@radix-ui/react-popper": {
1234
  "version": "1.1.3",
1235
  "resolved": "https://registry.npmjs.org/@radix-ui/react-popper/-/react-popper-1.1.3.tgz",
@@ -1392,6 +1417,35 @@
1392
  }
1393
  }
1394
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1395
  "node_modules/@radix-ui/react-use-callback-ref": {
1396
  "version": "1.0.1",
1397
  "resolved": "https://registry.npmjs.org/@radix-ui/react-use-callback-ref/-/react-use-callback-ref-1.0.1.tgz",
 
8
  "name": "question-generator",
9
  "version": "0.0.0",
10
  "dependencies": {
11
+ "@radix-ui/react-label": "^2.0.2",
12
  "@radix-ui/react-select": "^2.0.0",
13
  "@radix-ui/react-separator": "^1.0.3",
14
+ "@radix-ui/react-switch": "^1.0.3",
15
  "class-variance-authority": "^0.7.0",
16
  "clsx": "^2.1.1",
17
  "lucide-react": "^0.377.0",
 
1232
  }
1233
  }
1234
  },
1235
+ "node_modules/@radix-ui/react-label": {
1236
+ "version": "2.0.2",
1237
+ "resolved": "https://registry.npmjs.org/@radix-ui/react-label/-/react-label-2.0.2.tgz",
1238
+ "integrity": "sha512-N5ehvlM7qoTLx7nWPodsPYPgMzA5WM8zZChQg8nyFJKnDO5WHdba1vv5/H6IO5LtJMfD2Q3wh1qHFGNtK0w3bQ==",
1239
+ "dependencies": {
1240
+ "@babel/runtime": "^7.13.10",
1241
+ "@radix-ui/react-primitive": "1.0.3"
1242
+ },
1243
+ "peerDependencies": {
1244
+ "@types/react": "*",
1245
+ "@types/react-dom": "*",
1246
+ "react": "^16.8 || ^17.0 || ^18.0",
1247
+ "react-dom": "^16.8 || ^17.0 || ^18.0"
1248
+ },
1249
+ "peerDependenciesMeta": {
1250
+ "@types/react": {
1251
+ "optional": true
1252
+ },
1253
+ "@types/react-dom": {
1254
+ "optional": true
1255
+ }
1256
+ }
1257
+ },
1258
  "node_modules/@radix-ui/react-popper": {
1259
  "version": "1.1.3",
1260
  "resolved": "https://registry.npmjs.org/@radix-ui/react-popper/-/react-popper-1.1.3.tgz",
 
1417
  }
1418
  }
1419
  },
1420
+ "node_modules/@radix-ui/react-switch": {
1421
+ "version": "1.0.3",
1422
+ "resolved": "https://registry.npmjs.org/@radix-ui/react-switch/-/react-switch-1.0.3.tgz",
1423
+ "integrity": "sha512-mxm87F88HyHztsI7N+ZUmEoARGkC22YVW5CaC+Byc+HRpuvCrOBPTAnXgf+tZ/7i0Sg/eOePGdMhUKhPaQEqow==",
1424
+ "dependencies": {
1425
+ "@babel/runtime": "^7.13.10",
1426
+ "@radix-ui/primitive": "1.0.1",
1427
+ "@radix-ui/react-compose-refs": "1.0.1",
1428
+ "@radix-ui/react-context": "1.0.1",
1429
+ "@radix-ui/react-primitive": "1.0.3",
1430
+ "@radix-ui/react-use-controllable-state": "1.0.1",
1431
+ "@radix-ui/react-use-previous": "1.0.1",
1432
+ "@radix-ui/react-use-size": "1.0.1"
1433
+ },
1434
+ "peerDependencies": {
1435
+ "@types/react": "*",
1436
+ "@types/react-dom": "*",
1437
+ "react": "^16.8 || ^17.0 || ^18.0",
1438
+ "react-dom": "^16.8 || ^17.0 || ^18.0"
1439
+ },
1440
+ "peerDependenciesMeta": {
1441
+ "@types/react": {
1442
+ "optional": true
1443
+ },
1444
+ "@types/react-dom": {
1445
+ "optional": true
1446
+ }
1447
+ }
1448
+ },
1449
  "node_modules/@radix-ui/react-use-callback-ref": {
1450
  "version": "1.0.1",
1451
  "resolved": "https://registry.npmjs.org/@radix-ui/react-use-callback-ref/-/react-use-callback-ref-1.0.1.tgz",
web/package.json CHANGED
@@ -10,8 +10,10 @@
10
  "preview": "vite preview"
11
  },
12
  "dependencies": {
 
13
  "@radix-ui/react-select": "^2.0.0",
14
  "@radix-ui/react-separator": "^1.0.3",
 
15
  "class-variance-authority": "^0.7.0",
16
  "clsx": "^2.1.1",
17
  "lucide-react": "^0.377.0",
 
10
  "preview": "vite preview"
11
  },
12
  "dependencies": {
13
+ "@radix-ui/react-label": "^2.0.2",
14
  "@radix-ui/react-select": "^2.0.0",
15
  "@radix-ui/react-separator": "^1.0.3",
16
+ "@radix-ui/react-switch": "^1.0.3",
17
  "class-variance-authority": "^0.7.0",
18
  "clsx": "^2.1.1",
19
  "lucide-react": "^0.377.0",
web/src/App.jsx CHANGED
@@ -9,6 +9,10 @@ import { ChevronLeft, Menu } from "lucide-react"
9
  import { useEffect, useState } from "react";
10
  import { ToastContainer, toast } from "react-toastify"
11
  import 'react-toastify/dist/ReactToastify.css';
 
 
 
 
12
 
13
  function App() {
14
 
@@ -18,6 +22,7 @@ function App() {
18
  const [menuState, setMenuState] = useState(true);
19
  const [isLoading, setIsLoading] = useState(false);
20
  const [questions, setQuestions] = useState(null);
 
21
 
22
  const subjects = [
23
  { label: "Fisiologia", value: "fisiologia" },
@@ -105,76 +110,99 @@ function App() {
105
  </h1>
106
  </header>
107
  <main className="flex-1 flex overflow-hidden">
108
- {
109
- menuState &&
110
- <form
111
- onSubmit={handleSubmit}
112
- className="p-10 flex flex-col gap-2.5 absolute top-0 bg-black/95 h-full z-10 md:static md:h-full md:bg-transparent">
113
- <div className="md:sr-only">
114
- <ChevronLeft className="w-10 h-10" onClick={e => setMenuState(prev => !prev)} />
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
115
  </div>
116
- <h2>Selecione uma matéria:</h2>
117
- <Select defaultValue="biologia" >
118
- <SelectTrigger className="w-[180px]">
119
- <SelectValue placeholder="Matéria" />
120
- </SelectTrigger>
121
- <SelectContent >
122
- <SelectItem value="biologia">Biologia</SelectItem>
123
- </SelectContent>
124
- </Select>
125
- <h2>Selecione um conteúdo:</h2>
126
- <Select onValueChange={value => setSubject(value)}>
127
- <SelectTrigger className="w-[180px]">
128
- <SelectValue placeholder="Conteúdo" />
129
- </SelectTrigger>
130
- <SelectContent onChange={e => console.log(e)}>
131
- {subjects && subjects.map(({ label, value }) => (
132
- <SelectItem key={value} value={value}>{label}</SelectItem>
133
- ))}
134
- </SelectContent>
135
- </Select>
136
- <h2>Selecione uma dificuldade:</h2>
137
- <Select onValueChange={value => setDifficultie(value)}>
138
- <SelectTrigger className="w-[180px]">
139
- <SelectValue placeholder="Dificuldade" />
140
- </SelectTrigger>
141
- <SelectContent onChange={e => console.log(e)}>
142
- {difficulties && difficulties.map(({ label, value }) => (
143
- <SelectItem key={value} value={value}>{label}</SelectItem>
144
- ))}
145
- </SelectContent>
146
- </Select>
147
- <button className="h-10 bg-purple-500 rounded px-2.5 py-1 mt-5 hover:brightness-110 transition-all flex items-center justify-center disabled:hover:brightness-75 disabled:brightness-75"
148
- disabled={isLoading || !subject || !difficultie}>
149
- {
150
- isLoading ?
151
- <div className="animate-spin h-5 w-5 border-2 border-white border-r-purple-500 rounded-full"></div>
152
- :
153
- "Enviar"
154
- }
155
- </button>
156
- </form>
157
  }
158
- <section className="p-10 flex-1 md:border-l-2 md:border-l-white flex flex-col gap-2.5 ">
159
- <h2 className="text-2xl font-bold">Questões</h2>
160
- <div className="w-full h-full flex flex-col gap-5 rounded p-2.5 overflow-y-scroll">
161
- {questions ?
162
- questions.map(({ question, options, answer }, index) => (
163
- <div key={index} className="bg-slate-950 ring-2 ring-white p-2.5 rounded">
164
- {question}<br /><br />
165
- {options.map((option, i) => (
166
- <div key={i}>
167
- {option}
168
- </div>
169
- ))}<br />
170
- Resposta correta: {answer}
171
- </div>
172
- ))
173
- : <div className="p-2.5 bg-slate-950 ring-2 ring-white rounded">{"Ainda sem questões"}</div>}
174
- </div>
175
- </section>
176
  <ToastContainer />
177
  </main>
 
178
  </div>
179
  )
180
  }
 
9
  import { useEffect, useState } from "react";
10
  import { ToastContainer, toast } from "react-toastify"
11
  import 'react-toastify/dist/ReactToastify.css';
12
+ import { Switch } from "@/components/ui/switch"
13
+ import { Label } from "@/components/ui/label"
14
+ import { Input } from "@/components/ui/input"
15
+
16
 
17
  function App() {
18
 
 
22
  const [menuState, setMenuState] = useState(true);
23
  const [isLoading, setIsLoading] = useState(false);
24
  const [questions, setQuestions] = useState(null);
25
+ const [promptMode, setPromptMode] = useState(false);
26
 
27
  const subjects = [
28
  { label: "Fisiologia", value: "fisiologia" },
 
110
  </h1>
111
  </header>
112
  <main className="flex-1 flex overflow-hidden">
113
+ {menuState &&
114
+ <>
115
+ <div className="p-10 flex flex-col gap-5">
116
+ <div className="flex items-center space-x-2 w-56">
117
+ <Switch id="prompt-mode" checked={promptMode} onCheckedChange={setPromptMode} />
118
+ <Label htmlFor="prompt-mode">Prompt Mode</Label>
119
+ </div>
120
+ {!promptMode && (
121
+ <form
122
+ onSubmit={handleSubmit}
123
+ className="flex flex-col gap-2.5 absolute top-0 bg-black/95 h-full md:h-fit z-10 md:static md:bg-transparent">
124
+ <div className="md:sr-only">
125
+ <ChevronLeft className="w-10 h-10" onClick={e => setMenuState(prev => !prev)} />
126
+ </div>
127
+ <fieldset>
128
+ <h2>Selecione uma matéria:</h2>
129
+ <Select defaultValue="biologia">
130
+ <SelectTrigger className="w-[180px]">
131
+ <SelectValue placeholder="Matéria" />
132
+ </SelectTrigger>
133
+ <SelectContent>
134
+ <SelectItem value="biologia">Biologia</SelectItem>
135
+ </SelectContent>
136
+ </Select>
137
+ <h2>Selecione um conteúdo:</h2>
138
+ <Select onValueChange={value => setSubject(value)}>
139
+ <SelectTrigger className="w-[180px]">
140
+ <SelectValue placeholder="Conteúdo" />
141
+ </SelectTrigger>
142
+ <SelectContent onChange={e => console.log(e)}>
143
+ {subjects && subjects.map(({ label, value }) => (
144
+ <SelectItem key={value} value={value}>{label}</SelectItem>
145
+ ))}
146
+ </SelectContent>
147
+ </Select>
148
+ <h2>Selecione uma dificuldade:</h2>
149
+ <Select onValueChange={value => setDifficultie(value)}>
150
+ <SelectTrigger className="w-[180px]">
151
+ <SelectValue placeholder="Dificuldade" />
152
+ </SelectTrigger>
153
+ <SelectContent onChange={e => console.log(e)}>
154
+ {difficulties && difficulties.map(({ label, value }) => (
155
+ <SelectItem key={value} value={value}>{label}</SelectItem>
156
+ ))}
157
+ </SelectContent>
158
+ </Select>
159
+ </fieldset>
160
+ <button className="h-10 bg-purple-500 rounded px-2.5 py-1 mt-5 hover:brightness-110 transition-all flex items-center justify-center disabled:hover:brightness-75 disabled:brightness-75"
161
+ disabled={isLoading || !subject || !difficultie}>
162
+ {isLoading ?
163
+ <div className="animate-spin h-5 w-5 border-2 border-white border-r-purple-500 rounded-full"></div>
164
+ :
165
+ "Enviar"
166
+ }
167
+ </button>
168
+ </form>
169
+ )}
170
+
171
+
172
  </div>
173
+ <section className="p-10 flex-1 md:border-l-2 md:border-l-white flex flex-col gap-2.5 ">
174
+ {promptMode ? (
175
+ <>
176
+ <h2 className="text-2xl font-bold mb-5">Digite seu prompt para gerarmos as questões!</h2>
177
+ <Input placeholder="Digite seu prompt:" />
178
+ </>
179
+ ) : (
180
+ <>
181
+ <h2 className="text-2xl font-bold">Questões</h2>
182
+ <div className="w-full h-full flex flex-col gap-5 rounded p-2.5 overflow-y-scroll">
183
+ {questions ?
184
+ questions.map(({ question, options, answer }, index) => (
185
+ <div key={index} className="bg-slate-950 ring-2 ring-white p-2.5 rounded">
186
+ {question}<br /><br />
187
+ {options.map((option, i) => (
188
+ <div key={i}>
189
+ {option}
190
+ </div>
191
+ ))}<br />
192
+ Resposta correta: {answer}
193
+ </div>
194
+ ))
195
+ : <div className="p-2.5 bg-slate-950 ring-2 ring-white rounded">Escolha os filtros para criar as questões</div>
196
+ }
197
+ </div>
198
+ </>
199
+ )}
200
+ </section>
201
+ </>
 
 
 
 
 
 
 
 
 
 
 
 
202
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
203
  <ToastContainer />
204
  </main>
205
+
206
  </div>
207
  )
208
  }
web/src/components/ui/input.jsx ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import * as React from "react"
2
+
3
+ import { cn } from "@/lib/utils"
4
+
5
+ const Input = React.forwardRef(({ className, type, ...props }, ref) => {
6
+ return (
7
+ (<input
8
+ type={type}
9
+ className={cn(
10
+ "flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
11
+ className
12
+ )}
13
+ ref={ref}
14
+ {...props} />)
15
+ );
16
+ })
17
+ Input.displayName = "Input"
18
+
19
+ export { Input }
web/src/components/ui/label.jsx ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use client"
2
+
3
+ import * as React from "react"
4
+ import * as LabelPrimitive from "@radix-ui/react-label"
5
+ import { cva } from "class-variance-authority";
6
+
7
+ import { cn } from "@/lib/utils"
8
+
9
+ const labelVariants = cva(
10
+ "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
11
+ )
12
+
13
+ const Label = React.forwardRef(({ className, ...props }, ref) => (
14
+ <LabelPrimitive.Root ref={ref} className={cn(labelVariants(), className)} {...props} />
15
+ ))
16
+ Label.displayName = LabelPrimitive.Root.displayName
17
+
18
+ export { Label }
web/src/components/ui/switch.jsx ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use client"
2
+
3
+ import * as React from "react"
4
+ import * as SwitchPrimitives from "@radix-ui/react-switch"
5
+
6
+ import { cn } from "@/lib/utils"
7
+
8
+ const Switch = React.forwardRef(({ className, ...props }, ref) => (
9
+ <SwitchPrimitives.Root
10
+ className={cn(
11
+ "peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",
12
+ className
13
+ )}
14
+ {...props}
15
+ ref={ref}>
16
+ <SwitchPrimitives.Thumb
17
+ className={cn(
18
+ "pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0"
19
+ )} />
20
+ </SwitchPrimitives.Root>
21
+ ))
22
+ Switch.displayName = SwitchPrimitives.Root.displayName
23
+
24
+ export { Switch }