feat : connection made between login and home page

This commit is contained in:
2025-06-27 13:59:51 +05:30
parent 49dae3624f
commit 92531b02fd
7 changed files with 63 additions and 1048 deletions

View File

@@ -7,12 +7,35 @@ import bgImage from '@/app/image/media.jpg';
import frontPage from '@/app/image/ib_front_page.jpg'
import NextImage from 'next/image';
import { Providers } from "@/app/providers";
import { useRouter } from "next/navigation";
import { notifications } from "@mantine/notifications";
export default function Login() {
const [CIF, SetCIF] = useState('');
const [psw, SetPsw] = useState('');
async function handleLogin() {
const router = useRouter();
async function handleLogin(e:React.FormEvent) {
e.preventDefault();
// const login_password =localStorage.setItem("password",psw);
if (CIF === "30022497139" && psw === "SecurePass123!")
{
const token ="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWUsImlhdCI6MTUxNjIzOTAyMn0.KMUFsIDTnFmyG3nMiGM6H9FNFUROf3wh7SmqJp-QV30";
localStorage.setItem("customerNumber",CIF);
localStorage.setItem("password",psw);
localStorage.setItem("access_token",token);
router.push("/home");
}
else {
notifications.show({
withBorder: true,
color: 'red',
title: "Wrong User Id or Password",
message: "Wrong User Id or Password",
autoClose: 5000,
})
}
}
return (
@@ -83,7 +106,7 @@ export default function Login() {
<br></br>
<Box style={{ width: "370px", padding: "20px", border: "1px solid #e0e0d1", marginLeft: 30 }}>
<Flex justify="center" gap="md" >
<form>
<form onSubmit={handleLogin}>
<TextInput
label="User ID"
placeholder="Enter your CIF no"
@@ -93,13 +116,12 @@ export default function Login() {
pattern="\d*"
value={CIF}
onInput={(e) => {
const input =e.currentTarget.value.replace(/\D/g,'');
if(input.length<=11)
{
SetCIF(input);
}
const input = e.currentTarget.value.replace(/\D/g, '');
if (input.length <= 11) {
SetCIF(input);
}
}}
style={{ flex: 1 }}
required
/>
@@ -107,11 +129,13 @@ export default function Login() {
<PasswordInput
label="Password"
placeholder="Enter your password"
value={psw}
onChange={(e) => SetPsw(e.currentTarget.value)}
style={{ flex: 1 }}
required
/>
{/* <br></br> */}
<Button fullWidth variant="filled" mt="md" style={{ width: 100, align: "center", marginLeft: 40 }}>Login</Button>
<Button type="submit" fullWidth variant="filled" mt="md" style={{ width: 100, align: "center", marginLeft: 40 }}>Login</Button>
</form>
</Flex>
</Box>