11import { ReviewBoardItem } from "@/models/ReviewBoard" ;
2+ import { ReviewBoardCardTypeEnum } from "@/components/App/ReviewBoard/ReviewBoardUtils" ;
23import { APPROVAL_STATUS } from "@/utils/constants" ;
34import dateUtils from "@/utils/dateUtils" ;
45import { CalendarMonthRounded } from "@mui/icons-material" ;
5- import { Box , Chip , Typography } from "@mui/material" ;
6+ import { Box , Chip , Divider , Typography } from "@mui/material" ;
67import { BCDesignTokens } from "epic.theme" ;
8+ import { useRouter } from "@tanstack/react-router" ;
9+
10+ const reviewBoardDateFormat = "DD MMM. YYYY" ;
11+
12+ const ReviewBoardSectionItem = ( {
13+ item,
14+ sectionId,
15+ } : {
16+ item : ReviewBoardItem ;
17+ sectionId : ReviewBoardCardTypeEnum ;
18+ } ) => {
19+ const router = useRouter ( ) ;
720
8- const ReviewBoardSectionItem = ( { item } : { item : ReviewBoardItem } ) => {
921 const approvalCardColor = ( approvalStatus : string ) => {
1022 if ( approvalStatus === APPROVAL_STATUS . APPROVED ) {
1123 return "success" ;
@@ -17,6 +29,10 @@ const ReviewBoardSectionItem = ({ item }: { item: ReviewBoardItem }) => {
1729 return "default" ;
1830 } ;
1931
32+ const getFormattedDate = ( date : string | undefined ) => {
33+ return date ? dateUtils . formatDate ( date , reviewBoardDateFormat ) : "N/A" ;
34+ } ;
35+
2036 return (
2137 < Box
2238 key = { item . id }
@@ -27,8 +43,17 @@ const ReviewBoardSectionItem = ({ item }: { item: ReviewBoardItem }) => {
2743 backgroundColor : BCDesignTokens . surfaceColorBackgroundWhite ,
2844 borderRadius : BCDesignTokens . layoutBorderRadiusMedium ,
2945 border : `1px solid ${ BCDesignTokens . surfaceColorBorderDefault } ` ,
30- // height: 400,
3146 flexShrink : 0 ,
47+ cursor : "pointer" ,
48+ } }
49+ onClick = { ( ) => {
50+ // All review board items navigate to their related inspection page
51+ if ( item . ir_number ) {
52+ router . navigate ( {
53+ to : "/ce-database/inspections/$inspectionNumber" ,
54+ params : { inspectionNumber : item . ir_number } ,
55+ } ) ;
56+ }
3257 } }
3358 >
3459 < Box
@@ -49,7 +74,9 @@ const ReviewBoardSectionItem = ({ item }: { item: ReviewBoardItem }) => {
4974 fontSize : "0.75rem" ,
5075 } }
5176 />
52- { item . approval_status ? (
77+ { item . approval_status &&
78+ ( sectionId === ReviewBoardCardTypeEnum . DEPUTY_REVIEW ||
79+ sectionId === ReviewBoardCardTypeEnum . REVIEW_STATUS ) ? (
5380 < Chip
5481 variant = "outlined"
5582 size = "small"
@@ -79,7 +106,7 @@ const ReviewBoardSectionItem = ({ item }: { item: ReviewBoardItem }) => {
79106 variant = "caption"
80107 color = { BCDesignTokens . typographyColorPlaceholder }
81108 >
82- { item . name }
109+ { item . project_name }
83110 </ Typography >
84111 < Box sx = { { display : "flex" , alignItems : "center" , mt : 1 } } >
85112 < CalendarMonthRounded
@@ -90,7 +117,7 @@ const ReviewBoardSectionItem = ({ item }: { item: ReviewBoardItem }) => {
90117 } }
91118 />
92119 < Typography variant = "caption" >
93- { dateUtils . formatDate ( item . card_date ) }
120+ { getFormattedDate ( item . card_date ) }
94121 </ Typography >
95122 { item . types ? (
96123 < Typography
@@ -112,11 +139,124 @@ const ReviewBoardSectionItem = ({ item }: { item: ReviewBoardItem }) => {
112139 width : "fit-content" ,
113140 backgroundColor : BCDesignTokens . surfaceColorBackgroundLightBlue ,
114141 padding : 0.5 ,
142+ my : 0.5 ,
115143 borderRadius : BCDesignTokens . layoutBorderRadiusMedium ,
116144 } }
117145 >
118- { item . primary_officer . last_name }
146+ { item . primary_officer ? .last_name }
119147 </ Typography >
148+ { sectionId !== ReviewBoardCardTypeEnum . DRAFTING && (
149+ < >
150+ < Divider />
151+ < Box
152+ sx = { {
153+ display : "flex" ,
154+ flexDirection : "column" ,
155+ alignItems : "flex-start" ,
156+ mt : 1 ,
157+ } }
158+ >
159+ { sectionId === ReviewBoardCardTypeEnum . REVIEW_STATUS && (
160+ < Typography
161+ variant = "caption"
162+ color = { BCDesignTokens . typographyColorPlaceholder }
163+ >
164+ Review Date:
165+ < Typography
166+ variant = "caption"
167+ ml = { 0.25 }
168+ fontWeight = { BCDesignTokens . typographyFontWeightsBold }
169+ >
170+ { getFormattedDate ( item . review_date ) }
171+ </ Typography >
172+ </ Typography >
173+ ) }
174+ { ( sectionId === ReviewBoardCardTypeEnum . DEPUTY_REVIEW ||
175+ sectionId === ReviewBoardCardTypeEnum . REVIEW_STATUS ) && (
176+ < >
177+ < Typography
178+ variant = "caption"
179+ color = { BCDesignTokens . typographyColorPlaceholder }
180+ >
181+ Sent for Review:
182+ < Typography
183+ variant = "caption"
184+ ml = { 0.25 }
185+ fontWeight = {
186+ sectionId === ReviewBoardCardTypeEnum . REVIEW_STATUS
187+ ? BCDesignTokens . typographyFontWeightsRegular
188+ : BCDesignTokens . typographyFontWeightsBold
189+ }
190+ >
191+ { getFormattedDate ( item . send_for_review_date ) }
192+ </ Typography >
193+ </ Typography >
194+ { item . deputy_director_name && (
195+ < Typography
196+ variant = "caption"
197+ color = { BCDesignTokens . typographyColorPlaceholder }
198+ >
199+ Deputy Director:
200+ < Typography variant = "caption" ml = { 0.25 } >
201+ { item . deputy_director_name . substring (
202+ item . deputy_director_name . indexOf ( " " ) + 1
203+ ) }
204+ </ Typography >
205+ </ Typography >
206+ ) }
207+ </ >
208+ ) }
209+ { sectionId === ReviewBoardCardTypeEnum . HOLDER_REVIEW && (
210+ < >
211+ < Typography
212+ variant = "caption"
213+ color = { BCDesignTokens . typographyColorPlaceholder }
214+ >
215+ Due Date:
216+ < Typography
217+ variant = "caption"
218+ ml = { 0.25 }
219+ fontWeight = { BCDesignTokens . typographyFontWeightsBold }
220+ >
221+ { getFormattedDate ( item . expected_return_date ) }
222+ </ Typography >
223+ </ Typography >
224+ < Typography
225+ variant = "caption"
226+ color = { BCDesignTokens . typographyColorPlaceholder }
227+ >
228+ Report Sent:
229+ < Typography variant = "caption" ml = { 0.25 } >
230+ { getFormattedDate ( item . date_report_sent ) }
231+ </ Typography >
232+ </ Typography >
233+ </ >
234+ ) }
235+ { sectionId === ReviewBoardCardTypeEnum . FINALIZING_RECORD && (
236+ < Typography
237+ variant = "caption"
238+ color = { BCDesignTokens . typographyColorPlaceholder }
239+ >
240+ Response Date:
241+ < Typography variant = "caption" ml = { 0.25 } >
242+ { getFormattedDate ( item . date_response ) }
243+ </ Typography >
244+ </ Typography >
245+ ) }
246+ { sectionId === ReviewBoardCardTypeEnum . PENDING_ISSUANCE && (
247+ < Typography
248+ variant = "caption"
249+ color = { BCDesignTokens . typographyColorPlaceholder }
250+ >
251+ Issuance Date:
252+ < Typography variant = "caption" ml = { 0.25 } >
253+ { getFormattedDate ( item . intended_issuance_date ) }
254+ </ Typography >
255+ </ Typography >
256+ ) }
257+ </ Box >
258+ </ >
259+ ) }
120260 </ Box >
121261 ) ;
122262} ;
0 commit comments