Commit ·
fe54350
1
Parent(s): 59990de
SSR index page content
Browse files- frontend/src/app/genres/[genre]/page.js +2 -2
- frontend/src/app/index.css +3 -2
- frontend/src/app/page.js +27 -9
- frontend/src/app/search/page.js +2 -2
- frontend/src/components/shared/Card/MovieCard.js +2 -0
- frontend/src/components/shared/Card/TvShowCard.js +2 -0
- frontend/src/components/shared/Sections/ScrollSection.js +11 -2
- frontend/src/lib/LoadBalancer.js +2 -2
frontend/src/app/genres/[genre]/page.js
CHANGED
|
@@ -109,7 +109,7 @@ export default function GenrePage({ params }) {
|
|
| 109 |
{genreItems && (
|
| 110 |
<>
|
| 111 |
{genreItems.movies && genreItems.movies.length > 0 && (
|
| 112 |
-
<ScrollSection title="Movies">
|
| 113 |
{genreItems.movies.map((item, index) => (
|
| 114 |
<div key={index} className="genre-item-card">
|
| 115 |
<Link href={`/movie/${item[0]}`} passHref>
|
|
@@ -138,7 +138,7 @@ export default function GenrePage({ params }) {
|
|
| 138 |
)}
|
| 139 |
|
| 140 |
{genreItems.series && genreItems.series.length > 0 && (
|
| 141 |
-
<ScrollSection title="TV Shows">
|
| 142 |
{genreItems.series.map((item, index) => (
|
| 143 |
<div key={index} className="genre-item-card">
|
| 144 |
<Link href={`/series/${item[0]}`} passHref>
|
|
|
|
| 109 |
{genreItems && (
|
| 110 |
<>
|
| 111 |
{genreItems.movies && genreItems.movies.length > 0 && (
|
| 112 |
+
<ScrollSection title="Movies" link={"/movies"}>
|
| 113 |
{genreItems.movies.map((item, index) => (
|
| 114 |
<div key={index} className="genre-item-card">
|
| 115 |
<Link href={`/movie/${item[0]}`} passHref>
|
|
|
|
| 138 |
)}
|
| 139 |
|
| 140 |
{genreItems.series && genreItems.series.length > 0 && (
|
| 141 |
+
<ScrollSection title="TV Shows" link={"/tvshows"}>
|
| 142 |
{genreItems.series.map((item, index) => (
|
| 143 |
<div key={index} className="genre-item-card">
|
| 144 |
<Link href={`/series/${item[0]}`} passHref>
|
frontend/src/app/index.css
CHANGED
|
@@ -3,8 +3,8 @@
|
|
| 3 |
}
|
| 4 |
|
| 5 |
@media (orientation: landscape) {
|
| 6 |
-
.index-page-
|
| 7 |
-
|
| 8 |
}
|
| 9 |
}
|
| 10 |
|
|
@@ -16,6 +16,7 @@
|
|
| 16 |
|
| 17 |
.index-page-content{
|
| 18 |
width: 100dvw;
|
|
|
|
| 19 |
z-index: 1;
|
| 20 |
}
|
| 21 |
|
|
|
|
| 3 |
}
|
| 4 |
|
| 5 |
@media (orientation: landscape) {
|
| 6 |
+
.index-page-content {
|
| 7 |
+
padding: 50px;
|
| 8 |
}
|
| 9 |
}
|
| 10 |
|
|
|
|
| 16 |
|
| 17 |
.index-page-content{
|
| 18 |
width: 100dvw;
|
| 19 |
+
padding: 10px;
|
| 20 |
z-index: 1;
|
| 21 |
}
|
| 22 |
|
frontend/src/app/page.js
CHANGED
|
@@ -1,23 +1,41 @@
|
|
| 1 |
import HeroSection from "@/components/shared/Sections/HeroSection";
|
| 2 |
import "./index.css";
|
| 3 |
import ScrollSection from "@/components/shared/Sections/ScrollSection";
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
|
|
|
|
|
|
| 11 |
|
| 12 |
-
const HomePage = () => {
|
| 13 |
return (
|
| 14 |
<div className="app-container">
|
| 15 |
<div className="index-page">
|
| 16 |
<div className="index-page-container">
|
| 17 |
<HeroSection />
|
| 18 |
<div className="index-page-content">
|
| 19 |
-
<ScrollSection title="
|
| 20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
</div>
|
| 22 |
</div>
|
| 23 |
</div>
|
|
|
|
| 1 |
import HeroSection from "@/components/shared/Sections/HeroSection";
|
| 2 |
import "./index.css";
|
| 3 |
import ScrollSection from "@/components/shared/Sections/ScrollSection";
|
| 4 |
+
import apiClient from "@/api/apiClient";
|
| 5 |
+
import MovieCard from "@/components/shared/Card/MovieCard";
|
| 6 |
+
import TvShowCard from "@/components/shared/Card/TvShowCard";
|
| 7 |
|
| 8 |
+
// Fetch recent movies and TV shows
|
| 9 |
+
async function fetchRecent() {
|
| 10 |
+
const data = await apiClient.getRecent(10);
|
| 11 |
+
return data;
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
const HomePage = async () => {
|
| 15 |
+
const { movies, series } = await fetchRecent();
|
| 16 |
|
|
|
|
| 17 |
return (
|
| 18 |
<div className="app-container">
|
| 19 |
<div className="index-page">
|
| 20 |
<div className="index-page-container">
|
| 21 |
<HeroSection />
|
| 22 |
<div className="index-page-content">
|
| 23 |
+
<ScrollSection title="Movies" link={"/movies"}>
|
| 24 |
+
{movies.map((movie, index) => (
|
| 25 |
+
<MovieCard
|
| 26 |
+
key={index}
|
| 27 |
+
title={movie[0]}
|
| 28 |
+
/>
|
| 29 |
+
))}
|
| 30 |
+
</ScrollSection>
|
| 31 |
+
<ScrollSection title="TV Shows" link={"/tvshows"}>
|
| 32 |
+
{series.map((show, index) => (
|
| 33 |
+
<TvShowCard
|
| 34 |
+
key={index}
|
| 35 |
+
title={show[0]}
|
| 36 |
+
/>
|
| 37 |
+
))}
|
| 38 |
+
</ScrollSection>
|
| 39 |
</div>
|
| 40 |
</div>
|
| 41 |
</div>
|
frontend/src/app/search/page.js
CHANGED
|
@@ -39,14 +39,14 @@ const SearchPage = async ({ searchParams }) => {
|
|
| 39 |
{error && <div className="error-message">{error}</div>}
|
| 40 |
<div className="results-container">
|
| 41 |
{results.films.length > 0 && (
|
| 42 |
-
<ScrollSection title={"Movies"}>
|
| 43 |
{results.films.map((film, index) => (
|
| 44 |
<MovieCard key={index} title={film} />
|
| 45 |
))}
|
| 46 |
</ScrollSection>
|
| 47 |
)}
|
| 48 |
{results.tv_series.length > 0 && (
|
| 49 |
-
<ScrollSection title={"TV Series"}>
|
| 50 |
{results.tv_series.map((series, index) => (
|
| 51 |
<TvShowCard key={index} title={series} />
|
| 52 |
))}
|
|
|
|
| 39 |
{error && <div className="error-message">{error}</div>}
|
| 40 |
<div className="results-container">
|
| 41 |
{results.films.length > 0 && (
|
| 42 |
+
<ScrollSection title={"Movies"} link={"/movies"}>
|
| 43 |
{results.films.map((film, index) => (
|
| 44 |
<MovieCard key={index} title={film} />
|
| 45 |
))}
|
| 46 |
</ScrollSection>
|
| 47 |
)}
|
| 48 |
{results.tv_series.length > 0 && (
|
| 49 |
+
<ScrollSection title={"TV Series"} link={"/tvshows"}>
|
| 50 |
{results.tv_series.map((series, index) => (
|
| 51 |
<TvShowCard key={index} title={series} />
|
| 52 |
))}
|
frontend/src/components/shared/Card/MovieCard.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
|
|
|
|
|
| 1 |
import Image from "next/image";
|
| 2 |
import apiClient from "@/api/apiClient";
|
| 3 |
import "./Card.css";
|
|
|
|
| 1 |
+
'use server';
|
| 2 |
+
|
| 3 |
import Image from "next/image";
|
| 4 |
import apiClient from "@/api/apiClient";
|
| 5 |
import "./Card.css";
|
frontend/src/components/shared/Card/TvShowCard.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
|
|
|
|
|
| 1 |
import Image from 'next/image';
|
| 2 |
import apiClient from '@/api/apiClient';
|
| 3 |
import SkeletonLoader from '@/skeletons/Card/movieCard';
|
|
|
|
| 1 |
+
'use server';
|
| 2 |
+
|
| 3 |
import Image from 'next/image';
|
| 4 |
import apiClient from '@/api/apiClient';
|
| 5 |
import SkeletonLoader from '@/skeletons/Card/movieCard';
|
frontend/src/components/shared/Sections/ScrollSection.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
| 1 |
"use client";
|
| 2 |
import { useRef, useState, useEffect } from "react";
|
| 3 |
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
| 4 |
-
import { faCaretLeft, faCaretRight } from "@fortawesome/free-solid-svg-icons";
|
| 5 |
import "./ScrollSection.css";
|
|
|
|
| 6 |
|
| 7 |
-
const ScrollSection = ({ title, children }) => {
|
| 8 |
const scrollRef = useRef(null);
|
| 9 |
const [canScrollLeft, setCanScrollLeft] = useState(false);
|
| 10 |
const [canScrollRight, setCanScrollRight] = useState(true);
|
|
@@ -51,7 +52,15 @@ const ScrollSection = ({ title, children }) => {
|
|
| 51 |
return (
|
| 52 |
<section className="scroll-section">
|
| 53 |
<div className="scroll-section-controls">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
<h2>{title}</h2>
|
|
|
|
| 55 |
<div className="scroll-controls">
|
| 56 |
<button
|
| 57 |
onClick={() => scroll("left")}
|
|
|
|
| 1 |
"use client";
|
| 2 |
import { useRef, useState, useEffect } from "react";
|
| 3 |
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
| 4 |
+
import { faAngleRight, faCaretLeft, faCaretRight } from "@fortawesome/free-solid-svg-icons";
|
| 5 |
import "./ScrollSection.css";
|
| 6 |
+
import Link from "next/link";
|
| 7 |
|
| 8 |
+
const ScrollSection = ({ title, children, link=null }) => {
|
| 9 |
const scrollRef = useRef(null);
|
| 10 |
const [canScrollLeft, setCanScrollLeft] = useState(false);
|
| 11 |
const [canScrollRight, setCanScrollRight] = useState(true);
|
|
|
|
| 52 |
return (
|
| 53 |
<section className="scroll-section">
|
| 54 |
<div className="scroll-section-controls">
|
| 55 |
+
{link ? (
|
| 56 |
+
<Link href={link}>
|
| 57 |
+
<h2>
|
| 58 |
+
{title} <FontAwesomeIcon icon={faAngleRight} size="lg" />
|
| 59 |
+
</h2>
|
| 60 |
+
</Link>
|
| 61 |
+
) : (
|
| 62 |
<h2>{title}</h2>
|
| 63 |
+
)}
|
| 64 |
<div className="scroll-controls">
|
| 65 |
<button
|
| 66 |
onClick={() => scroll("left")}
|
frontend/src/lib/LoadBalancer.js
CHANGED
|
@@ -69,8 +69,8 @@ class LoadBalancerAPI {
|
|
| 69 |
return this._getRequest('/api/get/series/all');
|
| 70 |
}
|
| 71 |
|
| 72 |
-
async getRecent() {
|
| 73 |
-
return this._getRequest(
|
| 74 |
}
|
| 75 |
|
| 76 |
async getGenreItems(genres, mediaType = null, limit = 5) {
|
|
|
|
| 69 |
return this._getRequest('/api/get/series/all');
|
| 70 |
}
|
| 71 |
|
| 72 |
+
async getRecent(limit = 5) {
|
| 73 |
+
return this._getRequest(`/api/get/recent?limit=${limit}`);
|
| 74 |
}
|
| 75 |
|
| 76 |
async getGenreItems(genres, mediaType = null, limit = 5) {
|