diff --git a/src/App.js b/src/App.js index 2b189fa..2099f5e 100644 --- a/src/App.js +++ b/src/App.js @@ -140,7 +140,11 @@ export function App() { > - + {}, }; const AppContext = createContext(preview); export const useAppContext = () => useContext(AppContext); -export function AppProvider({ children }) { - const userId = useRef(""); // used for some conditions in webSocket message handler - - const [userPermissions, setUserPermissions] = useState([]); - // used for avatars and the tooltip for the avatar - const [users, setUsers] = useState([]); // { Id, Username, Avatar} +export function AppProvider({ children, options }) { + const [paymentPlan, setPaymentPlan] = useState(options.paymentPlan); return ( {children} diff --git a/src/Pages/Store/Employees/index.js b/src/Pages/Store/Employees/index.js index 9a2c083..18faf57 100644 --- a/src/Pages/Store/Employees/index.js +++ b/src/Pages/Store/Employees/index.js @@ -17,6 +17,7 @@ import { myFetch, EncodeStringToBase64, showInputsInvalidNotification, + Constants, } from "../../../utils"; import { useTranslation } from "react-i18next"; import MyTable from "../../../Components/MyTable"; @@ -29,6 +30,7 @@ import { } from "../../../Components/MyFormInputs"; import { Link, useParams } from "react-router-dom"; import CountUp from "react-countup"; +import { useAppContext } from "../../../Contexts/AppContext"; const { useBreakpoint } = Grid; @@ -36,6 +38,7 @@ export default function StoreEmployees() { const { t } = useTranslation(); const [notificationApi, notificationContextHolder] = notification.useNotification(); + const appContext = useAppContext(); const screenBreakpoint = useBreakpoint(); const { storeId } = useParams(); @@ -178,6 +181,10 @@ export default function StoreEmployees() { modalOptions={addEditEmployeeModalOptions} setModalOptions={setAddEditEmployeeModalOptions} fetchEmployees={fetchEmployees} + disabled={ + Constants.PAYMENT_PLAN[appContext.paymentPlan].maxEmployees <= + requestData.employees.length + } /> @@ -197,6 +204,7 @@ function ModalAddEditEmployee({ modalOptions, setModalOptions, fetchEmployees, + disabled, }) { const { t, i18n } = useTranslation(); const [notificationApi, notificationContextHolder] = @@ -257,6 +265,7 @@ function ModalAddEditEmployee({ onClick={() => setModalOptions({ ...modalOptions, mode: "add", isOpen: true }) } + disabled={disabled} > {t("employees.addEmployee")} diff --git a/src/utils.js b/src/utils.js index 0d764ea..aedad29 100644 --- a/src/utils.js +++ b/src/utils.js @@ -102,6 +102,16 @@ export const Constants = { PENDING_EMAIL_VERIFICATION: 4, }, SUPPORT_EMAIL: process.env.REACT_APP_SUPPORT_EMAIL, + PAYMENT_PLAN: [ + { + id: 0, // free + maxEmployees: 5, + }, + { + id: 1, // basic + maxEmployees: 15, + }, + ], }; export function isEmailValid(email) {