removed unsused zustand store
This commit is contained in:
parent
1f8a6b18df
commit
cca250b275
|
@ -17,25 +17,11 @@ import { NavPreMain } from "./navigations/nav-pre-main";
|
||||||
import { navData } from "@/prisma/data/nav";
|
import { navData } from "@/prisma/data/nav";
|
||||||
import { TeamSwitcher } from "../../../_components/team-switcher";
|
import { TeamSwitcher } from "../../../_components/team-switcher";
|
||||||
import { useGetCurrentUserQuery } from "../dashboard/user-management/_queries/queries";
|
import { useGetCurrentUserQuery } from "../dashboard/user-management/_queries/queries";
|
||||||
import { useUserStore } from "@/app/_lib/zustand/stores/user";
|
|
||||||
import { useUserActionsHandler } from "../dashboard/user-management/_handlers/actions/use-user-actions";
|
import { useUserActionsHandler } from "../dashboard/user-management/_handlers/actions/use-user-actions";
|
||||||
|
|
||||||
|
|
||||||
export function AppSidebar({ ...props }: React.ComponentProps<typeof Sidebar>) {
|
export function AppSidebar({ ...props }: React.ComponentProps<typeof Sidebar>) {
|
||||||
const { data: user, isPending, error } = useGetCurrentUserQuery()
|
|
||||||
|
|
||||||
const { setUser, setIsPending } = useUserStore();
|
|
||||||
|
|
||||||
// Set pending state
|
|
||||||
useEffect(() => {
|
|
||||||
setIsPending(isPending);
|
|
||||||
}, [isPending, setIsPending]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (user) {
|
|
||||||
setUser(user);
|
|
||||||
}
|
|
||||||
}, [user, setUser]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Sidebar collapsible="icon" {...props}>
|
<Sidebar collapsible="icon" {...props}>
|
||||||
|
|
|
@ -30,7 +30,7 @@ import { SettingsDialog } from "../settings/setting-dialog";
|
||||||
import { AlertDialog, AlertDialogTrigger, AlertDialogContent, AlertDialogHeader, AlertDialogFooter, AlertDialogTitle, AlertDialogDescription, AlertDialogCancel, AlertDialogAction } from "@/app/_components/ui/alert-dialog";
|
import { AlertDialog, AlertDialogTrigger, AlertDialogContent, AlertDialogHeader, AlertDialogFooter, AlertDialogTitle, AlertDialogDescription, AlertDialogCancel, AlertDialogAction } from "@/app/_components/ui/alert-dialog";
|
||||||
import { useSignOutHandler } from "@/app/(pages)/(auth)/_handlers/use-sign-out";
|
import { useSignOutHandler } from "@/app/(pages)/(auth)/_handlers/use-sign-out";
|
||||||
import { useGetCurrentUserQuery } from "../../dashboard/user-management/_queries/queries";
|
import { useGetCurrentUserQuery } from "../../dashboard/user-management/_queries/queries";
|
||||||
import { useUserStore } from "@/app/_lib/zustand/stores/user";
|
|
||||||
|
|
||||||
interface NavUserProps {
|
interface NavUserProps {
|
||||||
user: IUserSchema | null;
|
user: IUserSchema | null;
|
||||||
|
@ -39,7 +39,7 @@ interface NavUserProps {
|
||||||
|
|
||||||
export function NavUser() {
|
export function NavUser() {
|
||||||
|
|
||||||
const { user, isPending } = useUserStore()
|
const { data: user, isPending } = useGetCurrentUserQuery();
|
||||||
|
|
||||||
const { isMobile } = useSidebar();
|
const { isMobile } = useSidebar();
|
||||||
const [isDialogOpen, setIsDialogOpen] = useState(false);
|
const [isDialogOpen, setIsDialogOpen] = useState(false);
|
||||||
|
|
|
@ -1,18 +1,3 @@
|
||||||
import { IUserSchema } from "@/src/entities/models/users/users.model";
|
import { IUserSchema } from "@/src/entities/models/users/users.model";
|
||||||
import { create } from "zustand";
|
import { create } from "zustand";
|
||||||
|
|
||||||
interface UserState {
|
|
||||||
user: IUserSchema | null;
|
|
||||||
isPending: boolean;
|
|
||||||
setUser: (user: IUserSchema | null) => void;
|
|
||||||
setIsPending: (isPending: boolean) => void;
|
|
||||||
logout: () => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const useUserStore = create<UserState>((set) => ({
|
|
||||||
user: null,
|
|
||||||
isPending: false,
|
|
||||||
setUser: (user) => set({ user }),
|
|
||||||
setIsPending: (isPending) => set({ isPending }),
|
|
||||||
logout: () => set({ user: null, isPending: false }),
|
|
||||||
}));
|
|
Loading…
Reference in New Issue