Skip to content

Commit 9bb699c

Browse files
committed
refactor: update default canvas API endpoint in SettingsDialog
- Changed the API call in SettingsDialog to use the new endpoint '/api/templates/default' for fetching default canvas data. - Removed the previous fetch implementation, streamlining the code by utilizing the api.getDefaultCanvas() method for better maintainability.
1 parent b88811b commit 9bb699c

File tree

2 files changed

+5
-12
lines changed

2 files changed

+5
-12
lines changed

src/frontend/src/api/hooks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ export const api = {
118118

119119
getDefaultCanvas: async (): Promise<CanvasData> => {
120120
try {
121-
const result = await fetchApi('/api/pad/from-template/default');
121+
const result = await fetchApi('/api/templates/default');
122122
return result;
123123
} catch (error) {
124124
throw error;

src/frontend/src/ui/SettingsDialog.tsx

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { UserSettings, DEFAULT_SETTINGS } from "../types/settings";
55
import { RefreshCw } from "lucide-react";
66
import { normalizeCanvasData } from "../utils/canvasUtils";
77
import { capture } from "../utils/posthog";
8+
import { api } from "../api/hooks";
89
import "./SettingsDialog.scss";
910

1011
interface SettingsDialogProps {
@@ -47,17 +48,9 @@ const SettingsDialog: React.FC<SettingsDialogProps> = ({
4748
setIsRestoring(true);
4849
capture('restore_tutorial_canvas_clicked');
4950

50-
// Fetch the default canvas data from the backend
51-
const response = await fetch('/api/canvas/default', {
52-
method: 'GET',
53-
credentials: 'include'
54-
});
55-
56-
if (!response.ok) {
57-
throw new Error(`Failed to fetch default canvas: ${response.statusText}`);
58-
}
59-
60-
const defaultCanvasData = await response.json();
51+
// Use the API function from hooks.ts to fetch the default canvas
52+
const defaultCanvasData = await api.getDefaultCanvas();
53+
console.log("Default canvas data:", defaultCanvasData);
6154

6255
// Normalize the canvas data before updating the scene
6356
const normalizedData = normalizeCanvasData(defaultCanvasData);

0 commit comments

Comments
 (0)