@@ -11,6 +11,7 @@ import {
1111 useDisclosure ,
1212 VStack ,
1313} from "@chakra-ui/react"
14+ import { useFeatureIsOn , useGrowthBook } from "@growthbook/growthbook-react"
1415import { Button , Link } from "@opengovsg/design-system-react"
1516import _ from "lodash"
1617import { useEffect } from "react"
@@ -95,11 +96,15 @@ export const SiteDashboard = (): JSX.Element => {
9596 mutateAsync : updateViewedReviewRequests ,
9697 } = useUpdateViewedReviewRequests ( )
9798
99+ const isBrokenLinksReporterEnabled = useFeatureIsOn (
100+ "is_broken_links_report_enabled"
101+ )
102+
98103 const {
99104 data : brokenLinks ,
100105 isError : isBrokenLinksError ,
101106 isLoading : isBrokenLinksLoading ,
102- } = useGetBrokenLinks ( siteName )
107+ } = useGetBrokenLinks ( siteName , isBrokenLinksReporterEnabled )
103108
104109 const savedAt = getDateTimeFromUnixTime ( siteInfo ?. savedAt || 0 )
105110 const publishedAt = getDateTimeFromUnixTime ( siteInfo ?. publishedAt || 0 )
@@ -205,48 +210,52 @@ export const SiteDashboard = (): JSX.Element => {
205210 ) )
206211 ) }
207212 </ DisplayCardContent >
208-
209- { isBrokenLinksLoading || brokenLinks ?. status === "loading" ? (
210- < Skeleton w = "100%" height = "4rem" />
211- ) : (
213+ { isBrokenLinksReporterEnabled && (
212214 < >
213- < DisplayCardHeader mt = "0.75rem" >
214- < DisplayCardTitle > Your site health</ DisplayCardTitle >
215- < DisplayCardCaption >
216- { `Understand your site's broken references` }
217- </ DisplayCardCaption >
218- </ DisplayCardHeader >
219- < DisplayCardContent >
220- { isBrokenLinksError || brokenLinks ?. status === "error" ? (
221- < Text textStyle = "body-1" >
222- Unable to retrieve broken links report
223- </ Text >
224- ) : (
225- < DisplayCard
226- variant = "full"
227- bgColor = "background.action.defaultInverse"
228- >
229- < HStack w = "full" justifyContent = "space-between" >
230- < HStack >
231- < Text textStyle = "h4" >
232- { brokenLinks ?. status === "success" &&
233- brokenLinks ?. errors . length }
234- </ Text >
235- < Text textStyle = "body-1" >
236- broken references found
237- </ Text >
238- </ HStack >
239-
240- < Link
241- href = { `/sites/${ siteName } /linkCheckerReport` }
242- textStyle = "body-1"
215+ { isBrokenLinksLoading || brokenLinks ?. status === "loading" ? (
216+ < Skeleton w = "100%" height = "4rem" />
217+ ) : (
218+ < >
219+ < DisplayCardHeader mt = "0.75rem" >
220+ < DisplayCardTitle > Your site health</ DisplayCardTitle >
221+ < DisplayCardCaption >
222+ { `Understand your site's broken references` }
223+ </ DisplayCardCaption >
224+ </ DisplayCardHeader >
225+ < DisplayCardContent >
226+ { isBrokenLinksError ||
227+ brokenLinks ?. status === "error" ? (
228+ < Text textStyle = "body-1" >
229+ Unable to retrieve broken links report
230+ </ Text >
231+ ) : (
232+ < DisplayCard
233+ variant = "full"
234+ bgColor = "background.action.defaultInverse"
243235 >
244- View report
245- </ Link >
246- </ HStack >
247- </ DisplayCard >
248- ) }
249- </ DisplayCardContent >
236+ < HStack w = "full" justifyContent = "space-between" >
237+ < HStack >
238+ < Text textStyle = "h4" >
239+ { brokenLinks ?. status === "success" &&
240+ brokenLinks ?. errors . length }
241+ </ Text >
242+ < Text textStyle = "body-1" >
243+ broken references found
244+ </ Text >
245+ </ HStack >
246+
247+ < Link
248+ href = { `/sites/${ siteName } /linkCheckerReport` }
249+ textStyle = "body-1"
250+ >
251+ View report
252+ </ Link >
253+ </ HStack >
254+ </ DisplayCard >
255+ ) }
256+ </ DisplayCardContent >
257+ </ >
258+ ) }
250259 </ >
251260 ) }
252261 </ DisplayCard >
0 commit comments