Add feature wrapper to Audit.

This commit is contained in:
Patrick Fic
2024-04-24 08:59:23 -07:00
parent b1d8c036e7
commit 09b5fca3b3
10 changed files with 161 additions and 85 deletions

View File

@@ -0,0 +1,40 @@
import dayjs from "../../util/day";
import React from "react";
import { connect } from "react-redux";
import { createStructuredSelector } from "reselect";
import { selectBodyshop } from "../../redux/user/user.selectors";
import { Alert } from "antd";
const mapStateToProps = createStructuredSelector({
bodyshop: selectBodyshop
});
function FeatureWrapper({ bodyshop, featureName, noauth, children, ...restProps }) {
if (HasFeatureAccess({ featureName, bodyshop })) return children;
return (
noauth || (
<Alert
message={
"You do not currently have access to this feature. Please reach out to support at support@thinkimex.com or 604-839-3431 to request access."
}
type="warning"
/>
)
);
}
export function HasFeatureAccess({ featureName, bodyshop }) {
return bodyshop?.features?.allAccess || dayjs(bodyshop?.features[featureName]).isAfter(dayjs());
}
export default connect(mapStateToProps, null)(FeatureWrapper);
/*
dashboard
production-board
scoreboard
csi
tech-console
mobile-imaging
*/