Index: src/stock-adjustment-mobile/_adjustment-mobile.scss =================================================================== diff -u -N -r112d9b69164f6cbb93c29dbe9b3bfff80fb35a9d -rd995ecc1b4bcb36aeca37185706b3be57e8dfeca --- src/stock-adjustment-mobile/_adjustment-mobile.scss (.../_adjustment-mobile.scss) (revision 112d9b69164f6cbb93c29dbe9b3bfff80fb35a9d) +++ src/stock-adjustment-mobile/_adjustment-mobile.scss (.../_adjustment-mobile.scss) (revision d995ecc1b4bcb36aeca37185706b3be57e8dfeca) @@ -2,6 +2,23 @@ flex: 1 0 auto; display: flex; flex-direction: column; + + .confirmation-dialog { + display: flex; + flex: 1 0; + flex-direction: column; + box-shadow: 0 0 0.5em $shadow; + border-radius: 3px; + padding: 2em; + background-color: $white; + display: flex; + justify-content: center; + align-items: center; + text-align: center; + min-height: 100vh; + top: 50%; + left: 50%; + } .add-products-button { margin-left: auto; @@ -162,6 +179,6 @@ margin-bottom: 1em; } } - } -} \ No newline at end of file + +} Index: src/stock-adjustment-mobile/add-products-page/add-product-page.jsx =================================================================== diff -u -N -r3d9d4c87f856e5dd5cf72f5a8bd689d12a918e87 -rd995ecc1b4bcb36aeca37185706b3be57e8dfeca --- src/stock-adjustment-mobile/add-products-page/add-product-page.jsx (.../add-product-page.jsx) (revision 3d9d4c87f856e5dd5cf72f5a8bd689d12a918e87) +++ src/stock-adjustment-mobile/add-products-page/add-product-page.jsx (.../add-product-page.jsx) (revision d995ecc1b4bcb36aeca37185706b3be57e8dfeca) @@ -29,7 +29,7 @@ import { appendToAdjustment } from '../reducers/adjustment'; -const AddProductsPage = ({ adjustmentType, offlineService }) => { +const AddProductsPage = ({}) => { const history = useHistory(); const dispatch = useDispatch(); @@ -129,6 +129,7 @@ if (lotCode === productLot) { values.orderable = prod.orderable; values.stockCard = prod.stockCard; + values.productName = prod.orderable.fullProductName; } }); Index: src/stock-adjustment-mobile/adjustment-form.component.jsx =================================================================== diff -u -N -r42dda28050aaa4942efcbeb743eecce421e9579f -rd995ecc1b4bcb36aeca37185706b3be57e8dfeca --- src/stock-adjustment-mobile/adjustment-form.component.jsx (.../adjustment-form.component.jsx) (revision 42dda28050aaa4942efcbeb743eecce421e9579f) +++ src/stock-adjustment-mobile/adjustment-form.component.jsx (.../adjustment-form.component.jsx) (revision d995ecc1b4bcb36aeca37185706b3be57e8dfeca) @@ -13,21 +13,17 @@ * http://www.gnu.org/licenses.  For additional information contact info@OpenLMIS.org.  */ -import React, { useState, useEffect, useMemo } from 'react'; +import React from 'react'; import {useDispatch, useSelector} from 'react-redux'; import { useHistory } from 'react-router-dom'; -import { Form } from 'react-final-form'; -import arrayMutators from 'final-form-arrays'; -import { FieldArray } from 'react-final-form-arrays'; -import update from 'immutability-helper'; -import InputField from '../react-components/form-fields/input-field'; -import { formatLot, formatProductName, formatDate } from './format-utils'; -import ReadOnlyField from '../react-components/form-fields/read-only-field'; +import { toastProperties } from './format-utils'; import InlineField from '../react-components/form-fields/inline-field'; import AddButton from '../react-components/buttons/add-button'; import confirmAlertCustom from '../react-components/modals/confirm'; import { resetAdjustment } from './reducers/adjustment'; +import { setToastList } from './reducers/toasts'; +import BlockList from './components/block-list.component'; const AdjustmentForm = ({ stockAdjustmentCreationService, @@ -38,6 +34,7 @@ const adjustment = useSelector(state => state.adjustment.adjustment); const userHomeFacility = useSelector(state => state.facilities.userHomeFacility); const program = useSelector(state => state.program.program); + const toastList = useSelector(state => state.toasts.toasts); const onSubmit = () => { confirmAlertCustom ({ @@ -48,29 +45,43 @@ }); }; + const showToast = (type) => { + const toastPropertiesList = toastProperties.find((toast) => toast.title.toLowerCase() === type); + dispatch(setToastList([...toastList, toastPropertiesList])); + }; + const submitAdjustment = () => { stockAdjustmentCreationService.submitAdjustments(program.programId, userHomeFacility.id, adjustment, { state: 'adjustment' }).then(() => { - // TODO - add toast to inform user that there is success dispatch(resetAdjustment(adjustment)); + showToast('success'); history.push("/makeAdjustmentAddProducts/submitAdjustment/programChoice"); }) .catch(() => { - // TODO - add toast to inform user that there is error + showToast('error'); history.push("/makeAdjustmentAddProducts/submitAdjustment/programChoice"); }); } const onDelete = () => { // TODO - delete products from adjustment + showToast('success'); history.push("/makeAdjustmentAddProducts/submitAdjustment/programChoice"); }; const addProduct = () => { history.push("/makeAdjustmentAddProducts"); }; + const dataToDisplay = [ + {"key": "productName", "textToDisplay": ""}, + {"key": "stockOnHand", "textToDisplay": "Stock on Hand"}, + {"key": "displayLotMessage", "textToDisplay": "Lot Code"}, + {"key": "occurredDate", "textToDisplay": "Occured Date"} + ]; + const headerToDisplay = "productName"; + return (
@@ -84,11 +95,16 @@
+
); }; Index: src/stock-adjustment-mobile/reducers/toasts.jsx =================================================================== diff -u -N --- src/stock-adjustment-mobile/reducers/toasts.jsx (revision 0) +++ src/stock-adjustment-mobile/reducers/toasts.jsx (revision d995ecc1b4bcb36aeca37185706b3be57e8dfeca) @@ -0,0 +1,32 @@ +/* + * This program is part of the OpenLMIS logistics management information system platform software. + * Copyright © 2017 VillageReach + * + * This program is free software: you can redistribute it and/or modify it under the terms + * of the GNU Affero General Public License as published by the Free Software Foundation, either + * version 3 of the License, or (at your option) any later version. + *   + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  + * See the GNU Affero General Public License for more details. You should have received a copy of + * the GNU Affero General Public License along with this program. If not, see + * http://www.gnu.org/licenses.  For additional information contact info@OpenLMIS.org.  + */ + +import { createSlice } from '@reduxjs/toolkit'; + +export const toastsSlice = createSlice({ + name: 'toasts', + initialState: { + toasts: [], + }, + reducers: { + setToastList: (state, action) => { + state.toasts = action.payload; + }, + } +}); + +export const {setToastList} = toastsSlice.actions; + +export default toastsSlice.reducer; Index: src/stock-adjustment-mobile/store.jsx =================================================================== diff -u -N -r112d9b69164f6cbb93c29dbe9b3bfff80fb35a9d -rd995ecc1b4bcb36aeca37185706b3be57e8dfeca --- src/stock-adjustment-mobile/store.jsx (.../store.jsx) (revision 112d9b69164f6cbb93c29dbe9b3bfff80fb35a9d) +++ src/stock-adjustment-mobile/store.jsx (.../store.jsx) (revision d995ecc1b4bcb36aeca37185706b3be57e8dfeca) @@ -19,14 +19,16 @@ import reasonsReducer from "./reducers/reasons" import adjustmentReducer from "./reducers/adjustment" import programReducer from "./reducers/program" +import toastsReducer from "./reducers/toasts" const store = configureStore({ reducer: { facilities: facilitiesReducer, productOptions: productOptionsReducer, reasons: reasonsReducer, adjustment: adjustmentReducer, - program: programReducer + program: programReducer, + toasts: toastsReducer }, middleware: (getDefaultMiddleware) => getDefaultMiddleware({ serializableCheck: false