refactor: updated handling of setup steps

This commit is contained in:
Joel Jacob Stephen
2024-02-27 18:16:40 +05:30
parent f38e2b6884
commit 14506cd92a

View File

@@ -1,22 +1,37 @@
<template>
<SetupDataSharing @onSetupComplete="dataAnalyticsSetup" />
<SetupDataSharingAndNewsletter
@onSetupComplete="(status: boolean) => (isDataSharingAndNewsletterSetup = status)"
/>
</template>
<script setup lang="ts">
import { ref, watch } from 'vue';
import { useRouter } from 'vue-router';
import { useI18n } from '~/composables/i18n';
import { useToast } from '~/composables/toast';
import { auth } from '~/helpers/auth';
const t = useI18n();
const toast = useToast();
const router = useRouter();
const dataAnalyticsSetup = async (status: boolean) => {
if (status) {
const result = await auth.updateFirstTimeInfraSetupStatus();
if (result) {
console.log('Data sharing setup complete');
router.push('/dashboard');
const isDataSharingAndNewsletterSetup = ref(false);
// Watcher is added for future proofing as we can have multiple setup steps in future
watch(
() => isDataSharingAndNewsletterSetup.value,
async (status) => {
if (status) {
const result = await auth.updateFirstTimeInfraSetupStatus();
if (result) {
toast.success(t('state.setup_success'));
router.push('/dashboard');
} else {
toast.error(t('state.setup_failure'));
}
}
}
};
);
</script>
<route lang="yaml">