IO-2703 Resolve incorrect Feature wrapper use.
This commit is contained in:
@@ -1,23 +1,17 @@
|
|||||||
import dayjs from "../../utils/day";
|
import dayjs from '../../utils/day';
|
||||||
import React from "react";
|
import React from 'react';
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from 'react-i18next';
|
||||||
import { connect } from "react-redux";
|
import { connect } from 'react-redux';
|
||||||
import { createStructuredSelector } from "reselect";
|
import { createStructuredSelector } from 'reselect';
|
||||||
import { selectBodyshop } from "../../redux/user/user.selectors";
|
import { selectBodyshop } from '../../redux/user/user.selectors';
|
||||||
import AlertComponent from "../alert/alert.component";
|
import AlertComponent from '../alert/alert.component';
|
||||||
import InstanceRenderManager from '../../utils/instanceRenderMgr';
|
import InstanceRenderManager from '../../utils/instanceRenderMgr';
|
||||||
|
|
||||||
const mapStateToProps = createStructuredSelector({
|
const mapStateToProps = createStructuredSelector({
|
||||||
bodyshop: selectBodyshop,
|
bodyshop: selectBodyshop,
|
||||||
});
|
});
|
||||||
|
|
||||||
function FeatureWrapper({
|
function FeatureWrapper({ bodyshop, featureName, noauth, children, ...restProps }) {
|
||||||
bodyshop,
|
|
||||||
featureName,
|
|
||||||
noauth,
|
|
||||||
children,
|
|
||||||
...restProps
|
|
||||||
}) {
|
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
if (HasFeatureAccess({ featureName, bodyshop })) return children;
|
if (HasFeatureAccess({ featureName, bodyshop })) return children;
|
||||||
@@ -25,7 +19,13 @@ function FeatureWrapper({
|
|||||||
return (
|
return (
|
||||||
noauth || (
|
noauth || (
|
||||||
<AlertComponent
|
<AlertComponent
|
||||||
message={t("general.messages.nofeatureaccess", {app: InstanceRenderManager({imex:'$t(titles.imexonline)', rome: '$t(titles.romeonline)', promanager: '$t(titles.promanager)'})})}
|
message={t('general.messages.nofeatureaccess', {
|
||||||
|
app: InstanceRenderManager({
|
||||||
|
imex: '$t(titles.imexonline)',
|
||||||
|
rome: '$t(titles.romeonline)',
|
||||||
|
promanager: '$t(titles.promanager)',
|
||||||
|
}),
|
||||||
|
})}
|
||||||
type="warning"
|
type="warning"
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
@@ -33,10 +33,12 @@ function FeatureWrapper({
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function HasFeatureAccess({ featureName, bodyshop }) {
|
export function HasFeatureAccess({ featureName, bodyshop }) {
|
||||||
return (
|
console.log(
|
||||||
bodyshop?.features.allAccess ||
|
'Feature Name', featureName,
|
||||||
|
bodyshop?.features.allAccess,
|
||||||
dayjs(bodyshop?.features[featureName]).isAfter(dayjs())
|
dayjs(bodyshop?.features[featureName]).isAfter(dayjs())
|
||||||
);
|
);
|
||||||
|
return bodyshop?.features.allAccess || dayjs(bodyshop?.features[featureName]).isAfter(dayjs());
|
||||||
}
|
}
|
||||||
|
|
||||||
export default connect(mapStateToProps, null)(FeatureWrapper);
|
export default connect(mapStateToProps, null)(FeatureWrapper);
|
||||||
|
|||||||
@@ -290,7 +290,7 @@ export function JobLinesComponent({
|
|||||||
key: 'location',
|
key: 'location',
|
||||||
render: (text, record) => <JobLineLocationPopup jobline={record} disabled={jobRO} />,
|
render: (text, record) => <JobLineLocationPopup jobline={record} disabled={jobRO} />,
|
||||||
},
|
},
|
||||||
...(HasFeatureAccess({ featureName: 'bills' })
|
...(HasFeatureAccess({ featureName: 'bills', bodyshop })
|
||||||
? [
|
? [
|
||||||
{
|
{
|
||||||
title: t('joblines.labels.billref'),
|
title: t('joblines.labels.billref'),
|
||||||
|
|||||||
@@ -141,9 +141,10 @@ export function ReportCenterModalComponent({reportCenterModal, bodyshop}) {
|
|||||||
|
|
||||||
const grouped = _.groupBy(FilteredReportsList, "group");
|
const grouped = _.groupBy(FilteredReportsList, "group");
|
||||||
|
|
||||||
const groupExcludeKeyFilter = [...!HasFeatureAccess({featureName: 'bills'})? ["purchases"]:[],
|
const groupExcludeKeyFilter = [
|
||||||
...!HasFeatureAccess({featureName: 'timetickets'})? ["payroll"]:[],
|
...(!HasFeatureAccess({ featureName: 'bills', bodyshop }) ? ['purchases'] : []),
|
||||||
]
|
...(!HasFeatureAccess({ featureName: 'timetickets', bodyshop }) ? ['payroll'] : []),
|
||||||
|
];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ import ShopInfoSpeedPrint from "./shop-info.speedprint.component";
|
|||||||
import {useLocation, useNavigate} from "react-router-dom";
|
import {useLocation, useNavigate} from "react-router-dom";
|
||||||
import ShopInfoTaskPresets from "./shop-info.task-presets.component";
|
import ShopInfoTaskPresets from "./shop-info.task-presets.component";
|
||||||
import queryString from "query-string";
|
import queryString from "query-string";
|
||||||
import { HasFeatureAccess } from "../feature-wrapper/feature-wrapper.component";
|
|
||||||
import InstanceRenderManager from "../../utils/instanceRenderMgr";
|
import InstanceRenderManager from "../../utils/instanceRenderMgr";
|
||||||
|
|
||||||
const mapStateToProps = createStructuredSelector({
|
const mapStateToProps = createStructuredSelector({
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ export function ShopPage({bodyshop, setSelectedHeader, setBreadcrumbs}) {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
if(HasFeatureAccess("csi")){
|
if(HasFeatureAccess({featureName:"csi", bodyshop})){
|
||||||
items.push({
|
items.push({
|
||||||
key: "csiq",
|
key: "csiq",
|
||||||
label: t("bodyshop.labels.csiq"),
|
label: t("bodyshop.labels.csiq"),
|
||||||
|
|||||||
Reference in New Issue
Block a user