|
|
|
@ -1,7 +1,7 @@
|
|
|
|
|
import TvDetails from '@app/components/TvDetails';
|
|
|
|
|
import type { TvDetails as TvDetailsType } from '@server/models/Tv';
|
|
|
|
|
import axios from 'axios';
|
|
|
|
|
import type { NextPage } from 'next';
|
|
|
|
|
import type { GetServerSideProps, NextPage } from 'next';
|
|
|
|
|
|
|
|
|
|
interface TvPageProps {
|
|
|
|
|
tv?: TvDetailsType;
|
|
|
|
@ -11,12 +11,11 @@ const TvPage: NextPage<TvPageProps> = ({ tv }) => {
|
|
|
|
|
return <TvDetails tv={tv} />;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
TvPage.getInitialProps = async (ctx) => {
|
|
|
|
|
if (ctx.req) {
|
|
|
|
|
export const getServerSideProps: GetServerSideProps<TvPageProps> = async (
|
|
|
|
|
ctx
|
|
|
|
|
) => {
|
|
|
|
|
const response = await axios.get<TvDetailsType>(
|
|
|
|
|
`http://localhost:${process.env.PORT || 5055}/api/v1/tv/${
|
|
|
|
|
ctx.query.tvId
|
|
|
|
|
}`,
|
|
|
|
|
`http://localhost:${process.env.PORT || 5055}/api/v1/tv/${ctx.query.tvId}`,
|
|
|
|
|
{
|
|
|
|
|
headers: ctx.req?.headers?.cookie
|
|
|
|
|
? { cookie: ctx.req.headers.cookie }
|
|
|
|
@ -25,11 +24,10 @@ TvPage.getInitialProps = async (ctx) => {
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
props: {
|
|
|
|
|
tv: response.data,
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return {};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default TvPage;
|
|
|
|
|