mirror of
https://github.com/lemeow125/React-NotesApp.git
synced 2024-11-16 22:19:27 +08:00
Added timestamp to notes
This commit is contained in:
parent
9920738a33
commit
50781689e7
3 changed files with 25 additions and 15 deletions
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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("/");
|
||||
}}
|
||||
|
|
Loading…
Reference in a new issue