@@ -79,8 +79,10 @@ const LoginPage = ({
7979 handleClose ( ) ;
8080 } ;
8181
82- const handleLogin = async ( ) => {
83- if ( ! email || ! password || ! isValid ) {
82+ const handleLogin = async (
83+ demoData : { email : string ; password : string } | null = null ,
84+ ) => {
85+ if ( ! demoData && ( ! email || ! password || ! isValid ) ) {
8486 setEmailError ( "Email is required" ) ;
8587 setPasswordError ( "Password is required" ) ;
8688 setIsValid ( false ) ;
@@ -90,7 +92,7 @@ const LoginPage = ({
9092 try {
9193 const userData : User = await postData (
9294 "auth/login" ,
93- { email, password } ,
95+ demoData || { email, password } ,
9496 setErrorMessage ,
9597 ) ;
9698 if ( userData ) {
@@ -124,6 +126,10 @@ const LoginPage = ({
124126 }
125127 } ;
126128
129+ const handleDemoLogin = async ( email : string , password : string ) => {
130+ await handleLogin ( { email, password } ) ;
131+ } ;
132+
127133 return (
128134 < Dialog open = { open } onOpenChange = { handleDialogClose } modal >
129135 < DialogContent className = "px-3 py-8 w-full max-w-full h-full sm:w-auto sm:max-w-4xl sm:h-auto rounded-none sm:rounded-lg items-center" >
@@ -182,7 +188,7 @@ const LoginPage = ({
182188 < Button
183189 variant = "default"
184190 className = "w-full active:scale-95"
185- onClick = { handleLogin }
191+ onClick = { ( ) => handleLogin ( ) }
186192 >
187193 Sign in
188194 </ Button >
@@ -199,6 +205,27 @@ const LoginPage = ({
199205 Sign up
200206 </ Button >
201207 </ p >
208+ < p className = "text-sm flex gap-1 items-center justify-center" >
209+ < span className = "italic" > Demo login:</ span >
210+ < Button
211+ variant = { "outline" }
212+ className = "hover:bg-primary"
213+ onClick = { ( ) =>
214+ handleDemoLogin ( "[email protected] " , "B5TTP76m2NSBbye" ) 215+ }
216+ >
217+ John Doe
218+ </ Button >
219+ < Button
220+ variant = { "outline" }
221+ className = "hover:bg-primary"
222+ onClick = { ( ) =>
223+ handleDemoLogin ( "[email protected] " , "B5TTP76m2NSBbye" ) 224+ }
225+ >
226+ Sarah Smith
227+ </ Button >
228+ </ p >
202229 </ div >
203230
204231 { /* Right Section */ }
0 commit comments