You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
804 B
33 lines
804 B
4 years ago
|
import React from 'react';
|
||
|
import { NextPage } from 'next';
|
||
4 years ago
|
import type { MovieDetails as MovieDetailsType } from '../../../../server/models/Movie';
|
||
|
import MovieDetails from '../../../components/MovieDetails';
|
||
4 years ago
|
import axios from 'axios';
|
||
|
|
||
|
interface MoviePageProps {
|
||
|
movie?: MovieDetailsType;
|
||
|
}
|
||
|
|
||
|
const MoviePage: NextPage<MoviePageProps> = ({ movie }) => {
|
||
|
return <MovieDetails movie={movie} />;
|
||
|
};
|
||
|
|
||
|
MoviePage.getInitialProps = async (ctx) => {
|
||
|
if (ctx.req) {
|
||
|
const response = await axios.get<MovieDetailsType>(
|
||
|
`http://localhost:${process.env.PORT || 3000}/api/v1/movie/${
|
||
|
ctx.query.movieId
|
||
|
}`,
|
||
|
{ headers: ctx.req ? { cookie: ctx.req.headers.cookie } : undefined }
|
||
|
);
|
||
|
|
||
|
return {
|
||
|
movie: response.data,
|
||
|
};
|
||
|
}
|
||
|
|
||
|
return {};
|
||
|
};
|
||
|
|
||
|
export default MoviePage;
|