Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update: fixed transaction page, rerender issue #931

Merged
merged 2 commits into from
Nov 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions frontend/app/src/people/widgetViews/OrganizationDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,14 @@ const OrganizationDetails = (props: {

const getPaymentsHistory = useCallback(async () => {
if (!viewReportDisabled) {
const paymentHistories = await main.getPaymentHistories(uuid, 1, 20);
setPaymentsHistory(paymentHistories);
const paymentHistories = await main.getPaymentHistories(uuid, 1, 2000);
const payments = paymentHistories.map((history: PaymentHistory) => {
if (!history.payment_type) {
history.payment_type = 'payment';
}
return history;
});
setPaymentsHistory(payments);
}
}, [main, uuid, viewReportDisabled]);

Expand Down Expand Up @@ -309,15 +315,14 @@ const OrganizationDetails = (props: {
try {
await main.pollOrgBudgetInvoices(uuid);
getOrganizationBudget();
getPaymentsHistory();

const count = await main.organizationInvoiceCount(uuid);
if (count === 0) {
clearInterval(interval);
}

i++;
if (i > 10) {
if (i > 5) {
if (interval) clearInterval(interval);
}
} catch (e) {
Expand Down
21 changes: 3 additions & 18 deletions frontend/app/src/people/widgetViews/organization/HistoryModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,6 @@ const HistoryModal = (props: PaymentHistoryModalProps) => {
const isMobile = useIsMobile();
const { isOpen, close, url } = props;
const [filter, setFilter] = useState({ payment: true, deposit: true, withdraw: true });
const [paymentsHistory, setPaymentHistory] = useState(props.paymentsHistory);
const [currentPaymentsHistory, setCurrentPaymentHistory] = useState(props.paymentsHistory);

const { ui } = useStores();
Expand All @@ -244,25 +243,11 @@ const HistoryModal = (props: PaymentHistoryModalProps) => {
};

useEffect(() => {
const payments = paymentsHistory.map((history: PaymentHistory) => {
if (!history.payment_type) {
history.payment_type = 'payment';
}
return history;
});
setPaymentHistory(payments);
setCurrentPaymentHistory(payments);
}, [paymentsHistory]);

useEffect(() => {
const paymentsHistory = [...props.paymentsHistory];
setCurrentPaymentHistory(
paymentsHistory.filter((history: PaymentHistory) => {
if (filter[history.payment_type]) {
return history;
}
})
paymentsHistory.filter((history: PaymentHistory) => filter[history.payment_type])
);
}, [filter, paymentsHistory]);
}, [filter]);

return (
<Modal
Expand Down
Loading