Skip to content

Commit c63c6a4

Browse files
Merge pull request #3663 from Ren-Roros-Digital/DateAdded
feat: Standards addedDate property
2 parents 1cc076d + 24a3166 commit c63c6a4

File tree

2 files changed

+147
-0
lines changed

2 files changed

+147
-0
lines changed

src/components/CippStandards/CippStandardDialog.jsx

Lines changed: 28 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}
@@ -86,8 +93,17 @@ const CippStandardDialog = ({
8693
display: "flex",
8794
flexDirection: "column",
8895
height: "100%",
96+
position: "relative",
8997
}}
9098
>
99+
{isNewStandard(standard.addedDate) && (
100+
<Chip
101+
label="New"
102+
size="small"
103+
color="success"
104+
sx={{ position: "absolute"}}
105+
/>
106+
)}
91107
<CardContent sx={{ flexGrow: 1 }}>
92108
<Typography variant="h6" gutterBottom>
93109
{standard.label}
@@ -151,6 +167,18 @@ const CippStandardDialog = ({
151167
</Typography>
152168
</>
153169
)}
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+
)}
154182
</CardContent>
155183

156184
<CardContent>

0 commit comments

Comments
 (0)