1
1
import React from 'react' ;
2
2
import { IonIcon } from '@ionic/react' ; // For Ionic icons
3
3
import { personCircleOutline , shieldOutline } from 'ionicons/icons' ; // Admin/User Icons
4
- import { Link } from 'react-router-dom' ; // For navigation
5
-
4
+ import { useHistory } from 'react-router-dom' ; // For navigation
6
5
const HomeComponent = ( ) => {
6
+ const history = useHistory ( ) ;
7
+
8
+ const handleAdminClick = ( ) => {
9
+ history . push ( '/admindash' ) ;
10
+ } ;
11
+
12
+ const handleUserClick = ( ) => {
13
+ history . push ( '/userchoice' ) ;
14
+ } ;
7
15
return (
8
16
< div className = "min-h-screen flex flex-col justify-center items-center bg-gradient-to-b from-blue-100 via-white to-green-100" >
9
17
{ /* Header Section */ }
@@ -20,25 +28,21 @@ const HomeComponent = () => {
20
28
< div className = "grid grid-cols-1 md:grid-cols-2 gap-8 w-full max-w-4xl px-6" >
21
29
{ /* Admin Option */ }
22
30
< div className = "flex justify-center" >
23
- < Link to = "/admindash" className = "w-full" >
24
- < button className = "w-full md:w-80 py-12 bg-blue-500 text-white rounded-lg shadow-lg hover:bg-blue-600 focus:outline-none transition-all duration-300 transform hover:scale-105" >
31
+ < button onClick = { handleAdminClick } className = "w-full md:w-80 py-12 bg-blue-500 text-white rounded-lg shadow-lg hover:bg-blue-600 focus:outline-none transition-all duration-300 transform hover:scale-105" >
25
32
< div className = "flex items-center justify-center space-x-2" >
26
33
< IonIcon icon = { shieldOutline } className = "text-3xl" />
27
34
< span className = "text-2xl" > Admin</ span >
28
35
</ div >
29
36
</ button >
30
- </ Link >
31
37
</ div >
32
38
{ /* User Option */ }
33
39
< div className = "flex justify-center" >
34
- < Link to = "/login" className = "w-full" >
35
- < button className = "w-full md:w-80 py-12 bg-green-500 text-white rounded-lg shadow-lg hover:bg-green-600 focus:outline-none transition-all duration-300 transform hover:scale-105" >
40
+ < button onClick = { handleUserClick } className = "w-full md:w-80 py-12 bg-green-500 text-white rounded-lg shadow-lg hover:bg-green-600 focus:outline-none transition-all duration-300 transform hover:scale-105" >
36
41
< div className = "flex items-center justify-center space-x-2" >
37
42
< IonIcon icon = { personCircleOutline } className = "text-3xl" />
38
43
< span className = "text-2xl" > User</ span >
39
44
</ div >
40
45
</ button >
41
- </ Link >
42
46
</ div >
43
47
</ div >
44
48
</ div >
0 commit comments