import React, { Component } from 'react';
import ProviderComponent from '../lib/components/ProviderComponent';

const initializer = () => ({
  products: [
    { id: 1, name: 'mom-away', price: 50.00 },
    { id: 2, name: 'nasty-girl away', price: 100.00 },
    { id: 3, name: 'big-mean-eagle away', price: 200.00 },
  ],
});

const actions = ({
  addProduct: ({ state }, product) => {
    console.log('adding product:', product);
    const products = [...state.products, product];
    return { products };
  },
});

const MainProvider = ({ children }) => (
  <ProviderComponent
    {...({ initializer, actions })}
  >{children}
  </ProviderComponent>
);

export default MainProvider;
