10 Commits

Author SHA1 Message Date
Roman Krček
755f46a66c Fix "Next" button in event creation
All checks were successful
Build Docker image / build (push) Successful in 1m21s
Build Docker image / deploy (push) Successful in 3s
Build Docker image / verify (push) Successful in 27s
2025-09-03 16:36:34 +02:00
Roman Krček
83f3b45d6e Make the interface bigger
All checks were successful
Build Docker image / build (push) Successful in 1m34s
Build Docker image / deploy (push) Successful in 4s
Build Docker image / verify (push) Successful in 47s
2025-09-03 11:41:39 +02:00
Roman Krček
4f957d4da6 Going crazy
All checks were successful
Build Docker image / build (push) Successful in 1m30s
Build Docker image / deploy (push) Successful in 4s
Build Docker image / verify (push) Successful in 53s
2025-09-03 11:19:46 +02:00
Roman Krček
f6360edef3 Attempt 55 to fix bypass
All checks were successful
Build Docker image / build (push) Successful in 1m31s
Build Docker image / deploy (push) Successful in 3s
Build Docker image / verify (push) Successful in 53s
2025-09-03 10:58:48 +02:00
Roman Krček
28fc22fcd8 Another try to fix service worker bypassing cache
All checks were successful
Build Docker image / build (push) Successful in 1m28s
Build Docker image / deploy (push) Successful in 4s
Build Docker image / verify (push) Successful in 56s
2025-09-03 10:52:48 +02:00
Roman Krček
c881d660e2 Fix service worker mess
All checks were successful
Build Docker image / build (push) Successful in 2m10s
Build Docker image / deploy (push) Successful in 4s
Build Docker image / verify (push) Successful in 50s
2025-09-03 10:42:05 +02:00
Roman Krček
90287e098e Fix worker reloads 2025-09-03 10:42:05 +02:00
Roman Krček
1d4cae35a5 Fixed problem where auth is bypassed 2025-09-03 10:42:05 +02:00
3f771bf7b0 Merge pull request 'Fix when people order multiple times' (#26) from development into main
All checks were successful
Build Docker image / build (push) Successful in 2m54s
Build Docker image / deploy (push) Successful in 4s
Build Docker image / verify (push) Successful in 42s
Reviewed-on: #26
2025-09-03 08:35:00 +02:00
Roman Krček
f1179ddc09 Fix when people order multiple times 2025-09-03 08:34:22 +02:00
8 changed files with 97 additions and 86 deletions

View File

@@ -1,7 +1,7 @@
{
"name": "scan-wave",
"private": true,
"version": "0.0.1",
"version": "0.0.2",
"type": "module",
"scripts": {
"dev": "vite dev",

View File

@@ -25,6 +25,9 @@
onMount(async () => {
await authManager.checkConnection();
if (authState.isConnected && authState.token) {
onSuccess?.(authState.token);
}
});
async function handleConnect() {

View File

@@ -1,6 +1,6 @@
import { google } from 'googleapis';
import { getAuthenticatedClient } from '../auth/server.js';
import { GoogleSheet } from './types.ts';
import { GoogleSheet } from './types';
// Type for sheet data
export interface SheetData {

View File

@@ -5,7 +5,7 @@
<h1 class="text-3xl font-bold text-center mb-2">ScanWave</h1>
<h2 class="text-lg text-gray-600 text-center mb-8">Make entrance to your events a breeze.</h2>
<div class="flex space-x-4 w-full justify-center">
<a href="/private/home" class="bg-blue-600 hover:bg-blue-700 text-white font-bold py-3 px-8 rounded-full shadow-none border border-gray-300 w-64 text-center transition">
<a href="/private/home" class="bg-blue-600 hover:bg-blue-700 text-white font-bold py-3 px-8 rounded-full shadow-none border border-gray-300 w-64 text-center transition" data-sveltekit-reload>
Get started
</a>
</div>

View File

@@ -17,7 +17,7 @@
</script>
<nav class="border-b border-gray-300 bg-gray-50 p-2 text-gray-900">
<div class="container mx-auto max-w-2xl p-2">
<div class="container mx-auto max-w-4xl p-2">
<div class="flex items-center justify-between">
<a href="/private/home" class="text-lg font-bold" aria-label="ScanWave Home">ScanWave</a>
@@ -32,7 +32,7 @@
</nav>
<div class="container mx-auto max-w-2xl bg-white p-2">
<div class="container mx-auto max-w-4xl bg-white p-2">
<QueryClientProvider client={queryClient}>
{@render children()}
</QueryClientProvider>

View File

@@ -57,7 +57,7 @@
{$debouncedSearch ? `Search Results: "${$debouncedSearch}"` : 'All Events'}
</h1>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4 max-w-2xl mx-auto mb-10">
<div class="grid grid-cols-1 sm:grid-cols-2 xl:grid-cols-3 gap-4 mx-auto mb-10">
{#if isLoading}
<!-- Loading placeholders -->
{#each Array(4) as _}

View File

@@ -138,35 +138,64 @@
if (rows.length === 0) throw new Error('No data found in sheet');
// Extract participant data based on column mapping
const names: string[] = [];
const surnames: string[] = [];
const emails: string[] = [];
// --- Start of new logic to handle duplicates ---
// Skip header row (start from index 1)
// First, extract all potential participants from the sheet
const potentialParticipants = [];
for (let i = 1; i < rows.length; i++) {
const row = rows[i];
if (row.length > 0) {
const name = row[event.name_column - 1] || '';
const surname = row[event.surname_column - 1] || '';
const email = row[event.email_column - 1] || '';
const email = (row[event.email_column - 1] || '').trim();
const confirmation = row[event.confirmation_column - 1] || '';
// Only add if the row has meaningful data (not all empty) AND confirmation is TRUE
const isConfirmed =
confirmation.toString().toLowerCase() === 'true' ||
confirmation.toString().toLowerCase() === 'yes' ||
confirmation === '1' ||
confirmation === 'x';
if ((name.trim() || surname.trim() || email.trim()) && isConfirmed) {
names.push(name.trim());
surnames.push(surname.trim());
emails.push(email.trim());
if ((name.trim() || surname.trim() || email) && isConfirmed) {
potentialParticipants.push({ name: name.trim(), surname: surname.trim(), email });
}
}
}
// Create a map to count occurrences of each unique participant combination
const participantCounts = new Map<string, number>();
for (const p of potentialParticipants) {
const key = `${p.name}|${p.surname}|${p.email}`.toLowerCase(); // Create a unique key
participantCounts.set(key, (participantCounts.get(key) || 0) + 1);
}
// Create final arrays, modifying duplicate surnames to be unique
const names: string[] = [];
const surnames: string[] = [];
const emails: string[] = [];
const processedParticipants = new Map<string, number>();
for (const p of potentialParticipants) {
const key = `${p.name}|${p.surname}|${p.email}`.toLowerCase();
let finalSurname = p.surname;
// If this participant is a duplicate
if (participantCounts.get(key)! > 1) {
const count = (processedParticipants.get(key) || 0) + 1;
processedParticipants.set(key, count);
// If it's not the first occurrence, append a counter to the surname
if (count > 1) {
finalSurname = `${p.surname} (${count})`;
}
}
names.push(p.name);
surnames.push(finalSurname);
emails.push(p.email); // Keep the original email
}
// --- End of new logic ---
// Call database function to add participants
const { error: syncError } = await data.supabase.rpc('participants_add_bulk', {
p_event: eventId,

View File

@@ -1,87 +1,66 @@
/// <reference lib="webworker" />
/// <reference types="@sveltejs/kit" />
import { build, files, version } from '$service-worker';
// Create a unique cache name for this deployment
const CACHE = `cache-${version}`;
declare const self: ServiceWorkerGlobalScope;
const CACHE = `cache-${version}`;
const ASSETS = [
...build, // the app itself
...files // everything in `static`
...build,
...files
];
self.addEventListener('install', (event) => {
// Create a new cache and add all files to it
async function addFilesToCache() {
const cache = await caches.open(CACHE);
await cache.addAll(ASSETS);
}
self.addEventListener('install', (event: ExtendableEvent) => {
const addFilesToCache = async () => {
const cache = await caches.open(CACHE);
await cache.addAll(ASSETS);
};
event.waitUntil(addFilesToCache());
console.log(`[SW] Installing new service worker, cache name: ${CACHE}`);
event.waitUntil(addFilesToCache());
self.skipWaiting();
});
self.addEventListener('activate', (event) => {
// Remove previous cached data from disk
async function deleteOldCaches() {
for (const key of await caches.keys()) {
if (key !== CACHE) await caches.delete(key);
}
}
self.addEventListener('activate', (event: ExtendableEvent) => {
const deleteOldCaches = async () => {
for (const key of await caches.keys()) {
if (key !== CACHE) await caches.delete(key);
console.log("[SW] Removing old service worker")
}
};
event.waitUntil(deleteOldCaches());
event.waitUntil(deleteOldCaches());
self.clients.claim();
});
self.addEventListener('fetch', (event) => {
// ignore POST requests etc
if (event.request.method !== 'GET') return;
self.addEventListener('fetch', (event: FetchEvent) => {
if (event.request.method !== 'GET') return;
async function respond() {
const url = new URL(event.request.url);
// Skip caching for auth routes
if (url.pathname.startsWith('/auth/')) {
return fetch(event.request);
}
// For navigation requests, always fetch from the network to ensure
// server-side authentication checks are performed.
if (event.request.mode === 'navigate') {
event.respondWith(fetch(event.request));
return;
}
const cache = await caches.open(CACHE);
// For other requests (e.g., static assets), use a cache-first strategy.
const respond = async () => {
const cache = await caches.open(CACHE);
// `build`/`files` can always be served from the cache
if (ASSETS.includes(url.pathname)) {
const response = await cache.match(url.pathname);
const cachedResponse = await cache.match(event.request);
if (cachedResponse) {
return cachedResponse;
}
if (response) {
return response;
}
}
try {
return await fetch(event.request);
} catch {
// If the network fails, and it's not in the cache, it will fail,
// which is the expected behavior for non-navigation requests.
return new Response('Not found', { status: 404 });
}
};
// for everything else, try the network first, but
// fall back to the cache if we're offline
try {
const response = await fetch(event.request);
// if we're offline, fetch can return a value that is not a Response
// instead of throwing - and we can't pass this non-Response to respondWith
if (!(response instanceof Response)) {
throw new Error('invalid response from fetch');
}
// Do not cache private pages
if (response.status === 200 && !url.pathname.startsWith('/private')) {
cache.put(event.request, response.clone());
}
return response;
} catch (err) {
const response = await cache.match(event.request);
if (response) {
return response;
}
// if there's no cache, then just error out
// as there is nothing we can do to respond to this request
throw err;
}
}
event.respondWith(respond());
});
event.respondWith(respond());
});