-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1202 from appwrite/feat-session-alert-template
feat: session alert template
- Loading branch information
Showing
2 changed files
with
60 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
src/routes/(console)/project-[project]/auth/templates/emailSessionAlertTemplate.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<script lang="ts"> | ||
import EmailTemplate from './emailTemplate.svelte'; | ||
import LocaleOptions from './localeOptions.svelte'; | ||
import { loadEmailTemplate } from './+page.svelte'; | ||
import { page } from '$app/stores'; | ||
import { baseEmailTemplate, emailTemplate } from './store'; | ||
import { addNotification } from '$lib/stores/notifications'; | ||
import { Id } from '$lib/components'; | ||
import { Submit, trackError, trackEvent } from '$lib/actions/analytics'; | ||
const projectId = $page.params.project; | ||
let locale = 'en'; | ||
let loading = false; | ||
async function onLocaleChange() { | ||
const timeout = setTimeout(() => { | ||
loading = true; | ||
}, 1000); | ||
try { | ||
const template = await loadEmailTemplate(projectId, 'sessionalert', locale); | ||
emailTemplate.set(template); | ||
$baseEmailTemplate = { ...$emailTemplate }; | ||
trackEvent(Submit.EmailChangeLocale, { locale, type: 'sessionalert' }); | ||
} catch (error) { | ||
trackError(error, Submit.EmailChangeLocale); | ||
addNotification({ | ||
type: 'error', | ||
message: error.message | ||
}); | ||
} finally { | ||
clearTimeout(timeout); | ||
loading = false; | ||
} | ||
} | ||
</script> | ||
|
||
<div class="boxes-wrapper u-margin-block-start-16"> | ||
<LocaleOptions on:select={onLocaleChange} bind:value={locale} /> | ||
<EmailTemplate bind:loading> | ||
<Id value={'{{user}}'}>{'{{user}}'}</Id> | ||
<Id value={'{{project}}'}>{'{{project}}'}</Id> | ||
<Id value={'{{device}}'}>{'{{device}}'}</Id> | ||
<Id value={'{{ipAddress'}>{'{{ipAddress}}'}</Id> | ||
<Id value={'{{country'}>{'{{country}}'}</Id> | ||
</EmailTemplate> | ||
</div> |