Create professional demos and 3D mockups in seconds, directly in your browser
feat: add email validation and error handling in FeedbackWidget, update translations for email-related messages
CristianOlivera12384000a5cfe
diff --git a/app/components/ui/editor/FeedbackWidget.tsx b/app/components/ui/editor/FeedbackWidget.tsxindex e6a4220..df52c7c 100644--- a/app/components/ui/editor/FeedbackWidget.tsx+++ b/app/components/ui/editor/FeedbackWidget.tsx@@ -17,6 +17,7 @@ const TYPE_OPTIONS: { value: FeedbackType; icon: string }[] = [];const MESSAGE_MAX_LENGTH = 2000;+const EMAIL_REGEX = /^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/;const emptySubscribe = () => () => { };function useIsClient() {@@ -36,6 +37,7 @@ export function FeedbackWidget() {const [type, setType] = useState<FeedbackType>("bug");const [message, setMessage] = useState("");const [email, setEmail] = useState("");+ const [emailError, setEmailError] = useState(false);const [honeypot, setHoneypot] = useState("");const [status, setStatus] = useState<"idle" | "sending" | "success" | "error">("idle");@@ -43,6 +45,7 @@ export function FeedbackWidget() {setType("bug");setMessage("");setEmail("");+ setEmailError(false);setHoneypot("");setStatus("idle");}, []);@@ -67,6 +70,12 @@ export function FeedbackWidget() {if (honeypot) return;if (message.trim().length < 4) return;+ if (!user && email.trim() && !EMAIL_REGEX.test(email.trim())) {+ setEmailError(true);+ return;+ }+ setEmailError(false);+setStatus("sending");try {@@ -198,13 +207,28 @@ export function FeedbackWidget() {</div>{!user && (- <input- type="email"- value={email}- onChange={(e) => setEmail(e.target.value)}- placeholder={t("emailPlaceholder")}- className="w-full bg-muted border border-border rounded-xl px-4 py-2.5 text-sm text-foreground placeholder:text-muted-foreground/40 focus:outline-none focus:border-blue-500/50 focus:ring-1 focus:ring-blue-500/50 transition-all duration-200"- />+ <div className="space-y-1">+ <input+ type="email"+ value={email}+ onChange={(e) => {+ setEmail(e.target.value);+ setEmailError(false);+ }}+ placeholder={t("emailPlaceholder")}+ aria-invalid={emailError || undefined}+ className={`w-full bg-muted border rounded-xl px-4 py-2.5 text-sm text-foreground placeholder:text-muted-foreground/40 focus:outline-none focus:ring-1 transition-all duration-200 ${+ emailError+ ? "border-red-500/60 focus:border-red-500/70 focus:ring-red-500/50"+ : "border-border focus:border-blue-500/50 focus:ring-blue-500/50"+ }`}+ />+ {emailError && (+ <p className="px-1 text-[11px] text-red-600 dark:text-red-400">+ {t("emailInvalid")}+ </p>+ )}+ </div>)}{status === "error" && (diff --git a/messages/en.json b/messages/en.jsonindex 84afdd0..af777cb 100644--- a/messages/en.json+++ b/messages/en.json@@ -1377,7 +1377,10 @@"whip-showcase": "Whip Pan Showcase","spatial-roam": "Spatial Roam","rise-crash": "Rise and Crash",- "crane-sweep": "Crane Sweep"+ "crane-sweep": "Crane Sweep",+ "orbit-entrance": "Orbit Entrance",+ "turntable-drift": "Turntable Drift",+ "flick-exit": "Flick Exit"},"controls": {"intensity": "Intensity",@@ -1397,7 +1400,8 @@"zoomLabel": "Zoom","rotateZLabel": "Z rotation","reverseLabel": "Reverse direction",- "resetButton": "Reset customization"+ "resetButton": "Reset customization",+ "blurLabel": "Motion blur"}},"MobileTools": {@@ -1425,6 +1429,7 @@},"messagePlaceholder": "Tell us what happened or what you'd like to see...","emailPlaceholder": "Your email (optional, so we can reply)",+ "emailInvalid": "Please enter a valid email address.","submit": "Send","successMessage": "Thanks! We got your feedback.","errorMessage": "Couldn't send it. Please try again."diff --git a/messages/es.json b/messages/es.jsonindex f009469..65eb175 100644--- a/messages/es.json+++ b/messages/es.json@@ -1355,7 +1355,10 @@"whip-showcase": "MVTO de Paneo Rápido","spatial-roam": "MVTO Espacial Libre","rise-crash": "Elevación y Caída Rápida",- "crane-sweep": "Barrido de Grúa"+ "crane-sweep": "Barrido de Grúa",+ "orbit-entrance": "Entrada en órbita",+ "turntable-drift": "Giro de plataforma",+ "flick-exit": "Salida rápida"},"controls": {"intensity": "Intensidad",@@ -1375,7 +1378,8 @@"zoomLabel": "Zoom","rotateZLabel": "Rotación Z","reverseLabel": "Invertir dirección",- "resetButton": "Restablecer personalización"+ "resetButton": "Restablecer personalización",+ "blurLabel": "Desenfoque de movimiento"}},"MobileTools": {@@ -1403,6 +1407,7 @@},"messagePlaceholder": "Cuéntanos qué pasó o qué te gustaría ver...","emailPlaceholder": "Tu email (opcional, para responderte)",+ "emailInvalid": "Ingresa un correo electrónico válido.","submit": "Enviar","successMessage": "¡Gracias! Recibimos tu feedback.","errorMessage": "No se pudo enviar. Intenta de nuevo."diff --git a/messages/ko.json b/messages/ko.jsonindex 958bef1..e5b3206 100644--- a/messages/ko.json+++ b/messages/ko.json@@ -1377,7 +1377,10 @@"whip-showcase": "훽팬 쇼케이스","spatial-roam": "공간 자유 이동","rise-crash": "상승 및 추락",- "crane-sweep": "크레인 스윕"+ "crane-sweep": "크레인 스윕",+ "orbit-entrance": "오빗 입장",+ "turntable-drift": "턴테이블 드리프트",+ "flick-exit": "플릭 퇴장"},"controls": {"intensity": "강도",@@ -1397,7 +1400,8 @@"zoomLabel": "줌","rotateZLabel": "Z축 회전","reverseLabel": "방향 반전",- "resetButton": "커스터마이즈 초기화"+ "resetButton": "커스터마이즈 초기화",+ "blurLabel": "모션 블러"}},"MobileTools": {@@ -1425,6 +1429,7 @@},"messagePlaceholder": "발생한 문제나 보고 싶으신 기능을 알려주세요...","emailPlaceholder": "이메일 주소 (선택 사항, 답변용)",+ "emailInvalid": "올바른 이메일 주소를 입력해 주세요.","submit": "보내기","successMessage": "감사합니다! 피드백이 정상적으로 접수되었습니다.","errorMessage": "전송에 실패했습니다. 다시 시도해 주세요."diff --git a/messages/ru.json b/messages/ru.jsonindex e987125..c1d03cc 100644--- a/messages/ru.json+++ b/messages/ru.json@@ -1377,7 +1377,10 @@"whip-showcase": "Движ Быстрой Панорамы","spatial-roam": "Пространственный Движ","rise-crash": "Взлет и Падение",- "crane-sweep": "Панорама Кран-Стрелы"+ "crane-sweep": "Панорама Кран-Стрелы",+ "orbit-entrance": "Орбитальный вход",+ "turntable-drift": "Вращение подиума",+ "flick-exit": "Быстрый выход"},"controls": {"intensity": "Интенсивность",@@ -1397,7 +1400,8 @@"zoomLabel": "Масштаб","rotateZLabel": "Поворот по Z","reverseLabel": "Обратное направление",- "resetButton": "Сбросить настройки"+ "resetButton": "Сбросить настройки",+ "blurLabel": "Размытие движения"}},"MobileTools": {@@ -1425,6 +1429,7 @@},"messagePlaceholder": "Расскажите, что произошло или что бы вы хотели увидеть...","emailPlaceholder": "Ваш email (необязательно, для ответа)",+ "emailInvalid": "Пожалуйста, введите корректный адрес электронной почты.","submit": "Отправить","successMessage": "Спасибо! Мы получили ваш отзыв.","errorMessage": "Не удалось отправить. Пожалуйста, попробуйте еще раз."