import React, { useReducer } from 'react'
import { DataContext } from './DataContex';
import { dataReducer } from './dataReducer';

const INITIAL_STATE: Employees = {
     dataEmployee:[]
}

interface props {
    children: JSX.Element | JSX.Element[]
}


export const DataProvider = ({ children }: props) => {

    const [dataEmployee, dispatch] = useReducer(dataReducer, INITIAL_STATE)

    const addEmployee = (employee: DataEmployee[]) => {
         dispatch({type:'addAnniversary', payload: employee})
    }

    return (
        <DataContext.Provider value={{
            dataEmployee,
            addEmployee

        }}>
            {children}
        </DataContext.Provider>
    )
}
