Made note mapping use a common interface

This commit is contained in:
keannu125 2023-03-04 17:21:00 +08:00
parent e6b07438d4
commit 0f18c0be9e

View file

@ -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"