@@ -145,33 +145,48 @@ export function formatISODate(isoDate: string): string {
145145}
146146
147147export const formatWorkingRights = ( rights : WorkingRight [ ] ) : string => {
148- // If all rights are present, return "Any"
149- if ( rights . length === WORKING_RIGHTS . length ) {
148+ // If all rights except OTHER_RIGHTS are present, return "Any Working Rights"
149+ const essentialRights = WORKING_RIGHTS . filter (
150+ ( right ) => right !== "OTHER_RIGHTS" ,
151+ ) ;
152+ const hasAllEssentialRights = essentialRights . every ( ( right ) =>
153+ rights . includes ( right ) ,
154+ ) ;
155+
156+ if ( hasAllEssentialRights ) {
150157 return "Any Working Rights" ;
151158 }
152159
153160 // Check for AUS and NZ Citizens/PR combination
154161 const hasAus = rights . includes ( "AUS_CITIZEN_PR" ) ;
155162 const hasNz = rights . includes ( "NZ_CITIZEN_PR" ) ;
163+ const hasInt = rights . includes ( "INTERNATIONAL" ) ;
164+ const formattedRights : string [ ] = [ ] ;
165+
156166 if ( hasAus && hasNz ) {
157- return "AUS & NZ Citizen/PR" ;
167+ formattedRights . push ( "AUS & NZ Citizen/PR" ) ;
168+ } else {
169+ if ( hasAus ) formattedRights . push ( "AUS Citizen/PR" ) ;
170+ if ( hasNz ) formattedRights . push ( "NZ Citizen/PR" ) ;
171+ }
172+
173+ if ( hasInt ) {
174+ formattedRights . push ( "International" ) ;
158175 }
159176
160177 // Format remaining cases
161- return rights
162- . map ( ( right ) => {
178+ rights . forEach ( ( right ) => {
179+ if ( ! [ "AUS_CITIZEN_PR" , "NZ_CITIZEN_PR" , "INTERNATIONAL" ] . includes ( right ) ) {
163180 switch ( right ) {
164- case "AUS_CITIZEN_PR" :
165- return "AUS Citizen/PR" ;
166- case "NZ_CITIZEN_PR" :
167- return "NZ Citizen/PR" ;
168- case "INTERNATIONAL" :
169- return "International" ;
170181 case "OTHER_RIGHTS" :
171- return "Other" ;
182+ formattedRights . push ( "Other" ) ;
183+ break ;
172184 default :
173- return formatCapString ( right ) ;
185+ formattedRights . push ( formatCapString ( right ) ) ;
186+ break ;
174187 }
175- } )
176- . join ( ", " ) ;
188+ }
189+ } ) ;
190+
191+ return formattedRights . join ( ", " ) ;
177192} ;
0 commit comments