More notifications in participants table
This commit is contained in:
4
.github/copilot-instructions.md
vendored
4
.github/copilot-instructions.md
vendored
@@ -11,6 +11,10 @@ Basics: These you need to really follow!
|
|||||||
- server: $locals.supabase
|
- server: $locals.supabase
|
||||||
- Avoid unnceessary iterations. Once the problem is solved, ask me if i want to to continue and only then continue iterating.
|
- Avoid unnceessary iterations. Once the problem is solved, ask me if i want to to continue and only then continue iterating.
|
||||||
- Avoid sweeping changes throught the project. If you want to change something globally, ask me first.
|
- Avoid sweeping changes throught the project. If you want to change something globally, ask me first.
|
||||||
|
- to add a notification, use the toast component
|
||||||
|
- example: toast.success, toast.info, toast.warning, toast.error
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Do not fall back to the legacy $: label syntax or Svelte 3/4 stores! This is important!
|
Do not fall back to the legacy $: label syntax or Svelte 3/4 stores! This is important!
|
||||||
|
|
||||||
|
|||||||
@@ -74,10 +74,7 @@
|
|||||||
event = eventData;
|
event = eventData;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Error loading event:', err);
|
console.error('Error loading event:', err);
|
||||||
toast.add({
|
toast.error('Failed to load event');
|
||||||
message: 'Failed to load event',
|
|
||||||
type: 'error'
|
|
||||||
});
|
|
||||||
} finally {
|
} finally {
|
||||||
loading = false;
|
loading = false;
|
||||||
}
|
}
|
||||||
@@ -98,25 +95,22 @@
|
|||||||
participants = participantsData || [];
|
participants = participantsData || [];
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Error loading participants:', err);
|
console.error('Error loading participants:', err);
|
||||||
toast.add({
|
toast.error('Failed to load participants');
|
||||||
message: 'Failed to load participants',
|
|
||||||
type: 'error'
|
|
||||||
});
|
|
||||||
} finally {
|
} finally {
|
||||||
participantsLoading = false;
|
participantsLoading = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function syncParticipants() {
|
async function syncParticipants() {
|
||||||
if (!event || !event.sheet_id) return;
|
if (!event || !event.sheet_id) {
|
||||||
|
toast.error('Cannot sync participants: No Google Sheet is connected to this event');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Check if user has Google authentication
|
// Check if user has Google authentication
|
||||||
const refreshToken = localStorage.getItem('google_refresh_token');
|
const refreshToken = localStorage.getItem('google_refresh_token');
|
||||||
if (!refreshToken) {
|
if (!refreshToken) {
|
||||||
toast.add({
|
toast.error('Please connect your Google account first to sync participants');
|
||||||
message: 'Please connect your Google account first to sync participants',
|
|
||||||
type: 'error'
|
|
||||||
});
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -183,12 +177,19 @@
|
|||||||
|
|
||||||
// Reload participants
|
// Reload participants
|
||||||
await loadParticipants();
|
await loadParticipants();
|
||||||
|
|
||||||
|
// Show success message with count of synced participants
|
||||||
|
const previousCount = participants.length;
|
||||||
|
const newCount = names.length;
|
||||||
|
const addedCount = Math.max(0, participants.length - previousCount);
|
||||||
|
|
||||||
|
toast.success(
|
||||||
|
`Successfully synced participants. ${newCount} entries processed, ${addedCount} new participants added.`,
|
||||||
|
5000
|
||||||
|
);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Error syncing participants:', err);
|
console.error('Error syncing participants:', err);
|
||||||
toast.add({
|
toast.error(`Failed to sync participants: ${err instanceof Error ? err.message : 'Unknown error'}`);
|
||||||
message: 'Failed to sync participants',
|
|
||||||
type: 'error'
|
|
||||||
});
|
|
||||||
} finally {
|
} finally {
|
||||||
syncingParticipants = false;
|
syncingParticipants = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { toast } from '$lib/stores/toast.js';
|
||||||
|
|
||||||
interface Participant {
|
interface Participant {
|
||||||
id: string;
|
id: string;
|
||||||
name: string;
|
name: string;
|
||||||
@@ -28,6 +30,16 @@
|
|||||||
syncingParticipants: boolean;
|
syncingParticipants: boolean;
|
||||||
onSyncParticipants: () => void;
|
onSyncParticipants: () => void;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
|
// Handle sync participants with toast notifications
|
||||||
|
function handleSyncParticipants() {
|
||||||
|
|
||||||
|
// Show initial notification about sync starting
|
||||||
|
toast.info('Starting participant synchronization...', 2000);
|
||||||
|
|
||||||
|
// Call the parent component's sync function
|
||||||
|
onSyncParticipants();
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="mb-4 rounded-lg border border-gray-300 bg-white p-6">
|
<div class="mb-4 rounded-lg border border-gray-300 bg-white p-6">
|
||||||
|
|||||||
Reference in New Issue
Block a user