@@ -19,30 +19,35 @@ export default function CookiesModal({ opened, onClose }: CookiesModalProps) {
1919 const [ cookies , setCookiesState ] = useState ( "" ) ;
2020 const [ customEnabled , setCustomEnabled ] = useState ( false ) ;
2121 const [ saving , setSaving ] = useState ( false ) ;
22+ const [ validationError , setValidationError ] = useState < string | null > ( null ) ;
2223
2324 useEffect ( ( ) => {
2425 if ( ! opened ) return ;
2526 const id = requestAnimationFrame ( ( ) => {
2627 setCookiesState ( getUserCookies ( ) ) ;
2728 setCustomEnabled ( isCustomCookiesEnabled ( ) ) ;
29+ setValidationError ( null ) ;
2830 } ) ;
2931 return ( ) => cancelAnimationFrame ( id ) ;
3032 } , [ opened ] ) ;
3133
3234 const handleSave = async ( ) => {
3335 setSaving ( true ) ;
36+ setValidationError ( null ) ;
3437 try {
3538 if ( customEnabled && cookies . trim ( ) ) {
3639 const validation = validateCookies ( cookies ) ;
3740 if ( ! validation . valid ) {
38- setSaving ( false ) ;
41+ setValidationError ( validation . error || "Invalid cookie format." ) ;
3942 return ;
4043 }
4144 }
4245 setUserCookies ( cookies ) ;
4346 setCustomCookiesEnabled ( customEnabled ) ;
4447 onClose ( ) ;
4548 } catch {
49+ setValidationError ( "Failed to save cookies. Please try again." ) ;
50+ } finally {
4651 setSaving ( false ) ;
4752 }
4853 } ;
@@ -70,13 +75,20 @@ export default function CookiesModal({ opened, onClose }: CookiesModalProps) {
7075 </ Text >
7176 }
7277 checked = { customEnabled }
73- onChange = { ( e ) => setCustomEnabled ( e . currentTarget . checked ) }
78+ onChange = { ( e ) => {
79+ setCustomEnabled ( e . currentTarget . checked ) ;
80+ setValidationError ( null ) ;
81+ } }
7482 />
7583
7684 { customEnabled && (
7785 < Textarea
7886 value = { cookies }
79- onChange = { ( e ) => setCookiesState ( e . currentTarget . value ) }
87+ onChange = { ( e ) => {
88+ setCookiesState ( e . currentTarget . value ) ;
89+ setValidationError ( null ) ;
90+ } }
91+ error = { validationError }
8092 placeholder = "Paste your exported cookies.txt here..."
8193 minRows = { 6 }
8294 maxRows = { 10 }
0 commit comments