From 2d7e0aa63dd78efb24368b1a1c97159118a65bf2 Mon Sep 17 00:00:00 2001 From: TaegeonKim <61930500+Taegon21@users.noreply.github.com> Date: Mon, 1 Jul 2024 18:06:00 +0900 Subject: [PATCH] :sparkles: Implement custom script selection (#36) --- src/api/client.ts | 4 +- src/api/endpoints.ts | 2 +- src/api/hooks/useProfessor.ts | 1 + .../create-container/page.module.css | 22 ++++- src/app/(professor)/create-container/page.tsx | 95 ++++++++++++++++--- .../edit-container/page.module.css | 7 +- src/app/(professor)/edit-container/page.tsx | 49 ++-------- src/app/(professor)/layout.tsx | 2 +- src/type/schemas.ts | 2 +- 9 files changed, 120 insertions(+), 64 deletions(-) diff --git a/src/api/client.ts b/src/api/client.ts index 93b0da4..6aaa90d 100644 --- a/src/api/client.ts +++ b/src/api/client.ts @@ -4,8 +4,8 @@ import Cookies from "js-cookie"; const apiUrl = process.env.NEXT_PUBLIC_API_URL; const apiClient = axios.create({ - // baseURL: apiUrl, - baseURL: "/api", + baseURL: apiUrl, + // baseURL: "/api", headers: { "Content-Type": "application/json", }, diff --git a/src/api/endpoints.ts b/src/api/endpoints.ts index e913880..f1dc917 100644 --- a/src/api/endpoints.ts +++ b/src/api/endpoints.ts @@ -6,7 +6,7 @@ export const API_ENDPOINTS = { }, PROFESSOR: { CHECK: (professorId: string) => `/class/${professorId}/pod`, - CREATE: (professorId: string) => `api/class/${professorId}/create`, + CREATE: (professorId: string) => `/class/${professorId}/create`, DELETE: (professorId: string) => `/class/${professorId}/delete`, }, }; diff --git a/src/api/hooks/useProfessor.ts b/src/api/hooks/useProfessor.ts index b243918..68c9286 100644 --- a/src/api/hooks/useProfessor.ts +++ b/src/api/hooks/useProfessor.ts @@ -37,6 +37,7 @@ export const useCreateClass = () => { }, onError: (error) => { alert(`Error: ${error.message}`); + console.log("error", error); }, }); }; diff --git a/src/app/(professor)/create-container/page.module.css b/src/app/(professor)/create-container/page.module.css index b34ac96..18f3145 100644 --- a/src/app/(professor)/create-container/page.module.css +++ b/src/app/(professor)/create-container/page.module.css @@ -65,7 +65,6 @@ border: 1px solid #ccc; border-radius: 12px; width: 100%; - } .submitButton { @@ -99,6 +98,27 @@ cursor: pointer; } +.checkboxGroup { + display: flex; + flex-direction: column; + align-items: flex-start; + gap: 10px; + margin-top: 10px; +} +.firstLine { + display: flex; + gap: 15px; +} + +.checkbox { + display: flex; + align-items: center; +} + +.checkbox input { + margin-right: 5px; +} + @media (max-width: 768px) { .leftContainer { display: none; diff --git a/src/app/(professor)/create-container/page.tsx b/src/app/(professor)/create-container/page.tsx index a1b30f5..bd3c784 100644 --- a/src/app/(professor)/create-container/page.tsx +++ b/src/app/(professor)/create-container/page.tsx @@ -11,7 +11,7 @@ const CreateContainerPage = () => { const [classId, setClassId] = useState(""); const [studentIds, setStudentIds] = useState([""]); const [type, setType] = useState("vscode"); - const [script, setScript] = useState(""); + const [scripts, setScripts] = useState([]); const { mutate: createClass, status } = useCreateClass(); @@ -20,7 +20,7 @@ const CreateContainerPage = () => { studentIds, options: type === "vscode" ? { vscode: "yes" } : { ssh: "yes" }, command: [], - customScript: script, + customScript: scripts, }; const handleStudentIdChange = (index: number, value: string) => { @@ -39,8 +39,17 @@ const CreateContainerPage = () => { setStudentIds(newStudentIds); }; + const handleScriptChange = (value: string) => { + if (scripts.includes(value)) { + setScripts(scripts.filter((script) => script !== value)); + } else { + setScripts([...scripts, value]); + } + }; + const handleSubmit = (e: React.FormEvent) => { e.preventDefault(); + console.log("data:", containerData); createClass({ professorId: studentId, classData: containerData }); }; @@ -117,15 +126,79 @@ const CreateContainerPage = () => {
- - setScript(e.target.value)} - required - /> + +
+
+
+ handleScriptChange(e.target.value)} + /> + +
+
+ handleScriptChange(e.target.value)} + /> + +
+
+ handleScriptChange(e.target.value)} + /> + +
+
+
+
+ handleScriptChange(e.target.value)} + /> + +
+
+ handleScriptChange(e.target.value)} + /> + +
+
+ handleScriptChange(e.target.value)} + /> + +
+
+