mirror of
https://github.com/lemeow125/React-NotesApp.git
synced 2024-11-17 06:29:28 +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 { useQuery } from "react-query";
|
||||||
import { GetNotes } from "../Api/Api";
|
import { GetNotes } from "../Api/Api";
|
||||||
import { useSelector } from "react-redux";
|
import { useSelector } from "react-redux";
|
||||||
import { LoginState } from "../../Interfaces/Interfaces";
|
import { LoginState, NoteProps } from "../../Interfaces/Interfaces";
|
||||||
|
|
||||||
export default function Notes() {
|
export default function Notes() {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
@ -55,29 +55,18 @@ export default function Notes() {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{notes.map(
|
{notes.map((note: NoteProps, index: number) => {
|
||||||
(
|
return (
|
||||||
note: {
|
<Note
|
||||||
owner: string;
|
id={note.id}
|
||||||
title: string;
|
key={index}
|
||||||
content: string;
|
title={note.title}
|
||||||
id: number;
|
content={note.content}
|
||||||
date_created: Date;
|
date_created={note.date_created}
|
||||||
},
|
owner={note.owner}
|
||||||
index: number
|
/>
|
||||||
) => {
|
);
|
||||||
return (
|
})}
|
||||||
<Note
|
|
||||||
id={note.id}
|
|
||||||
key={index}
|
|
||||||
title={note.title}
|
|
||||||
content={note.content}
|
|
||||||
date_created={note.date_created}
|
|
||||||
owner={note.owner}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
)}
|
|
||||||
<Button
|
<Button
|
||||||
style={styles.button_green}
|
style={styles.button_green}
|
||||||
variant="contained"
|
variant="contained"
|
||||||
|
|
Loading…
Reference in a new issue