1- import { Button , Card , CardActions , CardContent , CardMedia } from ' @mui/material'
2- import Typography from ' @mui/material/Typography'
3- import React from 'react'
4- import { useTranslation } from ' react-i18next'
1+ import DeleteForeverIcon from " @mui/icons- material/DeleteForever" ;
2+ import EditIcon from " @mui/icons- material/Edit" ;
3+ import { Grid , IconButton , Paper } from "@mui/material" ;
4+ import React from " react" ;
55
6- import logoImage from 'features/posts/assets/imgs/logo192.png'
7- import { Post } from 'features/posts/types'
6+
7+ import { Post } from "features/posts/types" ;
8+
9+ const styles = {
10+ Icon : {
11+ marginLeft : "auto"
12+ } ,
13+ Paper : {
14+ margin : "auto" ,
15+ padding : 10 ,
16+ display : "flex" ,
17+ alignItems : "center" ,
18+ marginTop : 10
19+ }
20+ } ;
821
922export type PostCardViewProps = {
1023 post : Post
@@ -13,35 +26,43 @@ export type PostCardViewProps = {
1326}
1427
1528export const PostCardView = ( props : PostCardViewProps ) => {
16- const { t } = useTranslation ( )
1729
18- const { post, onDeleteClick, onUpdateClick } = props
30+ const { post, onDeleteClick, onUpdateClick } = props ;
1931
2032 const handleDeleteClick = ( ) => {
21- onDeleteClick ( post )
22- }
33+ onDeleteClick ( post ) ;
34+ } ;
2335
24- const handleUpdateClick = ( ) => onUpdateClick ( post )
36+ const handleUpdateClick = ( ) => onUpdateClick ( post ) ;
2537
2638 return (
2739 < >
28- < Card sx = { { height : '100%' , display : 'flex' , flexDirection : 'column' } } >
29- < CardMedia component = "img" src = { logoImage } alt = "random" />
30- < CardContent sx = { { flexGrow : 1 } } >
31- < Typography gutterBottom variant = "h5" component = "h2" >
32- { post . title }
33- </ Typography >
34- < Typography > { post . body } </ Typography >
35- </ CardContent >
36- < CardActions >
37- < Button size = "small" onClick = { handleDeleteClick } >
38- { t ( 'home.buttons.delete' ) }
39- </ Button >
40- < Button size = "small" onClick = { handleUpdateClick } >
41- { t ( 'home.buttons.update' ) }
42- </ Button >
43- </ CardActions >
44- </ Card >
40+ < Grid
41+ spacing = { 2 }
42+ xs = { 12 }
43+ item
44+ key = { post . id }
45+ >
46+ < Paper elevation = { 2 } style = { styles . Paper } >
47+ < span > < strong > { post . title } </ strong > - { post . body } </ span >
48+ < br />
49+ < IconButton
50+ color = "primary"
51+ aria-label = "Edit"
52+ style = { styles . Icon }
53+ onClick = { handleUpdateClick }
54+ >
55+ < EditIcon />
56+ </ IconButton >
57+ < IconButton
58+ color = "secondary"
59+ aria-label = "Delete"
60+ onClick = { handleDeleteClick }
61+ >
62+ < DeleteForeverIcon />
63+ </ IconButton >
64+ </ Paper >
65+ </ Grid >
4566 </ >
46- )
47- }
67+ ) ;
68+ } ;
0 commit comments