refractor code,

This commit is contained in:
root
2026-05-21 12:35:49 -04:00
parent e74681e810
commit f009ca10c6
158 changed files with 215801 additions and 5884 deletions
@@ -0,0 +1,32 @@
import { NotFoundError } from '../../http/errors'
import * as repo from './offer.repo'
export function listOffers(companyId: string, filters: { active?: string; public?: string }) {
return repo.findMany(companyId, filters)
}
export function getOffer(id: string, companyId: string) {
return repo.findByIdOrThrow(id, companyId)
}
export function createOffer(companyId: string, data: any, vehicleIds: string[]) {
return repo.create(companyId, data, vehicleIds)
}
export async function updateOffer(id: string, companyId: string, data: any, vehicleIds?: string[]) {
const existing = await repo.findFirst(id, companyId)
if (!existing) throw new NotFoundError('Offer not found')
return repo.update(id, data, vehicleIds)
}
export function deleteOffer(id: string, companyId: string) {
return repo.deleteMany(id, companyId)
}
export function setOfferActive(id: string, companyId: string, isActive: boolean) {
return repo.setActive(id, companyId, isActive)
}
export function getOfferStats(id: string, companyId: string) {
return repo.getStats(id, companyId)
}