Back

Version 3

8/25/2024
/**
* This web app creates a Side School Seminar location voting system.
* Users can vote for their preferred seminar location from four options.
* The app uses React for the frontend and SQLite for storing votes on the backend.
* The design is inspired by the provided Framer template.
*/
/** @jsxImportSource https://esm.sh/react */
import React, { useState, useEffect } from "https://esm.sh/react";
import { createRoot } from "https://esm.sh/react-dom/client";

const locations = [
{ id: 1, name: "Au camping", emoji: "⛺" },
{ id: 2, name: "Chez Ben", emoji: "🏢" },
{ id: 3, name: "Au Château", emoji: "🏰" },
{ id: 4, name: "Sur Saturne", emoji: "🪐" },
];

function App() {
const [votes, setVotes] = useState({});
const [voted, setVoted] = useState(false);

useEffect(() => {
fetchVotes();
}, []);

const fetchVotes = async () => {
const response = await fetch("/votes");
const data = await response.json();
setVotes(data);
};

const handleVote = async (locationId) => {
if (voted) return;

const response = await fetch("/vote", {
method: "POST",
olive-linkinbiotemplate.web.val.run
Updated: August 25, 2024