Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync develop with Main for release candidate v1.3.9 #1044

Merged
merged 2 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions components/Layout/Head.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ export const Head: React.VFC<{ title: string }> = ({ title }) => {
const tsln = useTranslation<WebTranslations>()
const altLang = tsln._language === 'en' ? 'fr' : 'en'

const [isCanadaDotCa, setIsCanadaDotCa] = useState(false)
const [isAlpha, setIsAlpha] = useState(false)

useEffect(() => {
if (typeof window !== undefined) {
const hostName = window.location.hostname
setIsCanadaDotCa(hostName.includes('.canada.ca'))
setIsAlpha(hostName.includes('.alpha.service'))
}
}, [])

Expand All @@ -35,28 +35,28 @@ export const Head: React.VFC<{ title: string }> = ({ title }) => {
<link
rel="canonical"
href={
isCanadaDotCa
? `https://estimateursv-oasestimator.service.canada.ca/${tsln._language}${router.pathname}`
: `http://ep-be.alpha.servicecanada.ca/${tsln._language}${router.pathname}`
isAlpha
? `http://ep-be.alpha.service.canada.ca/${tsln._language}${router.pathname}`
: `https://estimateursv-oasestimator.service.canada.ca/${tsln._language}${router.pathname}`
}
/>
<link
rel="alternate"
lang={altLang}
href={
isCanadaDotCa
? `https://estimateursv-oasestimator.service.canada.ca/${altLang}${router.pathname}`
: `https://ep-be.alpha.service.canada.ca/${altLang}${router.pathname}`
isAlpha
? `https://ep-be.alpha.service.canada.ca/${altLang}${router.pathname}`
: `https://estimateursv-oasestimator.service.canada.ca/${altLang}${router.pathname}`
}
/>

<link
rel="alternate"
lang={tsln._language}
href={
isCanadaDotCa
? `https://estimateursv-oasestimator.service.canada.ca/${tsln._language}${router.pathname}`
: `https://ep-be.alpha.service.canada.ca/${tsln._language}${router.pathname}`
isAlpha
? `https://ep-be.alpha.service.canada.ca/${tsln._language}${router.pathname}`
: `https://estimateursv-oasestimator.service.canada.ca/${tsln._language}${router.pathname}`
}
/>
<meta name="keywords" content={tsln.meta.homeKeywords} />
Expand Down
98 changes: 52 additions & 46 deletions components/Layout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export const Layout: React.VFC<{
title: string
}> = ({ children, title }) => {
const router = useRouter()
const hostname = typeof window !== 'undefined' ? window.location.hostname : ''

// basically returns 'results' or 'resultats' IF, otherwise index or questions in the other locale.
const langToggleLink =
Expand Down Expand Up @@ -53,54 +54,59 @@ export const Layout: React.VFC<{
onSubmit: () => {},
}

const breadcrumbs =
process.env.APP_ENV === 'production'
? [
{
text: tsln.breadcrumb1Title,
link: tsln.breadcrumb1URL,
},
{
text: tsln.breadcrumb2Title,
link: tsln.breadcrumb2URL,
},
{
text: tsln.breadcrumb3Title,
link: tsln.breadcrumb3URL,
},
{
text: tsln.breadcrumb4Title,
link: tsln.breadcrumb4URL,
},
]
: [
{
text: tsln.breadcrumb1aTitle,
link: tsln.breadcrumb1aURL,
},
{
text: tsln.breadcrumb2aTitle,
link: tsln.breadcrumb2aURL,
},
]
const getBreadcrumbs = () => {
const isBeta = !hostname.includes('.alpha.service')
const breadcrumbs =
process.env.APP_ENV === 'production' && isBeta
? [
{
text: tsln.breadcrumb1Title,
link: tsln.breadcrumb1URL,
},
{
text: tsln.breadcrumb2Title,
link: tsln.breadcrumb2URL,
},
{
text: tsln.breadcrumb3Title,
link: tsln.breadcrumb3URL,
},
{
text: tsln.breadcrumb4Title,
link: tsln.breadcrumb4URL,
},
]
: [
{
text: tsln.breadcrumb1aTitle,
link: tsln.breadcrumb1aURL,
},
{
text: tsln.breadcrumb2aTitle,
link: tsln.breadcrumb2aURL,
},
]

if (router.pathname === '/questions') {
breadcrumbs.push({
text: tsln.breadcrumb6Title,
link: tsln.breadcrumb6URL,
})
} else if (
router.pathname === '/results' ||
router.pathname === '/resultats'
) {
breadcrumbs.push({
text: tsln.breadcrumb6Title,
link: tsln.breadcrumb6URL,
}),
if (router.pathname === '/questions') {
breadcrumbs.push({
text: tsln.breadcrumb7Title,
link: tsln.breadcrumb7URL,
text: tsln.breadcrumb6Title,
link: tsln.breadcrumb6URL,
})
} else if (
router.pathname === '/results' ||
router.pathname === '/resultats'
) {
breadcrumbs.push({
text: tsln.breadcrumb6Title,
link: tsln.breadcrumb6URL,
}),
breadcrumbs.push({
text: tsln.breadcrumb7Title,
link: tsln.breadcrumb7URL,
})
}

return breadcrumbs
}

const handleOnClick = () => {
Expand All @@ -122,7 +128,7 @@ export const Layout: React.VFC<{
id="header"
locale={router.locale}
langUrl={langToggleLink}
breadcrumbItems={breadcrumbs}
breadcrumbItems={getBreadcrumbs()}
topNavProps={topnavProps}
headerText={{
globalHeader: tsln.globalHeader,
Expand Down
2 changes: 0 additions & 2 deletions styles/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -360,5 +360,3 @@
font-size: 12px;
}
}

{{/* just a comment */}}
10 changes: 8 additions & 2 deletions utils/api/definitions/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@ export const RequestSchema = Joi.object({
//.message(ValidationErrors.incomeWorkGreaterThanNetIncome),
age: Joi.number()
.required()
.messages({ 'any.required': ValidationErrors.invalidAge })
.messages({
'any.required': ValidationErrors.invalidAge,
'number.base': ValidationErrors.invalidAge,
})
.custom(customAgeValidation, 'Custom Validation'),
receiveOAS: Joi.boolean()
.required()
Expand Down Expand Up @@ -275,7 +278,10 @@ export const RequestSchema = Joi.object({
//.message(ValidationErrors.partnerIncomeWorkGreaterThanNetIncome),
partnerAge: Joi.number()
.required()
.messages({ 'any.required': ValidationErrors.invalidAge })
.messages({
'any.required': ValidationErrors.invalidAge,
'number.base': ValidationErrors.invalidAge,
})
.custom(customAgeValidation, 'Custom Validation'),
partnerLivingCountry: Joi.string()
.required()
Expand Down
Loading