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
|
||||
- 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.
|
||||
- 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!
|
||||
|
||||
|
||||
@@ -74,10 +74,7 @@
|
||||
event = eventData;
|
||||
} catch (err) {
|
||||
console.error('Error loading event:', err);
|
||||
toast.add({
|
||||
message: 'Failed to load event',
|
||||
type: 'error'
|
||||
});
|
||||
toast.error('Failed to load event');
|
||||
} finally {
|
||||
loading = false;
|
||||
}
|
||||
@@ -98,25 +95,22 @@
|
||||
participants = participantsData || [];
|
||||
} catch (err) {
|
||||
console.error('Error loading participants:', err);
|
||||
toast.add({
|
||||
message: 'Failed to load participants',
|
||||
type: 'error'
|
||||
});
|
||||
toast.error('Failed to load participants');
|
||||
} finally {
|
||||
participantsLoading = false;
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
const refreshToken = localStorage.getItem('google_refresh_token');
|
||||
if (!refreshToken) {
|
||||
toast.add({
|
||||
message: 'Please connect your Google account first to sync participants',
|
||||
type: 'error'
|
||||
});
|
||||
toast.error('Please connect your Google account first to sync participants');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -183,12 +177,19 @@
|
||||
|
||||
// Reload participants
|
||||
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) {
|
||||
console.error('Error syncing participants:', err);
|
||||
toast.add({
|
||||
message: 'Failed to sync participants',
|
||||
type: 'error'
|
||||
});
|
||||
toast.error(`Failed to sync participants: ${err instanceof Error ? err.message : 'Unknown error'}`);
|
||||
} finally {
|
||||
syncingParticipants = false;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { toast } from '$lib/stores/toast.js';
|
||||
|
||||
interface Participant {
|
||||
id: string;
|
||||
name: string;
|
||||
@@ -28,6 +30,16 @@
|
||||
syncingParticipants: boolean;
|
||||
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>
|
||||
|
||||
<div class="mb-4 rounded-lg border border-gray-300 bg-white p-6">
|
||||
|
||||
Reference in New Issue
Block a user