Skip to content

Commit

Permalink
Merge pull request #95 from WSU-4110/Ragad
Browse files Browse the repository at this point in the history
Ragad
  • Loading branch information
ragadalh authored Nov 19, 2024
2 parents 611148e + d3904a8 commit 3cefa44
Show file tree
Hide file tree
Showing 11 changed files with 245 additions and 46 deletions.
1 change: 1 addition & 0 deletions src/app/artistlogin/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export default function Login() {
// Authenticate using email and password
await signInWithEmailAndPassword(auth, email, password);
// Redirect to portfolio page after successful login
localStorage.setItem('role', 'artist');
router.push('/portfolio');
} catch (error) {
// Display error message if authentication fails
Expand Down
31 changes: 31 additions & 0 deletions src/app/barber/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
'use client';
import React from 'react';
import '../categories.css';
import Card from '../components/ui/card';

export default function BarberShops() {
const businesses: any[] = [];

return (
<div className="container">
<h1 className="title">Barber Shops</h1>
<div className="list">
{businesses.length > 0 ? (
businesses.map((business, index) => (
<Card
key={index}
businessName={business.businessName}
address={business.address}
images={business.images}
about={business.about}
services={business.services}
socialLinks={business.socialLinks}
/>
))
) : (
<p>No businesses available. Please check back later!</p>
)}
</div>
</div>
);
}
4 changes: 2 additions & 2 deletions src/app/clients/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import { useRouter } from 'next/navigation';
import React from 'react';
import Nav_bar from '../components/navbar_artist';
import Navbar from '../components/navigationbar';

const Clients: React.FC = () => {
const router = useRouter();
Expand All @@ -19,7 +19,7 @@ const Clients: React.FC = () => {

return (
<div className="min-h-screen bg-gray">
<Nav_bar />
<Navbar />
<header className="text-black py-7 text-left mt-19">
<h1 className="text-3xl text-center font-bold tracking-wide text-teal-500">Daves Barbershop</h1>
<h2 className="text-4xl text-center tracking-wide mt-2">Upcoming Bookings</h2>
Expand Down
86 changes: 59 additions & 27 deletions src/app/components/navbar_artist.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,59 @@
'use client'

import React from 'react';
import './navbar_artist.css';
import { useRouter } from 'next/navigation';

export default function Nav_bar() {
const router = useRouter();

const handlelogout = () => {
localStorage.removeItem('authToken');
alert('Logging out');
router.push('/');
}

return (
<nav className="navigation">
<ul>
<li><button onClick={() => router.push('/homepage')}>Home</button></li>
<li><button onClick={() => router.push('/portfolio')}>Portfolio</button></li>
<li><button onClick={() => router.push('/clients')}>Clients</button></li>
<li><button onClick={() => router.push('/helppage')}>Help</button></li>
<li><button onClick={handlelogout}>Log Out</button></li>
</ul>
</nav>
);
}
//'use client'

//import React, { useState, useEffect } from 'react';
//import './navbar_artist.css';
//import { useRouter } from 'next/navigation';
//import { auth } from '../firebase';

//export default function NavbarArtist() {
// const router = useRouter();
// const [user, setUser] = useState(null);
// const [role, setRole] = useState('');
// const [isLoading, setIsLoading] = useState(true);

// useEffect(() => {
// const userRole = localStorage.getItem('role');
// setRole(userRole || '');

// const unsubscribe = auth.onAuthStateChanged((currentUser) => {
// setUser(currentUser);
// setIsLoading(false);
// });

// return () => unsubscribe();
// }, []);

// const handleLogout = () => {
// localStorage.removeItem('role');
// auth.signOut();
// alert('Logging out');
// router.push('/');
// };

// if (isLoading) {
// return null;
// }

// if (role !== 'artist') {
// return null;
// }

// return (
// <nav className="navigation">
// <ul>
// <li><button onClick={() => router.push('/homepage')}>Home</button></li>
// <li><button onClick={() => router.push('/portfolio')}>Portfolio</button></li>
// <li><button onClick={() => router.push('/clients')}>Clients</button></li>
// <li><button onClick={() => router.push('/helppage')}>Help</button></li>
// {user ? (
// <>
// <li>Welcome, {user.displayName || user.email}</li>
// <li><button onClick={handleLogout}>Log Out</button></li>
// </>
// ) : (
// <li><button onClick={() => router.push('/artistlogin')}>Log In</button></li>
// )}
// </ul>
// </nav>
// );
//}
2 changes: 1 addition & 1 deletion src/app/components/navigationbar.css
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@
}

.navigation button:hover {
color: #f3cf9a;
color: #a7a39e;
}

88 changes: 77 additions & 11 deletions src/app/components/navigationbar.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,93 @@
'use client'
'use client';

import React from 'react';
import './navigationbar.css';
import React, { useState, useEffect } from 'react';
import { useRouter } from 'next/navigation';
import { auth } from '../firebase';
import './navigationbar.css';

export default function Navbar() {
const router = useRouter();
const [user, setUser] = useState<any>(null);
const [role, setRole] = useState<string>('');
const [isLoading, setIsLoading] = useState(true);
const [isAuthChecked, setIsAuthChecked] = useState(false);

useEffect(() => {
if (typeof window !== 'undefined') {
const userRole = localStorage.getItem('role');
setRole(userRole || '');
}
const unsubscribe = auth.onAuthStateChanged((currentUser) => {
setUser(currentUser);
setIsLoading(false);
setIsAuthChecked(true);
});

const handlelogout = () => {
localStorage.removeItem('authToken');
return () => unsubscribe();
}, []);
const handleLogout = () => {
localStorage.removeItem('role');
auth.signOut();
alert('Logging out');
router.push('/');
};
if (isLoading || !isAuthChecked) {
return null;
}

return (
<nav className="navigation">
<ul>
<li><button onClick={() => router.push('/homepage')}>Home</button></li>
<li><button onClick={() => router.push('/appointments')}>Appointments</button></li>
<li><button onClick={() => router.push('/userprofile')}>Profile</button></li>
<li><button onClick={() => router.push('/helppage')}>Help</button></li>
<li><button onClick={handlelogout}>Log Out</button></li>
<li>
<button onClick={() => router.push('/homepage')}>Home</button>
</li>

{role === 'artist' && (
<>
<li>
<button onClick={() => router.push('/portfolio')}>Portfolio</button>
</li>
<li>
<button onClick={() => router.push('/clients')}>Clients</button>
</li>
</>
)}

{role === 'customer' && (
<>
<li>
<button onClick={() => router.push('/appointments')}>Appointments</button>
</li>
<li>
<button onClick={() => router.push('/userprofile')}>Profile</button>
</li>
</>
)}

<li>
<button onClick={() => router.push('/helppage')}>Help</button>
</li>

{user ? (
<>
<li>
<button onClick={handleLogout}>Log Out</button>
</li>
</>
) : (
<li>
<button
onClick={() => {
role === 'artist'
? router.push('/artistlogin')
: router.push('/customerlogin');
}}
>
Log In
</button>
</li>
)}
</ul>
</nav>
);
}
}
1 change: 1 addition & 0 deletions src/app/customerlogin/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export default function CustomerLogin() {
// Authenticate using email and password
await signInWithEmailAndPassword(auth, email, password);
// Redirect to user profile page after successful login
localStorage.setItem('role', 'customer');
router.push('/userprofile');
} catch (error) {
// Display error message if authentication fails
Expand Down
31 changes: 31 additions & 0 deletions src/app/hair/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
'use client';
import React from 'react';
import '../categories.css';
import Card from '../components/ui/card';

export default function HairStylists() {
const businesses: any[] = [];

return (
<div className="container">
<h1 className="title">Hair Stylists</h1>
<div className="list">
{businesses.length > 0 ? (
businesses.map((business, index) => (
<Card
key={index}
businessName={business.businessName}
address={business.address}
images={business.images}
about={business.about}
services={business.services}
socialLinks={business.socialLinks}
/>
))
) : (
<p>No businesses available. Please check back later!</p>
)}
</div>
</div>
);
}
12 changes: 9 additions & 3 deletions src/app/homepage/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,23 +164,29 @@ export default function Home() {
<Image src={hairLogo} alt="Hair Stylists" width={40} height={40} />
</div>
<div className="text-container mt-2 opacity-0 group-hover:opacity-100 transition-opacity duration-300">
<a href="/hair" className="text-lg hover:text-teal-400">Hair Stylists</a>
<button onClick={() => router.push('/hair')} className="text-lg hover:text-teal-400">
Hair Stylists
</button>
</div>
</li>
<li className="sidebar-item mb-4 flex flex-col items-center group">
<div className="logo-container">
<Image src={tattooLogo} alt="Tattoo Artist" width={40} height={40} />
</div>
<div className="text-container mt-2 opacity-0 group-hover:opacity-100 transition-opacity duration-300">
<a href="/tattoo" className="text-lg hover:text-teal-400">Tattoo Artist</a>
<button onClick={() => router.push('/tattoo')} className="text-lg hover:text-teal-400">
Tattoo Artists
</button>
</div>
</li>
<li className="sidebar-item mb-4 flex flex-col items-center group">
<div className="logo-container">
<Image src={barberLogo} alt="Barber Shops" width={40} height={40} />
</div>
<div className="text-container mt-2 opacity-0 group-hover:opacity-100 transition-opacity duration-300">
<a href="/barber" className="text-lg hover:text-teal-400">Barber Shops</a>
<button onClick={() => router.push('/barber')} className="text-lg hover:text-teal-400">
Barber Shops
</button>
</div>
</li>
<li className="sidebar-item mb-4 flex flex-col items-center group">
Expand Down
4 changes: 2 additions & 2 deletions src/app/portfolio/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import React, { useRef, useState } from 'react';
import { useRouter } from 'next/navigation';
import './portfolio.css';
import Nav_bar from '../components/navbar_artist';
import Navbar from '../components/navigationbar';
import SocialMediaInput from '../components/socialmediainput'; // Default import (no curly braces)

export default function Portfolio() {
Expand Down Expand Up @@ -133,7 +133,7 @@ export default function Portfolio() {

return (
<div className="container">
<Nav_bar />
<Navbar />
<div className="business-name">
<input
type="text"
Expand Down
31 changes: 31 additions & 0 deletions src/app/tattoo/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
'use client';
import React from 'react';
import '../categories.css';
import Card from '../components/ui/card';

export default function TattooPage() {
const businesses: any[] = [];

return (
<div className="container">
<h1 className="title">Tattoo Artists</h1>
<div className="list">
{businesses.length > 0 ? (
businesses.map((business, index) => (
<Card
key={index}
businessName={business.businessName}
address={business.address}
images={business.images}
about={business.about}
services={business.services}
socialLinks={business.socialLinks}
/>
))
) : (
<p>No businesses available. Please check back later!</p>
)}
</div>
</div>
);
}

0 comments on commit 3cefa44

Please sign in to comment.