Gills-Chlorophyll / webfront

Front web face for the project - A few pages for advertising the project
0 stars 0 forks source link

Co2 footprint calculation page #9

Open kneerunjun opened 1 month ago

kneerunjun commented 1 month ago
kneerunjun commented 1 month ago

All the elements on the form would look better with

<div class="form-group">
  <label class="control-label">Input addons</label>
  <div class="form-group">
    <div class="input-group mb-3">
      <div class="input-group-prepend">
        <span class="input-group-text">$</span>
      </div>
      <input type="text" class="form-control" aria-label="Amount (to the nearest dollar)">
      <div class="input-group-append">
        <span class="input-group-text">.00</span>
      </div>
    </div>
  </div>
</div>
kneerunjun commented 1 month ago

Error condition for plant yield not handled

// this can be calculated for vegeterian as well, in that case only the plant yeild is considered
        if result.Vegeterian != "on" {
            if result.PlantYeildKgs != 0 {
                result.Footprint = result.Emissions / result.PlantYeildKgs
            } 
        } else {
            result.Footprint = result.Emissions / (result.FishYeildKgs + result.PlantYeildKgs)
        }
kneerunjun commented 1 month ago
c.Set("content", &ResultOrErr{
   Result: nil,
   Err:    &InvalidArgument{Err: fmt.Errorf("Plant yield for calculating Co2 footprint cannot be zero")},
})
return

Its much better to send the content as ResultOrErr To page dispatch as this then can render the error page correctly