refactor: improve notification naming and introduce type-safe enums
- Rename billFwd* to billsNotification* for clarity - Rename rentDueNotification* to rentNotification* for consistency - Rename utilBillsProofOfPayment to billsProofOfPayment - Introduce enums for type safety: - BillsNotificationStrategy (WhenPayed, WhenAttached) - BillsNotificationStatus (Scheduled, Sent, Failed) - RentNotificationStatus (Sent, Failed) - Replace "pending" status with "scheduled" for better semantics - Fix function names to proper camelCase - Fix incorrect import path in web-app/app/lib/format.ts 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -23,12 +23,12 @@ export async function GET(request: Request, { params: { id } }: { params: { id:
|
||||
const location = await dbClient.collection<BillingLocation>("lokacije")
|
||||
.findOne({ _id: locationID }, {
|
||||
projection: {
|
||||
utilBillsProofOfPayment: 1,
|
||||
billsProofOfPayment: 1,
|
||||
shareTTL: 1,
|
||||
}
|
||||
});
|
||||
|
||||
if (!location?.utilBillsProofOfPayment) {
|
||||
if (!location?.billsProofOfPayment) {
|
||||
notFound();
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ export async function GET(request: Request, { params: { id } }: { params: { id:
|
||||
}
|
||||
|
||||
// Convert fileContentsBase64 from Base64 string to binary
|
||||
const fileContentsBuffer = Buffer.from(location.utilBillsProofOfPayment.fileContentsBase64, 'base64');
|
||||
const fileContentsBuffer = Buffer.from(location.billsProofOfPayment.fileContentsBase64, 'base64');
|
||||
|
||||
// Convert fileContentsBuffer to format that can be sent to the client
|
||||
const fileContents = new Uint8Array(fileContentsBuffer);
|
||||
@@ -47,8 +47,8 @@ export async function GET(request: Request, { params: { id } }: { params: { id:
|
||||
status: 200,
|
||||
headers: {
|
||||
'Content-Type': 'application/pdf',
|
||||
'Content-Disposition': `attachment; filename="${location.utilBillsProofOfPayment.fileName}"`,
|
||||
'Last-Modified': `${location.utilBillsProofOfPayment.fileLastModified}`
|
||||
'Content-Disposition': `attachment; filename="${location.billsProofOfPayment.fileName}"`,
|
||||
'Last-Modified': `${location.billsProofOfPayment.fileLastModified}`
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user