feat: favorite & watch lists
This commit is contained in:
1 parent
960a7a6242
commit
8858e47d38
51 files changed
+561
-290
No files matched your search
@@ -2,5 +2,6 @@ export const paths = [
|
||||
{ path: '/', title: 'Random' },
|
||||
{ path: '/popular', title: 'Popular' },
|
||||
{ path: '/top', title: 'Top rated' },
|
||||
{ path: '/favorites', title: 'Favorites' }
|
||||
{ path: '/favorites', title: 'Favorites' },
|
||||
{ path: '/watch-list', title: 'Watch list' }
|
||||
];
|
||||
@@ -1,6 +1,6 @@
|
||||
'use client';
|
||||
|
||||
import { LogIn,LogOut, User as UserIcon, UserRound } from 'lucide-react';
|
||||
import { LogIn, LogOut, User as UserIcon, UserRound } from 'lucide-react';
|
||||
|
||||
import { Button } from '@/components/ui/button';
|
||||
import {
|
||||
@@ -11,8 +11,8 @@ import {
|
||||
DropdownMenuSeparator,
|
||||
DropdownMenuTrigger
|
||||
} from '@/components/ui/dropdown-menu';
|
||||
import useAccount from '@/hooks/useAccount';
|
||||
|
||||
import useAccount from './useAccount';
|
||||
import useAuth from './useAuth';
|
||||
import useLogOut from './useLogOut';
|
||||
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
import { useQuery, useQueryClient } from '@tanstack/react-query';
|
||||
|
||||
import { account } from '@/api';
|
||||
import { useSession } from '@/hooks/useSession';
|
||||
|
||||
const KEY = ['account'];
|
||||
|
||||
const useAccount = () => {
|
||||
const queryClient = useQueryClient();
|
||||
const session = useSession();
|
||||
|
||||
const query = useQuery({
|
||||
enabled: Boolean(session),
|
||||
staleTime: Infinity,
|
||||
notifyOnChangeProps: ['data'],
|
||||
queryKey: KEY,
|
||||
queryFn: () => account()
|
||||
});
|
||||
|
||||
if (session === null) {
|
||||
queryClient.removeQueries({ queryKey: KEY });
|
||||
queryClient.resetQueries({ queryKey: KEY });
|
||||
}
|
||||
|
||||
return session ? query.data : undefined;
|
||||
};
|
||||
|
||||
export default useAccount;
|
||||
@@ -16,7 +16,7 @@ interface Props {
|
||||
const Header: FC<Props> = ({ className }) => (
|
||||
<header
|
||||
className={cn(
|
||||
'flex justify-center bg-background/95 py-2 backdrop-blur supports-[backdrop-filter]:bg-background/60',
|
||||
'flex justify-center bg-background/95 md:py-2 py-1 backdrop-blur supports-[backdrop-filter]:bg-background/60',
|
||||
className
|
||||
)}
|
||||
>
|
||||
|
||||
Reference in new issue
Block a user