chore: update biome configuration and enhance error handling in schema files
- Enabled useIgnoreFile in biome.json for better file management. - Updated various correctness and style rules in biome.json to enforce stricter coding standards. - Added new biome lint command in package.json for improved code quality checks. - Refactored error handling in multiple schema files to use consistent error throwing patterns, enhancing readability and maintainability. - Improved user authentication checks across various schemas to ensure proper access control.
This commit is contained in:
@@ -156,14 +156,21 @@ export class RefundTicketSchema extends PothosSchema {
|
||||
const diffTime = Math.abs(now.diff(orderDate).toMillis())
|
||||
const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24))
|
||||
let refundAmount = 0
|
||||
if (diffDays < 1) refundAmount = order.total
|
||||
else if (diffDays < 3) refundAmount = order.total * 0.5
|
||||
if (refundAmount === 0) throw new Error('Cannot refund after 3 days')
|
||||
if (diffDays < 1) {
|
||||
refundAmount = order.total
|
||||
} else if (diffDays < 3) {
|
||||
refundAmount = order.total * 0.5
|
||||
}
|
||||
if (refundAmount === 0) {
|
||||
throw new Error('Cannot refund after 3 days')
|
||||
}
|
||||
// create refund ticket
|
||||
// get bank name from bank bin from banks.json
|
||||
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
||||
const bank = banks.data.find((bank: any) => bank.bin === ctx.http.me?.bankBin)
|
||||
if (!bank) throw new Error('Bank not found')
|
||||
if (!bank) {
|
||||
throw new Error('Bank not found')
|
||||
}
|
||||
const refundTicket = await this.prisma.refundTicket.create({
|
||||
data: {
|
||||
orderId: order.id,
|
||||
|
||||
Reference in New Issue
Block a user