Files
speckle-server/packages/frontend-2/components/feedback/Dialog.vue
T
andrewwallacespeckle 448353174c refactor(fe2): Gendo pre-launch tidyup (#3794)
* Styling updates

* Gendo Icon update

* Testing updates

* updates from testing

* Small design changes

* Fix build

* Fix dialog buttons

* Testing updates

* Lightbox effect

* Fix tippy

* Lightbox changes

* Updates

* Updates from testing

* Fix import

* Updates from testing

* Add mixpanel

* Reuse prompt

* Move reuse button

* Add v-tippy to truncated text

* Container Query

* Reorder buttons

* Copy prompt. Image loading

* Changes from testing

* Alert consolodation

* Final updates

* Feedback

* Typo

* Updates form call with Benjamin

* Controls to top

* Changes from testing

* Generic Feedback

* Small changes from testing

* Changes from Fabs

* Small change

* No max width on prompt

* Add Dialog Transparent story

* Open feedback dialog on click of button
2025-01-13 17:00:45 +00:00

110 lines
2.8 KiB
Vue

<template>
<LayoutDialog
v-model:open="isOpen"
:title="dialogTitle"
:buttons="dialogButtons"
:on-submit="onSubmit"
max-width="md"
>
<div class="flex flex-col gap-2">
<p class="text-body-xs text-foreground font-medium">
{{ dialogIntro }}
</p>
<FormTextArea
v-model="feedback"
:rules="[isRequired]"
name="feedback"
label="Feedback"
color="foundation"
/>
<p v-if="!hideSuppport" class="text-body-xs !leading-4">
Need help? For support, head over to our
<FormButton to="https://speckle.community/" target="_blank" link text>
community forum
</FormButton>
where we can chat and solve problems together.
</p>
</div>
</LayoutDialog>
</template>
<script setup lang="ts">
import type { LayoutDialogButton } from '@speckle/ui-components'
import { useForm } from 'vee-validate'
import { useMixpanel } from '~/lib/core/composables/mp'
import { useZapier } from '~/lib/core/composables/zapier'
import { useGlobalToast, ToastNotificationType } from '~~/lib/common/composables/toast'
import { isRequired } from '~/lib/common/helpers/validation'
import { useActiveUser } from '~~/lib/auth/composables/activeUser'
import { defaultZapierWebhookUrl } from '~/lib/common/helpers/route'
type FeedbackType = 'general' | 'gendo'
type FormValues = { feedback: string }
const props = withDefaults(
defineProps<{
type?: FeedbackType
title?: string
intro?: string
hideSuppport?: boolean
}>(),
{
type: 'general'
}
)
const isOpen = defineModel<boolean>('open', { required: true })
const { activeUser: user } = useActiveUser()
const mixpanel = useMixpanel()
const { sendWebhook } = useZapier()
const { triggerNotification } = useGlobalToast()
const { handleSubmit } = useForm<FormValues>()
const feedback = ref('')
const dialogButtons = computed((): LayoutDialogButton[] => [
{
text: 'Send',
props: { color: 'primary' },
submit: true,
id: 'sendFeedback'
}
])
const dialogTitle = computed(() => props.title || 'Give us feedback')
const dialogIntro = computed(
() =>
props.intro ||
'How can we improve Speckle? If you have a feature request, please also share how you would use it and why its important to you'
)
const onSubmit = handleSubmit(async () => {
if (!feedback.value) return
isOpen.value = false
triggerNotification({
type: ToastNotificationType.Success,
title: 'Thank you for your feedback!'
})
mixpanel.track('Feedback Sent', {
message: feedback.value,
feedbackType: props.type
})
await sendWebhook(defaultZapierWebhookUrl, {
userId: user.value?.id ?? '',
feedback: feedback.value
})
})
watch(isOpen, (newVal) => {
if (newVal) {
feedback.value = ''
}
})
</script>