fix languages
This commit is contained in:
@@ -3,5 +3,11 @@ export function presentCompany(company: any) {
|
||||
}
|
||||
|
||||
export function presentBrand(brand: any) {
|
||||
return brand
|
||||
if (!brand) return brand
|
||||
const { amanpaySecretKey, amanpayMerchantId, paypalEmail, paypalMerchantId, ...safe } = brand
|
||||
return {
|
||||
...safe,
|
||||
amanpayConfigured: !!(amanpayMerchantId && amanpaySecretKey),
|
||||
paypalConfigured: !!(paypalEmail || paypalMerchantId),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ router.post('/webhooks/amanpay', async (req, res, next) => {
|
||||
try {
|
||||
const rawBody = JSON.stringify(req.body)
|
||||
const signature = (req.headers['x-amanpay-signature'] as string) ?? ''
|
||||
if (amanpay.isConfigured() && !amanpay.verifyWebhookSignature(rawBody, signature)) {
|
||||
if (!amanpay.isConfigured() || !amanpay.verifyWebhookSignature(rawBody, signature)) {
|
||||
return res.status(401).json({ error: 'invalid_signature' })
|
||||
}
|
||||
await service.handleAmanpayWebhook(req.body)
|
||||
@@ -30,7 +30,7 @@ router.post('/webhooks/paypal', async (req, res, next) => {
|
||||
try {
|
||||
const rawBody = JSON.stringify(req.body)
|
||||
const isValid = await paypal.verifyWebhookEvent(req.headers as Record<string, string>, rawBody)
|
||||
if (paypal.isConfigured() && !isValid) return res.status(401).json({ error: 'invalid_signature' })
|
||||
if (!paypal.isConfigured() || !isValid) return res.status(401).json({ error: 'invalid_signature' })
|
||||
await service.handlePaypalWebhook(req.body)
|
||||
res.json({ received: true })
|
||||
} catch (err) { next(err) }
|
||||
|
||||
@@ -27,7 +27,7 @@ router.post('/webhooks/amanpay', async (req, res, next) => {
|
||||
try {
|
||||
const rawBody = JSON.stringify(req.body)
|
||||
const signature = (req.headers['x-amanpay-signature'] as string) ?? ''
|
||||
if (amanpay.isConfigured() && !amanpay.verifyWebhookSignature(rawBody, signature)) {
|
||||
if (!amanpay.isConfigured() || !amanpay.verifyWebhookSignature(rawBody, signature)) {
|
||||
return res.status(401).json({ error: 'invalid_signature' })
|
||||
}
|
||||
await service.handleAmanpayWebhook(req.body)
|
||||
@@ -39,7 +39,7 @@ router.post('/webhooks/paypal', async (req, res, next) => {
|
||||
try {
|
||||
const rawBody = JSON.stringify(req.body)
|
||||
const isValid = await paypal.verifyWebhookEvent(req.headers as Record<string, string>, rawBody)
|
||||
if (paypal.isConfigured() && !isValid) return res.status(401).json({ error: 'invalid_signature' })
|
||||
if (!paypal.isConfigured() || !isValid) return res.status(401).json({ error: 'invalid_signature' })
|
||||
await service.handlePaypalWebhook(req.body)
|
||||
res.json({ received: true })
|
||||
} catch (err) { next(err) }
|
||||
|
||||
@@ -123,7 +123,7 @@ router.delete('/:id/calendar/blocks/:blockId', requireRole('MANAGER'), async (re
|
||||
router.get('/:id/maintenance', async (req, res, next) => {
|
||||
try {
|
||||
const { id } = parseParams(idParamSchema, req)
|
||||
const logs = await service.getMaintenanceLogs(id)
|
||||
const logs = await service.getMaintenanceLogs(id, req.companyId)
|
||||
ok(res, logs)
|
||||
} catch (err) { next(err) }
|
||||
})
|
||||
|
||||
@@ -110,7 +110,9 @@ export async function deleteCalendarBlock(vehicleId: string, companyId: string,
|
||||
await repo.deleteCalendarBlock(blockId, vehicleId)
|
||||
}
|
||||
|
||||
export async function getMaintenanceLogs(id: string) {
|
||||
export async function getMaintenanceLogs(id: string, companyId: string) {
|
||||
const vehicle = await repo.findById(id, companyId)
|
||||
if (!vehicle) throw new NotFoundError('Vehicle not found')
|
||||
return repo.findMaintenanceLogs(id)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user