@@ -37,13 +37,24 @@ export function contactUsGet(req: Request, res: Response): void {
3737 if ( req . query . supportType === SUPPORT_TYPE . GOV_SERVICE ) {
3838 return res . render ( "contact-us/index-gov-service-contact-us.njk" ) ;
3939 }
40+ let fromPage = req . headers . referer ;
4041
41- return res . render ( "contact-us/index-public-contact-us.njk" ) ;
42+ if ( req . headers . referer && req . headers . referer . includes ( "fromPage" ) ) {
43+ const urlObj = new URL ( req . headers . referer ) ;
44+ fromPage = urlObj . searchParams . get ( "fromPage" ) ;
45+ }
46+
47+ return res . render ( "contact-us/index-public-contact-us.njk" , {
48+ fromPage : fromPage ,
49+ } ) ;
4250}
4351
4452export function contactUsFormPost ( req : Request , res : Response ) : void {
4553 let url = PATH_NAMES . CONTACT_US_QUESTIONS ;
46- const queryParams = new URLSearchParams ( { theme : req . body . theme } ) . toString ( ) ;
54+ const queryParams = new URLSearchParams ( {
55+ theme : req . body . theme ,
56+ fromPage : req . body . fromPage ,
57+ } ) . toString ( ) ;
4758 if (
4859 [ ZENDESK_THEMES . ACCOUNT_CREATION , ZENDESK_THEMES . SIGNING_IN ] . includes (
4960 req . body . theme
@@ -55,8 +66,12 @@ export function contactUsFormPost(req: Request, res: Response): void {
5566}
5667
5768export function furtherInformationGet ( req : Request , res : Response ) : void {
69+ if ( ! req . query . theme ) {
70+ return res . redirect ( PATH_NAMES . CONTACT_US ) ;
71+ }
5872 return res . render ( "contact-us/further-information/index.njk" , {
5973 theme : req . query . theme ,
74+ fromPage : req . query . fromPage ,
6075 } ) ;
6176}
6277
@@ -65,12 +80,16 @@ export function furtherInformationPost(req: Request, res: Response): void {
6580 const queryParams = new URLSearchParams ( {
6681 theme : req . body . theme ,
6782 subtheme : req . body . subtheme ,
83+ fromPage : req . body . fromPage ,
6884 } ) . toString ( ) ;
6985
7086 res . redirect ( url + "?" + queryParams ) ;
7187}
7288
7389export function contactUsQuestionsGet ( req : Request , res : Response ) : void {
90+ if ( ! req . query . theme ) {
91+ return res . redirect ( PATH_NAMES . CONTACT_US ) ;
92+ }
7493 let pageTitle = themeToPageTitle [ req . query . theme as string ] ;
7594 if (
7695 req . query . subtheme === ZENDESK_THEMES . SOMETHING_ELSE &&
@@ -84,6 +103,7 @@ export function contactUsQuestionsGet(req: Request, res: Response): void {
84103 theme : req . query . theme ,
85104 subtheme : req . query . subtheme ,
86105 backurl : req . headers . referer ,
106+ fromPage : req . query . fromPage ,
87107 pageTitleHeading : pageTitle ,
88108 } ) ;
89109}
@@ -116,6 +136,7 @@ export function contactUsQuestionsFormPost(
116136 feedbackContact : req . body . contact === "true" ,
117137 questions : questions ,
118138 themeQuestions : themeQuestions ,
139+ referer : req . body . fromPage ,
119140 } ) ;
120141
121142 return res . redirect ( PATH_NAMES . CONTACT_US_SUBMIT_SUCCESS ) ;
0 commit comments