Skip to content

Commit 31a1006

Browse files
committed
fix: frontend ipfs removed
1 parent 74886a5 commit 31a1006

File tree

3 files changed

+1
-131
lines changed

3 files changed

+1
-131
lines changed

frontend/src/App.tsx

Lines changed: 1 addition & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,11 @@
1-
import { useState, useEffect } from 'react'
2-
import { useIPFS } from './context/IPFSContext'
3-
import { Task, TaskDifficulty } from '../../objects/BoardTask'
1+
import { useState } from 'react'
42
import reactLogo from './assets/react.svg'
53
import viteLogo from '/vite.svg'
64
import './App.css'
75

86

97
function App() {
10-
const { ipfsBoard, loading: configLoading, error } = useIPFS();
118
const [count, setCount] = useState(0)
12-
const [title, setTitle] = useState("");
13-
const [description, setDescription] = useState("");
14-
const [cid, setCid] = useState<string | null>(null);
15-
const [loading, setLoading] = useState(false);
16-
17-
// Sync config loading with local loading
18-
useEffect(() => {
19-
setLoading(configLoading);
20-
}, [configLoading]);
21-
22-
if (loading) return <p>Loading configuration...</p>;
23-
if (error) return <p>Error loading config: {error.message}</p>;
24-
if (!ipfsBoard) return <p>No config loaded</p>;
25-
26-
const createAndUploadTask = async () => {
27-
setLoading(true);
28-
try {
29-
const task = new Task({
30-
title,
31-
description,
32-
difficulty: TaskDifficulty.EASY,
33-
tags: ["demo"],
34-
createdBy: "User123",
35-
});
36-
37-
const newCid = await ipfsBoard.publishTask(task);
38-
setCid(newCid);
39-
} catch (err) {
40-
console.error(err);
41-
} finally {
42-
setLoading(false);
43-
}
44-
};
45-
46-
const downloadTask = async () => {
47-
if (!cid) return;
48-
try {
49-
const task = await ipfsBoard.loadTaskFromIPFS(cid);
50-
alert(`Loaded task: ${task.title}`);
51-
} catch (err) {
52-
console.error(err);
53-
}
54-
};
559

5610
return (
5711
<>
@@ -75,31 +29,6 @@ function App() {
7529
<p className="read-the-docs">
7630
Click on the Vite and React logos to learn more
7731
</p>
78-
<div style={{ padding: 20 }}>
79-
<h2>Create Task</h2>
80-
<input
81-
type="text"
82-
placeholder="Task title"
83-
value={title}
84-
onChange={(e) => setTitle(e.target.value)}
85-
/>
86-
<br />
87-
<textarea
88-
placeholder="Task description"
89-
value={description}
90-
onChange={(e) => setDescription(e.target.value)}
91-
/>
92-
<br />
93-
<button onClick={createAndUploadTask} disabled={loading}>
94-
{loading ? "Uploading..." : "Upload to IPFS"}
95-
</button>
96-
{cid && (
97-
<>
98-
<p>✅ Task uploaded with CID: {cid}</p>
99-
<button onClick={downloadTask}>Download Task from IPFS</button>
100-
</>
101-
)}
102-
</div>
10332
</>
10433
)
10534
}

frontend/src/context/IPFSContext.tsx

Lines changed: 0 additions & 56 deletions
This file was deleted.

frontend/src/main.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
import { StrictMode } from 'react'
22
import { createRoot } from 'react-dom/client'
3-
import { IPFSProvider } from "./context/IPFSContext.tsx";
43
import './index.css'
54
import App from './App.tsx'
65

76
createRoot(document.getElementById('root')!).render(
87
<StrictMode>
9-
<IPFSProvider>
108
<App />
11-
</IPFSProvider>
129
</StrictMode>,
1310
)

0 commit comments

Comments
 (0)