push rasad front on new repo
This commit is contained in:
45
src/contexts/AppContext.js
Normal file
45
src/contexts/AppContext.js
Normal file
@@ -0,0 +1,45 @@
|
||||
import { createContext, useState } from "react";
|
||||
import { PropTypes } from "prop-types";
|
||||
import moment from "moment/moment";
|
||||
|
||||
export const AppContext = createContext();
|
||||
|
||||
export const AppContextProvider = (props) => {
|
||||
const [notifState, setNotifState] = useState({
|
||||
open: false,
|
||||
vertical: "top",
|
||||
horizontal: "center",
|
||||
severity: "success",
|
||||
msg: "",
|
||||
});
|
||||
|
||||
const [selectedDate1, setSelectedDate1] = useState(
|
||||
moment(new Date()).format("YYYY-MM-DD")
|
||||
);
|
||||
const [selectedDate2, setSelectedDate2] = useState(
|
||||
moment(new Date()).format("YYYY-MM-DD")
|
||||
);
|
||||
|
||||
const openNotif = (newState) => {
|
||||
setNotifState({ open: true, ...newState });
|
||||
};
|
||||
|
||||
return (
|
||||
<AppContext.Provider
|
||||
value={[
|
||||
openNotif,
|
||||
notifState,
|
||||
selectedDate1,
|
||||
setSelectedDate1,
|
||||
selectedDate2,
|
||||
setSelectedDate2,
|
||||
]}
|
||||
>
|
||||
{props.children}
|
||||
</AppContext.Provider>
|
||||
);
|
||||
};
|
||||
|
||||
AppContextProvider.propTypes = {
|
||||
children: PropTypes.any,
|
||||
};
|
||||
24
src/contexts/SidebarContext.js
Normal file
24
src/contexts/SidebarContext.js
Normal file
@@ -0,0 +1,24 @@
|
||||
import { createContext, useState } from "react";
|
||||
import { PropTypes } from "prop-types";
|
||||
|
||||
export const SidebarContext = createContext();
|
||||
|
||||
export const sidebarContextValues = {
|
||||
sidebarState: false,
|
||||
};
|
||||
|
||||
export const SidebarContextProvider = (props) => {
|
||||
const [sideBarMobileState, setSidebarMobileState] = useState(false);
|
||||
|
||||
return (
|
||||
<SidebarContext.Provider
|
||||
value={[sideBarMobileState, setSidebarMobileState]}
|
||||
>
|
||||
{props.children}
|
||||
</SidebarContext.Provider>
|
||||
);
|
||||
};
|
||||
|
||||
SidebarContextProvider.propTypes = {
|
||||
children: PropTypes.any,
|
||||
};
|
||||
Reference in New Issue
Block a user