diff --git a/.env.development b/.env.development index 63f71024b..6b671da74 100644 --- a/.env.development +++ b/.env.development @@ -7,5 +7,6 @@ REACT_APP_REPORTING_API_ROOT=https://dev-k8s.treetracker.org/reporting REACT_APP_REPORTING_ENABLED=true REACT_APP_ENABLE_EARNINGS=true REACT_APP_ENABLE_PAYMENTS=true +REACT_APP_ENABLE_MESSAGING=true REACT_APP_API_URL=https://dev-k8s.treetracker.org REACT_APP_EARNINGS_API_MAPPING=/earnings diff --git a/src/components/GrowerDetail.js b/src/components/GrowerDetail.js index aac7f8d2c..6a33fb7eb 100644 --- a/src/components/GrowerDetail.js +++ b/src/components/GrowerDetail.js @@ -292,18 +292,19 @@ const GrowerDetail = ({ open, growerId, onClose }) => { ID: - {hasPermission(appContext.user, [POLICIES.SUPER_PERMISSION]) && ( - - - - )} + {process.env.REACT_APP_ENABLE_MESSAGING === 'true' && + hasPermission(appContext.user, [POLICIES.SUPER_PERMISSION]) && ( + + + + )} Captures diff --git a/src/components/common/Menu.js b/src/components/common/Menu.js index a0402361a..a413bde9a 100644 --- a/src/components/common/Menu.js +++ b/src/components/common/Menu.js @@ -60,9 +60,6 @@ const useStyles = makeStyles((theme) => ({ textDecoration: 'none', color: theme.palette.primary.main, }, - disabledLinkItem: { - pointerEvents: 'none', - }, })); export default function GSMenu(props) { @@ -89,49 +86,43 @@ export default function GSMenu(props) { {item.name} - {item.children.map((child, i) => ( - - !disabled) + .map((child, i) => ( + - - - - {child.icon && } - - - - - {child.name} - + + + + + {child.icon && } + + + + + {child.name} + + - - - - ))} + + + ))} ) : ( diff --git a/src/context/AppContext.js b/src/context/AppContext.js index 906681296..1309c20ba 100644 --- a/src/context/AppContext.js +++ b/src/context/AppContext.js @@ -32,7 +32,8 @@ import InboxRounded from '@material-ui/icons/InboxRounded'; import { session, hasPermission, POLICIES } from '../models/auth'; import api from '../api/treeTrackerApi'; -export const AppContext = createContext({}); // no initial context here because we want login values to be 'undefined' until they are confirmed +// no initial context here because we want login values to be 'undefined' until they are confirmed +export const AppContext = createContext({}); function getRoutes(user) { return [ @@ -101,6 +102,9 @@ function getRoutes(user) { disabled: process.env.REACT_APP_ENABLE_PAYMENTS !== 'true', }, ], + disabled: + process.env.REACT_APP_ENABLE_EARNINGS !== 'true' && + process.env.REACT_APP_ENABLE_PAYMENTS !== 'true', }, { name: 'Growers', @@ -149,10 +153,12 @@ function getRoutes(user) { linkTo: '/messaging', component: MessagingView, icon: InboxRounded, - disabled: !hasPermission(user, [ - POLICIES.SUPER_PERMISSION, - POLICIES.SEND_MESSAGES, - ]), + disabled: + process.env.REACT_APP_ENABLE_MESSAGING !== 'true' || + !hasPermission(user, [ + POLICIES.SUPER_PERMISSION, + POLICIES.SEND_MESSAGES, + ]), }, ]; } @@ -167,7 +173,6 @@ export const AppProvider = (props) => { // check if the user has an org load organizations when the user changes useEffect(() => { - // if (user && token && !user?.policy?.organization?.id) { if (user && token) { loadOrganizations(); } @@ -192,7 +197,6 @@ export const AppProvider = (props) => { } ) .then((response) => { - // console.log('CONTEXT CHECK SESSION', response.data, 'USER', localUser, 'TOKEN', localToken); if (response.status === 200) { if (response.data.token === undefined) { //the role has not changed