FIrst round of changes for Instance Manger & Pro Manager

This commit is contained in:
Patrick Fic
2024-02-16 14:01:39 -07:00
parent 3e44458f5c
commit af7ff2d8b5
36 changed files with 1068 additions and 885 deletions

View File

@@ -1,41 +1,41 @@
import dayjs from "../../utils/day";
import React from "react";
import {useTranslation} from "react-i18next";
import {connect} from "react-redux";
import {createStructuredSelector} from "reselect";
import {selectBodyshop} from "../../redux/user/user.selectors";
import { useTranslation } from "react-i18next";
import { connect } from "react-redux";
import { createStructuredSelector } from "reselect";
import { selectBodyshop } from "../../redux/user/user.selectors";
import AlertComponent from "../alert/alert.component";
const mapStateToProps = createStructuredSelector({
bodyshop: selectBodyshop,
bodyshop: selectBodyshop,
});
function FeatureWrapper({
bodyshop,
featureName,
noauth,
children,
...restProps
}) {
const {t} = useTranslation();
bodyshop,
featureName,
noauth,
children,
...restProps
}) {
const { t } = useTranslation();
if (HasFeatureAccess({featureName, bodyshop})) return children;
if (HasFeatureAccess({ featureName, bodyshop })) return children;
return (
noauth || (
<AlertComponent
message={t("general.messages.nofeatureaccess")}
type="warning"
/>
)
);
return (
noauth || (
<AlertComponent
message={t("general.messages.nofeatureaccess")}
type="warning"
/>
)
);
}
export function HasFeatureAccess({featureName, bodyshop}) {
return (
bodyshop.features.allAccess ||
dayjs(bodyshop.features[featureName]).isAfter(dayjs())
);
export function HasFeatureAccess({ featureName, bodyshop }) {
return (
bodyshop?.features.allAccess ||
dayjs(bodyshop?.features[featureName]).isAfter(dayjs())
);
}
export default connect(mapStateToProps, null)(FeatureWrapper);