Skip to content

Commit

Permalink
Merge pull request #782 from DTS-STN/typescript-conversion
Browse files Browse the repository at this point in the history
Covert library functions, document, and dashboard to typescript
  • Loading branch information
Charles-Pham authored Dec 19, 2024
2 parents 19b0e58 + dffa2b1 commit 7ed55bf
Show file tree
Hide file tree
Showing 12 changed files with 186 additions and 48 deletions.
4 changes: 1 addition & 3 deletions components/BenefitTasks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,10 @@ interface Tasks {
id: string
}

interface TaskListProps {
export interface TaskListProps {
title: string
dataCy: string
tasks: Tasks[]
}

interface BenefitTasksProps {
locale: string
taskList: TaskListProps
Expand Down
4 changes: 0 additions & 4 deletions components/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ interface AlertProps {
type: string
alertHeading: string
alertBody: string
alert_icon_alt_text: string
alert_icon_id: string
}
interface CardProps {
cardTitle: string
Expand All @@ -31,8 +29,6 @@ const Card = ({
type: '',
alertHeading: '',
alertBody: '',
alert_icon_alt_text: '',
alert_icon_id: '',
},
],
locale,
Expand Down
10 changes: 5 additions & 5 deletions graphql/mappers/decision-reviews.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ interface GetSchDecisionReviewsV1 {
scDestinationURLEn: string
scDestinationURLFr: string
schBetaPopUp: boolean
schURLType: string
schURLType?: string
}>
}>
}
Expand Down Expand Up @@ -95,7 +95,7 @@ export async function getDecisionReviewsContent(): Promise<DecisionReviewContent
areaLabel: askFragment?.scFragments[0].scLinkTextAssistiveEn,
link: buildLink(
askFragment?.scFragments[0].schURLType,
askFragment?.scFragments[0].scDestinationURLEn,
askFragment?.scFragments[0].scDestinationURLEn ?? '',
),
betaPopUp: askFragment?.scFragments[0].schBetaPopUp,
},
Expand All @@ -108,7 +108,7 @@ export async function getDecisionReviewsContent(): Promise<DecisionReviewContent
areaLabel: appealFragment?.scFragments[0].scLinkTextAssistiveEn,
link: buildLink(
appealFragment?.scFragments[0].schURLType,
appealFragment?.scFragments[0].scDestinationURLEn,
appealFragment?.scFragments[0].scDestinationURLEn ?? '',
),
betaPopUp: appealFragment?.scFragments[0].schBetaPopUp,
},
Expand Down Expand Up @@ -138,7 +138,7 @@ export async function getDecisionReviewsContent(): Promise<DecisionReviewContent
areaLabel: askFragment?.scFragments[0].scLinkTextAssistiveFr,
link: buildLink(
askFragment?.scFragments[0].schURLType,
askFragment?.scFragments[0].scDestinationURLFr,
askFragment?.scFragments[0].scDestinationURLFr ?? '',
),
betaPopUp: askFragment?.scFragments[0].schBetaPopUp,
},
Expand All @@ -151,7 +151,7 @@ export async function getDecisionReviewsContent(): Promise<DecisionReviewContent
areaLabel: appealFragment?.scFragments[0].scLinkTextAssistiveFr,
link: buildLink(
appealFragment?.scFragments[0].schURLType,
appealFragment?.scFragments[0].scDestinationURLFr,
appealFragment?.scFragments[0].scDestinationURLFr ?? '',
),
betaPopUp: appealFragment?.scFragments[0].schBetaPopUp,
},
Expand Down
87 changes: 86 additions & 1 deletion graphql/mappers/my-dashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ const getCachedContent = () => {
})
}

export async function getMyDashboardContent() {
export async function getMyDashboardContent(): Promise<MyDashboardContent> {
const response = await getCachedContent()
const pageAlertContent = response?.data.schPageV1ByPath.item.schAlerts

Expand Down Expand Up @@ -209,3 +209,88 @@ export async function getMyDashboardContent() {
}
return mappedHome
}

export interface MyDashboardContent {
err?: string
en?: {
pageName: string | undefined
heading: string | undefined
pageAlerts:
| {
id: string | undefined
alertHeading: string | undefined
alertBody: string | undefined
type: string[] | undefined
}[]
| undefined
cards:
| {
id: string
title: string
dropdownText: string
cardAlerts:
| {
id: string
alertHeading: string
alertBody: string | undefined
type: string[] | undefined
}[]
| undefined
lists: {
title: string
tasks: {
id: string
title: string
areaLabel: string
link: string
icon: string
betaPopUp: boolean
}[]
}[]
}[]
| undefined
exitBeta: { title: null | undefined; link: string | undefined }
}
fr?: {
pageName: string | undefined
heading: string | undefined
pageAlerts:
| {
id: string | undefined
alertHeading: string | undefined
alertBody: string | undefined
type: string[] | undefined
}[]
| undefined
cards:
| (
| {
id: string
title: string
dropdownText: string
cardAlerts:
| {
id: string
alertHeading: string
alertBody: string | undefined
type: string[] | undefined
}[]
| undefined
lists: {
title: string
tasks: {
id: string
title: string
areaLabel: string
link: string
icon: string
betaPopUp: boolean
}[]
}[]
}
| undefined
)[]
| undefined
exitBeta: { title: null | undefined; link: string | undefined }
}
}
4 changes: 2 additions & 2 deletions graphql/mappers/security-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ export async function getSecuritySettingsContent(): Promise<SecuritySettingsCont
text: securityQuestions?.scLinkTextEn,
link: buildLink(
securityQuestions?.schURLType,
securityQuestions?.scDestinationURLEn,
securityQuestions?.scDestinationURLEn ?? '',
),
},
subTitle: securityQuestions?.scDescriptionEn.json[0].content[0].value,
Expand Down Expand Up @@ -186,7 +186,7 @@ export async function getSecuritySettingsContent(): Promise<SecuritySettingsCont
text: securityQuestions?.scLinkTextFr,
link: buildLink(
securityQuestions?.schURLType,
securityQuestions?.scDestinationURLFr,
securityQuestions?.scDestinationURLFr ?? '',
),
},
subTitle: securityQuestions?.scDescriptionFr.json[0].content[0].value,
Expand Down
2 changes: 1 addition & 1 deletion lib/links.js → lib/links.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//build links is used to prepend links with their corresponding environment. ie MSCA with their test vs prod environment
export function buildLink(linkType, link) {
export function buildLink(linkType: string | undefined, link: string) {
//If no type assume full or relative link
if (linkType === undefined) {
return link
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion lib/programs.js → lib/programs.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const programs = (acronym) => {
export const programs = (acronym: string) => {
switch (acronym.toLowerCase()) {
case 'ei':
return 'Employment Insurance'
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 7ed55bf

Please sign in to comment.