Prakash Maity 6 months ago
parent
commit
bbf975275f
11 changed files with 40 additions and 41 deletions
  1. BIN
      public/assets/images/auth/loginbg.webp
  2. +2
    -2
      src/app/(auth)/login/loginPage.module.scss
  3. +21
    -8
      src/app/(auth)/login/page.tsx
  4. +0
    -2
      src/components/reviewModal/ReviewModal.tsx
  5. +0
    -8
      src/components/reviewModal/components/reviewModalContent/ReviewModalContent.tsx
  6. +0
    -2
      src/components/table/TanStackTable.tsx
  7. +0
    -4
      src/components/wrapper/dashboardWrapper.tsx
  8. +3
    -2
      src/services/api/loginApi.ts
  9. +1
    -0
      src/services/home.services.ts
  10. +12
    -12
      src/theme.ts
  11. +1
    -1
      src/utilities/utilityConstant.ts

BIN
public/assets/images/auth/loginbg.webp View File

Before After

+ 2
- 2
src/app/(auth)/login/loginPage.module.scss View File

@ -4,8 +4,8 @@
background: var(--bg_white); background: var(--bg_white);
.images { .images {
width: 100%; width: 100%;
max-width: 500px;
object-fit: contain;
object-fit: cover;
margin-inline: auto; margin-inline: auto;
opacity: 0.6;
} }
} }

+ 21
- 8
src/app/(auth)/login/page.tsx View File

@ -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 { register, handleSubmit, formState: { errors }, control } = useForm<LoginFormValues>({
const router = useRouter();
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)
setError('Invalid credentials');
setLoader(false);
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


+ 0
- 2
src/components/reviewModal/ReviewModal.tsx View File

@ -53,8 +53,6 @@ const ReviewModal = ({
handleClose, handleClose,
reviewModalData, reviewModalData,
}: ReviewModalProps) => { }: ReviewModalProps) => {
console.log("reviewModalData", reviewModalData);
return ( return (
<Box> <Box>
<Modal <Modal


+ 0
- 8
src/components/reviewModal/components/reviewModalContent/ReviewModalContent.tsx View File

@ -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" />
} }


+ 0
- 2
src/components/table/TanStackTable.tsx View File

@ -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 (


+ 0
- 4
src/components/wrapper/dashboardWrapper.tsx View File

@ -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" }}>


+ 3
- 2
src/services/api/loginApi.ts View File

@ -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
- 0
src/services/home.services.ts View File

@ -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 {


+ 12
- 12
src/theme.ts View File

@ -1,20 +1,20 @@
'use client';
import { Roboto } from 'next/font/google';
import { createTheme } from '@mui/material/styles';
"use client";
import { Roboto } from "next/font/google";
import { createTheme } from "@mui/material/styles";
const roboto = Roboto({ const roboto = Roboto({
weight: ['300', '400', '500', '700'],
subsets: ['latin'],
display: 'swap',
weight: ["300", "400", "500", "700"],
subsets: ["latin"],
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
light: getCssVariableValue('--primary_light').trim() || '#dae7f9', // Fallback to default color
main: getCssVariableValue("--primary").trim() || "#6290cb", // Fallback to default color
light: getCssVariableValue("--primary_light").trim() || "#dae7f9", // Fallback to default color
}, },
}, },
components: { components: {
MuiCardContent: { MuiCardContent: {
styleOverrides: { styleOverrides: {
root: { root: {
'&:last-child': {
paddingBottom: '16px', // Override the padding for the last child
"&:last-child": {
paddingBottom: "16px", // Override the padding for the last child
}, },
}, },
}, },


+ 1
- 1
src/utilities/utilityConstant.ts View File

@ -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…
Cancel
Save