mirror of
https://github.com/WDI-Ideas/rubix-admin-panel.git
synced 2026-04-27 14:45:51 +00:00
login update
This commit is contained in:
2
.env
2
.env
@@ -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"
|
||||
@@ -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,16 +57,15 @@ 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({
|
||||
render: () => (
|
||||
<ToastBox status={"error"} message={"Invalid credentials"} />
|
||||
@@ -157,17 +160,28 @@ const Login = () => {
|
||||
Password <span className="text-danger">*</span>
|
||||
</FormLabel>
|
||||
|
||||
<Input
|
||||
{...register("password")}
|
||||
focusBorderColor="purple.500"
|
||||
type="password"
|
||||
name="password"
|
||||
variant="filled"
|
||||
placeholder="Password"
|
||||
size="lg"
|
||||
className="web-text-medium"
|
||||
/>
|
||||
|
||||
<InputGroup size="lg">
|
||||
<Input
|
||||
{...register("password")}
|
||||
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,15 +243,13 @@ const Login = () => {
|
||||
position: "absolute",
|
||||
top: 0,
|
||||
left: 0,
|
||||
width:300
|
||||
width: 300,
|
||||
}}
|
||||
|
||||
src={Ellipse4}
|
||||
alt="bg-img"
|
||||
/>
|
||||
|
||||
|
||||
<img
|
||||
<img
|
||||
style={{
|
||||
position: "absolute",
|
||||
bottom: 0,
|
||||
|
||||
Reference in New Issue
Block a user