Sha256: 79b2d2baf09b2da0c68aa14729b2562904989dd27943952c00593ac16cb29a67
Contents?: true
Size: 1.19 KB
Versions: 3
Compression:
Stored size: 1.19 KB
Contents
import * as types from '../constants/ActionTypes' import 'isomorphic-fetch' //const endpoint = 'http://localhost:3000' const endpoint = '' export function receiveMaterials(materials) { return { type: types.MATERIAL_RECEIVE, materials: materials } } export function searchMaterials() { return dispatch => { return fetch(endpoint + '/api/materials') .then(response => response.json()) .then(json => dispatch(receiveMaterials(json))) } } export function showOrder(order) { console.log(order) return { type: types.MATERIAL_SHOW_ORDER, order: order } } export function purchaseOrder(material_id) { return dispatch => { return fetch(endpoint + '/api/purchase_orders', { method: 'post', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' }, body: JSON.stringify({ quantity: 10, arrival_date: '2014-03-21', material_id: material_id, supplier_id: 1 }) }) .then(response => response.json()) .then(json => dispatch(showOrder(json))) } } export function hideSnackbar() { return { type: types.MATERIAL_HIDE_SNACKBAR } }
Version data entries
3 entries across 3 versions & 1 rubygems