uses db to store feedback submissions status

This commit is contained in:
Keviin Åberg Kultalahti 2021-07-22 12:38:46 +02:00
parent 7f89d3c357
commit bf76fda1d5
2 changed files with 17 additions and 15 deletions

View File

@ -14,6 +14,8 @@
Divider,
Layout,
} from "@budibase/bbui"
import { auth } from "stores/portal"
let step = 0
let ratings = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
let options = [
@ -43,15 +45,21 @@
improvements,
comment,
})
document.cookie = "feedbackSubmitted=true"
dispatch("submitted")
auth.updateSelf({
flags: {
feedbackSubmitted: true,
},
})
dispatch("complete")
}
function cancelFeedback() {
document.cookie = "feedbackSubmitted=true"
dispatch("submitted")
auth.updateSelf({
flags: {
feedbackSubmitted: true,
},
})
dispatch("complete")
}
</script>

View File

@ -7,6 +7,7 @@
import VersionModal from "components/deploy/VersionModal.svelte"
import NPSFeedbackForm from "components/feedback/NPSFeedbackForm.svelte"
import { get } from "builderStore/api"
import { auth } from "stores/portal"
import { isActive, goto, layout } from "@roxi/routify"
import Logo from "assets/bb-emblem.svg"
import { capitalise } from "helpers"
@ -21,15 +22,8 @@
let userShouldPostFeedback = false
function checkIfUserHasSubmittedFeedback() {
return document.cookie
?.split("; ")
?.find(row => row.startsWith("feedbackSubmitted="))
?.split("=")[1]
}
function previewApp() {
if (!checkIfUserHasSubmittedFeedback() === true) {
if (!$auth?.user?.flags?.feedbackSubmitted === true) {
userShouldPostFeedback = true
}
window.open(`/${application}`)
@ -111,7 +105,7 @@
{/await}
{#if userShouldPostFeedback}
<NPSFeedbackForm on:submitted={() => (userShouldPostFeedback = false)} />
<NPSFeedbackForm on:complete={() => (userShouldPostFeedback = false)} />
{/if}
<style>