@@ -12,15 +12,67 @@ const ratingOptions: Array<{ rating: 1 | 2 | 3 | 4; emoji: string; label: string
1212 { rating : 4 , emoji : '\u{1F929}' , label : 'Great' } ,
1313] ;
1414
15+ const DISCORD_URL = 'https://discord.gg/goose-oss' ;
16+
1517export default function FeedbackBanner ( { onRate, onDismiss } : FeedbackBannerProps ) {
16- const [ submitted , setSubmitted ] = useState ( false ) ;
18+ const [ submittedRating , setSubmittedRating ] = useState < 1 | 2 | 3 | 4 | null > ( null ) ;
1719
1820 const handleRate = ( rating : 1 | 2 | 3 | 4 ) => {
19- setSubmitted ( true ) ;
20- setTimeout ( ( ) => onRate ( rating ) , 1000 ) ;
21+ setSubmittedRating ( rating ) ;
22+ if ( rating > 1 ) {
23+ setTimeout ( ( ) => onRate ( rating ) , 1000 ) ;
24+ }
25+ } ;
26+
27+ const handleDismissAfterLowRating = ( ) => {
28+ if ( submittedRating ) {
29+ onRate ( submittedRating ) ;
30+ }
2131 } ;
2232
23- if ( submitted ) {
33+ if ( submittedRating === 1 ) {
34+ return (
35+ < div className = "flex flex-col items-center gap-1.5 py-2 animate-[fadein_300ms_ease-in_forwards]" >
36+ < span className = "text-xs text-text-secondary" >
37+ Sorry to hear that. Let us know how we can improve:
38+ </ span >
39+ < div className = "flex items-center gap-3 text-xs" >
40+ < a
41+ href = { DISCORD_URL }
42+ target = "_blank"
43+ rel = "noopener noreferrer"
44+ onClick = { handleDismissAfterLowRating }
45+ className = "text-text-secondary underline hover:text-text-primary transition-colors"
46+ >
47+ Chat on Discord
48+ </ a >
49+ < button
50+ onClick = { handleDismissAfterLowRating }
51+ className = "ml-1 p-0.5 rounded text-text-secondary hover:text-text-primary hover:bg-background-secondary transition-colors cursor-pointer"
52+ title = "Dismiss"
53+ aria-label = "Dismiss"
54+ >
55+ < svg
56+ xmlns = "http://www.w3.org/2000/svg"
57+ width = "14"
58+ height = "14"
59+ viewBox = "0 0 24 24"
60+ fill = "none"
61+ stroke = "currentColor"
62+ strokeWidth = "2"
63+ strokeLinecap = "round"
64+ strokeLinejoin = "round"
65+ >
66+ < line x1 = "18" y1 = "6" x2 = "6" y2 = "18" />
67+ < line x1 = "6" y1 = "6" x2 = "18" y2 = "18" />
68+ </ svg >
69+ </ button >
70+ </ div >
71+ </ div >
72+ ) ;
73+ }
74+
75+ if ( submittedRating ) {
2476 return (
2577 < div className = "flex items-center justify-center py-2 text-xs text-text-secondary animate-[fadein_300ms_ease-in_forwards]" >
2678 Thanks for the feedback!
0 commit comments