Merge branch 'master' of https://git.sentientgeeks.us/Amit/mui-demo-project
This commit is contained in:
commit
bbf975275f
BIN
public/assets/images/auth/loginbg.webp
Normal file
BIN
public/assets/images/auth/loginbg.webp
Normal file
Binary file not shown.
After Width: | Height: | Size: 94 KiB |
@ -4,8 +4,8 @@
|
|||||||
background: var(--bg_white);
|
background: var(--bg_white);
|
||||||
.images {
|
.images {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
max-width: 500px;
|
object-fit: cover;
|
||||||
object-fit: contain;
|
|
||||||
margin-inline: auto;
|
margin-inline: auto;
|
||||||
|
opacity: 0.6;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@ import { useDispatch, useSelector } from "react-redux";
|
|||||||
import { RootState } from "@/services/store";
|
import { RootState } from "@/services/store";
|
||||||
import { setAuthTokens, setUserDetails } from "@/services/store/authSlice";
|
import { setAuthTokens, setUserDetails } from "@/services/store/authSlice";
|
||||||
import { routes } from "constant/route.constant";
|
import { routes } from "constant/route.constant";
|
||||||
|
import { grey } from "@mui/material/colors";
|
||||||
|
|
||||||
const loginSchema = z.object({
|
const loginSchema = z.object({
|
||||||
username: z.string(),
|
username: z.string(),
|
||||||
@ -30,15 +31,20 @@ type LoginFormValues = z.infer<typeof loginSchema>;
|
|||||||
|
|
||||||
export default function LoginPage() {
|
export default function LoginPage() {
|
||||||
const [loader, setLoader] = useState(false);
|
const [loader, setLoader] = useState(false);
|
||||||
const router = useRouter()
|
const router = useRouter();
|
||||||
const { register, handleSubmit, formState: { errors }, control } = useForm<LoginFormValues>({
|
const {
|
||||||
|
register,
|
||||||
|
handleSubmit,
|
||||||
|
formState: { errors },
|
||||||
|
control,
|
||||||
|
} = useForm<LoginFormValues>({
|
||||||
resolver: zodResolver(loginSchema),
|
resolver: zodResolver(loginSchema),
|
||||||
});
|
});
|
||||||
const [error, setError] = useState("");
|
const [error, setError] = useState("");
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const onSubmit = async (data: LoginFormValues) => {
|
const onSubmit = async (data: LoginFormValues) => {
|
||||||
try {
|
try {
|
||||||
setLoader(true)
|
setLoader(true);
|
||||||
const response = await loginApi(data);
|
const response = await loginApi(data);
|
||||||
localStorage.setItem("token", response.token);
|
localStorage.setItem("token", response.token);
|
||||||
localStorage.setItem("refreshToken", response.refreshToken);
|
localStorage.setItem("refreshToken", response.refreshToken);
|
||||||
@ -52,8 +58,8 @@ export default function LoginPage() {
|
|||||||
setLoader(false)
|
setLoader(false)
|
||||||
router.push(routes.PRODUCTS);
|
router.push(routes.PRODUCTS);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
setLoader(false)
|
setLoader(false);
|
||||||
setError('Invalid credentials');
|
setError("Invalid credentials");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -63,7 +69,11 @@ export default function LoginPage() {
|
|||||||
<Grid item display={{ xs: "none", md: "block" }} md={7}>
|
<Grid item display={{ xs: "none", md: "block" }} md={7}>
|
||||||
<Box
|
<Box
|
||||||
height={"100%"}
|
height={"100%"}
|
||||||
sx={{ background: "var(--primary)" }}
|
sx={{
|
||||||
|
background: grey[900],
|
||||||
|
overflow: "hidden",
|
||||||
|
height: "100vh",
|
||||||
|
}}
|
||||||
display={"flex"}
|
display={"flex"}
|
||||||
alignItems={"center"}
|
alignItems={"center"}
|
||||||
justifyContent={"space-between"}
|
justifyContent={"space-between"}
|
||||||
@ -88,7 +98,7 @@ export default function LoginPage() {
|
|||||||
paddingBlock={5}
|
paddingBlock={5}
|
||||||
>
|
>
|
||||||
<img src={UTILITY_CONSTANT.IMAGES.AUTH.HEADER_LOG} alt="logo" />
|
<img src={UTILITY_CONSTANT.IMAGES.AUTH.HEADER_LOG} alt="logo" />
|
||||||
<form onSubmit={handleSubmit(onSubmit)}>
|
<form onSubmit={handleSubmit(onSubmit)} style={{ width: "100%" }}>
|
||||||
<Typography variant="h4">Welcome to Convexsol</Typography>
|
<Typography variant="h4">Welcome to Convexsol</Typography>
|
||||||
<Typography variant="h4">Sign in to your account</Typography>
|
<Typography variant="h4">Sign in to your account</Typography>
|
||||||
<Box
|
<Box
|
||||||
@ -116,7 +126,10 @@ export default function LoginPage() {
|
|||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
<Box width={"100%"} marginBlockStart={"20px"}>
|
<Box width={"100%"} marginBlockStart={"20px"}>
|
||||||
<CustomizedButtons btnType="submit" label={!loader ? "Login" : "Login..."} />
|
<CustomizedButtons
|
||||||
|
btnType="submit"
|
||||||
|
label={!loader ? "Login" : "Login..."}
|
||||||
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
</form>
|
</form>
|
||||||
<Box
|
<Box
|
||||||
|
@ -53,8 +53,6 @@ const ReviewModal = ({
|
|||||||
handleClose,
|
handleClose,
|
||||||
reviewModalData,
|
reviewModalData,
|
||||||
}: ReviewModalProps) => {
|
}: ReviewModalProps) => {
|
||||||
console.log("reviewModalData", reviewModalData);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box>
|
<Box>
|
||||||
<Modal
|
<Modal
|
||||||
|
@ -11,8 +11,6 @@ interface ReviewModalContentProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const ReviewModalContent = ({ data }: ReviewModalContentProps) => {
|
const ReviewModalContent = ({ data }: ReviewModalContentProps) => {
|
||||||
// const [value, setValue] = React.useState<number | null>(data?.rating);
|
|
||||||
// const [hover, setHover] = React.useState(-1);
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Box
|
<Box
|
||||||
@ -58,12 +56,6 @@ const ReviewModalContent = ({ data }: ReviewModalContentProps) => {
|
|||||||
size="small"
|
size="small"
|
||||||
precision={0.5}
|
precision={0.5}
|
||||||
readOnly
|
readOnly
|
||||||
// onChange={(event, newValue) => {
|
|
||||||
// setValue(newValue);
|
|
||||||
// }}
|
|
||||||
// onChangeActive={(event, newHover) => {
|
|
||||||
// setHover(newHover);
|
|
||||||
// }}
|
|
||||||
emptyIcon={
|
emptyIcon={
|
||||||
<StarIcon style={{ opacity: 0.55 }} fontSize="inherit" />
|
<StarIcon style={{ opacity: 0.55 }} fontSize="inherit" />
|
||||||
}
|
}
|
||||||
|
@ -119,7 +119,6 @@ const TanStackTable = ({ data }: any) => {
|
|||||||
const handleButtonClick = (rowData: any) => {
|
const handleButtonClick = (rowData: any) => {
|
||||||
setReviewModalData(rowData?.reviews);
|
setReviewModalData(rowData?.reviews);
|
||||||
handleOpen();
|
handleOpen();
|
||||||
// console.log("Button clicked for row:", rowData?.reviews);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const table = useReactTable({
|
const table = useReactTable({
|
||||||
@ -130,7 +129,6 @@ const TanStackTable = ({ data }: any) => {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setTableData(data?.products);
|
setTableData(data?.products);
|
||||||
console.log("Server data", data);
|
|
||||||
}, [data]);
|
}, [data]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -94,10 +94,6 @@ export default function DashboardWrapper(props: Props) {
|
|||||||
};
|
};
|
||||||
const [activeIndex, setActiveIndex] = useState<number | null>(null);
|
const [activeIndex, setActiveIndex] = useState<number | null>(null);
|
||||||
|
|
||||||
React.useEffect(() => {
|
|
||||||
console.log("User Data", userData);
|
|
||||||
}, [userData]);
|
|
||||||
|
|
||||||
const drawer = (
|
const drawer = (
|
||||||
<>
|
<>
|
||||||
<Toolbar sx={{ minHeight: "72px !important" }}>
|
<Toolbar sx={{ minHeight: "72px !important" }}>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// api.ts
|
// api.ts
|
||||||
import axiosInstance from '../axios/axiosInstance';
|
import axiosInstance from "../axios/axiosInstance";
|
||||||
|
|
||||||
export interface LoginResponse {
|
export interface LoginResponse {
|
||||||
id: number;
|
id: number;
|
||||||
@ -18,7 +18,8 @@ interface LoginData {
|
|||||||
password: string;
|
password: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Login API POST */
|
||||||
export const loginApi = async (data: LoginData): Promise<LoginResponse> => {
|
export const loginApi = async (data: LoginData): Promise<LoginResponse> => {
|
||||||
const response = await axiosInstance.post<LoginResponse>('/auth/login', data);
|
const response = await axiosInstance.post<LoginResponse>("/auth/login", data);
|
||||||
return response.data;
|
return response.data;
|
||||||
};
|
};
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import axios, { isAxiosError } from "axios";
|
import axios, { isAxiosError } from "axios";
|
||||||
|
|
||||||
|
/** Product List Home Page */
|
||||||
const homeServices = {
|
const homeServices = {
|
||||||
getProducts: async () => {
|
getProducts: async () => {
|
||||||
try {
|
try {
|
||||||
|
24
src/theme.ts
24
src/theme.ts
@ -1,20 +1,20 @@
|
|||||||
'use client';
|
"use client";
|
||||||
import { Roboto } from 'next/font/google';
|
import { Roboto } from "next/font/google";
|
||||||
import { createTheme } from '@mui/material/styles';
|
import { createTheme } from "@mui/material/styles";
|
||||||
|
|
||||||
const roboto = Roboto({
|
const roboto = Roboto({
|
||||||
weight: ['300', '400', '500', '700'],
|
weight: ["300", "400", "500", "700"],
|
||||||
subsets: ['latin'],
|
subsets: ["latin"],
|
||||||
display: 'swap',
|
display: "swap",
|
||||||
});
|
});
|
||||||
|
|
||||||
const getCssVariableValue = (variable: string): string => {
|
const getCssVariableValue = (variable: string): string => {
|
||||||
if (typeof window !== 'undefined') {
|
if (typeof window !== "undefined") {
|
||||||
return getComputedStyle(document.documentElement).getPropertyValue(
|
return getComputedStyle(document.documentElement).getPropertyValue(
|
||||||
variable
|
variable
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return '';
|
return "";
|
||||||
};
|
};
|
||||||
|
|
||||||
const theme = createTheme({
|
const theme = createTheme({
|
||||||
@ -23,16 +23,16 @@ const theme = createTheme({
|
|||||||
},
|
},
|
||||||
palette: {
|
palette: {
|
||||||
primary: {
|
primary: {
|
||||||
main: getCssVariableValue('--primary').trim() || '#6290cb', // Fallback to default color
|
main: getCssVariableValue("--primary").trim() || "#6290cb", // Fallback to default color
|
||||||
light: getCssVariableValue('--primary_light').trim() || '#dae7f9', // Fallback to default color
|
light: getCssVariableValue("--primary_light").trim() || "#dae7f9", // Fallback to default color
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
MuiCardContent: {
|
MuiCardContent: {
|
||||||
styleOverrides: {
|
styleOverrides: {
|
||||||
root: {
|
root: {
|
||||||
'&:last-child': {
|
"&:last-child": {
|
||||||
paddingBottom: '16px', // Override the padding for the last child
|
paddingBottom: "16px", // Override the padding for the last child
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -2,7 +2,7 @@ export const UTILITY_CONSTANT = {
|
|||||||
IMAGES: {
|
IMAGES: {
|
||||||
AUTH: {
|
AUTH: {
|
||||||
HEADER_LOG: "/assets/images/auth/headerLogo.webp",
|
HEADER_LOG: "/assets/images/auth/headerLogo.webp",
|
||||||
LOGIN_BG: "/assets/images/auth/loginbg.svg",
|
LOGIN_BG: "/assets/images/auth/loginbg.webp",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user