Skip to content

Commit 1cc86bd

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

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}
@@ -90,6 +97,9 @@ const CippStandardDialog = ({
9097
>
9198
<CardContent sx={{ flexGrow: 1 }}>
9299
<Typography variant="h6" gutterBottom>
100+
{isNewStandard(standard.addedDate) && (
101+
<> <Chip label="New" size="small" color="success" sx={{ ml: 1 }} /> </>
102+
)}
93103
{standard.label}
94104
</Typography>
95105
{standard.helpText && (
@@ -151,6 +161,18 @@ const CippStandardDialog = ({
151161
</Typography>
152162
</>
153163
)}
164+
{standard.addedDate?.length > 0 && (
165+
<>
166+
<Typography variant="subtitle2" sx={{ mt: 2 }}>
167+
Date Added:
168+
</Typography>
169+
<Box sx={{ display: "flex", alignItems: "center" }}>
170+
<Typography variant="body2" color="textSecondary">
171+
{standard.addedDate}
172+
</Typography>
173+
</Box>
174+
</>
175+
)}
154176
</CardContent>
155177

156178
<CardContent>

0 commit comments

Comments
 (0)