i18n front : facettes localisées + Web Push (SW push, abonnement, toggle profil)
Build & Deploy / build (push) Successful in 6s
Build & Deploy / build (push) Successful in 6s
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -2,6 +2,30 @@
|
||||
definePageMeta({ middleware: 'auth' })
|
||||
const { t, locale, locales, setLocale } = useI18n()
|
||||
const auth = useAuthStore()
|
||||
const { isSupported, enable, disable, sendTest } = usePush()
|
||||
const toast = useToast()
|
||||
|
||||
const pushOn = ref(auth.push.enabled)
|
||||
const pushLoading = ref(false)
|
||||
|
||||
async function togglePush(val: boolean) {
|
||||
pushLoading.value = true
|
||||
try {
|
||||
if (val) {
|
||||
await enable(auth.push.vapid_public_key || '')
|
||||
pushOn.value = true
|
||||
toast.add({ title: 'Rappels activés 🔥', color: 'primary' })
|
||||
} else {
|
||||
await disable()
|
||||
pushOn.value = false
|
||||
}
|
||||
} catch (e) {
|
||||
pushOn.value = false
|
||||
toast.add({ title: (e as Error).message || t('common.error'), color: 'error' })
|
||||
} finally {
|
||||
pushLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function doLogout() {
|
||||
await auth.logout()
|
||||
@@ -44,6 +68,17 @@ async function doLogout() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<UCard v-if="isSupported()" :ui="{ body: 'p-4' }">
|
||||
<div class="flex items-center justify-between gap-3">
|
||||
<div>
|
||||
<p class="font-semibold">Rappels de série 🔥</p>
|
||||
<p class="text-xs text-zinc-500">Un rappel le soir si tu risques de perdre ta flamme.</p>
|
||||
</div>
|
||||
<USwitch v-model="pushOn" :loading="pushLoading" @update:model-value="togglePush" />
|
||||
</div>
|
||||
<UButton v-if="pushOn" size="xs" variant="link" color="neutral" class="mt-1 -ml-2" label="Envoyer un test" @click="sendTest" />
|
||||
</UCard>
|
||||
|
||||
<UButton block color="neutral" variant="subtle" icon="i-lucide-log-out" :label="t('auth.logout')" @click="doLogout" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
Reference in New Issue
Block a user