@@ -171,6 +171,7 @@ export function GameExperience({
171171 const [ notes , setNotes ] = useState ( "" )
172172 const [ submitting , setSubmitting ] = useState ( false )
173173 const [ submitted , setSubmitted ] = useState ( false )
174+ const [ hasRated , setHasRated ] = useState ( false )
174175 const [ submitError , setSubmitError ] = useState < string | null > ( null )
175176 const { user, loading : authLoading } = useDiscordAccount ( )
176177
@@ -183,6 +184,20 @@ export function GameExperience({
183184 if ( j ?. success ) {
184185 setExperiences ( j . experiences || [ ] )
185186 if ( j . stats ) setStats ( j . stats as Stats )
187+ if ( j . myRating ) {
188+ setHasRated ( true )
189+ setRating ( j . myRating . rating )
190+ const d = ( j . myRating . distro || "" ) . toLowerCase ( )
191+ if ( d === "windows" ) {
192+ setPlatform ( "windows" )
193+ setDistro ( "" )
194+ } else {
195+ setPlatform ( "linux" )
196+ setDistro ( j . myRating . distro || "" )
197+ }
198+ setProtonVersion ( j . myRating . proton_version || "" )
199+ setNotes ( j . myRating . notes || "" )
200+ }
186201 }
187202 } )
188203 . catch ( ( ) => { } )
@@ -233,11 +248,14 @@ export function GameExperience({
233248 if ( ! res . ok || ! json . success ) {
234249 setSubmitError ( json . error || "Failed to submit. Please try again." )
235250 } else {
251+ if ( json . updated ) setHasRated ( true )
236252 setSubmitted ( true )
237- setDistro ( "" )
238- setProtonVersion ( "" )
239- setRating ( null )
240- setNotes ( "" )
253+ if ( ! json . updated && ! hasRated ) {
254+ setDistro ( "" )
255+ setProtonVersion ( "" )
256+ setRating ( null )
257+ setNotes ( "" )
258+ }
241259 fetchExperiences ( )
242260 }
243261 } catch {
@@ -318,7 +336,7 @@ export function GameExperience({
318336 < div className = "flex items-start gap-3 p-4 rounded-xl bg-emerald-500/10 border border-emerald-500/20" >
319337 < CheckCircle2 className = "h-5 w-5 text-emerald-500 mt-0.5 shrink-0" />
320338 < div className = "flex-1" >
321- < div className = "text-sm font-semibold text-emerald-500" > Thanks for the rating!</ div >
339+ < div className = "text-sm font-semibold text-emerald-500" > { hasRated ? " Thanks for updating your rating!" : "Thanks for the rating!" } </ div >
322340 < div className = "text-xs text-muted-foreground mt-1" > Your report is now part of the average above.</ div >
323341 < div className = "flex flex-wrap items-center gap-3 mt-3" >
324342 { onLeaveComment && (
@@ -327,13 +345,15 @@ export function GameExperience({
327345 Leave a detailed comment
328346 </ Button >
329347 ) }
330- < button onClick = { ( ) => setSubmitted ( false ) } className = "text-xs text-muted-foreground underline hover:text-foreground" > Rate again</ button >
348+ < button onClick = { ( ) => setSubmitted ( false ) } className = "text-xs text-muted-foreground underline hover:text-foreground" >
349+ { hasRated ? "Edit rating" : "Rate again" }
350+ </ button >
331351 </ div >
332352 </ div >
333353 </ div >
334354 ) : (
335355 < div className = "space-y-4" >
336- < div className = "text-sm font-semibold text-foreground" > How is it running for you?</ div >
356+ < div className = "text-sm font-semibold text-foreground" > { hasRated ? "Update your rating" : " How is it running for you?" } </ div >
337357
338358 < div className = "space-y-1.5" >
339359 < StarRating value = { rating } onChange = { setRating } />
@@ -436,7 +456,7 @@ export function GameExperience({
436456 className = "gap-2"
437457 >
438458 { submitting ? < Loader2 className = "h-4 w-4 animate-spin" /> : < Send className = "h-4 w-4" /> }
439- { submitting ? "Submitting…" : "Submit rating" }
459+ { submitting ? "Submitting…" : hasRated ? "Update rating" : "Submit rating" }
440460 </ Button >
441461 </ div >
442462 ) }
0 commit comments