mirror of
https://github.com/lemeow125/React-NotesApp.git
synced 2024-11-16 22:19:27 +08:00
Made note mapping use a common interface
This commit is contained in:
parent
e6b07438d4
commit
0f18c0be9e
1 changed files with 13 additions and 24 deletions
|
@ -6,7 +6,7 @@ import { Button } from "@mui/material";
|
|||
import { useQuery } from "react-query";
|
||||
import { GetNotes } from "../Api/Api";
|
||||
import { useSelector } from "react-redux";
|
||||
import { LoginState } from "../../Interfaces/Interfaces";
|
||||
import { LoginState, NoteProps } from "../../Interfaces/Interfaces";
|
||||
|
||||
export default function Notes() {
|
||||
const navigate = useNavigate();
|
||||
|
@ -55,29 +55,18 @@ export default function Notes() {
|
|||
|
||||
return (
|
||||
<>
|
||||
{notes.map(
|
||||
(
|
||||
note: {
|
||||
owner: string;
|
||||
title: string;
|
||||
content: string;
|
||||
id: number;
|
||||
date_created: Date;
|
||||
},
|
||||
index: number
|
||||
) => {
|
||||
return (
|
||||
<Note
|
||||
id={note.id}
|
||||
key={index}
|
||||
title={note.title}
|
||||
content={note.content}
|
||||
date_created={note.date_created}
|
||||
owner={note.owner}
|
||||
/>
|
||||
);
|
||||
}
|
||||
)}
|
||||
{notes.map((note: NoteProps, index: number) => {
|
||||
return (
|
||||
<Note
|
||||
id={note.id}
|
||||
key={index}
|
||||
title={note.title}
|
||||
content={note.content}
|
||||
date_created={note.date_created}
|
||||
owner={note.owner}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
<Button
|
||||
style={styles.button_green}
|
||||
variant="contained"
|
||||
|
|
Loading…
Reference in a new issue