Skip to content

Commit

Permalink
fix: dashboard landing ui
Browse files Browse the repository at this point in the history
  • Loading branch information
tamalCodes committed Oct 20, 2024
1 parent 863a7c0 commit 442fda9
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 43 deletions.
4 changes: 2 additions & 2 deletions src/components/shared/navbar/Navbar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@

.navbar_link {
color: #8c321b;
font-weight: 600;
font-family: "Poppins", sans-serif;
font-weight: 500;
font-family: var(--outfit);
text-decoration: none;
font-size: 17px;
line-height: 1;
Expand Down
45 changes: 38 additions & 7 deletions src/components/shared/profileCompletion/ProfileCompletion.jsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
/* eslint-disable no-unused-vars */
import { useState } from "react";
import { useDispatch, useSelector } from "react-redux";

import { selectUser, updateUserData } from "@redux/slice/userSlice";
import { selectUser } from "@redux/slice/userSlice";
import { UpdateUser } from "@service/MilanApi";
import { useMutation } from "@tanstack/react-query";
import getProfileFields from "@utils/getProfileFields";
import { showErrorToast, showSuccessToast } from "@utils/Toasts";
import _ from "lodash";
import { useState } from "react";
import { useDispatch, useSelector } from "react-redux";
import { Button } from "..";
import getProfileFields from "../../../utils/getProfileFields";
import "./ProfileCompletion.scss";

const ProfileCompletion = () => {
const [credentials, setCredentials] = useState({});
const [errors, setErrors] = useState({});
const user = useSelector(selectUser);
const fields = getProfileFields(user);
const dispatch = useDispatch();
Expand All @@ -24,17 +24,45 @@ const ProfileCompletion = () => {
});
};

const { mutate: handleUpdateDetails } = useMutation({
const { mutate: mutate_UpdateDetails } = useMutation({
mutationFn: UpdateUser,
onSuccess: (data) => {
dispatch(updateUserData(credentials));
showSuccessToast(data?.message);
},
onError: (error) => {
showErrorToast(error?.message);
},
});

const handleUpdateDetails = () => {
const newErrors = {};

if (
credentials?.tagLine?.length < 20 ||
credentials?.tagLine?.length > 100
) {
newErrors.tagLine = "Tagline must be between 20 and 100 characters";
}

if (
credentials?.description?.length < 100 ||
credentials?.description?.length > 500
) {
newErrors.description =
"Description must be between 100 and 500 characters";
}

if (Object.keys(newErrors).length > 0) {
setErrors(newErrors);
} else {
// Clear errors if there are none
setErrors({});
mutate_UpdateDetails({
credentials: credentials,
});
}
};

return (
<div className="profilecompletion_overlay">
<div className="profilecompletion_modal">
Expand Down Expand Up @@ -74,6 +102,9 @@ const ProfileCompletion = () => {
placeholder={`Enter your ${field}`}
/>
)}
{errors[field] && (
<span className="profilecompletion_error">{errors[field]}</span>
)}
</div>
))}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
bottom: 0;
background-color: rgba(0, 0, 0, 0.8);
backdrop-filter: blur(6px);
z-index: 20;
z-index: 101;
display: flex;
justify-content: center;
align-items: center;
Expand Down Expand Up @@ -123,6 +123,12 @@
font-size: 10px !important;
}
}

.profilecompletion_error {
color: red;
font-size: 15px;
margin-top: 5px;
}
}
}

Expand Down
8 changes: 7 additions & 1 deletion src/hooks/useAuth.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,13 @@ export function useAuth(authType) {

if (response?.status === 201 || response?.status === 200) {
showSuccessToast(response?.data?.message);
dispatch(updateUserData({ ...response.data.user, isLoggedIn: true }));
dispatch(
updateUserData({
isLoggedIn: true,
email: response.data.user.email,
userName: response.data.user.userName,
}),
);

setTimeout(() => {
navigate("/");
Expand Down
51 changes: 19 additions & 32 deletions src/pages/dashboard/Dashboard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,9 @@ import "swiper/css";
import "swiper/css/autoplay";
import "swiper/css/navigation";
import "swiper/css/pagination";
import useSWR from "swr";
import EventsMarqueeCards from "../../components/private/events/marquee/EventsMarqueeCards";
import { Button, Navbar, ProfileCompletion } from "../../components/shared";
import { eventEndpoints } from "../../integrations/ApiEndpoints";
import { fetchDashboard } from "../../service/MilanApi";
import { defaults } from "../../static/Constants";
import fetcher from "../../utils/Fetcher";
import convertToBase64 from "../../utils/convertToBase64";
import "./Dashboard.scss";

Expand All @@ -24,11 +20,13 @@ const Dashboard = () => {
const [coverImage, setCoverImage] = useState("");
const [logo, setLogo] = useState("");
const user = useSelector(selectUser);
const { data } = useQuery({
queryKey: ["dashboardData"],

const { data: dashboardData } = useQuery({
queryKey: ["dashboard"],
queryFn: fetchDashboard,
refetchOnMount: false,
retry: 2,
refetchOnMount: true,
refetchOnWindowFocus: false,
retry: 0,
});

const toggleExpand = () => {
Expand All @@ -48,7 +46,7 @@ const Dashboard = () => {
}
};

const { data: events } = useSWR(eventEndpoints.all, fetcher);
// const { data: events } = useSWR(eventEndpoints.all, fetcher);

const handleUpdateProfile = () => {
console.log("Update Profile");
Expand Down Expand Up @@ -112,18 +110,11 @@ const Dashboard = () => {
<div className="header">
<div className="name">
<h1 className="profile_header_name dashboard_heading">
{data?.name}{" "}
{dashboardData?.name}{" "}
</h1>
{data?.tagline ? (
<h2 className="profile_header_tagline">{data?.tagline}</h2>
) : (
<h2
className="profile_header_tagline"
style={{ opacity: 0 }}
>
{" "}
Lorem ipsum dolor sit amet consectetur adipisicing elit.
Impedit cum laudantium
{dashboardData?.tagline && (
<h2 className="profile_header_tagline">
{dashboardData?.tagline}
</h2>
)}
</div>
Expand All @@ -150,14 +141,10 @@ const Dashboard = () => {

<div className="header_mobile">
<div className="name">
<h1 className="profile_header_name">{data?.name} </h1>
{data?.tagline ? (
<h2 className="profile_header_tagline">{data?.tagline}</h2>
) : (
<h2 className="profile_header_tagline" style={{ opacity: 0 }}>
{" "}
Lorem ipsum dolor sit amet consectetur adipisicing elit.
Impedit cum laudantium
<h1 className="profile_header_name">{dashboardData?.name} </h1>
{dashboardData?.tagline && (
<h2 className="profile_header_tagline">
{dashboardData?.tagline}
</h2>
)}
</div>
Expand All @@ -172,7 +159,7 @@ const Dashboard = () => {
</div>

<div className="dashboard_body">
{data?.description && (
{dashboardData?.description && (
<div className="about">
<h1 className="dashboard_heading">About Us</h1>
<div className="about_content">
Expand All @@ -181,7 +168,7 @@ const Dashboard = () => {
isExpanded ? "expanded" : ""
}`}
>
{data?.description}
{dashboardData?.description}
</p>
<div className="readmore_div">
{!isExpanded && (
Expand All @@ -197,7 +184,7 @@ const Dashboard = () => {
</div>
)}

{data?.events && (
{/* {data?.events && (
<div className="events">
<h1 className="dashboard_heading">Events Hosted</h1>
Expand All @@ -207,7 +194,7 @@ const Dashboard = () => {
))}
</div>
</div>
)}
)} */}
</div>
</div>
</div>
Expand Down

0 comments on commit 442fda9

Please sign in to comment.