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