Skip to content

Commit

Permalink
Rendering the notes from the given user now
Browse files Browse the repository at this point in the history
  • Loading branch information
Stuartwastaken committed Nov 12, 2023
1 parent c0ce817 commit 8a89251
Showing 1 changed file with 25 additions and 15 deletions.
40 changes: 25 additions & 15 deletions app/lib/components/note_listview.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,37 @@
// note_listview.tsx
import React from 'react';
import React, { useState, useEffect } from 'react';
import { User } from "../models/user_class";
import ApiService from '../utils/api_service';
import { Note } from '../../types';

interface Note {
id: number;
title: string;
content: string;
}
const NoteListView: React.FC = () => {
const [notes, setNotes] = useState<Note[]>([]);

// Dummy data for the list
const notes: Note[] = [
{ id: 1, title: 'Note 1', content: 'Lorem ipsum dolor sit amet...' },
{ id: 2, title: 'Note 2', content: 'Consectetur adipiscing elit...' },
{ id: 3, title: 'Note 3', content: 'Sed do eiusmod tempor...' },
// ... add as many notes as needed
];
useEffect(() => {
const fetchNotes = async () => {
const user = User.getInstance();
const userName = await user.getName();
if (userName) {
try {
const userNotes = await ApiService.fetchMessages(false, true, userName);
setNotes(userNotes);
} catch (error) {
console.error('Error fetching notes:', error);
// Handle the error as appropriate for your application
}
}
};

fetchNotes();
}, []);

const NoteListView: React.FC = () => {
return (
<div className="my-4">
{notes.map((note) => (
<div key={note.id} className="mb-2 p-2 bg-white rounded shadow">
<h3 className="text-lg font-semibold">{note.title}</h3>
<p>{note.content}</p>
<p>{note.text}</p>
{/* Render other note properties as needed */}
</div>
))}
</div>
Expand Down

0 comments on commit 8a89251

Please sign in to comment.