-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make share thoughts button optional (#2282)
- Loading branch information
1 parent
ec9349b
commit 4870ef7
Showing
5 changed files
with
16 additions
and
37 deletions.
There are no files selected for viewing
31 changes: 5 additions & 26 deletions
31
met-web/src/components/engagement/view/EngagementBanner/BannerSection.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,25 @@ | ||
import React from 'react'; | ||
import { Grid, Skeleton } from '@mui/material'; | ||
import { Skeleton } from '@mui/material'; | ||
import { Banner } from '../../../banner/Banner'; | ||
import { PrimaryButton } from 'components/common'; | ||
import { SubmissionStatus } from 'constants/engagementStatus'; | ||
import { When } from 'react-if'; | ||
import EngagementInfoSection from '../EngagementInfoSection'; | ||
import { Engagement } from 'models/engagement'; | ||
|
||
export interface EngagementBannerProps { | ||
startSurvey: () => void; | ||
isEngagementLoading: boolean; | ||
savedEngagement: Engagement | null; | ||
mockStatus?: SubmissionStatus; | ||
isLoggedIn: boolean; | ||
mockStatus?: SubmissionStatus; | ||
surveyButton?: React.ReactNode; | ||
} | ||
export const BannerSection = ({ | ||
startSurvey, | ||
isEngagementLoading, | ||
savedEngagement, | ||
isLoggedIn, | ||
mockStatus, | ||
}: EngagementBannerProps) => { | ||
const surveyId = savedEngagement?.surveys[0]?.id ?? ''; | ||
const isPreview = isLoggedIn; | ||
const currentStatus = isPreview ? mockStatus : savedEngagement?.submission_status; | ||
const isOpen = currentStatus === SubmissionStatus.Open; | ||
|
||
export const BannerSection = ({ isEngagementLoading, savedEngagement, surveyButton }: EngagementBannerProps) => { | ||
if (isEngagementLoading || !savedEngagement) { | ||
return <Skeleton variant="rectangular" width="100%" height="35em" />; | ||
} | ||
|
||
return ( | ||
<Banner imageUrl={savedEngagement.banner_url} height="480px"> | ||
<EngagementInfoSection savedEngagement={savedEngagement}> | ||
<When condition={surveyId && isOpen}> | ||
<Grid item container direction={{ xs: 'column', sm: 'row' }} xs={12} justifyContent="flex-end"> | ||
<PrimaryButton data-testid="EngagementBanner/share-your-thoughts-button" onClick={startSurvey}> | ||
Share Your Thoughts | ||
</PrimaryButton> | ||
</Grid> | ||
</When> | ||
</EngagementInfoSection> | ||
<EngagementInfoSection savedEngagement={savedEngagement}>{surveyButton}</EngagementInfoSection> | ||
</Banner> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters