diff --git a/package.json b/package.json index 1108c1d..e7a7464 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "version": "0.0.0", "type": "module", "scripts": { - "dev": "vite", + "dev": "vite --mode development", "build": "vite build", "lint": "eslint .", "preview": "vite preview" diff --git a/src/pages/AssignmentPage.jsx b/src/pages/AssignmentPage.jsx index f66dbff..e1aa9f8 100644 --- a/src/pages/AssignmentPage.jsx +++ b/src/pages/AssignmentPage.jsx @@ -19,7 +19,7 @@ const AssignmentPage = () => { const [user, setUser] = useState([]); - const VITE_ASSIGNMENT_URL = import.meta.env.VITE_ASSIGNMENT_URL; + const ASSIGNMENT_BASE = import.meta.env.VITE_ASSIGNMENT_URL; const authUrl = import.meta.env.VITE_AUTH_URL; const [searchTerm, setSearchTerm] = useState(""); const [showPassword, setShowPassword] = useState(false); @@ -36,7 +36,7 @@ const AssignmentPage = () => { if (!appName) return; // Don't alert for empty name const timer = setTimeout(() => { fetch( - `${VITE_ASSIGNMENT_URL}/instructor/checkAssignmentByAppName/${appName}` + `${ASSIGNMENT_BASE}/instructor/checkAssignmentByAppName/${appName}` ) .then((response) => { if (!response.ok) { @@ -64,7 +64,7 @@ const AssignmentPage = () => { console.log("Checking QR code number:", qrCodeNumber); // Added console log const timer = setTimeout(() => { fetch( - `${VITE_ASSIGNMENT_URL}/instructor/checkAssignmentByQRCode/${qrCodeNumber}` + `${ASSIGNMENT_BASE}/instructor/checkAssignmentByQRCode/${qrCodeNumber}` ) .then((response) => { if (!response.ok) { @@ -98,7 +98,7 @@ const AssignmentPage = () => { console.log("User:", user); const res = await fetch( - `${VITE_ASSIGNMENT_URL}/instructor/list/${user.userId}`, + `${ASSIGNMENT_BASE}/instructor/list/${user.userId}`, { method: "GET", } @@ -156,7 +156,7 @@ const AssignmentPage = () => { if (editingIndex !== null) { //edit mode - await fetch(`${VITE_ASSIGNMENT_URL}/instructor/update/${assignmentId}`, { + await fetch(`${ASSIGNMENT_BASE}/instructor/update/${assignmentId}`, { method: "PUT", body: formData, }) @@ -185,7 +185,7 @@ const AssignmentPage = () => { throw new Error("Failed to submit assignment: file not found."); } - await fetch(`${VITE_ASSIGNMENT_URL}/instructor/create`, { + await fetch(`${ASSIGNMENT_BASE}/instructor/create`, { method: "POST", body: formData, }) @@ -234,7 +234,7 @@ const AssignmentPage = () => { const project = projects[index]; if (window.confirm("Are you sure you want to delete this assignment?")) { fetch( - `${VITE_ASSIGNMENT_URL}/instructor/delete/${project.assignmentid}`, + `${ASSIGNMENT_BASE}/instructor/delete/${project.assignmentid}`, { method: "DELETE", } diff --git a/src/pages/CodeEditor.jsx b/src/pages/CodeEditor.jsx index 987ef8f..11f2537 100644 --- a/src/pages/CodeEditor.jsx +++ b/src/pages/CodeEditor.jsx @@ -3,10 +3,9 @@ import { useLocation } from "react-router-dom"; import EditorPanel from "../components/EditorPanel"; import PreviewPanel from "../components/PreviewPanel"; -const ASSIGNMENT_BASE = "http://localhost:8082"; +const ASSIGNMENT_BASE = import.meta.env.VITE_ASSIGNMENT_URL; export default function PageCodeEditor() { - const location = useLocation(); const qrCodeNumber = location.state?.qrCodeNumber; @@ -55,7 +54,7 @@ export default function PageCodeEditor() { const res = await fetch(`${ASSIGNMENT_BASE}/student/save`, { method: "POST", headers: { "Content-Type": "application/json" }, - body: JSON.stringify({ appName, code }) + body: JSON.stringify({ appName, code }), }); if (!res.ok) throw new Error("Save failed"); alert("Notebook saved"); @@ -74,7 +73,7 @@ export default function PageCodeEditor() { const res = await fetch(`${ASSIGNMENT_BASE}/student/restart`, { method: "POST", headers: { "Content-Type": "application/json" }, - body: JSON.stringify({ appName }) + body: JSON.stringify({ appName }), }); if (!res.ok) throw new Error("Restart failed"); alert("App restarted"); @@ -87,16 +86,19 @@ export default function PageCodeEditor() { }; return ( -
+
{/* Python Editor */} @@ -118,13 +120,20 @@ export default function PageCodeEditor() { fontSize: "1.2rem", color: "#05d9e8", textShadow: "0 0 5px #05d9e8", - marginBottom: "1rem" + marginBottom: "1rem", }} > 🐍 Snake Brain (Python) -
+
-