File tree Expand file tree Collapse file tree 2 files changed +147
-0
lines changed Expand file tree Collapse file tree 2 files changed +147
-0
lines changed Original file line number Diff line number Diff line change
1
+ import { differenceInDays } from 'date-fns' ;
1
2
import {
2
3
Dialog ,
3
4
DialogActions ,
@@ -47,6 +48,12 @@ const CippStandardDialog = ({
47
48
[ ]
48
49
) ;
49
50
51
+ const isNewStandard = ( dateAdded ) => {
52
+ const currentDate = new Date ( ) ;
53
+ const addedDate = new Date ( dateAdded ) ;
54
+ return differenceInDays ( currentDate , addedDate ) <= 30 ;
55
+ } ;
56
+
50
57
return (
51
58
< Dialog
52
59
open = { dialogOpen }
@@ -86,8 +93,17 @@ const CippStandardDialog = ({
86
93
display : "flex" ,
87
94
flexDirection : "column" ,
88
95
height : "100%" ,
96
+ position : "relative" ,
89
97
} }
90
98
>
99
+ { isNewStandard ( standard . addedDate ) && (
100
+ < Chip
101
+ label = "New"
102
+ size = "small"
103
+ color = "success"
104
+ sx = { { position : "absolute" } }
105
+ />
106
+ ) }
91
107
< CardContent sx = { { flexGrow : 1 } } >
92
108
< Typography variant = "h6" gutterBottom >
93
109
{ standard . label }
@@ -151,6 +167,18 @@ const CippStandardDialog = ({
151
167
</ Typography >
152
168
</ >
153
169
) }
170
+ { standard . addedDate ?. length > 0 && (
171
+ < >
172
+ < Typography variant = "subtitle2" sx = { { mt : 2 } } >
173
+ Date Added:
174
+ </ Typography >
175
+ < Box sx = { { display : "flex" , alignItems : "center" } } >
176
+ < Typography variant = "body2" color = "textSecondary" >
177
+ { standard . addedDate }
178
+ </ Typography >
179
+ </ Box >
180
+ </ >
181
+ ) }
154
182
</ CardContent >
155
183
156
184
< CardContent >
You can’t perform that action at this time.
0 commit comments