|
| 1 | +<template> |
| 2 | + <Dialog |
| 3 | + v-model:visible="$leadminerStore.passiveMiningDialog" |
| 4 | + modal |
| 5 | + :header="t('header')" |
| 6 | + class="w-full sm:w-[35rem]" |
| 7 | + > |
| 8 | + <p> |
| 9 | + {{ t('paragraph_1') }} <br /> |
| 10 | + {{ t('paragraph_2') }} |
| 11 | + </p> |
| 12 | + <template #footer> |
| 13 | + <div class="flex flex-col sm:flex-row justify-between w-full gap-2"> |
| 14 | + <Button |
| 15 | + :label="t('yes_enable')" |
| 16 | + class="w-full sm:w-auto" |
| 17 | + @click="enablePassiveMining()" |
| 18 | + /> |
| 19 | + <Button |
| 20 | + :label="$t('common.cancel')" |
| 21 | + class="w-full sm:w-auto" |
| 22 | + severity="secondary" |
| 23 | + @click="closePassiveMiningDialog()" |
| 24 | + /> |
| 25 | + </div> |
| 26 | + </template> |
| 27 | + </Dialog> |
| 28 | +</template> |
| 29 | + |
| 30 | +<script setup lang="ts"> |
| 31 | +import type { MiningSource } from '~/types/mining'; |
| 32 | +
|
| 33 | +const miningSource = ref<MiningSource>(); |
| 34 | +
|
| 35 | +const $leadminerStore = useLeadminerStore(); |
| 36 | +const $supabase = useSupabaseClient(); |
| 37 | +
|
| 38 | +const { t } = useI18n({ |
| 39 | + useScope: 'local', |
| 40 | +}); |
| 41 | +
|
| 42 | +watch( |
| 43 | + () => $leadminerStore.passiveMiningDialog, |
| 44 | + (newVal) => { |
| 45 | + if (newVal) { |
| 46 | + miningSource.value = $leadminerStore.activeMiningSource; |
| 47 | + } |
| 48 | + }, |
| 49 | +); |
| 50 | +
|
| 51 | +function closePassiveMiningDialog() { |
| 52 | + $leadminerStore.passiveMiningDialog = false; |
| 53 | +} |
| 54 | +
|
| 55 | +async function enablePassiveMining() { |
| 56 | + if (miningSource.value) { |
| 57 | + const { error } = await $supabase |
| 58 | + // @ts-expect-error: Issue with nuxt/supabase |
| 59 | + .schema('private') |
| 60 | + .from('mining_sources') |
| 61 | + .update({ passive_mining: true }) |
| 62 | + .match({ email: miningSource.value.email }); |
| 63 | +
|
| 64 | + if (error) { |
| 65 | + throw error; |
| 66 | + } |
| 67 | + } |
| 68 | + closePassiveMiningDialog(); |
| 69 | +} |
| 70 | +</script> |
| 71 | + |
| 72 | +<i18n lang="json"> |
| 73 | +{ |
| 74 | + "en": { |
| 75 | + "header": "Continuous Contact Extraction", |
| 76 | + "paragraph_1": "Enable continuous contact extraction from future emails?", |
| 77 | + "paragraph_2": "New contacts found in incoming emails will be automatically saved.", |
| 78 | + "yes_enable": "Yes, enable" |
| 79 | + }, |
| 80 | + "fr": { |
| 81 | + "header": "Extraction continue des contacts", |
| 82 | + "paragraph_1": "Activer l'extraction continue des contacts à partir des futurs e-mails ?", |
| 83 | + "paragraph_2": "Les nouveaux contacts trouvés dans les e-mails entrants seront automatiquement enregistrés.", |
| 84 | + "yes_enable": "Oui, activer" |
| 85 | + } |
| 86 | +} |
| 87 | +</i18n> |
0 commit comments