mirror of
https://github.com/WDI-Ideas/rubix-admin-panel.git
synced 2026-04-27 18:05:52 +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_IMAGE_URL="https://rubix.betadelivery.com"
|
||||||
VITE_API_ENVIRONMENT="development"
|
VITE_API_ENVIRONMENT="development"
|
||||||
@@ -18,14 +18,18 @@ import {
|
|||||||
FormControl,
|
FormControl,
|
||||||
FormLabel,
|
FormLabel,
|
||||||
Input,
|
Input,
|
||||||
|
InputGroup,
|
||||||
|
InputRightElement,
|
||||||
useToast,
|
useToast,
|
||||||
} from "@chakra-ui/react";
|
} from "@chakra-ui/react";
|
||||||
import GlobalStateContext from "../Contexts/GlobalStateContext";
|
import GlobalStateContext from "../Contexts/GlobalStateContext";
|
||||||
import Cookies from 'js-cookie';
|
import Cookies from "js-cookie";
|
||||||
import { validationSchema } from "../Validations/Validations";
|
import { validationSchema } from "../Validations/Validations";
|
||||||
import ToastBox from "../Components/ToastBox";
|
import ToastBox from "../Components/ToastBox";
|
||||||
|
|
||||||
const Login = () => {
|
const Login = () => {
|
||||||
|
const [show, setShow] = useState(false);
|
||||||
|
const handleClick = () => setShow(!show);
|
||||||
const { isAuthenticate, setIsAuthenticate } = useContext(GlobalStateContext);
|
const { isAuthenticate, setIsAuthenticate } = useContext(GlobalStateContext);
|
||||||
const toast = useToast();
|
const toast = useToast();
|
||||||
// const { isAuthenticate } = useSelector((state) => state?.auth);
|
// const { isAuthenticate } = useSelector((state) => state?.auth);
|
||||||
@@ -45,7 +49,7 @@ const Login = () => {
|
|||||||
if (value.name === "Admin" && value.password === "Admin") {
|
if (value.name === "Admin" && value.password === "Admin") {
|
||||||
return setTimeout(() => {
|
return setTimeout(() => {
|
||||||
// dispatch(loginUser(true));
|
// dispatch(loginUser(true));
|
||||||
setIsAuthenticate(true)
|
setIsAuthenticate(true);
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
toast({
|
toast({
|
||||||
render: () => (
|
render: () => (
|
||||||
@@ -53,16 +57,15 @@ const Login = () => {
|
|||||||
),
|
),
|
||||||
});
|
});
|
||||||
|
|
||||||
Cookies.set('isAuthenticated', true, { expires: 7 });
|
Cookies.set("isAuthenticated", true, { expires: 7 });
|
||||||
navigate("/");
|
navigate("/");
|
||||||
}, 2000); // 3-second delay
|
}, 2000); // 3-second delay
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
return setTimeout(() => {
|
return setTimeout(() => {
|
||||||
// dispatch(loginUser(true));
|
// dispatch(loginUser(true));
|
||||||
setIsAuthenticate(false)
|
setIsAuthenticate(false);
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
|
|
||||||
toast({
|
toast({
|
||||||
render: () => (
|
render: () => (
|
||||||
<ToastBox status={"error"} message={"Invalid credentials"} />
|
<ToastBox status={"error"} message={"Invalid credentials"} />
|
||||||
@@ -157,17 +160,28 @@ const Login = () => {
|
|||||||
Password <span className="text-danger">*</span>
|
Password <span className="text-danger">*</span>
|
||||||
</FormLabel>
|
</FormLabel>
|
||||||
|
|
||||||
<Input
|
<InputGroup size="lg">
|
||||||
{...register("password")}
|
<Input
|
||||||
focusBorderColor="purple.500"
|
{...register("password")}
|
||||||
type="password"
|
className="web-text-medium"
|
||||||
name="password"
|
focusBorderColor="purple.500"
|
||||||
variant="filled"
|
variant="filled"
|
||||||
placeholder="Password"
|
pr="4.5rem"
|
||||||
size="lg"
|
type={show ? "text" : "password"}
|
||||||
className="web-text-medium"
|
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 && (
|
{errors.password && (
|
||||||
<span className="text-danger web-text-small fw-bold ps-2 d-flex align-items-center gap-1 mt-1">
|
<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}
|
<TiWarning className="fw-bold fs-5 " /> {errors.password.message}
|
||||||
@@ -229,15 +243,13 @@ const Login = () => {
|
|||||||
position: "absolute",
|
position: "absolute",
|
||||||
top: 0,
|
top: 0,
|
||||||
left: 0,
|
left: 0,
|
||||||
width:300
|
width: 300,
|
||||||
}}
|
}}
|
||||||
|
|
||||||
src={Ellipse4}
|
src={Ellipse4}
|
||||||
alt="bg-img"
|
alt="bg-img"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<img
|
||||||
<img
|
|
||||||
style={{
|
style={{
|
||||||
position: "absolute",
|
position: "absolute",
|
||||||
bottom: 0,
|
bottom: 0,
|
||||||
|
|||||||
Reference in New Issue
Block a user