NextJSNetflix/pages/index.tsx

37 lines
812 B
TypeScript
Raw Normal View History

2023-08-18 12:00:58 +00:00
import Billboard from "@/components/Billboard"
import MovieList from "@/components/MovieList"
2023-06-26 14:50:04 +00:00
import Navbar from "@/components/Navbar"
2023-06-04 12:33:10 +00:00
import useCurrentUser from "@/hooks/useCurrentUser"
2023-08-18 12:00:58 +00:00
import useMoviesList from "@/hooks/useMoviesList"
2023-06-04 12:33:10 +00:00
import { NextPageContext } from "next"
import { signOut,getSession } from "next-auth/react"
export async function getServerSideProps(context: NextPageContext){
const session = await getSession(context)
if(!session){
return {
redirect: {
destination: '/auth',
permanent: false,
},
}
}
return {
props: {}
}
}
2023-06-03 09:45:49 +00:00
export default function Home() {
2023-08-18 12:00:58 +00:00
const { data: film = [] } = useMoviesList();
2023-06-03 09:45:49 +00:00
return (
2023-06-04 12:33:10 +00:00
<>
2023-06-26 14:50:04 +00:00
<Navbar />
2023-08-18 12:00:58 +00:00
<Billboard />
<div>
<MovieList title="Popolari" data={film} />
</div>
2023-06-04 12:33:10 +00:00
</>
2023-06-03 09:45:49 +00:00
)
}