(refactor) locationAction: optimizing query not to return binary data
This commit is contained in:
@@ -420,6 +420,7 @@ export const fetchAllLocations = withUser(async (user:AuthenticatedUser, year:nu
|
||||
billedTo: "$$bill.billedTo",
|
||||
payedAmount: "$$bill.payedAmount",
|
||||
hasAttachment: { $ne: ["$$bill.attachment", null] },
|
||||
proofOfPayment: "$$bill.proofOfPayment",
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -435,7 +436,12 @@ export const fetchAllLocations = withUser(async (user:AuthenticatedUser, year:nu
|
||||
// "yearMonth": 1,
|
||||
"yearMonth.year": 1,
|
||||
"yearMonth.month": 1,
|
||||
"bills": 1,
|
||||
"bills._id": 1,
|
||||
"bills.name": 1,
|
||||
"bills.paid": 1,
|
||||
"bills.hasAttachment": 1,
|
||||
"bills.payedAmount": 1,
|
||||
"bills.proofOfPayment.uploadedAt": 1,
|
||||
"seenByTenantAt": 1,
|
||||
// "bills.attachment": 0,
|
||||
// "bills.notes": 0,
|
||||
@@ -652,7 +658,7 @@ export const uploadUtilBillsProofOfPayment = async (locationID: string, formData
|
||||
}
|
||||
|
||||
// Validate file type
|
||||
if (file && file.type !== 'application/pdf') {
|
||||
if (file && file.size > 0 && file.type !== 'application/pdf') {
|
||||
return { success: false, error: 'Only PDF files are accepted' };
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user