You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{/* TODO (Sean): Include Logic to handle retrieving of editable data here and display in a modal component */}
308
307
<Modal
309
308
title="Edit Problem"
310
309
open={isEditModalOpen&&isEditModalOpen[index]}
@@ -399,11 +398,14 @@ export default function Home() {
399
398
</Form.Item>
400
399
</Form>
401
400
</Modal>
402
-
<Button
403
-
className="edit-button"
404
-
icon={<EditOutlined/>}
405
-
onClick={()=>handleEditClick(index,question)}
406
-
></Button>
401
+
{
402
+
isAdmin&&
403
+
<Button
404
+
className="edit-button"
405
+
icon={<EditOutlined/>}
406
+
onClick={()=>handleEditClick(index,question)}
407
+
></Button>
408
+
}
407
409
{/* TODO (Ryan): Include Pop-up confirmation for delete when clicked and link to delete API --> can also explore success notification or look into react-toast*/}
408
410
<Button
409
411
className="delete-button"
@@ -493,115 +495,117 @@ export default function Home() {
493
495
<divclassName="content-card">
494
496
<divclassName="content-row-1">
495
497
<divclassName="content-title">Problems</div>
496
-
<divclassName="create-button">
497
-
{/* TODO (Sean): Launch a popup modal that links to the backend api to create a new entry in db, --> look into success/error notification/react toast */}
498
-
<Button
499
-
type="primary"
500
-
icon={<PlusCircleOutlined/>}
501
-
onClick={showNewProblemModal}
502
-
>
503
-
Create New Problem
504
-
</Button>
505
-
<Modal
506
-
title="Create New Problem"
507
-
open={isNewProblemModalOpen}
508
-
// onOk={() => setIsNewProblemModelOpen(false)} // Replace with handleSubmit
509
-
onCancel={()=>setIsNewProblemModelOpen(false)}
510
-
footer={null}
511
-
width={600}
512
-
>
513
-
<Form
514
-
name="create-form"
515
-
{...layout}
516
-
form={form}
517
-
onFinish={(values)=>{
518
-
handleCreateQuestion(values);
519
-
}}
498
+
{
499
+
isAdmin&&
500
+
<divclassName="create-button">
501
+
<Button
502
+
type="primary"
503
+
icon={<PlusCircleOutlined/>}
504
+
onClick={showNewProblemModal}
520
505
>
521
-
<Form.Item
522
-
name="title"
523
-
label="Title"
524
-
rules={[
525
-
{
526
-
required: true,
527
-
message: "Please enter question title!",
528
-
},
529
-
]}
530
-
>
531
-
<Inputname="title"/>
532
-
</Form.Item>
533
-
<Form.Item
534
-
name="description"
535
-
label="Description"
536
-
rules={[
537
-
{
538
-
required: true,
539
-
message: "Please enter question description!",
540
-
},
541
-
]}
542
-
>
543
-
<TextAreaname="description"/>
544
-
</Form.Item>
545
-
<Form.Item
546
-
name="complexity"
547
-
label="Complexity"
548
-
rules={[
549
-
{
550
-
required: true,
551
-
message: "Please select a complexity!",
552
-
},
553
-
]}
506
+
Create New Problem
507
+
</Button>
508
+
<Modal
509
+
title="Create New Problem"
510
+
open={isNewProblemModalOpen}
511
+
// onOk={() => setIsNewProblemModelOpen(false)} // Replace with handleSubmit
512
+
onCancel={()=>setIsNewProblemModelOpen(false)}
513
+
footer={null}
514
+
width={600}
515
+
>
516
+
<Form
517
+
name="create-form"
518
+
{...layout}
519
+
form={form}
520
+
onFinish={(values)=>{
521
+
handleCreateQuestion(values);
522
+
}}
554
523
>
555
-
<Select
556
-
options={[
524
+
<Form.Item
525
+
name="title"
526
+
label="Title"
527
+
rules={[
557
528
{
558
-
label: "Easy",
559
-
value: "easy",
529
+
required: true,
530
+
message: "Please enter question title!",
560
531
},
532
+
]}
533
+
>
534
+
<Inputname="title"/>
535
+
</Form.Item>
536
+
<Form.Item
537
+
name="description"
538
+
label="Description"
539
+
rules={[
561
540
{
562
-
label: "Medium",
563
-
value: "medium",
541
+
required: true,
542
+
message: "Please enter question description!",
564
543
},
544
+
]}
545
+
>
546
+
<TextAreaname="description"/>
547
+
</Form.Item>
548
+
<Form.Item
549
+
name="complexity"
550
+
label="Complexity"
551
+
rules={[
565
552
{
566
-
label: "Hard",
567
-
value: "hard",
553
+
required: true,
554
+
message: "Please select a complexity!",
568
555
},
569
556
]}
570
-
onChange={(value)=>
571
-
form.setFieldValue("complexity",value)
572
-
}
573
-
allowClear
574
-
/>
575
-
</Form.Item>
576
-
<Form.Item
577
-
name="categories"
578
-
label="Categories"
579
-
rules={[
580
-
{
581
-
required: true,
582
-
message: "Please select the relevant categories!",
0 commit comments