Skip to content

Commit

Permalink
feat: add verify Message button to headers
Browse files Browse the repository at this point in the history
  • Loading branch information
thanhdatle committed Apr 12, 2023
1 parent 4f6edab commit 0868c9f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
3 changes: 2 additions & 1 deletion public/locales/gov/en/translation.json
Expand Up @@ -28,7 +28,8 @@
"builtBy": "https://open.gov.sg",
"linkedin": "https://sg.linkedin.com/company/open-government-products",
"facebook": "https://www.facebook.com/opengovsg",
"apiDoc": "https://guide.go.gov.sg/developer-guide/api-documentation"
"apiDoc": "https://guide.go.gov.sg/developer-guide/api-documentation",
"verifyMessages": "https://check.go.gov.sg"
},
"builtBy": "Built by Open Government Products"
},
Expand Down
25 changes: 25 additions & 0 deletions src/client/app/components/BaseLayout/BaseLayoutHeader.tsx
Expand Up @@ -27,6 +27,7 @@ import homeIcon from '@assets/components/app/base-layout/home-icon.svg'
import Section from '../Section'
import loginActions from '../../../login/actions'
import { GoGovReduxState } from '../../reducers/types'
import assetVariant from '../../../../shared/util/asset-variant'

type StyleProps = {
isLoggedIn: boolean
Expand Down Expand Up @@ -118,6 +119,21 @@ type BaseLayoutHeaderProps = {
toStick: boolean
}

type HeaderButtonProps = {
text: string
link: string
public: boolean
icon: string
mobileOrder?: number
internalLink?: boolean
displayNotEnabledForVariant?: string[]
}

function isEnabledForAssetVariant(header: HeaderButtonProps) {
if (header.displayNotEnabledForVariant === undefined) return true
return !header.displayNotEnabledForVariant.includes(assetVariant)
}

const BaseLayoutHeader: FunctionComponent<BaseLayoutHeaderProps> = ({
backgroundType,
hideNavButtons = false,
Expand Down Expand Up @@ -176,6 +192,14 @@ const BaseLayoutHeader: FunctionComponent<BaseLayoutHeaderProps> = ({
public: true,
icon: githubIcon,
},
{
text: 'Verify Messages',
link: i18next.t('general.links.verifyMessages'),
public: true,
icon: githubIcon,
mobileOrder: 6,
displayNotEnabledForVariant: ['edu', 'health'],
},
{
text: 'Guide',
link: i18next.t('general.links.faq'),
Expand Down Expand Up @@ -273,6 +297,7 @@ const BaseLayoutHeader: FunctionComponent<BaseLayoutHeaderProps> = ({
{!hideNavButtons &&
headers.map(
(header) =>
isEnabledForAssetVariant(header) &&
(header.public ? !isLoggedIn : isLoggedIn) && (
<Button
href={
Expand Down

0 comments on commit 0868c9f

Please sign in to comment.