@@ -12,144 +12,113 @@ const AdminLogin = () => {
1212 const routeChange = ( path ) => {
1313 history . push ( path ) ;
1414 } ;
15- // const routeChange = (res) => {
16- // let path
17- // if(res){
18- // if(res.code===0){
19- // toast.error("Invalid Credentials", {
20- // autoClose: 5000,
21- // hideProgressBar: false,
22- // closeOnClick: true,
23- // pauseOnHover: true,
24- // draggable: true,
25- // progress: undefined,
26- // });
27- // console.log("inside this");
28-
29- // }
30- // else
31- // {
32- // path='/admin'
33- // history.push(path);
34- // }
35- // }
36- // else
37- // {
38- // path='/admin'
39- // history.push(path);
40- // }
41-
42-
43-
44- // };
45- const validate = async ( ) => {
46-
47- let Username = username ;
48- let Password = password ;
49- const { error } = loginFormSchema . validate ( { Username, Password} ) ;
50- if ( error ) {
51- toast . error ( error . message , {
52- autoClose : 5000 ,
53- hideProgressBar : false ,
54- closeOnClick : true ,
55- pauseOnHover : true ,
56- draggable : true ,
57- progress : undefined ,
58- } ) ;
59- } else {
60- let res = await getToken ( username , password ) ;
61- if ( res . code !== 0 ) {
62- routeChange ( "/admin" ) ;
63- } else {
64- toast . error ( "Invalid Credentials" , {
15+ const validate = async ( ) => {
16+ let Username = username ;
17+ let Password = password ;
18+ const { error } = loginFormSchema . validate ( { Username, Password } ) ;
19+ if ( error ) {
20+ toast . error ( error . message , {
6521 autoClose : 5000 ,
6622 hideProgressBar : false ,
6723 closeOnClick : true ,
6824 pauseOnHover : true ,
6925 draggable : true ,
7026 progress : undefined ,
7127 } ) ;
28+ } else {
29+ let res = await getToken ( username , password ) ;
30+ if ( res . code !== 0 ) {
31+ routeChange ( "/admin" ) ;
32+ } else {
33+ toast . error ( "Invalid Credentials" , {
34+ autoClose : 5000 ,
35+ hideProgressBar : false ,
36+ closeOnClick : true ,
37+ pauseOnHover : true ,
38+ draggable : true ,
39+ progress : undefined ,
40+ } ) ;
41+ }
7242 }
73- }
74- } ;
43+ } ;
7544 const handleOnClick = ( e ) => {
7645 e . preventDefault ( ) ;
77- validate ( )
46+ validate ( ) ;
7847 } ;
79-
48+
8049 return (
8150 < div className = "flex md:container md:mx-auto h-screen items-center justify-center" >
8251 < ToastContainer />
83- < div
84- id = "container"
85- className = "flex flex-col align-middle w-full max-w-md px-4 py-8 bg-white rounded-lg shadow dark:bg-gray-800 sm:px-6 md:px-8 lg:px-10"
86- style = { { backgroundColor : "#383844" } }
87- >
88- < div className = "self-center mb-6 text-xl font-light sm:text-2xl text-white" >
89- Evie Admin Login
90- </ div >
91- < div className = "mt-8" >
92- < form autoComplete = "off" >
93- < div className = "flex flex-col mb-2" >
94- < div className = "flex relative " >
95- < span className = "inline-flex items-center px-3 bg-none mt-2 text-white text-sm" >
96- < svg
97- width = "15"
98- height = "15"
99- fill = "currentColor"
100- viewBox = "0 0 1792 1792"
101- xmlns = "http://www.w3.org/2000/svg"
102- >
103- < path d = "M1792 710v794q0 66-47 113t-113 47h-1472q-66 0-113-47t-47-113v-794q44 49 101 87 362 246 497 345 57 42 92.5 65.5t94.5 48 110 24.5h2q51 0 110-24.5t94.5-48 92.5-65.5q170-123 498-345 57-39 100-87zm0-294q0 79-49 151t-122 123q-376 261-468 325-10 7-42.5 30.5t-54 38-52 32.5-57.5 27-50 9h-2q-23 0-50-9t-57.5-27-52-32.5-54-38-42.5-30.5q-91-64-262-182.5t-205-142.5q-62-42-117-115.5t-55-136.5q0-78 41.5-130t118.5-52h1472q65 0 112.5 47t47.5 113z" > </ path >
104- </ svg >
105- </ span >
106- < input
107- type = "text"
108- className = "flex-1 appearance-none w-full py-2 px-4 bg-white text-gray-700 placeholder-gray-400 text-base focus:outline-none focus:ring-1 focus:ring-indigo-800 outline-none focus:border-transparent"
109- placeholder = "Username"
110- name = "uname"
111- onChange = { ( e ) => setUsername ( e . target . value ) }
112- style = { { backgroundColor :"#16151C" } }
113- />
52+ < div
53+ id = "container"
54+ className = "flex flex-col align-middle w-full max-w-md px-4 py-8 bg-white rounded-lg shadow dark:bg-gray-800 sm:px-6 md:px-8 lg:px-10"
55+ style = { { backgroundColor : "#383844" } }
56+ >
57+ < div className = "self-center text-xl font-light sm:text-2xl text-white" >
58+ Evie Admin Login
59+ </ div >
60+ < div className = "mt-4" >
61+ < form autoComplete = "off" >
62+ < div className = "flex flex-col mb-2" >
63+ < div className = "flex relative " >
64+ < span className = "inline-flex items-center px-3 bg-none mt-2 text-white text-sm" >
65+ < svg
66+ width = "15"
67+ height = "15"
68+ fill = "currentColor"
69+ viewBox = "0 0 1792 1792"
70+ xmlns = "http://www.w3.org/2000/svg"
71+ >
72+ < path d = "M1792 710v794q0 66-47 113t-113 47h-1472q-66 0-113-47t-47-113v-794q44 49 101 87 362 246 497 345 57 42 92.5 65.5t94.5 48 110 24.5h2q51 0 110-24.5t94.5-48 92.5-65.5q170-123 498-345 57-39 100-87zm0-294q0 79-49 151t-122 123q-376 261-468 325-10 7-42.5 30.5t-54 38-52 32.5-57.5 27-50 9h-2q-23 0-50-9t-57.5-27-52-32.5-54-38-42.5-30.5q-91-64-262-182.5t-205-142.5q-62-42-117-115.5t-55-136.5q0-78 41.5-130t118.5-52h1472q65 0 112.5 47t47.5 113z" > </ path >
73+ </ svg >
74+ </ span >
75+ < input
76+ type = "text"
77+ className = "flex-1 appearance-none w-full py-2 px-4 bg-white text-gray-700 placeholder-gray-400 text-base focus:outline-none outline-none focus:border-transparent"
78+ placeholder = "Username"
79+ name = "uname"
80+ onChange = { ( e ) => setUsername ( e . target . value ) }
81+ style = { { backgroundColor : "#16151C" } }
82+ />
83+ </ div >
11484 </ div >
115- </ div >
116- < div className = "flex flex-col mb-6 " >
117- < div className = "flex relative " >
118- < span className = "inline-flex items-center px-3 bg-none mt-2 text-white text-sm" >
119- < svg
120- width = "15"
121- height = "15 "
122- fill = "currentColor "
123- viewBox = "0 0 1792 1792 "
124- xmlns = "http://www.w3.org/2000/svg"
125- >
126- < path d = "M1376 768q40 0 68 28t28 68v576q0 40-28 68t-68 28h-960q-40 0-68-28t-28-68v-576q0-40 28-68t68-28h32v-320q0-185 131.5-316.5t316.5-131.5 316.5 131.5 131.5 316.5q0 26-19 45t-45 19h-64q-26 0-45-19t-19-45q0-106-75-181t-181-75-181 75-75 181v320h736z" > </ path >
127- </ svg >
128- </ span >
129- < input
130- type = "password "
131- className = "flex-1 appearance-none w-full py-2 px-4 bg-white text-gray-700 placeholder-gray-400 text-base focus:outline-none focus:ring-1 focus:ring-indigo-800 outline-none focus:border-transparent "
132- placeholder = "Password "
133- name = "password"
134- onChange = { ( e ) => setPassword ( e . target . value ) }
135- style = { { backgroundColor : "#16151C" } }
136- / >
85+ < div className = "flex flex-col mb-6" >
86+ < div className = "flex relative " >
87+ < span className = "inline- flex items-center px-3 bg-none mt-2 text-white text-sm " >
88+ < svg
89+ width = "15"
90+ height = "15"
91+ fill = "currentColor "
92+ viewBox = "0 0 1792 1792 "
93+ xmlns = "http://www.w3.org/2000/svg "
94+ >
95+ < path d = "M1376 768q40 0 68 28t28 68v576q0 40-28 68t-68 28h-960q-40 0-68-28t-28-68v-576q0-40 28-68t68-28h32v-320q0-185 131.5-316.5t316.5-131.5 316.5 131.5 131.5 316.5q0 26-19 45t-45 19h-64q-26 0-45-19t-19-45q0-106-75-181t-181-75-181 75-75 181v320h736z" > </ path >
96+ </ svg >
97+ </ span >
98+ < input
99+ type = "password"
100+ className = "flex-1 appearance-none w-full py-2 px-4 bg-white text-gray-700 placeholder-gray-400 text-base focus:outline-none outline-none focus:border-transparent "
101+ placeholder = "Password "
102+ name = "password "
103+ onChange = { ( e ) => setPassword ( e . target . value ) }
104+ style = { { backgroundColor : "#16151C" } }
105+ />
106+ </ div >
137107 </ div >
138- </ div >
139- < div className = "flex w-full" >
140- < button
141- type = "submit "
142- className = "text-white transition ease-in duration-200 text-center text-base font-semibold focus:outline-none focus:ring-2 focus:ring-offset-2 fc-button w-full rounded-lg "
143- onClick = { handleOnClick }
144- style = { { backgroundColor : "#16151C" } }
145- >
146- Login
147- </ button >
148- </ div >
149- </ form >
108+ < div className = "flex w-full" >
109+ < button
110+ type = "submit"
111+ className = "text-white transition ease-in duration-200 text-center text-base font-semibold focus:outline-none focus:ring-2 focus:ring-offset-2 fc-button w-full rounded-lg "
112+ onClick = { handleOnClick }
113+ style = { { backgroundColor : "#16151C" } }
114+ >
115+ Login
116+ </ button >
117+ </ div >
118+ </ form >
119+ </ div >
150120 </ div >
151121 </ div >
152- </ div >
153122 ) ;
154123} ;
155124
0 commit comments