mirror of
https://github.com/lemeow125/React-NotesApp.git
synced 2025-04-19 16:31: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;
|
title: string;
|
||||||
content: string;
|
content: string;
|
||||||
id: number;
|
id: number;
|
||||||
|
date_created: string;
|
||||||
}
|
}
|
||||||
export default function Note(props: props) {
|
export default function Note(props: props) {
|
||||||
return (
|
return (
|
||||||
|
@ -16,6 +17,7 @@ export default function Note(props: props) {
|
||||||
<div style={styles.note_content}>
|
<div style={styles.note_content}>
|
||||||
<p style={styles.text_small}>{props.content}</p>
|
<p style={styles.text_small}>{props.content}</p>
|
||||||
</div>
|
</div>
|
||||||
|
<p style={styles.text_medium}>Timestamp: {props.date_created}</p>
|
||||||
<Button
|
<Button
|
||||||
style={styles.button_remove}
|
style={styles.button_remove}
|
||||||
variant="contained"
|
variant="contained"
|
||||||
|
|
|
@ -55,17 +55,28 @@ export default function NoteMapper() {
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{notes.map((note: { title: string; content: string; id: number }, i) => {
|
{notes.map(
|
||||||
console.log(note);
|
(
|
||||||
return (
|
note: {
|
||||||
<Note
|
title: string;
|
||||||
id={note.id}
|
content: string;
|
||||||
key={i}
|
id: number;
|
||||||
title={note.title}
|
date_created: string;
|
||||||
content={note.content}
|
},
|
||||||
/>
|
i
|
||||||
);
|
) => {
|
||||||
})}
|
console.log(note);
|
||||||
|
return (
|
||||||
|
<Note
|
||||||
|
id={note.id}
|
||||||
|
key={i}
|
||||||
|
title={note.title}
|
||||||
|
content={note.content}
|
||||||
|
date_created={note.date_created}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
)}
|
||||||
<Button
|
<Button
|
||||||
style={styles.button_add}
|
style={styles.button_add}
|
||||||
variant="contained"
|
variant="contained"
|
||||||
|
|
|
@ -43,10 +43,7 @@ export default function NewNote() {
|
||||||
style={styles.button_add}
|
style={styles.button_add}
|
||||||
variant="contained"
|
variant="contained"
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
axios.post("http://localhost:8000/api/v1/notes/", {
|
axios.post("http://localhost:8000/api/v1/notes/", note);
|
||||||
title: note.title,
|
|
||||||
content: note.content,
|
|
||||||
});
|
|
||||||
console.log("foo");
|
console.log("foo");
|
||||||
navigate("/");
|
navigate("/");
|
||||||
}}
|
}}
|
||||||
|
|
Loading…
Add table
Reference in a new issue