From 1255bb138a5c4d4d36868cfad20f10ca9df481c8 Mon Sep 17 00:00:00 2001 From: tituschewxj Date: Wed, 13 Nov 2024 17:41:25 +0800 Subject: [PATCH 1/7] feat: update frontend ui for crud testcases --- apps/frontend/src/app/question/page.tsx | 132 ++++++++++++++++++++++-- 1 file changed, 126 insertions(+), 6 deletions(-) diff --git a/apps/frontend/src/app/question/page.tsx b/apps/frontend/src/app/question/page.tsx index cb88d0bf3f..a65f3e5097 100644 --- a/apps/frontend/src/app/question/page.tsx +++ b/apps/frontend/src/app/question/page.tsx @@ -14,12 +14,17 @@ import { Tag, Modal, Form, + Tabs, + Checkbox, + Tooltip, + Card, } from "antd"; import { Content } from "antd/es/layout/layout"; import { DeleteOutlined, EditOutlined, PlusCircleOutlined, + PlusOutlined, SearchOutlined, } from "@ant-design/icons"; import "./styles.scss"; @@ -40,6 +45,7 @@ import { import Link from "next/link"; import TextArea from "antd/es/input/TextArea"; import { ValidateUser, VerifyTokenResponseType } from "../services/user"; +import TabPane from "antd/es/tabs/TabPane"; /** * defines the State of the page whe a user is deleing an object. Has 3 general states: @@ -120,10 +126,9 @@ export default function QuestionListPage() { const [isAdmin, setIsAdmin] = useState(undefined); useLayoutEffect(() => { - ValidateUser() - .then((data: VerifyTokenResponseType) => { - setIsAdmin(data.data.isAdmin); - }) + ValidateUser().then((data: VerifyTokenResponseType) => { + setIsAdmin(data.data.isAdmin); + }); }, []); const handleEditClick = (index: number, question: Question) => { @@ -248,6 +253,34 @@ export default function QuestionListPage() { return () => clearTimeout(timeout); }, [search]); + const [visibleTests, setVisibleTests] = useState([ + { key: "1", title: "Visible Test 1" }, + ]); + const [hiddenTests, setHiddenTests] = useState([]); // FIXME: fix the type!! + const [tabIndex, setTabIndex] = useState(2); + + const handleAddVisibleTest = () => { + const newKey = `${Date.now()}`; // Use unique timestamp as key + setVisibleTests([...visibleTests, { key: newKey }]); + }; + + const handleAddHiddenTest = () => { + const newKey = `${Date.now()}`; // Use unique timestamp as key + setHiddenTests([...hiddenTests, { key: newKey }]); + }; + + const handleRemoveVisibleTest = (targetKey: string) => { + if (visibleTests.length > 1) { + setVisibleTests( + visibleTests.filter((test: any) => test.key !== targetKey) + ); + } + }; + + const handleRemoveHiddenTest = (targetKey: string) => { + setHiddenTests(hiddenTests.filter((test: any) => test.key !== targetKey)); + }; + // Table column specification var columns: TableProps["columns"]; if (isAdmin) { @@ -343,7 +376,7 @@ export default function QuestionListPage() { }, ]} > -