Select vehicle when importing drivvo csv.

Select what vehicle to import for on frontend. Actually import the data to the db
This commit is contained in:
Alf Sebastian Houge
2022-04-04 17:13:14 +02:00
parent bfaebf17d0
commit e8f7815d8d
4 changed files with 84 additions and 37 deletions

View File

@@ -32,7 +32,12 @@ func drivvoImport(c *gin.Context) {
c.JSON(http.StatusUnprocessableEntity, err)
return
}
errors := service.DrivvoImport(bytes, c.MustGet("userId").(string))
vehicleId := c.PostForm("vehicleID")
if vehicleId == "" {
c.JSON(http.StatusUnprocessableEntity, "Missing Vehicle ID")
return
}
errors := service.DrivvoImport(bytes, c.MustGet("userId").(string), vehicleId)
if len(errors) > 0 {
c.JSON(http.StatusUnprocessableEntity, gin.H{"errors": errors})
return