Skip to content

Commit 4bebeab

Browse files
exam form view with mocked data - no api
1 parent 7f55f75 commit 4bebeab

File tree

6 files changed

+133
-8
lines changed

6 files changed

+133
-8
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import TakeExamForm from "@/components/exam/TakeExamForm";
2+
import { Metadata } from "next";
3+
4+
export const metadata: Metadata = {
5+
title: "Next.js TakeExam Page",
6+
description: "This is Next.js TakeExam Page",
7+
};
8+
9+
export default function TakeExam() {
10+
return <TakeExamForm />;
11+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { useState } from "react";
2+
import ListWithRadio from "../ui/list/ListWithRadio";
3+
4+
export default function QuestionInput() {
5+
const [selectedOption, setSelectedOption] = useState<string | null>(null);
6+
7+
return (
8+
<div className="col-span-full">
9+
10+
<ListWithRadio
11+
value={selectedOption} // controlled
12+
onChange={(val: React.SetStateAction<string | null>) => setSelectedOption(val)}
13+
/>
14+
</div>)
15+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
"use client";
2+
import React from "react";
3+
import Button from "../ui/button/Button";
4+
import Form from "../form/Form";
5+
import ComponentCard from "../common/ComponentCard";
6+
import QuestionInput from "./QuestionInput";
7+
8+
export default function TakeExamForm() {
9+
const handleSubmit = (e: React.FormEvent) => {
10+
e.preventDefault();
11+
console.log("Form submitted:");
12+
};
13+
return (
14+
<ComponentCard title="Exam Form">
15+
<Form onSubmit={handleSubmit}>
16+
<div className="grid grid-cols-1 gap-6 sm:grid-cols-2">
17+
18+
19+
{Array.from({ length: 5 }).map((_, i) => (
20+
<QuestionInput key={i} />
21+
))}
22+
23+
24+
<div className="col-span-full">
25+
<Button className="w-full" size="sm">
26+
Submit
27+
</Button>
28+
</div>
29+
</div>
30+
</Form>
31+
</ComponentCard>
32+
);
33+
}

frontend/src/components/form/form-elements/DocumentDropZone.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import React, { useState } from "react";
33
import ComponentCard from "../../common/ComponentCard";
44
import { useDropzone } from "react-dropzone";
5-
import Button from "@/components/ui/button/Button";
65
import SpinnerButton from "@/components/ui/button/SpinnerButton";
76

87
const DropzoneComponent: React.FC = () => {

frontend/src/components/ui/button/SpinnerButton.tsx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
import React, { ReactNode } from "react";
2-
import Button, { ButtonProps } from "./Button";
2+
import Button from "./Button";
33
import Spinner from "@/components/ui/spinner";
44

55
interface SpinnerButtonProps {
66
children: ReactNode; // Button text or content
7-
size?: "sm" | "md"; // Button size
8-
variant?: "primary" | "outline"; // Button variant
97
startIcon?: ReactNode; // Icon before the text
10-
endIcon?: ReactNode; // Icon after the text
118
onClick?: () => void; // Click handler
129
disabled?: boolean; // Disabled state
1310
className?: string; // Disabled state
@@ -16,10 +13,7 @@ interface SpinnerButtonProps {
1613

1714
const SpinnerButton: React.FC<SpinnerButtonProps> = ({
1815
children,
19-
size = "md",
20-
variant = "primary",
2116
startIcon,
22-
endIcon,
2317
onClick,
2418
className = "",
2519
disabled = false,
@@ -31,6 +25,11 @@ const SpinnerButton: React.FC<SpinnerButtonProps> = ({
3125
{...props}
3226
startIcon={loading ? <Spinner /> : startIcon}
3327
disabled={disabled || loading}
28+
onClick={onClick}
29+
className={className}
30+
variant="primary"
31+
32+
3433
>
3534
{children}
3635
</Button>
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
"use client";
2+
import React, { useState } from "react";
3+
import RadioSm from "../../form/input/RadioSm";
4+
5+
export default function ListWithRadio() {
6+
const [selectedValue, setSelectedValue] = useState<string>("option1");
7+
8+
const handleChange = (value: string) => {
9+
setSelectedValue(value);
10+
console.log("Selected Value:", value);
11+
};
12+
return (
13+
<div className="rounded-lg border border-gray-200 bg-white dark:border-gray-800 dark:bg-white/[0.03] sm:w-fit">
14+
<ul className="flex flex-col">
15+
<li className="border-b border-gray-200 px-3 py-2.5 last:border-b-0 dark:border-gray-800">
16+
<RadioSm
17+
id="option1"
18+
name="example"
19+
value="option1"
20+
checked={selectedValue === "option1"}
21+
label="Lorem ipsum dolor sit amet"
22+
onChange={handleChange}
23+
/>
24+
</li>
25+
<li className="border-b border-gray-200 px-3 py-2.5 last:border-b-0 dark:border-gray-800">
26+
<RadioSm
27+
id="option2"
28+
name="example"
29+
value="option2"
30+
checked={selectedValue === "option2"}
31+
label="It is a long established fact reader"
32+
onChange={handleChange}
33+
/>
34+
</li>
35+
<li className="border-b border-gray-200 px-3 py-2.5 last:border-b-0 dark:border-gray-800">
36+
<RadioSm
37+
id="option3"
38+
name="example"
39+
value="option3"
40+
checked={selectedValue === "option3"}
41+
label="Lorem ipsum dolor sit amet"
42+
onChange={handleChange}
43+
/>
44+
</li>
45+
<li className="border-b border-gray-200 px-3 py-2.5 last:border-b-0 dark:border-gray-800">
46+
<RadioSm
47+
id="option4"
48+
name="example"
49+
value="option4"
50+
checked={selectedValue === "option4"}
51+
label="Lorem ipsum dolor sit amet"
52+
onChange={handleChange}
53+
/>
54+
</li>
55+
<li className="border-b border-gray-200 px-3 py-2.5 last:border-b-0 dark:border-gray-800">
56+
<RadioSm
57+
id="option5"
58+
name="example"
59+
value="option5"
60+
checked={selectedValue === "option5"}
61+
label="Lorem ipsum dolor sit amet"
62+
onChange={handleChange}
63+
/>
64+
</li>
65+
</ul>
66+
</div>
67+
);
68+
}

0 commit comments

Comments
 (0)