()
| 27 | } |
| 28 | |
| 29 | const AddProblemCard = () => { |
| 30 | const [newProblems, setNewProblems] = useState<Problem[]>([]); |
| 31 | const [title, setTitle] = useState(""); |
| 32 | const [description, setDescription] = useState(""); |
| 33 | const [notionDocId, setNotionDocId] = useState(""); |
| 34 | const [type, setType] = useState<ProblemType>(ProblemType.Blog); |
| 35 | const { toast } = useToast(); |
| 36 | |
| 37 | const handleCreateProblem = async () => { |
| 38 | const problem = await createProblem({ title, description, type, notionDocId }); |
| 39 | if (problem) { |
| 40 | newProblems.push(problem); |
| 41 | toast({ |
| 42 | title: "Added problem", |
| 43 | description: "Problem added", |
| 44 | }); |
| 45 | return; |
| 46 | } |
| 47 | |
| 48 | toast({ |
| 49 | title: "Couldn't add problem", |
| 50 | description: "Please try again later", |
| 51 | }); |
| 52 | }; |
| 53 | |
| 54 | return ( |
| 55 | <div> |
| 56 | <Card className="cols-span-4 p-4 m-2 w-full"> |
| 57 | <Select |
| 58 | onValueChange={(e: ProblemType) => { |
| 59 | setType(e); |
| 60 | }} |
| 61 | > |
| 62 | <SelectTrigger className="w-[180px]"> |
| 63 | <SelectValue placeholder="Type" /> |
| 64 | </SelectTrigger> |
| 65 | <SelectContent> |
| 66 | <SelectItem value={ProblemType.Blog}>Blog</SelectItem> |
| 67 | <SelectItem value={ProblemType.MCQ}>MCQ</SelectItem> |
| 68 | </SelectContent> |
| 69 | </Select> |
| 70 | |
| 71 | <Input |
| 72 | type="text" |
| 73 | placeholder="Problem title" |
| 74 | className="my-2" |
| 75 | onChange={(event) => { |
| 76 | setTitle(event.target.value); |
| 77 | }} |
| 78 | /> |
| 79 | <Input |
| 80 | type="text" |
| 81 | placeholder="Description" |
| 82 | className="my-2" |
| 83 | onChange={(event) => { |
| 84 | setDescription(event.target.value); |
| 85 | }} |
| 86 | /> |
nothing calls this directly
no test coverage detected