import { ActionTypes } from '../config/constants';

const initialState = {
	items: [],
  fields: [
    {
      filterType: 'textfield',
      name: 'summary',
      label: 'Summary',
      type: 'text',
      required: true,
    },
    {
      filterType: 'textfield',
      name: 'phase',
      label: 'Phase',
      type: 'text',
      required: true,
    },
    {
      filterType: 'textfield',
      name: 'feature',
      label: 'Feature',
      type: 'text',
    },
    {
      filterType: 'textfield',
      name: 'budgetHours.column',
      label: 'Team',
      type: 'text',
    },
    {
      filterType: 'textfield',
      name: 'budgetHours.value',
      label: 'Hours',
      type: 'number',
    },
    {
      filterType: 'none',
      name: 'descriptions.workplan',
      label: 'Workplan description',
      type: 'text',
      required: true,
    },
    {
      filterType: 'none',
      name: 'descriptions.budget',
      label: 'Budget description',
      type: 'text',
    },
    {
      filterType: 'none',
      name: 'descriptions.assumptions',
      label: 'Assumptions',
      type: 'text',
    },
    {
      filterType: 'none',
      name: 'descriptions.clientResponsibilities',
      label: 'Client Responsibilities',
      type: 'text',
    },
    {
      filterType: 'none',
      name: 'descriptions.exclusions',
      label: 'Exclusions',
      type: 'text',
    },
    {
      filterType: 'custom',
      name: 'tags',
      label: 'Tags',
      type: 'text',
      required: true,
    },
  ],
  query: {},
  userColumns: {
    summary: true,
    phase: true,
    feature: true,
    'budgetHours.column': true,
    'budgetHours.value': true,
    tags: true,
  },
  visibleItems: [],
};

export default (state = initialState, action) => {
	switch(action.type) {
		case ActionTypes.BUDGETS_ADD_ITEM:
			return {
				...state,
				items: [ 
					...state.items, 
					action.payload.item, 
				],
			};

		case ActionTypes.BUDGETS_REMOVE_ITEM:
			return {
				...state,
				items: state.items.filter(item => item.id !== action.payload.itemId)
			};

		case ActionTypes.BUDGETS_SEARCH:
      return {
				...state,
				query: action.payload.query,
        visibleItems: action.payload.visibleItems,
			};

		case ActionTypes.BUDGETS_SUBSCRIBE:
			return {
				...state,
			};

    case ActionTypes.BUDGETS_TOGGLE_COL:
      return {
        ...state,
        userColumns: {
          ...state.userColumns,
          [action.payload.columnName]: !state.userColumns[action.payload.columnName],
        }
      };

    case ActionTypes.BUDGETS_UPDATE:
      return {
        ...state,
        items: action.payload.items,
        visibleItems: action.payload.items,
      };

		case ActionTypes.BUDGETS_UPDATE_ITEM:
			return {
				...state,
				items: state.items.map(item => action.payload.updatedItem.id === item.id ? action.payload.updatedItem : item),
			};

		default:
			return state;
	}
};
@@ -43,16 +43,45 @@
 stants';
+%0Aimport nanoid from 'nanoid';
 %0A%0Aconst 
@@ -1718,16 +1718,539 @@
 e,%0A  %7D,%0A
+  defaultItem:  %7B%0A    id: nanoid(),%0A    summary:  %22%22,%0A    phase:    %22%22,%0A    feature:  %22%22,%0A    budgetHours: %7B %0A      column: %22%22,%0A      value: 0,%0A    %7D,%0A    descriptions: %7B%0A      workplan: %5B%5D,%0A      budget: %5B%5D,%0A      assumptions: %5B%5D,%0A      exclusions: %5B%5D,%0A    %7D,%0A    tags: %22%22,%0A%0A    'budgetHours.column': %22%22,%0A    'budgetHours.value': 0,%0A    'descriptions.workplan': %5B%5D,%0A    'descriptions.budget': %5B%5D,%0A    'descriptions.clientResponsibilities': %5B%5D,%0A    'descriptions.assumptions': %5B%5D,%0A    'descriptions.exclusions': %5B%5D,  %0A  %7D,%0A
   visibl

Add defaultItems to store