Skip to content

Commit 24ba030

Browse files
committed
feat: Standards addedDate property
1 parent 44eba18 commit 24ba030

File tree

2 files changed

+141
-0
lines changed

2 files changed

+141
-0
lines changed

src/components/CippStandards/CippStandardDialog.jsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { differenceInDays } from 'date-fns';
12
import {
23
Dialog,
34
DialogActions,
@@ -47,6 +48,12 @@ const CippStandardDialog = ({
4748
[]
4849
);
4950

51+
const isNewStandard = (dateAdded) => {
52+
const currentDate = new Date();
53+
const addedDate = new Date(dateAdded);
54+
return differenceInDays(currentDate, addedDate) <= 30;
55+
};
56+
5057
return (
5158
<Dialog
5259
open={dialogOpen}
@@ -151,6 +158,21 @@ const CippStandardDialog = ({
151158
</Typography>
152159
</>
153160
)}
161+
{standard.addedDate?.length > 0 && (
162+
<>
163+
<Typography variant="subtitle2" sx={{ mt: 2 }}>
164+
Date Added:
165+
</Typography>
166+
<Box sx={{ display: "flex", alignItems: "center" }}>
167+
<Typography variant="body2" color="textSecondary">
168+
{standard.addedDate}
169+
</Typography>
170+
{isNewStandard(standard.addedDate) && (
171+
<Chip label="New" size="small" color="success" sx={{ ml: 1 }} />
172+
)}
173+
</Box>
174+
</>
175+
)}
154176
</CardContent>
155177

156178
<CardContent>

0 commit comments

Comments
 (0)