<table class="table is-bordered is-striped is-hoverable is-fullwidth">
  <thead>
    <tr>
      <th><!-- Preview --></th>
      <th>Year</th>
      <th>Make</th>
      <th>Model</th>
      <th>Engine</th>
      <th>Trim</th>
      <th><abbr title="Interior / Exterior">Colors</abbr></th>
      <th>Mileage</th>
      <th>Price</th>
      <th><!-- Actions --></th>
    </tr>
  </thead>
  <tbody>
    <% inventory.forEach(vehicle => { %>
      <tr>
        <td style="width: 128px">
          <figure class="image is-4by3" style="width: 128px; height: 96px">
            <% if (vehicle.Images instanceof Array && typeof vehicle.Images[0] === "object" && typeof vehicle.Images[0].url === "string") { %>
              <img src="<%=vehicle.Images[0].url%>>" alt="Placeholder product image">
            <% } else { %>
              <img src="https://api.placeholder.app/image/1280x960?text=Coming Soon..." alt="Placeholder product image">
            <% } %>
          </figure>
        </td>
        <td><%= vehicle.ModelYear %></td>
        <td><%= vehicle.Make %></td>
        <td><%= vehicle.Model %></td>
        <td><%= vehicle.Engine || "N/A" %></td>
        <td><%= vehicle.Trim || "N/A" %></td>
        <td>
          <span>
            <%= vehicle.IntColor[0] %>
            <% if (typeof(vehicle.IntColor[1]) === "string") { %>
              <div class="is-color-block" style="background-color: <%= vehicle.IntColor[1] %>;"></div>
            <% } %>
          </span>
          /
          <span>
            <%= vehicle.ExtColor[0] %>
            <% if (typeof(vehicle.ExtColor[1]) === "string") { %>
              <div class="is-color-block" style="background-color: <%= vehicle.ExtColor[1] %>;"></div>
            <% } %>
          </span>
        </td>
        <td><%= (Math.round(Number(vehicle.Odometer) / 100) * 100).toLocaleString() %>mi</td>
        <td>
          <%= parseFloat(vehicle.Price).toLocaleString('en-US', {
            style: 'currency',
            currency: 'USD',
            minimumFractionDigits: 0
          }) %>
        </td>
        <td><a href='<%= env.APPLICATION_INVENTORY_URL + "/" + vehicle.StockNum %>'>View</a></td>
      </tr>
    <% }) %>
  </tbody>
</table>
