diff --git a/client/src/cash/Cash.js b/client/src/cash/Cash.js
index 6f22627..76435b2 100644
--- a/client/src/cash/Cash.js
+++ b/client/src/cash/Cash.js
@@ -5,7 +5,7 @@ import axios from 'axios';
import { MAKE_MONEY_MOVE } from '../RouteNames';
import { withRouter } from 'react-router-dom';
import { formatMoney } from '../common/formatting';
-import YesNoModal from "../common/YesNoModal";
+import InputModal from "../common/InputModal";
import { errorToast } from "../common/errorHelpers";
import M from 'materialize-css';
@@ -26,9 +26,10 @@ const Cash = (props) => {
getCashForHomies();
}, []);
- const settleFlowForHomie = async (id) => {
+ const settleFlowForHomie = async (id, amountToSettle) => {
+ console.log('Amount to settle : ', amountToSettle);
try {
- const response = await axios.delete(`/api/homies/${id}/settle`);
+ const response = await axios.post(`/api/homies/${id}/settle`, { amount: amountToSettle });
if (response.status === 200 && response.data) {
M.toast({ html: 'Settled' });
}else{
@@ -51,9 +52,11 @@ const Cash = (props) => {
[
- settleFlowForHomie(homieLine.homie.id)}
+ inputLabel={'Settle to'}
+ defaultInputValue={homieLine.amount}
+ confirmAction={(settleAmount) => settleFlowForHomie(homieLine.homie.id, settleAmount)}
triggerNode={Settle}
/>
]
diff --git a/client/src/common/InputModal.js b/client/src/common/InputModal.js
new file mode 100644
index 0000000..48df526
--- /dev/null
+++ b/client/src/common/InputModal.js
@@ -0,0 +1,50 @@
+import React, { useRef } from 'react';
+import {Modal, Button, Row, Col} from 'react-materialize';
+
+const InputModal = (props) => {
+ const { title, body, confirmAction, stopAction, triggerNode, defaultInputValue, inputLabel } = props;
+ const inputField = useRef(null);
+
+ return(
+
+
+
+
+
+
+
+
+ ]}
+ bottomSheet
+ fixedFooter={false}
+ header={title}
+ id="Modal-1"
+ open={false}
+ options={{
+ dismissible: true,
+ endingTop: '10%',
+ inDuration: 250,
+ onCloseEnd: null,
+ onCloseStart: null,
+ onOpenEnd: null,
+ onOpenStart: null,
+ opacity: 0.5,
+ outDuration: 250,
+ preventScrolling: true,
+ startingTop: '4%'
+ }}
+ trigger={triggerNode}
+ >
+ {body}
+
+
+
+
+
+
+ )
+}
+
+export default InputModal;
\ No newline at end of file
|