Added payment done and pending visible to Admin and Developers without filters
This commit is contained in:
@@ -30,16 +30,20 @@ async function get(req: NextApiRequest, res: NextApiResponse) {
|
||||
return;
|
||||
}
|
||||
|
||||
const codeQuery = query(
|
||||
collection(db, "payments"),
|
||||
// where("agent", "==", "xRMirufz6PPQqxKBgvPTWiWKBD63"),
|
||||
where(req.session.user.type, "==", req.session.user.id)
|
||||
// Based on the logic of query we should be able to do this:
|
||||
// where("isPaid", "==", paid === "paid"),
|
||||
// but for some reason it is ignoring all but the first clause
|
||||
// I opted into only fetching relevant content for the user
|
||||
// and then filter it with JS
|
||||
);
|
||||
// if it's an admin, don't apply query filters
|
||||
const whereClauses = ["admin", "developer"].includes(req.session.user.type)
|
||||
? []
|
||||
: [
|
||||
// where("agent", "==", "xRMirufz6PPQqxKBgvPTWiWKBD63"),
|
||||
where(req.session.user.type, "==", req.session.user.id),
|
||||
// Based on the logic of query we should be able to do this:
|
||||
// where("isPaid", "==", paid === "paid"),
|
||||
// but for some reason it is ignoring all but the first clause
|
||||
// I opted into only fetching relevant content for the user
|
||||
// and then filter it with JS
|
||||
];
|
||||
|
||||
const codeQuery = query(collection(db, "payments"), ...whereClauses);
|
||||
|
||||
const snapshot = await getDocs(codeQuery);
|
||||
if (snapshot.empty) {
|
||||
|
||||
Reference in New Issue
Block a user