Email notifications: settings UI + mail adapter #4

Open
hudson wants to merge 162 commits from email-notifications into dev
Showing only changes of commit a7b948740c - Show all commits

View file

@ -17,6 +17,7 @@
import {Mail} from "@app/mail" import {Mail} from "@app/mail"
import {notificationSettings, publishSettings, userSettingsValues} from "@app/settings" import {notificationSettings, publishSettings, userSettingsValues} from "@app/settings"
import {emailNotificationState} from "@app/push/adapters/common" import {emailNotificationState} from "@app/push/adapters/common"
import {EMAIL_NOTIFICATION_SERVER} from "@app/env"
const clearError = () => { const clearError = () => {
if ($emailNotificationState.error) { if ($emailNotificationState.error) {
@ -185,51 +186,53 @@
{/snippet} {/snippet}
</FieldInline> </FieldInline>
</div> </div>
<div class="card bg-surface flex flex-col gap-4 shadow-md"> {#if EMAIL_NOTIFICATION_SERVER}
<strong class="text-lg">Email Digest Settings</strong> <div class="card bg-surface flex flex-col gap-4 shadow-md">
<FieldInline> <strong class="text-lg">Email Digest Settings</strong>
{#snippet label()}
<p>Receive email digest of missed activity</p>
{/snippet}
{#snippet input()}
<ToggleInput bind:checked={settings.email} />
{/snippet}
</FieldInline>
{#if settings.email}
<FieldInline> <FieldInline>
{#snippet label()} {#snippet label()}
<p>Email address</p> <p>Receive email digest of missed activity</p>
{/snippet} {/snippet}
{#snippet input()} {#snippet input()}
<input <ToggleInput bind:checked={settings.email} />
type="email"
class="input input-bordered w-full"
bind:value={settings.emailAddress}
oninput={clearError}
placeholder="you@example.com" />
{/snippet} {/snippet}
</FieldInline> </FieldInline>
<FieldInline> {#if settings.email}
{#snippet label()} <FieldInline>
<p>Frequency</p> {#snippet label()}
{/snippet} <p>Email address</p>
{#snippet input()} {/snippet}
<select {#snippet input()}
class="select select-bordered" <input
bind:value={settings.emailFrequency} type="email"
onchange={clearError}> class="input input-bordered w-full"
<option value="daily">Daily</option> bind:value={settings.emailAddress}
<option value="weekly">Weekly</option> oninput={clearError}
</select> placeholder="you@example.com" />
{/snippet} {/snippet}
</FieldInline> </FieldInline>
{/if} <FieldInline>
{#if $emailNotificationState.error} {#snippet label()}
<div class="text-sm text-error p-3"> <p>Frequency</p>
{$emailNotificationState.error} {/snippet}
</div> {#snippet input()}
{/if} <select
</div> class="select select-bordered"
bind:value={settings.emailFrequency}
onchange={clearError}>
<option value="daily">Daily</option>
<option value="weekly">Weekly</option>
</select>
{/snippet}
</FieldInline>
{/if}
{#if $emailNotificationState.error}
<div class="text-sm text-error p-3">
{$emailNotificationState.error}
</div>
{/if}
</div>
{/if}
<div class="card sticky -bottom-3 shadow-md flex flex-row items-center justify-between gap-4"> <div class="card sticky -bottom-3 shadow-md flex flex-row items-center justify-between gap-4">
<Button class="button button-neutral" onclick={reset} disabled={loading} <Button class="button button-neutral" onclick={reset} disabled={loading}
>Discard Changes</Button> >Discard Changes</Button>