Added missing fussy search fileds and support for number

This commit is contained in:
Joao Ramos
2024-08-05 19:32:53 +01:00
parent f0d7d7644b
commit 48faee07f6
2 changed files with 15 additions and 7 deletions

View File

@@ -27,6 +27,10 @@ export function useListSearch<T>(fields: string[][], rows: T[]) {
if (typeof value === "string") {
return value.toLowerCase().includes(searchText);
}
if (typeof value === "number") {
return (value as Number).toString().includes(searchText);
}
});
});
}, [fields, rows, text]);

View File

@@ -390,7 +390,7 @@ interface PaypalPaymentWithUserData extends PaypalPayment {
email: string;
}
const paypalFilterRows = [["email"], ["name"]];
const paypalFilterRows = [["email"], ["name"], ["orderId"], ["value"]];
export default function PaymentRecord() {
const [selectedCorporateUser, setSelectedCorporateUser] = useState<User>();
const [selectedAgentUser, setSelectedAgentUser] = useState<User>();
@@ -874,10 +874,12 @@ export default function PaymentRecord() {
const updatedPaypalPayments = useMemo(
() =>
paypalPayments.filter((p) => {
paypalPayments
.filter((p) => {
const date = moment(p.createdAt);
return date.isAfter(startDatePaymob) && date.isBefore(endDatePaymob);
}).map((p) => {
})
.map((p) => {
const user = users.find((x) => x.id === p.userId) as User;
return { ...p, name: user?.name, email: user?.email };
}),
@@ -1508,7 +1510,9 @@ export default function PaymentRecord() {
if (finalDate) {
// basicly selecting a final day works as if I'm selecting the first
// minute of that day. this way it covers the whole day
setEndDatePaymob(moment(finalDate).endOf("day").toDate());
setEndDatePaymob(
moment(finalDate).endOf("day").toDate()
);
return;
}
setEndDatePaymob(null);