1
1
import { FC } from 'react' ;
2
2
import { useTranslation } from 'react-i18next' ;
3
3
4
+ import DeleteIcon from '@mui/icons-material/Delete' ;
4
5
import Button from '@mui/material/Button' ;
5
6
import Card from '@mui/material/Card' ;
6
7
import CardActions from '@mui/material/CardActions' ;
7
8
import CardContent from '@mui/material/CardContent' ;
8
9
import Divider from '@mui/material/Divider' ;
10
+ import IconButton from '@mui/material/IconButton' ;
9
11
import Typography from '@mui/material/Typography' ;
10
12
import grey from '@mui/material/colors/grey' ;
11
13
@@ -20,16 +22,20 @@ const Response: FC<{
20
22
onSelect ?: ( id : string ) => void ;
21
23
enableBuildAction ?: boolean ;
22
24
evaluationType ?: EvaluationType ;
25
+ onDelete ?: ( id : string ) => void ;
23
26
} > = ( {
24
27
responseId,
25
28
response,
26
29
onSelect,
30
+ onDelete,
27
31
enableBuildAction = true ,
28
32
evaluationType = EvaluationType . None ,
29
33
} ) => {
30
34
const { t } = useTranslation ( ) ;
31
35
32
36
const showSelectButton = typeof onSelect !== 'undefined' ;
37
+ const showDeleteButton = typeof onDelete !== 'undefined' ;
38
+ const showActions = showDeleteButton || showSelectButton ;
33
39
34
40
const renderEvaluationComponent = ( ) : JSX . Element => {
35
41
if ( evaluationType === EvaluationType . UsefulnessNoveltyRating ) {
@@ -58,18 +64,28 @@ const Response: FC<{
58
64
</ Typography >
59
65
</ CardContent >
60
66
{ evaluationType !== EvaluationType . None && renderEvaluationComponent ( ) }
61
- { showSelectButton && (
67
+ { showActions && (
62
68
< >
63
69
< Divider />
64
70
< CardActions >
65
- < Button
66
- disabled = { ! enableBuildAction }
67
- onClick = { ( ) => {
68
- if ( typeof onSelect !== 'undefined' ) onSelect ( responseId ) ;
69
- } }
70
- >
71
- { t ( 'BUILD_ON_THIS_IDEA' ) }
72
- </ Button >
71
+ { showSelectButton && (
72
+ < Button
73
+ disabled = { ! enableBuildAction }
74
+ onClick = { ( ) => {
75
+ if ( typeof onSelect !== 'undefined' ) onSelect ( responseId ) ;
76
+ } }
77
+ >
78
+ { t ( 'BUILD_ON_THIS_IDEA' ) }
79
+ </ Button >
80
+ ) }
81
+ { showDeleteButton && (
82
+ < IconButton
83
+ sx = { { marginLeft : 'auto' } }
84
+ onClick = { ( ) => onDelete ( responseId ) }
85
+ >
86
+ < DeleteIcon />
87
+ </ IconButton >
88
+ ) }
73
89
</ CardActions >
74
90
</ >
75
91
) }
0 commit comments