import {createContext, useReducer} from "react";

export const PrintContext = createContext();

const reducer = (state, action) => {
    switch (action.type) {
        case "SET_PRINT_PAGE":
            return {
                ...state, count: action.count
            };
        case "SET_PRINT_TITLE":
            return {
                ...state, title: action.title
            };
    }
};
export const PrintProvider = ({children}) => {
    const [printDetails, printDispatch] = useReducer(reducer, {title: '', count: 0});
    return (
        <PrintContext.Provider value={{printDetails, printDispatch}}>
            {children}
        </PrintContext.Provider>
    );
};