From 730c0a9a4114b1589ef89be1051757274aae5f08 Mon Sep 17 00:00:00 2001 From: Leyla Xasiyeva Date: Sat, 5 Apr 2025 17:01:15 +0200 Subject: [PATCH 1/3] Landing page buttons linked for navigation --- app/page.tsx | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/app/page.tsx b/app/page.tsx index 03f4258..f29d442 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -3,24 +3,23 @@ import React from 'react'; import Link from 'next/link'; import './styles/globals.css'; // Importing global CSS +import { useRouter } from 'next/navigation'; const LandingPage = () => { + const router = useRouter(); + return (
- - - +

Memory Deck

-

Helping elderly individuals and those with memory loss retain valuable information through interactive flashcards

+

+ Helping elderly individuals and those with memory loss retain valuable information through interactive flashcards +

- - - - - {/* Apply the new registerButton class */} - + +
From 6e59411e2eac77176eb1365fd34b90423cb3deea Mon Sep 17 00:00:00 2001 From: Leyla Xasiyeva Date: Sun, 6 Apr 2025 19:44:45 +0200 Subject: [PATCH 2/3] Initial commit for issue108 - navigation to the Edit Flashcard page --- app/flashcards/edit/[id]/page.tsx | 68 +++++++++++++++++++++++++++++++ app/home/page.tsx | 8 +++- 2 files changed, 74 insertions(+), 2 deletions(-) create mode 100644 app/flashcards/edit/[id]/page.tsx diff --git a/app/flashcards/edit/[id]/page.tsx b/app/flashcards/edit/[id]/page.tsx new file mode 100644 index 0000000..3f1348a --- /dev/null +++ b/app/flashcards/edit/[id]/page.tsx @@ -0,0 +1,68 @@ +// app/flashcards/edit/[id]/page.tsx + +"use client"; + +import { useEffect, useState } from 'react'; +import { useParams } from 'next/navigation'; +import { Input, Button, Spin } from 'antd'; + +interface Flashcard { + id: number; + title: string; + content: string; +} + +export default function EditFlashcardPage() { + const { id } = useParams(); // Get flashcard ID from URL + const [flashcard, setFlashcard] = useState(null); + const [loading, setLoading] = useState(true); + + // Simulate loading flashcard data + useEffect(() => { + const fetchFlashcard = async () => { + try { + const res = await fetch(`/api/flashcards/${id}`); + if (!res.ok) throw new Error("Failed to load flashcard"); + const data = await res.json(); + setFlashcard(data); + } catch (error) { + console.error(error); + } finally { + setLoading(false); + } + }; + + fetchFlashcard(); + }, [id]); + + + const handleSave = () => { + console.log("Saving changes:", flashcard); + // You'd send `flashcard` to your API here + }; + + if (loading || !flashcard) { + return ; + } + + return ( +
+

Edit Flashcard

+ setFlashcard({ ...flashcard, title: e.target.value })} + placeholder="Title" + /> + setFlashcard({ ...flashcard, content: e.target.value })} + placeholder="Content" + /> + +
+ ); +} diff --git a/app/home/page.tsx b/app/home/page.tsx index acfac22..caed161 100644 --- a/app/home/page.tsx +++ b/app/home/page.tsx @@ -230,8 +230,12 @@ const FlashcardPage = () => { ], onClick: (e) => { e.domEvent.stopPropagation(); - console.log(`Clicked ${e.key} on card ${flashcard.id}`); - } + if (e.key === 'edit') { + router.push(`/flashcards/edit/${flashcard.id}`); + } else if (e.key === 'delete') { + console.log(`Delete flashcard ${flashcard.id}`); + } + } }} trigger={['click']} placement="bottomRight" From bded47d0c4fff10b3ec16790a110b8874115081b Mon Sep 17 00:00:00 2001 From: Leyla Xasiyeva Date: Mon, 7 Apr 2025 09:26:47 +0200 Subject: [PATCH 3/3] Implemented Edit page placeholder without API calls and commented out the code that makes the necessary A PI calls --- app/flashcards/edit/[id]/page.tsx | 84 ++++++++++++++++++++++++++++++- 1 file changed, 82 insertions(+), 2 deletions(-) diff --git a/app/flashcards/edit/[id]/page.tsx b/app/flashcards/edit/[id]/page.tsx index 3f1348a..f30c887 100644 --- a/app/flashcards/edit/[id]/page.tsx +++ b/app/flashcards/edit/[id]/page.tsx @@ -1,4 +1,84 @@ -// app/flashcards/edit/[id]/page.tsx +"use client"; + +import { useEffect, useState } from 'react'; +import { useParams } from 'next/navigation'; +import { Input, Button, Spin } from 'antd'; +import React from 'react'; + +interface Flashcard { + id: number; + title: string; + content: string; +} + +export default function EditFlashcardPage() { + const { id } = useParams(); // Get flashcard ID from URL + const [flashcard, setFlashcard] = useState(null); + const [loading, setLoading] = useState(true); + + // Simulate loading flashcard data + useEffect(() => { + const simulateFetchFlashcard = async () => { + // Simulate a delay to mimic an API call + setTimeout(() => { + // Simulated flashcard data based on the ID + const simulatedData: Flashcard = { + id: Number(id), + title: `Flashcard Title ${id}`, + content: `Content for flashcard ${id}` + }; + + setFlashcard(simulatedData); + setLoading(false); + }, 500); // Simulated loading time + }; + + simulateFetchFlashcard(); + }, [id]); + + const handleSave = () => { + console.log("Saving changes:", flashcard); + // You can implement the API call here when ready + }; + + const handleDiscard = () => { + console.log("Discarding changes"); + // Reset the state or navigate back + }; + + if (loading || !flashcard) { + return ; + } + + return ( +
+

Edit Flashcard

+ setFlashcard({ ...flashcard, title: e.target.value })} + placeholder="e.g. What is your name?" + /> + setFlashcard({ ...flashcard, content: e.target.value })} + placeholder="e.g. My name is John Doe." + /> +
+ + +
+
+ ); +} + + +/*// app/flashcards/edit/[id]/page.tsx "use client"; @@ -65,4 +145,4 @@ export default function EditFlashcardPage() {
); -} +}*/