mirror of
https://github.com/i701/sarlink-portal.git
synced 2025-07-08 07:16:31 +00:00
feat: enhance payment retrieval with flexible query parameters and add dynamic filters to payments page ✨
This commit is contained in:
@ -90,10 +90,19 @@ export async function getPayment({ id }: { id: string }) {
|
||||
return data;
|
||||
}
|
||||
|
||||
export async function getPayments() {
|
||||
type GetPaymentProps = {
|
||||
[key: string]: string | number | undefined; // Allow additional properties for flexibility
|
||||
};
|
||||
|
||||
export async function getPayments(params: GetPaymentProps) {
|
||||
// Build query string from all defined params
|
||||
const query = Object.entries(params)
|
||||
.filter(([_, value]) => value !== undefined && value !== "")
|
||||
.map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`)
|
||||
.join("&");
|
||||
const session = await getServerSession(authOptions);
|
||||
const response = await fetch(
|
||||
`${process.env.SARLINK_API_BASE_URL}/api/billing/payment/`,
|
||||
`${process.env.SARLINK_API_BASE_URL}/api/billing/payment/?${query}`,
|
||||
{
|
||||
method: "GET",
|
||||
headers: {
|
||||
|
Reference in New Issue
Block a user