Skip to content

Commit

Permalink
Done changes
Browse files Browse the repository at this point in the history
I hv done the changes and only used Tailwind CSS
RamakrushnaBiswal#66
  • Loading branch information
maitri-vv committed Oct 8, 2024
1 parent e857ce6 commit 8b68c29
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 26 deletions.
13 changes: 12 additions & 1 deletion frontend/src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,15 @@ body,

body{
background: #F1EADC;
}
}


@keyframes bounce {
0%, 100% {
transform: translateY(0);
}
50% {
transform: translateY(-10px);
}
}

36 changes: 21 additions & 15 deletions frontend/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

import './App.css';
import Navbar from '../src/components/Shared/Navbar';
import Footer from "../src/components/Shared/Footer"
import Footer from "../src/components/Shared/Footer";
import { Outlet } from 'react-router-dom';

import {KindeProvider} from "@kinde-oss/kinde-auth-react";
import React, { useState, useEffect } from 'react';
import { KindeProvider } from "@kinde-oss/kinde-auth-react";

function App() {
const [showButton, setShowButton] = useState(false);
Expand All @@ -28,18 +28,24 @@ function App() {

return (
<KindeProvider
clientId={import.meta.env.VITE_KINDE_CLIENT_ID}
domain={import.meta.env.VITE_KINDE_DOMAIN}
redirectUri={import.meta.env.VITE_KINDE_REDIRECT_URI}
logoutUri={import.meta.env.VITE_KINDE_LOGOUT_REDIRECT_URI}
>
<Navbar />
<Outlet />
<Footer />
</KindeProvider>


clientId={import.meta.env.VITE_KINDE_CLIENT_ID}
domain={import.meta.env.VITE_KINDE_DOMAIN}
redirectUri={import.meta.env.VITE_KINDE_REDIRECT_URI}
logoutUri={import.meta.env.VITE_KINDE_LOGOUT_REDIRECT_URI}
>
<Navbar />
<Outlet />
<Footer />

{showButton && (
<button
onClick={scrollToTop}
className="fixed bottom-8 right-8 bg-[#E0F0B1] hover:bg-amber-300 text-white font-bold py-2 px-4 rounded-full shadow-lg transition-transform duration-300 transform hover:scale-110" >
</button>
)}
</KindeProvider>
);
}

export default App;
export default App;
20 changes: 10 additions & 10 deletions frontend/src/components/Shared/Navbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ const Navbar = () => {
const [isMenuOpen, setIsMenuOpen] = useState(false);
const location = useLocation();
const wasAuthenticated = useRef(null);
const { setEmail } = useAuth();

// Get setEmail from useAuth, or fallback to an empty object if useAuth is undefined
const { setEmail } = useAuth() || {};

const menuItems = [
{ name: "Home", path: "/" },
Expand Down Expand Up @@ -44,7 +46,6 @@ const Navbar = () => {
}
if (!wasAuthenticated.current && isAuthenticated) {
message.success("Login successful!");
// Fetch user details only when authentication is successful
fetchUserDetails();
}
wasAuthenticated.current = isAuthenticated;
Expand All @@ -53,8 +54,8 @@ const Navbar = () => {
const fetchUserDetails = async () => {
try {
const user = getUser();
if (user) {
setEmail(user.email); // Store email in the context
if (user && setEmail) {
setEmail(user.email); // Only call setEmail if it's defined
console.log("User email:", user.email);
}
} catch (error) {
Expand Down Expand Up @@ -92,7 +93,7 @@ const Navbar = () => {
const handleLogout = async () => {
try {
await logout();
setEmail(null);
if (setEmail) setEmail(null);
} catch (error) {
message.error("Logout failed. Please try again.");
}
Expand Down Expand Up @@ -127,7 +128,6 @@ const Navbar = () => {
))}
{isAuthenticated ? (
<button

onClick={handleLogout}
className={`${baseTextColorClass} ${hoverTextColorClass} transform hover:scale-110 hover:-translate-y-1 transition `}
type="button"
Expand Down Expand Up @@ -184,7 +184,7 @@ const Navbar = () => {
key={item.name}
to={item.path}
className={`block px-4 py-3 rounded-md text-base font-semibold transition duration-300
${mobileMenuBaseTextColorClass} hover:bg-amber-300 hover:text-black`}
${mobileMenuBaseTextColorClass} hover:bg-amber-300 hover:text-black`}
>
{item.name}
</Link>
Expand All @@ -193,15 +193,15 @@ const Navbar = () => {
<button
onClick={handleLogout}
className={`block w-full text-left px-4 py-3 rounded-md text-base font-semibold transition duration-300
${mobileMenuBaseTextColorClass} hover:bg-amber-300 hover:text-black`}
${mobileMenuBaseTextColorClass} hover:bg-amber-300 hover:text-black`}
>
Log Out
</button>
) : (
<button
onClick={handleLogin}
className={`block w-full text-left px-4 py-3 rounded-md text-base font-semibold transition duration-300
${mobileMenuBaseTextColorClass} hover:bg-amber-300 hover:text-black`}
${mobileMenuBaseTextColorClass} hover:bg-amber-300 hover:text-black`}
>
Log In
</button>
Expand All @@ -213,4 +213,4 @@ const Navbar = () => {
);
};

export default Navbar;
export default Navbar;

0 comments on commit 8b68c29

Please sign in to comment.