Skip to content

Commit 70a2e19

Browse files
committed
Add topic dropdown selector in Admin panel
1 parent b25072f commit 70a2e19

File tree

1 file changed

+28
-4
lines changed

1 file changed

+28
-4
lines changed

feature-login-signup-ui/frontend/src/components/admin/QuestionForm.js

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,21 @@ import toast from 'react-hot-toast';
33
import apiClient from '../../services/apiClient';
44
import './QuestionForm.css';
55

6+
// Available topics matching TopicSelector.tsx
7+
const AVAILABLE_TOPICS = [
8+
"Arrays",
9+
"LinkedList",
10+
"Binary Tree",
11+
"Graphs",
12+
"Dynamic Programming",
13+
"Trees",
14+
"Greedy",
15+
"Two Pointers",
16+
"Sorting",
17+
"Recursion",
18+
"Strings"
19+
];
20+
621
function QuestionForm({ editingQuestion, onQuestionSaved, onCancel }) {
722
const [formData, setFormData] = useState({
823
title: '',
@@ -186,13 +201,22 @@ function QuestionForm({ editingQuestion, onQuestionSaved, onCancel }) {
186201

187202
<div className="form-group">
188203
<label>Topic *</label>
189-
<input
190-
type="text"
204+
<select
191205
value={formData.topic}
192206
onChange={(e) => setFormData({ ...formData, topic: e.target.value })}
193-
placeholder="e.g., Arrays, Strings, Trees"
194207
required
195-
/>
208+
>
209+
<option value="">Select a topic</option>
210+
{AVAILABLE_TOPICS.map((topic) => (
211+
<option key={topic} value={topic}>
212+
{topic}
213+
</option>
214+
))}
215+
{/* Show current topic if editing and it's not in the list (backward compatibility) */}
216+
{editingQuestion && formData.topic && !AVAILABLE_TOPICS.includes(formData.topic) && (
217+
<option value={formData.topic}>{formData.topic} (current)</option>
218+
)}
219+
</select>
196220
</div>
197221

198222
<div className="form-group">

0 commit comments

Comments
 (0)