adjusted monaco editor to get the QR Code number instead of assignment id
This commit is contained in:
parent
4b207b83d4
commit
8a62bbfa1e
1 changed files with 7 additions and 4 deletions
|
|
@ -4,8 +4,11 @@ import EditorPanel from "../components/EditorPanel";
|
||||||
import PreviewPanel from "../components/PreviewPanel";
|
import PreviewPanel from "../components/PreviewPanel";
|
||||||
|
|
||||||
export default function PageCodeEditor() {
|
export default function PageCodeEditor() {
|
||||||
const { assignmentId: routeId } = useParams();
|
|
||||||
const assignmentId = routeId || "52";
|
const { qrCodeNumber: routeId } = useParams();
|
||||||
|
// console.log("Assignment ID:", assignmentId);
|
||||||
|
const qrCodeNumber = routeId || "2256";
|
||||||
|
console.log("QR Code Number:", qrCodeNumber);
|
||||||
|
|
||||||
const [appName, setAppName] = useState("");
|
const [appName, setAppName] = useState("");
|
||||||
const [code, setCode] = useState("# NOW LOADING");
|
const [code, setCode] = useState("# NOW LOADING");
|
||||||
|
|
@ -15,14 +18,14 @@ export default function PageCodeEditor() {
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetch(`https://assignment-service.fly.dev/student/assignment/${assignmentId}`)
|
fetch(`https://assignment-service.fly.dev/student/assignment/${qrCodeNumber}`)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
if (!res.ok) throw new Error("Failed to fetch assignment");
|
if (!res.ok) throw new Error("Failed to fetch assignment");
|
||||||
return res.json();
|
return res.json();
|
||||||
})
|
})
|
||||||
.then((data) => setAppName(data.appname))
|
.then((data) => setAppName(data.appname))
|
||||||
.catch((err) => console.error("Assignment fetch error:", err));
|
.catch((err) => console.error("Assignment fetch error:", err));
|
||||||
}, [assignmentId]);
|
}, [qrCodeNumber]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!appName) return;
|
if (!appName) return;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue