2023-12-09 15:47:03 +01:00
|
|
|
<template>
|
2024-02-22 16:56:35 +01:00
|
|
|
<div class="w-full md:w-4/5 lg:w-3/5 md:mx-auto md:max-w-4xl p-4">
|
2024-09-18 19:20:52 +02:00
|
|
|
<div class="w-full flex flex-col sm:flex-row gap-2">
|
|
|
|
|
<div
|
|
|
|
|
v-for="(stat, index) in [
|
|
|
|
|
{ label: 'Views', value: totalViews, placeholder: '123' },
|
|
|
|
|
{ label: 'Submissions', value: totalSubmissions, placeholder: '123' },
|
|
|
|
|
{ label: 'Completion Rate', value: completionRate + '%', placeholder: '100%' },
|
|
|
|
|
{ label: 'Average Duration', value: averageDuration, placeholder: '10 seconds' }
|
|
|
|
|
]"
|
|
|
|
|
:key="index"
|
|
|
|
|
class="border border-gray-300 rounded-lg shadow-sm p-4 w-full mx-auto"
|
|
|
|
|
>
|
|
|
|
|
<div class="mb-2 text-sm text-gray-500">
|
|
|
|
|
{{ stat.label }}
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<Loader
|
|
|
|
|
v-if="isLoading"
|
|
|
|
|
class="h-6 w-6 text-nt-blue"
|
|
|
|
|
/>
|
|
|
|
|
<span
|
|
|
|
|
v-else-if="form.is_pro"
|
|
|
|
|
class="font-medium text-2xl"
|
|
|
|
|
>
|
|
|
|
|
{{ stat.value }}
|
|
|
|
|
</span>
|
|
|
|
|
<span
|
|
|
|
|
v-else
|
|
|
|
|
class="blur-[3px]"
|
|
|
|
|
>
|
|
|
|
|
{{ stat.placeholder }}
|
|
|
|
|
</span>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
2024-04-15 19:39:03 +02:00
|
|
|
<form-stats :form="form" />
|
2023-12-09 15:47:03 +01:00
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
2024-02-06 09:59:43 +01:00
|
|
|
<script setup>
|
2024-04-15 19:39:03 +02:00
|
|
|
import FormStats from "~/components/open/forms/components/FormStats.vue"
|
2023-12-09 15:47:03 +01:00
|
|
|
|
2024-02-06 09:59:43 +01:00
|
|
|
const props = defineProps({
|
2024-04-15 19:39:03 +02:00
|
|
|
form: { type: Object, required: true },
|
2024-02-06 09:59:43 +01:00
|
|
|
})
|
2023-12-20 18:38:43 +01:00
|
|
|
|
2024-02-06 09:59:43 +01:00
|
|
|
definePageMeta({
|
2024-04-15 19:39:03 +02:00
|
|
|
middleware: "auth",
|
2024-02-06 09:59:43 +01:00
|
|
|
})
|
|
|
|
|
useOpnSeoMeta({
|
2024-04-15 19:39:03 +02:00
|
|
|
title: props.form ? "Form Analytics - " + props.form.title : "Form Analytics",
|
2024-02-06 09:59:43 +01:00
|
|
|
})
|
2024-09-18 19:20:52 +02:00
|
|
|
|
|
|
|
|
const isLoading = ref(false)
|
|
|
|
|
const totalViews = ref(0)
|
|
|
|
|
const totalSubmissions = ref(0)
|
|
|
|
|
const completionRate = ref(0)
|
|
|
|
|
const averageDuration = ref('-')
|
|
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
|
getCardData()
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const getCardData = async() => {
|
|
|
|
|
if (!props.form || !props.form.is_pro) { return null }
|
|
|
|
|
isLoading.value = true
|
|
|
|
|
opnFetch(
|
|
|
|
|
"/open/workspaces/" +
|
|
|
|
|
props.form.workspace_id +
|
|
|
|
|
"/form-stats-details/" +
|
|
|
|
|
props.form.id,
|
|
|
|
|
).then((responseData) => {
|
|
|
|
|
if (responseData) {
|
|
|
|
|
totalViews.value = responseData.views ?? 0
|
|
|
|
|
totalSubmissions.value = responseData.submissions ?? 0
|
|
|
|
|
completionRate.value = Math.min(100,responseData.completion_rate ?? 0)
|
|
|
|
|
averageDuration.value = responseData.average_duration ?? '-'
|
|
|
|
|
isLoading.value = false
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
2023-12-09 15:47:03 +01:00
|
|
|
</script>
|