Skip to content

Commit

Permalink
fixes: bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
ayussh-2 committed Oct 27, 2024
1 parent 85b9be6 commit d70fa17
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 36 deletions.
4 changes: 2 additions & 2 deletions src/app/register/page.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use client';
import { useContext, useEffect, useState } from 'react';
import { useContext, useLayoutEffect, useState } from 'react';

import Cookies from 'js-cookie';
import Link from 'next/link';
Expand Down Expand Up @@ -283,7 +283,7 @@ function Page() {
}
}

useEffect(() => {
useLayoutEffect(() => {
if (Cookies.get('userDataDB')) {
router.push('/');
toast.success('You have been already registered!', {
Expand Down
24 changes: 10 additions & 14 deletions src/components/HeroSection/Hero.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import './Hero.css';

import { motion } from 'framer-motion';
import Cookies from 'js-cookie';
import Image from 'next/image';
import Link from 'next/link';
import { motion } from 'framer-motion';

import { HeroGreenPrimaryButton, HeroLogoText, HeroPrimaryButton } from './styles';

export const Hero = () => {
Expand All @@ -15,12 +18,7 @@ export const Hero = () => {
visible: { scale: 1, opacity: 1, transition: { duration: 1.2, ease: 'easeOut' } },
};

const buttonVariants = {
hover: {
scale: 1.1,
transition: { yoyo: Infinity },
},
};
const isRegistered = Cookies.get('userDataDB');

return (
<div className='relative h-screen overflow-hidden md:h-[105vh] flex-col justify-center items-center'>
Expand Down Expand Up @@ -94,18 +92,16 @@ export const Hero = () => {
animate={{ opacity: 1 }}
transition={{ duration: 1, delay: 1 }}
>
<Link href='/register'>
<motion.div variants={buttonVariants} whileHover='hover'>
{!isRegistered && (
<Link href='/register'>
<HeroPrimaryButton>Register</HeroPrimaryButton>
</motion.div>
</Link>
</Link>
)}
<Link
href='https://drive.google.com/file/d/1jglpl2SzbmpRc73ML80zREhnpxxQF4qx/view?usp=sharing'
target='_blank'
>
<motion.div variants={buttonVariants} whileHover='hover'>
<HeroGreenPrimaryButton>Brochure</HeroGreenPrimaryButton>
</motion.div>
<HeroGreenPrimaryButton>Brochure</HeroGreenPrimaryButton>
</Link>
</motion.div>
</motion.div>
Expand Down
22 changes: 2 additions & 20 deletions src/components/ProfileMenu/ProfileMenu.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
'use client';
import { useContext, useEffect, useState } from 'react';
import { useContext } from 'react';

import Cookies from 'js-cookie';
import { usePathname, useRouter } from 'next/navigation';
import { toast } from 'react-hot-toast';

import { AuthContext } from '@/context/auth-context';
import { useUserDetails } from '@/hooks/useUserDetails';
Expand All @@ -25,13 +23,10 @@ import {

function ProfileMenu({ handleProfileToggle, handleNavClose }) {
const { handleSignOut } = useContext(AuthContext);
const [isRegistered, setIsRegistered] = useState(false);
const getUserDetails = useUserDetails();
const user = getUserDetails();
const router = useRouter();
const path = usePathname();
const isNitr = getUserDetails()?.isNitR;

const isRegistered = Cookies.get('userDataDB');
const handleLogout = () => {
handleSignOut();
handleProfileToggle();
Expand All @@ -43,19 +38,6 @@ function ProfileMenu({ handleProfileToggle, handleNavClose }) {
handleNavClose(false);
};

useEffect(() => {
const mongoId = Cookies.get('userDataDB');
if (mongoId) {
if (path === '/register') {
toast.success('You are already registered!');
router.push('/');
}
setIsRegistered(true);
} else {
setIsRegistered(false);
}
}, []);

return (
<Container>
<MenuCard
Expand Down

0 comments on commit d70fa17

Please sign in to comment.