refactor: updated handling of setup steps
This commit is contained in:
@@ -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">
|
||||
|
||||
Reference in New Issue
Block a user