22541 extract breadcrumb route-state helper and align phase22 auth locale test
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
export const normalizeRouteStateQuery = (query = {}) => {
|
||||
const viewAll = query?.va === "true";
|
||||
const advanced = query?.adv === "true";
|
||||
const address = query?.ads === "true";
|
||||
|
||||
return {
|
||||
viewAll,
|
||||
advanced,
|
||||
address,
|
||||
key: query?.key
|
||||
};
|
||||
};
|
||||
|
||||
export const resolveSearchResultsHref = ({
|
||||
query = {},
|
||||
hasSession = false,
|
||||
includeViewAll = true,
|
||||
fallbackToMyPortalWhenNoFlags = false,
|
||||
isDnsRoute = false
|
||||
} = {}) => {
|
||||
const routeState = normalizeRouteStateQuery(query);
|
||||
const { viewAll, advanced, address, key } = routeState;
|
||||
const base = hasSession ? "/myportal" : "";
|
||||
|
||||
if (fallbackToMyPortalWhenNoFlags && !viewAll && !advanced && !address) {
|
||||
return {
|
||||
pathname: "/myportal"
|
||||
};
|
||||
}
|
||||
|
||||
if (isDnsRoute) {
|
||||
return {
|
||||
pathname: `${base}/dnsapplications`
|
||||
};
|
||||
}
|
||||
|
||||
if (includeViewAll && viewAll) {
|
||||
return {
|
||||
pathname: "/myportal/viewall",
|
||||
query: { key }
|
||||
};
|
||||
}
|
||||
|
||||
if (advanced) {
|
||||
return {
|
||||
pathname: `${base}/advancedsearchresults`,
|
||||
query
|
||||
};
|
||||
}
|
||||
|
||||
if (address) {
|
||||
return {
|
||||
pathname: `${base}/addresssearchresults`,
|
||||
query
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
pathname: `${base}/searchresults`,
|
||||
query
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user