From 9c396976bb42a9d41407358ce1a1d37242230f21 Mon Sep 17 00:00:00 2001 From: gabrhr <73925454+gabrhr@users.noreply.github.com> Date: Fri, 27 May 2022 12:50:13 -0500 Subject: Add redux, dispatch and etiquetas MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - estetica de etiquetas (ok) - add message, pedido Reducer - add dispatch en Componentes con connect - add api reducer que obtienen el JSON todo ok #TODO - FIX logica de añadiir - FIX axios y dispatch fuera de un componente --- .../odiparpack/app/redux/modules/crudTableForm.js | 1 + front/odiparpack/app/redux/modules/message.js | 30 ++++++++++++++++++++++ front/odiparpack/app/redux/modules/pedido.js | 16 ++++++++++++ 3 files changed, 47 insertions(+) create mode 100644 front/odiparpack/app/redux/modules/message.js create mode 100644 front/odiparpack/app/redux/modules/pedido.js (limited to 'front/odiparpack/app/redux/modules') diff --git a/front/odiparpack/app/redux/modules/crudTableForm.js b/front/odiparpack/app/redux/modules/crudTableForm.js index d5194c1..29b9813 100644 --- a/front/odiparpack/app/redux/modules/crudTableForm.js +++ b/front/odiparpack/app/redux/modules/crudTableForm.js @@ -24,6 +24,7 @@ const initialItem = (keyTemplate, anchor) => { for (let i = 0; i < rawKey.length; i += 1) { if (rawKey[i] !== 'id') { const itemIndex = anchor.findIndex(a => a.name === rawKey[i]); + if (itemIndex == -1) continue staticKey[rawKey[i]] = anchor[itemIndex].initialValue; } } diff --git a/front/odiparpack/app/redux/modules/message.js b/front/odiparpack/app/redux/modules/message.js new file mode 100644 index 0000000..e02eb08 --- /dev/null +++ b/front/odiparpack/app/redux/modules/message.js @@ -0,0 +1,30 @@ +import { CLOSE_MESSAGE,OPEN_MESSAGE } from 'ba-actions/actionTypes'; + +const initState = { + message: '', + type: '', + openMessage: false +} + +const message = (state = initState, action = {}) => { + + const { type, payload } = action; + + switch (type) { + + case CLOSE_MESSAGE: + return {...initState} + case OPEN_MESSAGE: + return { + ...state, + ...payload, + openMessage: true + } + default: + return state + + } + +} + +export default message; \ No newline at end of file diff --git a/front/odiparpack/app/redux/modules/pedido.js b/front/odiparpack/app/redux/modules/pedido.js new file mode 100644 index 0000000..9101fe4 --- /dev/null +++ b/front/odiparpack/app/redux/modules/pedido.js @@ -0,0 +1,16 @@ +import { LISTA_PEDIDO } from 'ba-actions/actionTypes'; + +const initState = { + pedidos : [] +} + +const pedido = (state = initState, action) => { + switch (action.type) { + case LISTA_PEDIDO: + return { ...state, pedidos: action.payload } + default : + return state + } +} + +export default pedido; \ No newline at end of file -- cgit v1.2.3 From 32fb17de8f78317b165b6f269a8bab2d4e852d0d Mon Sep 17 00:00:00 2001 From: gabrhr <73925454+gabrhr@users.noreply.github.com> Date: Mon, 30 May 2022 20:08:04 -0500 Subject: Fix axios and add new MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - FIX logica de añadiir (ok) - FIX axios y dispatch fuera de un componente (ok) - Cambiar las notificaciones --- front/odiparpack/app/redux/modules/crudTableForm.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'front/odiparpack/app/redux/modules') diff --git a/front/odiparpack/app/redux/modules/crudTableForm.js b/front/odiparpack/app/redux/modules/crudTableForm.js index 29b9813..acf9abd 100644 --- a/front/odiparpack/app/redux/modules/crudTableForm.js +++ b/front/odiparpack/app/redux/modules/crudTableForm.js @@ -31,6 +31,19 @@ const initialItem = (keyTemplate, anchor) => { return Map(staticKey); }; + +const initialItemNew = (anchor) => { + const [...rawKey] = anchor.map((e) => e.name); + const staticKey = {}; + for (let i = 0; i < rawKey.length; i += 1) { + if (rawKey[i] !== 'id') { + staticKey[rawKey[i]] = anchor[i].initialValue; + } + } + + return Map(staticKey); +}; + let editingIndex = 0; const initialImmutableState = fromJS(initialState); @@ -46,7 +59,7 @@ export default function reducer(state = initialImmutableState, action = {}) { case `${branch}/${ADD_NEW}`: return state.withMutations((mutableState) => { const raw = state.get('dataTable').last(); - const initial = initialItem(raw, action.anchor); + const initial = initialItemNew(action.anchor); mutableState.set('formValues', initial); mutableState.set('showFrm', true); }); -- cgit v1.2.3 From cbc7d7f7494508fda69e88c76702a878bebca0e2 Mon Sep 17 00:00:00 2001 From: gabrhr <73925454+gabrhr@users.noreply.github.com> Date: Tue, 31 May 2022 03:58:23 -0500 Subject: Add Almacenes - todo de almacenes, redux, pagina - mejoro form de pedido (etiqueta estado, RUC) #TODO - Ver combobox con API --- front/odiparpack/app/redux/modules/almacen.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 front/odiparpack/app/redux/modules/almacen.js (limited to 'front/odiparpack/app/redux/modules') diff --git a/front/odiparpack/app/redux/modules/almacen.js b/front/odiparpack/app/redux/modules/almacen.js new file mode 100644 index 0000000..bb9b7d6 --- /dev/null +++ b/front/odiparpack/app/redux/modules/almacen.js @@ -0,0 +1,16 @@ +import { LISTA_ALMACEN } from 'ba-actions/actionTypes'; + +const initState = { + almacenes : [] +} + +const almacen = (state = initState, action) => { + switch (action.type) { + case LISTA_ALMACEN: + return { ...state, pedidos: action.payload } + default : + return state + } +} + +export default almacen; \ No newline at end of file -- cgit v1.2.3