From 200e2d3c2f25a3a33111f7955649cff95f40c09c Mon Sep 17 00:00:00 2001 From: lebaudantoine Date: Mon, 18 Nov 2024 01:04:22 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=A9(frontend)=20introduce=20multistep?= =?UTF-8?q?=20form?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add an open feedback form step, to allow people giving us some feedbacks on what's wrong with our product. --- .../src/features/rooms/components/Rating.tsx | 140 ++++++++++++++++-- src/frontend/src/locales/de/rooms.json | 10 ++ src/frontend/src/locales/en/rooms.json | 10 ++ src/frontend/src/locales/fr/rooms.json | 10 ++ 4 files changed, 155 insertions(+), 15 deletions(-) diff --git a/src/frontend/src/features/rooms/components/Rating.tsx b/src/frontend/src/features/rooms/components/Rating.tsx index b25c1087..e873a326 100644 --- a/src/frontend/src/features/rooms/components/Rating.tsx +++ b/src/frontend/src/features/rooms/components/Rating.tsx @@ -1,9 +1,10 @@ -import { Button, H, Text } from '@/primitives' -import { useState } from 'react' +import { Button, H, Text, TextArea } from '@/primitives' +import { useEffect, useState } from 'react' import { cva } from '@/styled-system/css' import { useTranslation } from 'react-i18next' -import { styled } from '@/styled-system/jsx' +import { styled, VStack } from '@/styled-system/jsx' import { usePostHog } from 'posthog-js/react' +import { PostHog } from 'posthog-js' const Card = styled('div', { base: { @@ -13,6 +14,8 @@ const Card = styled('div', { marginTop: '1.5rem', borderRadius: '0.25rem', boxShadow: '', + minWidth: '380px', + minHeight: '196px', }, }) @@ -65,8 +68,76 @@ const labelRecipe = cva({ }, }) -export const Rating = ({ maxRating = 7, ...props }) => { - const posthog = usePostHog() +const OpenFeedback = ({ + posthog, + onNext, +}: { + posthog: PostHog + onNext: () => void +}) => { + const { t } = useTranslation('rooms', { keyPrefix: 'openFeedback' }) + const [feedback, setFeedback] = useState('') + + const onContinue = () => { + setFeedback('') + onNext() + } + + const onSubmit = () => { + try { + posthog.capture('survey sent', { + $survey_id: '01933c5a-5a1d-0000-ada8-e39f5918c2d4', + $survey_response: feedback, + }) + } catch (e) { + console.warn(e) + } finally { + onContinue() + } + } + + return ( + + {t('question')} +