Open source video conferencing app powered by LiveKit. Built with Django and React.
✨(frontend) add email collection step for anonymous survey responses
lebaudantoine433a3a7cdf28
diff --git a/src/frontend/src/features/rooms/components/Rating.tsx b/src/frontend/src/features/rooms/components/Rating.tsxindex b910bb25..d5d45615 100644--- a/src/frontend/src/features/rooms/components/Rating.tsx+++ b/src/frontend/src/features/rooms/components/Rating.tsx@@ -1,5 +1,5 @@-import { Button, H, Text, TextArea } from '@/primitives'-import { useEffect, useState } from 'react'+import { Button, H, Input, Text, TextArea } from '@/primitives'+import { useEffect, useMemo, useState } from 'react'import { cva } from '@/styled-system/css'import { useTranslation } from 'react-i18next'import { styled, VStack } from '@/styled-system/jsx'@@ -237,9 +237,74 @@ const ConfirmationMessage = ({ onNext }: { onNext: () => void }) => {)}+const AuthenticationMessage = ({+ onNext,+ posthog,+}: {+ onNext: () => void+ posthog: PostHog+}) => {+ const { t } = useTranslation('rooms', { keyPrefix: 'authenticationMessage' })++ const [email, setEmail] = useState('')++ const onSubmit = () => {+ posthog.people.set({ unsafe_email: email })+ onNext()+ }++ return (+ <Card+ style={{+ maxWidth: '380px',+ display: 'flex',+ flexDirection: 'column',+ justifyContent: 'center',+ }}+ >+ <H lvl={3}>{t('heading')}</H>+ <Input+ id="emailInput"+ name="email"+ placeholder={t('placeholder')}+ required+ value={email}+ onChange={(e) => setEmail(e.target.value)}+ style={{+ marginBottom: '1rem',+ }}+ />+ <VStack gap="0.5">+ <Button+ variant="primary"+ size="sm"+ fullWidth+ isDisabled={!email}+ onPress={onSubmit}+ >+ {t('submit')}+ </Button>+ <Button+ invisible+ variant="secondary"+ size="sm"+ fullWidth+ onPress={onNext}+ >+ {t('ignore')}+ </Button>+ </VStack>+ </Card>+ )+}+export const Rating = () => {const posthog = usePostHog()+ const isUserAnonymous = useMemo(() => {+ return posthog.get_property('$user_state') == 'anonymous'+ }, [posthog])+const [step, setStep] = useState(0)if (step == 0) {@@ -251,6 +316,17 @@ export const Rating = () => {}if (step == 2) {+ return isUserAnonymous ? (+ <AuthenticationMessage+ posthog={posthog}+ onNext={() => setStep(step + 1)}+ />+ ) : (+ <ConfirmationMessage onNext={() => setStep(0)} />+ )+ }++ if (step == 3) {return <ConfirmationMessage onNext={() => setStep(0)} />}}diff --git a/src/frontend/src/locales/de/rooms.json b/src/frontend/src/locales/de/rooms.jsonindex 299bf8eb..15d91583 100644--- a/src/frontend/src/locales/de/rooms.json+++ b/src/frontend/src/locales/de/rooms.json@@ -173,6 +173,12 @@"heading": "","body": ""},+ "authenticationMessage": {+ "heading": "",+ "placeholder": "",+ "submit": "",+ "ignore": ""+ },"participants": {"subheading": "","contributors": "",diff --git a/src/frontend/src/locales/en/rooms.json b/src/frontend/src/locales/en/rooms.jsonindex 2b343793..2076fa60 100644--- a/src/frontend/src/locales/en/rooms.json+++ b/src/frontend/src/locales/en/rooms.json@@ -172,6 +172,12 @@"heading": "Thank you for your submission","body": "Our product team takes the time to carefully review your feedback. We will get back to you as soon as possible."},+ "authenticationMessage": {+ "heading": "How can we contact you?",+ "placeholder": "Your email",+ "submit": "Send",+ "ignore": "Ignore"+ },"participants": {"subheading": "In room","you": "You",diff --git a/src/frontend/src/locales/fr/rooms.json b/src/frontend/src/locales/fr/rooms.jsonindex ccffd018..cae9c09d 100644--- a/src/frontend/src/locales/fr/rooms.json+++ b/src/frontend/src/locales/fr/rooms.json@@ -172,6 +172,12 @@"heading": "Merci pour votre retour","body": "Notre équipe produit prend le temps d'analyser attentivement vos réponses. Nous reviendrons vers vous dans les plus brefs délais."},+ "authenticationMessage": {+ "heading": "Comment pouvons-nous vous recontacter ?",+ "placeholder": "Votre email",+ "submit": "Envoyer",+ "ignore": "Ignorer"+ },"participants": {"subheading": "Dans la réunion","you": "Vous",