Skip to content

Commit 0969521

Browse files
Merge pull request #96 from Evolutionary-Algorithms-On-Click/evoc-v2-phase1
More endpoint mismatch found and fixed
2 parents b70a2a2 + 53dbee2 commit 0969521

4 files changed

Lines changed: 19 additions & 13 deletions

File tree

app/create/custom-ea/[problemID]/notebook/[notebookID]/_components/KernelControls.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,18 @@ export default function KernelControls({
2020
try {
2121
const base =
2222
env("NEXT_PUBLIC_V2_BACKEND_BASE_URL") ?? "http://localhost:8080";
23-
const data = await authenticatedFetchV2(`/api/v1/sessions`, {
23+
const res = await fetch(`${base}/api/v1/sessions`, {
2424
method: "POST",
2525
credentials: "include",
2626
headers: { "Content-Type": "application/json" },
2727
body: JSON.stringify({ notebook_id: notebookId, language }),
2828
});
29+
if (!res.ok) {
30+
throw new Error(
31+
`Failed to start session: ${res.status} ${res.statusText}`
32+
);
33+
}
34+
const data = await res.json();
2935
setSession(data);
3036
onSessionCreated && onSessionCreated(data);
3137
return data;
@@ -47,7 +53,7 @@ export default function KernelControls({
4753
setError(null);
4854
try {
4955
const base =
50-
env("NEXT_PUBLIC_BACKEND_BASE_URL") ?? "http://localhost:8080";
56+
env("NEXT_PUBLIC_V2_BACKEND_BASE_URL") ?? "http://localhost:8080";
5157
await fetch(`${base}/api/v1/sessions/${session.id}`, {
5258
method: "DELETE",
5359
credentials: "include",

app/create/custom-ea/[problemID]/notebook/[notebookID]/_components/hooks/useAutosave.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import { useState, useEffect, useRef, useCallback } from 'react';
44
import { mapToApiFormat } from '../utils/notebook-mapper';
55
import isEqual from 'lodash.isequal'; // Using a library for deep equality check is more robust
6-
import { authenticatedFetch } from '../../../../../../../utils/api';
6+
import { authenticatedFetchV2 } from '../../../../../../../utils/api';
77

88
const AUTOSAVE_INTERVAL = 30 * 1000; // 30 seconds
99

@@ -109,7 +109,7 @@ export default function useAutosave(notebookId, cells, deletedCellIds, clearDele
109109
}
110110

111111
try {
112-
await authenticatedFetch(`/api/v1/notebooks/${notebookId}/cells`, {
112+
await authenticatedFetchV2(`/api/v1/notebooks/${notebookId}/cells`, {
113113
method: "PATCH",
114114
body: JSON.stringify(payload),
115115
});

app/create/custom-ea/[problemID]/notebook/page.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { useParams, useRouter } from "next/navigation";
66
import { LogOut, Plus, PlayCircle, BookOpen } from "lucide-react";
77
import formatDate from "@/app/utils/formatDate";
88
import Loader from "@/app/_components/Loader";
9-
import { authenticatedFetch } from "@/app/utils/api";
9+
import { authenticatedFetchV2 } from "@/app/utils/api";
1010
import { Card, CreateCard, PSDetails } from "./_components";
1111

1212
// Main App
@@ -56,7 +56,7 @@ export default function NotebookDashboard() {
5656
setLoadingNotebooks(true);
5757
setNotebooksError(null);
5858
try {
59-
const data = await authenticatedFetch("/api/v1/notebooks", {
59+
const data = await authenticatedFetchV2("/api/v1/notebooks", {
6060
method: "GET",
6161
signal: controller.signal,
6262
});
@@ -92,7 +92,7 @@ export default function NotebookDashboard() {
9292
setLoadingProblem(true);
9393
setProblemError(null);
9494
try {
95-
const data = await authenticatedFetch(
95+
const data = await authenticatedFetchV2(
9696
`/api/v1/problems/${routeProblemId}`,
9797
{
9898
method: "GET",
@@ -143,7 +143,7 @@ export default function NotebookDashboard() {
143143
: null,
144144
};
145145

146-
const created = await authenticatedFetch("/api/v1/notebooks", {
146+
const created = await authenticatedFetchV2("/api/v1/notebooks", {
147147
method: "POST",
148148
body: JSON.stringify(payload),
149149
});
@@ -191,7 +191,7 @@ export default function NotebookDashboard() {
191191
}
192192

193193
try {
194-
await authenticatedFetch(`/api/v1/notebooks/${notebookId}`, {
194+
await authenticatedFetchV2(`/api/v1/notebooks/${notebookId}`, {
195195
method: "PUT",
196196
body: JSON.stringify({ title: newName }),
197197
});
@@ -220,7 +220,7 @@ export default function NotebookDashboard() {
220220
}
221221

222222
try {
223-
await authenticatedFetch(`/api/v1/notebooks/${notebookId}`, {
223+
await authenticatedFetchV2(`/api/v1/notebooks/${notebookId}`, {
224224
method: "DELETE",
225225
});
226226

app/create/custom-ea/page.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { LogOut } from "lucide-react";
88
import CreateNewAction from "./_components/non-functional/newPSActionButton";
99
import ProblemStatementForm from "./_components/non-functional/PSform";
1010
import StatementsList from "./_components/feature/PSList";
11-
import { authenticatedFetch } from "@/app/utils/api";
11+
import { authenticatedFetchV2 } from "@/app/utils/api";
1212

1313
// Parent Component
1414
export default function CustomEA() {
@@ -44,7 +44,7 @@ export default function CustomEA() {
4444
setLoadingStatements(true);
4545
setStatementsError(null);
4646
try {
47-
const data = await authenticatedFetch("/api/v1/problems", {
47+
const data = await authenticatedFetchV2("/api/v1/problems", {
4848
method: "GET",
4949
signal: controller.signal,
5050
});
@@ -114,7 +114,7 @@ export default function CustomEA() {
114114
description_json: newStatement,
115115
};
116116

117-
const createdProblem = await authenticatedFetch("/api/v1/problems", {
117+
const createdProblem = await authenticatedFetchV2("/api/v1/problems", {
118118
method: "POST",
119119
body: JSON.stringify(payload),
120120
});

0 commit comments

Comments
 (0)