This commit is contained in:
@@ -4,7 +4,10 @@ import { useSidebar } from "@/context/SidebarContext";
|
|||||||
import AppHeader from "@/layout/AppHeader";
|
import AppHeader from "@/layout/AppHeader";
|
||||||
import AppSidebar from "@/layout/AppSidebar";
|
import AppSidebar from "@/layout/AppSidebar";
|
||||||
import Backdrop from "@/layout/Backdrop";
|
import Backdrop from "@/layout/Backdrop";
|
||||||
import React from "react";
|
import { apiGetCurrentUser } from "@/service/auth";
|
||||||
|
import { setUserData } from "@/store/features/userSlice";
|
||||||
|
import React, { useEffect } from "react";
|
||||||
|
import { useDispatch } from "react-redux";
|
||||||
|
|
||||||
export default function AdminLayout({
|
export default function AdminLayout({
|
||||||
children,
|
children,
|
||||||
@@ -12,13 +15,27 @@ export default function AdminLayout({
|
|||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
}) {
|
}) {
|
||||||
const { isExpanded, isHovered, isMobileOpen } = useSidebar();
|
const { isExpanded, isHovered, isMobileOpen } = useSidebar();
|
||||||
|
const dispatch = useDispatch()
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const fetchUser = async () => {
|
||||||
|
try {
|
||||||
|
const userData = await apiGetCurrentUser();
|
||||||
|
dispatch(setUserData(userData.data));
|
||||||
|
} catch (err) {
|
||||||
|
console.error("Lỗi:", err);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
fetchUser();
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
|
||||||
// Dynamic class for main content margin based on sidebar state
|
// Dynamic class for main content margin based on sidebar state
|
||||||
const mainContentMargin = isMobileOpen
|
const mainContentMargin = isMobileOpen
|
||||||
? "ml-0"
|
? "ml-0"
|
||||||
: isExpanded || isHovered
|
: isExpanded || isHovered
|
||||||
? "lg:ml-[290px]"
|
? "lg:ml-[290px]"
|
||||||
: "lg:ml-[90px]";
|
: "lg:ml-[90px]";
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="min-h-screen xl:flex">
|
<div className="min-h-screen xl:flex">
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ export default function SignInForm() {
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<div className="grid grid-cols-1 gap-3 sm:grid-cols-2 sm:gap-5">
|
<div className="grid grid-cols-1 gap-3 sm:gap-5">
|
||||||
<button
|
<button
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
const redirectUrl = HOME_URL;
|
const redirectUrl = HOME_URL;
|
||||||
@@ -143,19 +143,6 @@ export default function SignInForm() {
|
|||||||
</svg>
|
</svg>
|
||||||
Sign in with Google
|
Sign in with Google
|
||||||
</button>
|
</button>
|
||||||
{/* <button className="inline-flex items-center justify-center gap-3 py-3 text-sm font-normal text-gray-700 transition-colors bg-gray-100 rounded-lg px-7 hover:bg-gray-200 hover:text-gray-800 dark:bg-white/5 dark:text-white/90 dark:hover:bg-white/10">
|
|
||||||
<svg
|
|
||||||
width="21"
|
|
||||||
className="fill-current"
|
|
||||||
height="20"
|
|
||||||
viewBox="0 0 21 20"
|
|
||||||
fill="none"
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
>
|
|
||||||
<path d="M15.6705 1.875H18.4272L12.4047 8.75833L19.4897 18.125H13.9422L9.59717 12.4442L4.62554 18.125H1.86721L8.30887 10.7625L1.51221 1.875H7.20054L11.128 7.0675L15.6705 1.875ZM14.703 16.475H16.2305L6.37054 3.43833H4.73137L14.703 16.475Z" />
|
|
||||||
</svg>
|
|
||||||
Sign in with X
|
|
||||||
</button> */}
|
|
||||||
</div>
|
</div>
|
||||||
<div className="relative py-3 sm:py-5">
|
<div className="relative py-3 sm:py-5">
|
||||||
<div className="absolute inset-0 flex items-center">
|
<div className="absolute inset-0 flex items-center">
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ export default function SignUpForm() {
|
|||||||
|
|
||||||
{step === 1 && (
|
{step === 1 && (
|
||||||
<>
|
<>
|
||||||
<div className="grid grid-cols-1 gap-3 sm:grid-cols-2 sm:gap-5">
|
<div className="grid grid-cols-1 gap-3 sm:gap-5">
|
||||||
<button
|
<button
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
const redirectUrl = HOME_URL;
|
const redirectUrl = HOME_URL;
|
||||||
@@ -184,9 +184,6 @@ export default function SignUpForm() {
|
|||||||
</svg>
|
</svg>
|
||||||
Sign up with Google
|
Sign up with Google
|
||||||
</button>
|
</button>
|
||||||
{/* <button className="inline-flex items-center justify-center gap-3 py-3 text-sm font-normal text-gray-700 transition-colors bg-gray-100 rounded-lg px-7 hover:bg-gray-200 hover:text-gray-800 dark:bg-white/5 dark:text-white/90 dark:hover:bg-white/10">
|
|
||||||
Sign up with X
|
|
||||||
</button> */}
|
|
||||||
</div>
|
</div>
|
||||||
<div className="relative py-3 sm:py-5">
|
<div className="relative py-3 sm:py-5">
|
||||||
<div className="absolute inset-0 flex items-center">
|
<div className="absolute inset-0 flex items-center">
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
"use client";
|
"use client";
|
||||||
import { apiGetCurrentUser } from "@/service/auth";
|
|
||||||
import { setUserData } from "@/store/features/userSlice";
|
|
||||||
import React, { createContext, useContext, useState, useEffect } from "react";
|
import React, { createContext, useContext, useState, useEffect } from "react";
|
||||||
import { useDispatch } from "react-redux";
|
|
||||||
|
|
||||||
type SidebarContextType = {
|
type SidebarContextType = {
|
||||||
isExpanded: boolean;
|
isExpanded: boolean;
|
||||||
@@ -36,7 +33,6 @@ export const SidebarProvider: React.FC<{ children: React.ReactNode }> = ({
|
|||||||
const [isHovered, setIsHovered] = useState(false);
|
const [isHovered, setIsHovered] = useState(false);
|
||||||
const [activeItem, setActiveItem] = useState<string | null>(null);
|
const [activeItem, setActiveItem] = useState<string | null>(null);
|
||||||
const [openSubmenu, setOpenSubmenu] = useState<string | null>(null);
|
const [openSubmenu, setOpenSubmenu] = useState<string | null>(null);
|
||||||
const dispatch = useDispatch();
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const handleResize = () => {
|
const handleResize = () => {
|
||||||
@@ -55,17 +51,6 @@ export const SidebarProvider: React.FC<{ children: React.ReactNode }> = ({
|
|||||||
};
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const fetchUser = async () => {
|
|
||||||
try {
|
|
||||||
const userData = await apiGetCurrentUser();
|
|
||||||
dispatch(setUserData(userData.data));
|
|
||||||
} catch (err) {
|
|
||||||
console.error("Lỗi:", err);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
fetchUser();
|
|
||||||
}, [])
|
|
||||||
|
|
||||||
const toggleSidebar = () => {
|
const toggleSidebar = () => {
|
||||||
setIsExpanded((prev) => !prev);
|
setIsExpanded((prev) => !prev);
|
||||||
|
|||||||
Reference in New Issue
Block a user