Skip to content

Commit

Permalink
feat(AAiT.web.g1): Added toast and glass navbar
Browse files Browse the repository at this point in the history
  • Loading branch information
Son-OfAnton committed Sep 2, 2023
1 parent 90f9ea7 commit 967a9d9
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 14 deletions.
2 changes: 1 addition & 1 deletion aait/web/group-1/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { Metadata } from "next";
import { Poppins } from "next/font/google";
import { NavBar } from "@/components/layout/NavBar";

import { ToastContainer } from 'react-toastify'
import { ToastContainer } from "react-toastify";
import 'react-toastify/dist/ReactToastify.css'

const inter = Poppins({
Expand Down
5 changes: 3 additions & 2 deletions aait/web/group-1/app/profile/account/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import React, { useState } from 'react';
import Image from 'next/image';
import { useChangePasswordMutation } from '@/store/features/user/userApi';

import { toast } from 'react-toastify';

export default function Page() {
const [changePassword] = useChangePasswordMutation()
Expand All @@ -13,10 +13,11 @@ export default function Page() {

const handleSaveChanges = () => {
if(newPassword !== confirmPass) {
window.alert("Password don't match")
toast.error('Passwords are not matching')
return
}
changePassword({"oldPassword": oldPassword, "newPassword": newPassword})
toast.success("Password changed successfuly")

}

Expand Down
40 changes: 29 additions & 11 deletions aait/web/group-1/components/layout/NavBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ interface NavItems {
export const NavBar = () => {
const router = useRouter()
const [isMenuToggled, setIsMenuToggled] = useState<boolean>(false);
const userData = localStorage.getItem('user');
const currUser = userData ? JSON.parse(userData) : null;

const navItems: NavItems[] = [
{
Expand Down Expand Up @@ -61,13 +63,19 @@ export const NavBar = () => {

{/* login signup section */}
<div className="flex gap-2">
<Link href={'/signin'} className="btn">Login</Link>
<button
className="btn bg-blue-800 text-white"
onClick={() => router.push('/profile')}
>
Profile
</button>
<Link href="/signin" className="btn">Login</Link>
<Link href="/profile">
<div className="relative rounded-full w-10 h-10">
<Image
src={currUser ? currUser.userProfile: "https://res.cloudinary.com/djtkzulun/image/upload/v1684307248/Portfolio/dgxjqlgpys1imwnw2bhq"}
alt="User Avatar"
layout="fill"
objectFit="cover"
className="rounded-full"
/>
</div>
</Link>

</div>
</div>

Expand All @@ -80,17 +88,27 @@ export const NavBar = () => {

<div className="flex flex-col items-end relative">
<button onClick={() => setIsMenuToggled(!isMenuToggled)}>
<Image src={"./images/burger.svg"} alt="" width={40} height={40} />
<img src="./images/burger.svg" className="w-10 h-10" />
</button>

{/* Navigation section */}
{isMenuToggled && (
<div className="flex flex-col w-36 items-center space-y-1 absolute top-10 right-0 bg-blue-100 shadow-lg">
<div className="flex flex-col w-36 items-center space-y-1 absolute top-10 right-0 bg-opacity-30 backdrop-blur-sm bg-white border border-opacity-20 border-gray-200 rounded-lg shadow-lg">
<Link href="/profile">
<div className="relative rounded-full w-10 h-10">
<Image
src={currUser ? currUser.userProfile: "https://res.cloudinary.com/djtkzulun/image/upload/v1684307248/Portfolio/dgxjqlgpys1imwnw2bhq"}
alt="User Avatar"
layout="fill"
objectFit="cover"
className="rounded-full"
/>
</div>
</Link>
{navItems.map((nav: NavItems) => (
<LinkItems key={nav.name} name={nav.name} link={nav.link} />
))}
<button className="btn">Login</button>
<button className="btn">Donate</button>
<Link className="btn" href="/signin">Login</Link>
</div>
)}
</div>
Expand Down

0 comments on commit 967a9d9

Please sign in to comment.