Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: cookies functionality, hyperlinks and shown appropriate content in footer #1079

Merged
merged 18 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/Banners/HomeBanner.jsx
YuvarajSingh-0 marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like you have resolved the conflicts in the wrong manner. You overwrote the incoming changes (the changes that I made) with the changes of the current branch (the changes that you had previously).

That is a reason why some UI has also changed. Take a look at this screenshot below.
The left image is the changes that are made by you. The right one is what is currently deployed.

image

Please fix this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, you want the left image to look like the right one.... Right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct. You can check the current code that we have for more reference.

Copy link
Member Author

@YuvarajSingh-0 YuvarajSingh-0 Oct 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What should I replace in place of 'usertype' cookie? (in line number 28 in HomeBanner.jsx)

Copy link
Member

@tamalCodes tamalCodes Oct 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think starting from here it would be the best to keep the changes as it is.

I previously updated the code for the home banner about what to show in the buttons on instances where the user is not logged in, the club is logged in OR the user is logged in. So I think we can maybe ignore the changes for the HomeBanner.jsx file.

I also see that you have optimized the code for the conditional rendering, thanks for that.
Can you confirm for me if the Login and Logout-based rendering functionality is working perfectly for the footer and stuffs ? IF yes we can merge the same.

Copy link
Member Author

@YuvarajSingh-0 YuvarajSingh-0 Oct 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, It's Working fine, I've checked it now.

There was also an issue with login trigger while logging in i.e., the login functionality is not hitting the correct backend url for login, I fixed it in ApiEndpoints.js file. And also upon clicking the profile icon after logging in, due to this line the redirecting url does not exist due to no usertype cookie. But I think that part of code depends on backend, like setting cookie with name usertype and all.

Apart from these, the footer section is good to merge. But one thing, While logging out, Both cookies isLoggedIn and Token should be deleted, failing either one may result in inconsistent results while conditional rendering. Because footer only checks isLoggedIn cookie, so even if there is no Token cookie but there is isLoggedIn cookie, it still considers it as logged in.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Login and the usertype works fine when normally logging in. Google authentication won't work just yet - so please stay tuned. You can learn more about that in this issue.

The token is an HTTP-only cookie - so you won't be able to access the cookie from the front end. So checking for the Token cookie makes no sense. Currently, we might have some glitch in the backend where the logout function fails to clear the cookies in production - but it should work properly in the local.

image

Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const HomeBanner = () => {
</div>

<div className="banner_signup_btndiv">
{Cookies.get("token") || Cookies.get("club") ? (
{Cookies.get("Token") || Cookies.get("club") ? (
YuvarajSingh-0 marked this conversation as resolved.
Show resolved Hide resolved
<div className="banner_btn_div">
<Button
className="banner_signup_btn"
Expand Down
8 changes: 4 additions & 4 deletions src/components/Footer/Footer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const Footer = () => {
};

useEffect(() => {
if (Cookies.get("token")) setLogged(true);
if (Cookies.get("Token")) setLogged(true);
}, []);

useEffect(() => {
Expand All @@ -56,7 +56,7 @@ const Footer = () => {
const handleReportSubmit = async (e) => {
e.preventDefault();

if (!Cookies.get("token")) {
if (!Cookies.get("Token")) {
YuvarajSingh-0 marked this conversation as resolved.
Show resolved Hide resolved
toast.error("You must be logged in to report an issue");
return;
}
Expand Down Expand Up @@ -233,7 +233,7 @@ const Footer = () => {
</Link>
) : (
<Link
to="/user/login"
to="/auth/login"
className="text-decoration-none footer_auth_text"
>
Login
Expand All @@ -250,7 +250,7 @@ const Footer = () => {
</Link>
) : (
<Link
to="/user/register"
to="/auth/signup"
className="text-decoration-none footer_auth_text"
>
Register
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Donate/Donate.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const Donate = () => {

const [clubData, setClubData] = useState([]);
const [loading, setLoading] = useState(false);
const [isLoggedIn] = useState(Cookies.get("token"));
const [isLoggedIn] = useState(Cookies.get("Token"));
YuvarajSingh-0 marked this conversation as resolved.
Show resolved Hide resolved
var navigate = useNavigate();

useEffect(() => {
Expand Down
Loading