add response interceptors for refreshTokens method
This commit is contained in:
committed by
Daniel Hutzel
parent
76cbf7f9ca
commit
938abb6387
27
media-store/app/src/hocs/withRestrictions.js
Normal file
27
media-store/app/src/hocs/withRestrictions.js
Normal file
@@ -0,0 +1,27 @@
|
||||
import React from "react";
|
||||
import { Redirect } from "react-router-dom";
|
||||
import { useAppState } from "../hooks/useAppState";
|
||||
|
||||
const withRestrictions = (Component, isUserMeetRestrictions) => {
|
||||
return (props) => {
|
||||
const { user, invoicedItems } = useAppState();
|
||||
return isUserMeetRestrictions({ user, invoicedItems }) ? (
|
||||
<Component {...props} />
|
||||
) : (
|
||||
<Redirect exact to="/error" />
|
||||
);
|
||||
};
|
||||
};
|
||||
|
||||
const withRestrictedSection = (Component, isUserMeetRestrictions) => {
|
||||
return (props) => {
|
||||
const { user, invoicedItems } = useAppState();
|
||||
return (
|
||||
isUserMeetRestrictions({ user, invoicedItems }) && (
|
||||
<Component {...props} />
|
||||
)
|
||||
);
|
||||
};
|
||||
};
|
||||
|
||||
export { withRestrictions, withRestrictedSection };
|
||||
Reference in New Issue
Block a user