diff --git a/src/components/Authorization/Authorization.tsx b/src/components/Authorization/Authorization.tsx index 20676a44adfa6b26eaaa80a4a018d155def22d17..08db3cea5572ddc10184b44cece73f59e49e5ce7 100644 --- a/src/components/Authorization/Authorization.tsx +++ b/src/components/Authorization/Authorization.tsx @@ -25,15 +25,16 @@ interface WithAuthProps { * This creates a "personal area" in the working implementation. * @returns {FC<T>} wrapped component. */ -export const withAuthorization = <T extends WithAuthProps = WithAuthProps>( + +export const withAuthorization = (allowedRoles: string[]) => < + T extends WithAuthProps = WithAuthProps +>( WrappedComponent: React.ComponentType<T>, ): FC<T> => { // Creating the inner component. The calculated Props type here is the where the magic happens. const ComponentWithAuthorization: FC<T> = ( props: Omit<T, keyof WithAuthProps>, ) => { - const { allowedRoles } = props as T; - const { role, isAuth } = useContext(AuthContext); console.log(`ROLE ${role} AUTH ${isAuth}`);