Cleanup for error notifications

This commit is contained in:
Roman Krček
2025-07-14 14:34:38 +02:00
parent 06f2553b42
commit b9db3d22a3
4 changed files with 76 additions and 87 deletions

View File

@@ -42,7 +42,7 @@
selectedSheet: null as GoogleSheet | null, selectedSheet: null as GoogleSheet | null,
sheetData: [] as string[][], sheetData: [] as string[][],
columnMapping: { columnMapping: {
name: 0, // Initialize to 0 (no column selected) name: 0, // Initialize to 0 (no column selected)
surname: 0, surname: 0,
email: 0, email: 0,
confirmation: 0 confirmation: 0
@@ -111,8 +111,9 @@
'/auth/google', '/auth/google',
'google-auth', 'google-auth',
'width=500,height=600,scrollbars=yes,resizable=yes,left=' + 'width=500,height=600,scrollbars=yes,resizable=yes,left=' +
Math.round(window.screen.width / 2 - 250) + ',top=' + Math.round(window.screen.width / 2 - 250) +
Math.round(window.screen.height / 2 - 300) ',top=' +
Math.round(window.screen.height / 2 - 300)
); );
if (!popup) { if (!popup) {
@@ -190,7 +191,6 @@
cleanUp(); cleanUp();
} }
}, 60 * 1000); // Reduced from 3min to 1min }, 60 * 1000); // Reduced from 3min to 1min
} catch (error) { } catch (error) {
console.error('Error connecting to Google:', error); console.error('Error connecting to Google:', error);
authData.error = 'Failed to connect to Google'; authData.error = 'Failed to connect to Google';
@@ -332,7 +332,7 @@
const response = await fetch('/private/api/google/sheets/recent', { const response = await fetch('/private/api/google/sheets/recent', {
method: 'GET', method: 'GET',
headers: { headers: {
'Authorization': `Bearer ${localStorage.getItem('google_refresh_token')}` Authorization: `Bearer ${localStorage.getItem('google_refresh_token')}`
} }
}); });
@@ -363,7 +363,7 @@
const response = await fetch(`/private/api/google/sheets/${sheet.id}/data`, { const response = await fetch(`/private/api/google/sheets/${sheet.id}/data`, {
method: 'GET', method: 'GET',
headers: { headers: {
'Authorization': `Bearer ${localStorage.getItem('google_refresh_token')}` Authorization: `Bearer ${localStorage.getItem('google_refresh_token')}`
} }
}); });
@@ -427,49 +427,45 @@
}); });
</script> </script>
<div class="max-w-4xl mx-auto p-6"> <!-- Header -->
<!-- Header --> <StepNavigator {currentStep} {totalSteps} />
<StepNavigator {currentStep} {totalSteps} />
<!-- Step Content --> <!-- Step Content -->
<div class="rounded-lg border border-gray-300 bg-white p-6 mb-4"> <div class="mb-4 rounded border border-gray-300 bg-white p-6">
{#if currentStep === 0} {#if currentStep === 0}
<GoogleAuthStep <GoogleAuthStep
bind:errors onSuccess={(token) => {
onSuccess={(token) => { authData.error = null;
authData.error = null; authData.token = token;
authData.token = token; authData.isConnected = true;
authData.isConnected = true; setTimeout(checkGoogleAuth, 100);
setTimeout(checkGoogleAuth, 100); }}
}} onError={(error) => {
onError={(error) => { authData.error = error;
authData.error = error; authData.isConnected = false;
authData.isConnected = false; }}
}} />
/> {:else if currentStep === 1}
{:else if currentStep === 1} <EventDetailsStep bind:eventData />
<EventDetailsStep bind:eventData /> {:else if currentStep === 2}
{:else if currentStep === 2} <GoogleSheetsStep
<GoogleSheetsStep bind:sheetsData bind:errors {loadRecentSheets} {selectSheet} {toggleSheetList} /> bind:sheetsData
{:else if currentStep === 3} {loadRecentSheets}
<EmailSettingsStep bind:emailData bind:errors /> {selectSheet}
{/if} {toggleSheetList}
/>
{#if errors.submit} {:else if currentStep === 3}
<div class="mt-4 p-3 bg-red-50 border border-red-200 rounded"> <EmailSettingsStep bind:emailData />
<p class="text-sm text-red-600">{errors.submit}</p> {/if}
</div>
{/if}
</div>
<!-- Navigation -->
<StepNavigation
{currentStep}
{totalSteps}
{canProceed}
{loading}
{prevStep}
{nextStep}
{createEvent}
/>
</div> </div>
<!-- Navigation -->
<StepNavigation
{currentStep}
{totalSteps}
{canProceed}
{loading}
{prevStep}
{nextStep}
{createEvent}
/>

View File

@@ -54,7 +54,6 @@
Detected templates: {bodyTemplatesDetected.map((v) => v.name).join(', ')} Detected templates: {bodyTemplatesDetected.map((v) => v.name).join(', ')}
</p> </p>
{/if} {/if}
<!-- Errors now shown as toast notifications -->
</div> </div>
<div> <div>

View File

@@ -21,7 +21,5 @@
onSuccess={onSuccess} onSuccess={onSuccess}
onError={onError} onError={onError}
/> />
<!-- Error messages are now shown as toast notifications -->
</div> </div>
</div> </div>

View File

@@ -255,8 +255,6 @@
{/if} {/if}
</div> </div>
{/if} {/if}
<!-- Error messages are now shown as toast notifications -->
</div> </div>
{#if sheetsData.selectedSheet && sheetsData.sheetData.length > 0} {#if sheetsData.selectedSheet && sheetsData.sheetData.length > 0}
@@ -370,8 +368,6 @@
<div class="text-gray-600">Loading sheet data...</div> <div class="text-gray-600">Loading sheet data...</div>
</div> </div>
{/if} {/if}
<!-- Error messages are now shown as toast notifications -->
</div> </div>