11import { useState , useEffect } from "react" ;
22import { useParams , useNavigate } from "react-router-dom" ;
33import { toast } from 'react-toastify' ;
4- import { useDispatch , useSelector } from 'react-redux' ;
4+ import { useSelector } from 'react-redux' ;
55import { motion } from 'framer-motion' ;
66import { BaseUrl } from './BaseUrl' ;
77
@@ -24,25 +24,9 @@ const item = {
2424} ;
2525
2626export default function Record ( ) {
27- const [ loggedIn , setLoggedIn ] = useState ( false ) ;
2827 const userState = useSelector ( ( state ) => state . userState ) ;
2928 const companyId = userState . user ? userState . user . companyId : null ;
3029
31- // Check if user is logged in
32- useEffect ( ( ) => {
33- const checkLoginStatus = async ( ) => {
34- console . error ( "Entire userState:" , userState ) ; // Log the entire state
35- if ( userState . user ) {
36- console . error ( "userState.user exists:" , userState . user ) ;
37- setLoggedIn ( true ) ;
38- } else {
39- console . error ( "userState.user is null or undefined" ) ;
40- setLoggedIn ( false ) ;
41- }
42- } ;
43- checkLoginStatus ( ) ;
44- } , [ userState ] ) ;
45-
4630 // State to hold the form data
4731 const [ form , setForm ] = useState ( {
4832 employeeName : "" ,
@@ -201,7 +185,7 @@ export default function Record() {
201185 < div className = "mt-2" >
202186 < div className = "flex rounded-md shadow-sm ring-1 ring-inset ring-slate-300 focus-within:ring-2 focus-within:ring-inset focus-within:ring-indigo-400 sm:max-w-md" >
203187 < input
204- readOnly = { loggedIn }
188+ readOnly = { ! ! userState . user }
205189 type = "number"
206190 name = "companyId"
207191 id = "companyId"
0 commit comments