Added timestamp to notes

This commit is contained in:
keannu125 2023-02-24 22:29:45 +08:00
parent 9920738a33
commit 50781689e7
3 changed files with 25 additions and 15 deletions

View file

@ -7,6 +7,7 @@ export interface props {
title: string;
content: string;
id: number;
date_created: string;
}
export default function Note(props: props) {
return (
@ -16,6 +17,7 @@ export default function Note(props: props) {
<div style={styles.note_content}>
<p style={styles.text_small}>{props.content}</p>
</div>
<p style={styles.text_medium}>Timestamp: {props.date_created}</p>
<Button
style={styles.button_remove}
variant="contained"

View file

@ -55,17 +55,28 @@ export default function NoteMapper() {
}
return (
<>
{notes.map((note: { title: string; content: string; id: number }, i) => {
console.log(note);
return (
<Note
id={note.id}
key={i}
title={note.title}
content={note.content}
/>
);
})}
{notes.map(
(
note: {
title: string;
content: string;
id: number;
date_created: string;
},
i
) => {
console.log(note);
return (
<Note
id={note.id}
key={i}
title={note.title}
content={note.content}
date_created={note.date_created}
/>
);
}
)}
<Button
style={styles.button_add}
variant="contained"

View file

@ -43,10 +43,7 @@ export default function NewNote() {
style={styles.button_add}
variant="contained"
onClick={async () => {
axios.post("http://localhost:8000/api/v1/notes/", {
title: note.title,
content: note.content,
});
axios.post("http://localhost:8000/api/v1/notes/", note);
console.log("foo");
navigate("/");
}}