Skip to content

Commit

Permalink
fix(refuel, vehicle): adding (#501)
Browse files Browse the repository at this point in the history
  • Loading branch information
MatiasG19 authored Dec 19, 2024
1 parent 100a940 commit b4fe8f2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/scripts/databaseRepositories/refuelRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@ async function getFilteredRefuels(
}

async function addRefuel(refuel: Refuel): Promise<number> {
return (await db.refuels.add(refuel)) as number
return (await db.refuels.add({
date: refuel.date,
refueledAmount: refuel.refueledAmount,
payedAmount: refuel.payedAmount,
distanceDriven: refuel.distanceDriven,
vehicleId: refuel.distanceDriven
} as Refuel)) as number
}

async function updateRefuel(refuel: Refuel) {
Expand Down
7 changes: 6 additions & 1 deletion src/scripts/databaseRepositories/vehicleRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ async function getVehicles(): Promise<Vehicle[]> {
}

async function addVehicle(vehicle: Vehicle): Promise<number> {
return (await db.vehicles.add(vehicle)) as number
return (await db.vehicles.add({
name: vehicle.name,
plateNumber: vehicle.plateNumber,
currencyUnit: vehicle.currencyUnit,
fuelUnitId: vehicle.fuelUnitId
} as Vehicle)) as number
}

async function updateVehicle(vehicle: Vehicle) {
Expand Down

0 comments on commit b4fe8f2

Please sign in to comment.