prod-wag-backend-automate-s.../WebServices/management-frontend/src/eventRouters/pageRetriever.tsx

14 lines
620 B
TypeScript

import { PageProps } from "../validations/translations/translation";
import { UnAuthorizedPage } from "./unauthorizedpage";
import menuPages from "./index";
export function retrievePageByUrl(url: string, lang: "en" | "tr"): React.FC<PageProps> {
if (url in menuPages) {
const PageComponent = menuPages[url as keyof typeof menuPages];
// Return a new component that passes the lang prop to the original component
return (props: PageProps) => <PageComponent {...props} lang={lang} />;
}
// Also pass lang to UnAuthorizedPage
return (props: PageProps) => <UnAuthorizedPage {...props} lang={lang} />;
}