fix(passenger-api): fix seed TypeScript errors for dev

This commit is contained in:
Abubeker Yasin
2026-06-08 11:35:12 +03:00
parent 72f8441a2b
commit 11192b6d49

View File

@@ -147,9 +147,9 @@ async function seedCoachTypesAndClasses() {
for (const ct of coachTypes) { for (const ct of coachTypes) {
await prisma.coachType.upsert({ await prisma.coachType.upsert({
where: { code: ct.code }, where: { id: ct.code },
update: {}, update: {},
create: ct, create: { ...ct, id: ct.code },
}); });
} }
@@ -161,7 +161,7 @@ async function seedCoachTypesAndClasses() {
]; ];
for (const sc of seatClasses) { for (const sc of seatClasses) {
const ct = await prisma.coachType.findUnique({ where: { code: sc.coachCode } }); const ct = await prisma.coachType.findUnique({ where: { id: sc.coachCode } });
await prisma.seatClass.upsert({ await prisma.seatClass.upsert({
where: { coachTypeId_name: { coachTypeId: ct!.id, name: sc.name } }, where: { coachTypeId_name: { coachTypeId: ct!.id, name: sc.name } },
update: {}, update: {},
@@ -204,9 +204,9 @@ async function seedRoute() {
async function seedCoaches() { async function seedCoaches() {
console.log('\n🚃 Seeding coaches and seats...'); console.log('\n🚃 Seeding coaches and seats...');
const ecoCoachType = await prisma.coachType.findUnique({ where: { code: 'ECO' } }); const ecoCoachType = await prisma.coachType.findUnique({ where: { id: 'ECO' } });
const ecoBedCoachType = await prisma.coachType.findUnique({ where: { code: 'ECO_BED' } }); const ecoBedCoachType = await prisma.coachType.findUnique({ where: { id: 'ECO_BED' } });
const vipBedCoachType = await prisma.coachType.findUnique({ where: { code: 'VIP_BED' } }); const vipBedCoachType = await prisma.coachType.findUnique({ where: { id: 'VIP_BED' } });
const coaches = [ const coaches = [
{ number: 'C-001', coachTypeId: ecoCoachType!.id, arrangement: '2+2', capacity: 48 }, { number: 'C-001', coachTypeId: ecoCoachType!.id, arrangement: '2+2', capacity: 48 },
@@ -330,7 +330,7 @@ async function seedFareRules() {
fareRules.push({ fareRules.push({
routeId: route!.id, routeId: route!.id,
seatClassId: sc.id, seatClassId: sc.id,
passengerCategory: 'ADULT', passengerCategory: 'ADULT' as const,
baseFareMinor: sc.baseFareMinor, baseFareMinor: sc.baseFareMinor,
currency: 'ETB', currency: 'ETB',
validFrom, validFrom,
@@ -338,7 +338,7 @@ async function seedFareRules() {
fareRules.push({ fareRules.push({
routeId: route!.id, routeId: route!.id,
seatClassId: sc.id, seatClassId: sc.id,
passengerCategory: 'CHILD', passengerCategory: 'CHILD' as const,
baseFareMinor: Math.floor(sc.baseFareMinor * 0.5), baseFareMinor: Math.floor(sc.baseFareMinor * 0.5),
discountPercent: 50, discountPercent: 50,
currency: 'ETB', currency: 'ETB',
@@ -396,7 +396,7 @@ async function seedPaymentMethods() {
await prisma.paymentMethod.upsert({ await prisma.paymentMethod.upsert({
where: { type: m.type as any }, where: { type: m.type as any },
update: {}, update: {},
create: m, create: { ...m, type: m.type as any, region: m.region as any },
}); });
} }
console.log(`${methods.length} payment methods created`); console.log(`${methods.length} payment methods created`);