import { get_fest_counts, add_fest_counts } from '$lib/db'

export async function load() {
  console.log('click')
  let { people, tents, cars, year } = await get_fest_counts()
  // console.log({ people, tents, cars, year })
  return {
    people,
    tents,
    cars,
    year
  }
}
export const actions = {
  default: async ({ request }) => {
    const data = await request.formData()
    // console.log("save", data)
    const people = parseInt(String(data.get("people")))
    const tents = parseInt(String(data.get("tents")))
    const cars = parseInt(String(data.get("cars")))
    const reply = add_fest_counts(people, tents, cars, 25)
    console.log("clicked", reply)
  }
}
