Skip to content

Commit

Permalink
Merge branch 'dev' into product-card-size
Browse files Browse the repository at this point in the history
  • Loading branch information
pooranjoyb authored Jul 28, 2024
2 parents abd6a83 + b87f4f5 commit db67016
Show file tree
Hide file tree
Showing 13 changed files with 410 additions and 81 deletions.
13 changes: 12 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"react-loading-skeleton": "^3.4.0",
"react-redux": "^9.1.2",
"react-router-dom": "^6.22.1",
"react-tilt": "^1.0.2",
"react-toastify": "^10.0.5",
"redux-persist": "^6.0.0",
"redux-persist-transform-encrypt": "^5.1.1",
Expand Down
25 changes: 25 additions & 0 deletions react-tilt.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
declare module 'react-tilt' {
import * as React from 'react';

interface TiltOptions {
reverse?: boolean;
max?: number;
perspective?: number;
scale?: number;
speed?: number;
transition?: boolean;
axis?: null | 'x' | 'y';
reset?: boolean;
easing?: string;
}

interface TiltProps {
options?: TiltOptions;
className?: string;
style?: React.CSSProperties;
children?: React.ReactNode; // Add this line to include the children property
}

export const Tilt: React.FC<TiltProps>;
}

12 changes: 6 additions & 6 deletions src/admin/AdminLayout/AdminLayout.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import React from "react";
import { Outlet } from "react-router-dom";
import Sidebar from "./Sidebar";
import '../admin.css'
import AdminNavbar from "./AdminNavbar";

const AdminLayout: React.FC = () => {
return (
<>
<div className="relative z-10">
<AdminNavbar />
</div>
<div className="flex">
<Sidebar />
<div className="p-8 flex flex-col w-full">
<span className="text-2xl font-bold">
Welcome to SuperAdmin Portal!
</span>
<div className="dashboard p-8 flex flex-col w-full lg::absolute">
<Outlet />
</div>
</div>
Expand Down
196 changes: 196 additions & 0 deletions src/admin/AdminLayout/AdminNavbar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
import { useState } from "react";
import { Link } from "react-router-dom";
import { useDispatch, useSelector } from "react-redux";
import { Slide, toast } from "react-toastify";
import { adminLoggedOut } from "../../utils/features/Auth/authSlice";
import { RootState } from "../../utils/features/store";
import { motion, useMotionValueEvent, useScroll } from "framer-motion";


function AdminNavbar() {
const userName = useSelector((state: RootState) => state.auth.user?.username);
const dispatch = useDispatch();
const [showMenu, setShowMenu] = useState(false);
const [showHamburgerMenu, setShowHamburgerMenu] = useState(false);

const toastNotification = (message: string) => {
toast(message, {
position: "top-right",
autoClose: 5000,
closeOnClick: true,
pauseOnHover: false,
transition: Slide,
});
};

const handleToggleMenu = () => {
setShowMenu((prev) => !prev);
};

const handleCloseMenu = () => {
setShowMenu(false);
};

const handleToggleHamburgerMenu = () => {
setShowHamburgerMenu((prev) => !prev);
};


function logoutAdmin() {
dispatch(adminLoggedOut());
}

const { scrollY } = useScroll();
const [hidden, setHidden] = useState(false);

useMotionValueEvent(scrollY, "change", (latest) => {
const previous = scrollY.getPrevious();
if (previous && latest > previous && latest > 80) {
setHidden(true);
} else {
setHidden(false);
}
});

return (
<>
<div className="navbar flex justify-between bg-base-100 p-4">
<div className="flex md:ml-16 ml-2">
<Link to="/admin">
<img
src="/logo.png"
alt="Admin Logo"
className="md:w-36 w-20 duration-100"
/>
</Link>
</div>

<div className="hidden lg:flex justify-center z-[100]">
<motion.div
variants={{
visible: { y: 0 },
Hidden: { y: "-200%" },
}}
animate={hidden ? "Hidden" : "visible"}
transition={{ duration: 0.3, ease: "easeInOut" }}
className="navbar rounded-3xl fixed top-4 w-auto flex justify-center backdrop-filter backdrop-blur-md shadow-2xl max-w-screen-xl"
>
<ul className="flex justify-between px-12">
<a href="/admin">
<li className="hover:scale-105 duration-75 text-sm hover:font-semibold px-4 rounded-full">
Dashboard
</li>
</a>
<a href="/admin/order">
<li className="hover:scale-105 duration-75 text-sm hover:font-semibold px-4 rounded-full">
Orders
</li>
</a>
<a href="/admin/transaction">
<li className="hover:scale-105 duration-75 text-sm hover:font-semibold px-4 rounded-full">
Transactions
</li>
</a>
<a href="/admin/add-product">
<li className="hover:scale-105 duration-75 text-sm hover:font-semibold px-4 rounded-full">
Add Prdocut
</li>
</a>
</ul>
</motion.div>
</div>

<div className="flex-none gap-6 md:mr-16 mr-2">
<div className="dropdown dropdown-end">
<div
tabIndex={0}
role="button"
className="btn btn-ghost btn-circle avatar"
onClick={handleToggleMenu}
>
<div className="w-10 rounded-full">
<img src={"/images/winter2.jpg"} />
</div>
</div>
{showMenu && (
<ul
tabIndex={0}
className="menu menu-sm dropdown-content mt-3 z-[1] p-2 bg-base-100 rounded-box w-52 shadow-2xl"
>
<li onClick={handleCloseMenu}>
<Link to={"/admin"} className="justify-between">
{`${userName}` || <p>Profile</p>}
</Link>
</li>
<li onClick={() => {
logoutAdmin();
handleCloseMenu();
toastNotification("Logged out successfully!");
}}>
<h1>{<p>Logout</p>}</h1>
</li>
</ul>
)}
</div>
<div className="lg:hidden">
<button
className="btn btn-ghost btn-circle"
onClick={handleToggleHamburgerMenu}
>
<svg
xmlns="http://www.w3.org/2000/svg"
className="h-5 w-5"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
>
<path
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth="2"
d="M4 6h16M4 12h16m-7 6h7"
/>
</svg>
</button>
</div>
</div>
</div>
{showHamburgerMenu && (
<div className="lg:hidden bg-base-100 p-4 shadow-2xl absolute top-16 right-0 w-full">
<ul className="menu menu-compact">
<a href="/admin">
<li className="hover:scale-105 duration-75 text-sm hover:font-semibold px-4 my-2 rounded-full">
Dashboard
</li>
</a>
<a href="/admin/order">
<li className="hover:scale-105 duration-75 text-sm hover:font-semibold px-4 my-2 rounded-full">
Orders
</li>
</a>
<a href="/admin/transaction">
<li className="hover:scale-105 duration-75 text-sm hover:font-semibold px-4 my-2 rounded-full">
Transactions
</li>
</a>
<a href="/admin/add-product">
<li className="hover:scale-105 duration-75 text-sm hover:font-semibold px-4 my-2 rounded-full">
Add Prdocut
</li>
</a>
<li className="hover:scale-105 duration-75 text-sm hover:font-semibold px-4 rounded-full hover:cursor-pointer" onClick={() => {
logoutAdmin();
setShowHamburgerMenu(false);
toastNotification("Logged out successfully!");
}}>

Logout
</li>
</ul>
</div>
)}
</>
);
}

export default AdminNavbar;
11 changes: 1 addition & 10 deletions src/admin/AdminLayout/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,12 @@ function Sidebar() {
Open drawer
</label>
</div>
<div className="drawer-side bg-base-200">
<div className="drawer-side border-r">
<label
htmlFor="my-drawer"
aria-label="close sidebar"
className="drawer-overlay"
></label>
<div className="flex md:ml-16 ml-2">
<Link to="/admin">
<img
src="./logo.png"
alt="PopShop Logo"
className="md:w-36 w-20 duration-100 mt-4 -ml-4"
/>
</Link>
</div>
<ul className="menu bg-white text-lg w-80 p-8">
<li className="pt-1 pb-1">
<Link to='/admin'>
Expand Down
4 changes: 2 additions & 2 deletions src/admin/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ function Dashboard() {
</div>
</div>
<div className="grid grid-cols-1 sm:grid-cols-8 gap-4 mt-4">
<div className="col-span-2 sm:col-span-3 bg-white border border-gray-300 p-4 rounded-lg">
<div className="sm:col-span-3 bg-white border border-gray-300 p-4 rounded-lg">
<h2 className="text-xl font-bold mb-8">Today Orders</h2>
<p className="text-sm mb-2">{currentDate}</p>
<p className="text-3xl font-bold mb-4">$ 450K</p>
Expand Down Expand Up @@ -374,7 +374,7 @@ function Dashboard() {
Online Users
</h2>
</div>
<div className="flex-grow flex flex-col">
<div className="flex-grow flex flex-col overflow-hidden">
<div
className="flex-grow origin-bottom pr-4"
style={{ height: "200px" }}
Expand Down
5 changes: 5 additions & 0 deletions src/admin/admin.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@media screen and (max-width: 768px) {
.dashboard{
position: absolute;
}
}
8 changes: 7 additions & 1 deletion src/components/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { Link } from "react-router-dom";
import axios from 'axios';
import Button from "./Button";
import { supabase } from '../utils/client';
import GoogleTranslateComponent from './GoogleTranslateComponent';


const Socials = () => {
return (
Expand Down Expand Up @@ -85,6 +87,8 @@ const ServicesList = () => {

export default function NewFooter() {
const [email, setEmail] = useState('');
const today = new Date();
const year = today.getFullYear();

const handleSubscribe = async () => {
if (!email) {
Expand Down Expand Up @@ -177,17 +181,19 @@ export default function NewFooter() {
<span>Weekend: 10am - 3pm</span>
</p>
<Socials />
<GoogleTranslateComponent />
</div>
<div className="sm:w-52 grow w-full mx-auto">
<ServicesList />
</div>

</div>
<div className="mt-12 border-t border-gray-100 flex flex-wrap max-sm:text-left items-center justify-between pt-8 space-8 gap-x-8">
<div className="text-xs flex gap-x-4">
<Link to="/home/terms-and-conditions">Terms & Conditions</Link>
</div>
<p className="text-xs text-gray-500">
&copy; 2024. PopShop.com. All rights reserved.
&copy; {year}. PopShop.com. All rights reserved.
</p>
</div>
</div>
Expand Down
Loading

0 comments on commit db67016

Please sign in to comment.