login update

This commit is contained in:
2024-06-10 17:28:43 +05:30
parent dc5d7dd620
commit fdbab559c8
2 changed files with 34 additions and 22 deletions

2
.env
View File

@@ -1,3 +1,3 @@
VITE_API_BASE_URL="https://rubix.betadelivery.com/api"
VITE_API_BASE_URL="https://rubix.betadelivery.com"
VITE_API_IMAGE_URL="https://rubix.betadelivery.com"
VITE_API_ENVIRONMENT="development"

View File

@@ -18,14 +18,18 @@ import {
FormControl,
FormLabel,
Input,
InputGroup,
InputRightElement,
useToast,
} from "@chakra-ui/react";
import GlobalStateContext from "../Contexts/GlobalStateContext";
import Cookies from 'js-cookie';
import Cookies from "js-cookie";
import { validationSchema } from "../Validations/Validations";
import ToastBox from "../Components/ToastBox";
const Login = () => {
const [show, setShow] = useState(false);
const handleClick = () => setShow(!show);
const { isAuthenticate, setIsAuthenticate } = useContext(GlobalStateContext);
const toast = useToast();
// const { isAuthenticate } = useSelector((state) => state?.auth);
@@ -45,7 +49,7 @@ const Login = () => {
if (value.name === "Admin" && value.password === "Admin") {
return setTimeout(() => {
// dispatch(loginUser(true));
setIsAuthenticate(true)
setIsAuthenticate(true);
setIsLoading(false);
toast({
render: () => (
@@ -53,14 +57,13 @@ const Login = () => {
),
});
Cookies.set('isAuthenticated', true, { expires: 7 });
Cookies.set("isAuthenticated", true, { expires: 7 });
navigate("/");
}, 2000); // 3-second delay
} else {
return setTimeout(() => {
// dispatch(loginUser(true));
setIsAuthenticate(false)
setIsAuthenticate(false);
setIsLoading(false);
toast({
@@ -157,17 +160,28 @@ const Login = () => {
Password <span className="text-danger">*</span>
</FormLabel>
<InputGroup size="lg">
<Input
{...register("password")}
focusBorderColor="purple.500"
type="password"
name="password"
variant="filled"
placeholder="Password"
size="lg"
className="web-text-medium"
focusBorderColor="purple.500"
variant="filled"
pr="4.5rem"
type={show ? "text" : "password"}
placeholder="Enter password"
/>
<InputRightElement width="4.5rem">
<Button
h="1.75rem"
size="sm"
fontSize={"xs"}
color={"purple.800"}
onClick={handleClick}
>
{show ? "Hide" : "Show"}
</Button>
</InputRightElement>
</InputGroup>
{errors.password && (
<span className="text-danger web-text-small fw-bold ps-2 d-flex align-items-center gap-1 mt-1">
<TiWarning className="fw-bold fs-5 " /> {errors.password.message}
@@ -229,14 +243,12 @@ const Login = () => {
position: "absolute",
top: 0,
left: 0,
width:300
width: 300,
}}
src={Ellipse4}
alt="bg-img"
/>
<img
style={{
position: "absolute",