Allow entering custom amount to settle #18

Merged
bilal.catic merged 4 commits from allow-entering-custom-amount-to-settle into master 2020-10-06 08:43:05 +02:00
Showing only changes of commit d13e656651 - Show all commits

View File

@@ -11,7 +11,6 @@ import M from 'materialize-css';
const Cash = (props) => {
const [homiesCash, setHomiesCash] = useState([]);
const [, forceUpdate] = useReducer(x => x + 1, 0);
//const [importance, setImportance] = useState(10);
useEffect( () => {
@@ -27,18 +26,17 @@ const Cash = (props) => {
}, []);
const settleFlowForHomie = async (id, amountToSettle) => {
console.log('Amount to settle : ', amountToSettle);
try {
const response = await axios.post(`/api/homies/${id}/settle`, { amount: amountToSettle });
if (response.status === 200 && response.data) {
M.toast({ html: 'Settled' });
setHomiesCash(response.data);
}else{
errorToast();
}
} catch(e) {
errorToast();
}
forceUpdate();
}
const cashTableBody = homiesCash.map( (homieLine) => {