Skip to content

Commit

Permalink
route: season tv show
Browse files Browse the repository at this point in the history
  • Loading branch information
Ibaliqbal committed Jul 12, 2024
1 parent d0c06cc commit de4ebdc
Show file tree
Hide file tree
Showing 40 changed files with 888 additions and 204 deletions.
5 changes: 0 additions & 5 deletions auth.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { defineConfig } from "auth-astro";
import Google from "@auth/core/providers/google";
import Credentials from "@auth/core/providers/credentials";
import { supabase } from "@/lib/supabase/supabase";
import { checkValidUser, registerUser } from "@/lib/supabase/function";

export default defineConfig({
Expand All @@ -27,9 +25,6 @@ export default defineConfig({
image: user.image,
});
}

console.log("Registered", user.email, user.name, user.image);
console.log(checkUser);
}

return token;
Expand Down
2 changes: 0 additions & 2 deletions src/actions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ export const server = {
country: z.string(),
}),
handler: async ({ name, email, country }) => {
// call a mailing service, or store to a database

const { error, data } = await supabase
.from("users")
.update({ email, country, name })
Expand Down
4 changes: 2 additions & 2 deletions src/components/AllTrending/Card.astro
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const {
---

<article
class="w-full card flex flex-col h-full rounded-md"
class="w-full card flex flex-col h-full rounded-md hover:scale-95 transition-transform ease-in-out duration-300"
transition:name={`${media_type} ${id} card`}
>
<Link href={`/${media_type}/${id}`} class="flex flex-col h-full">
Expand All @@ -32,7 +32,7 @@ const {
<Image
src={`${import.meta.env.PUBLIC_TMDB_IMG_URL}${poster_path}`}
alt="Poster"
loading={i < 4 ? "eager" : "lazy"}
loading="eager"
inferSize={true}
class="w-full aspect-auto rounded-t-md"
transition:name={`${media_type} ${id} poster`}
Expand Down
36 changes: 18 additions & 18 deletions src/components/AllTrending/Homepage.astro
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@ const time = "day";
const datas = await getTrendingDatas(type, time, 1);
---

<main>
<section class="w-full">
<div class="w-full flex justify-between items-center">
<h1 class="text-2xl font-bold">Trending All</h1>
<Link
href={`/trending?page=1&type=${type}&time=${time}`}
class="text-blue-600 text-lg hover:text-xl transition-all duration-300 ease-linear"
>See more</Link
>
</div>
<section class="w-full mt-3 grid grid-cols-4 gap-4">
{
datas.results.map((data: AllTrending, i: number) => (
<Card i={i} {...data} />
))
}
</section>
<section class="w-full">
<div class="w-full flex justify-between items-center">
<h1 class="text-2xl font-bold">Trending All</h1>
<Link
href={`/trending?page=1&type=${type}&time=${time}`}
class="text-blue-600 text-lg hover:text-xl transition-all duration-300 ease-linear"
>See more</Link
>
</div>
<section
class="w-full mt-3 grid lg:grid-cols-4 md:grid-cols-3 grid-cols-2 gap-4"
>
{
datas.results.map((data: AllTrending, i: number) => (
<Card i={i} {...data} />
))
}
</section>
</main>
</section>
4 changes: 2 additions & 2 deletions src/components/Banner.astro
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ const { poster } = Astro.props;
src={`${import.meta.env.PUBLIC_TMDB_IMG_URL_ORIGINAL_SIZE}${poster}`}
alt={"Banner"}
loading="eager"
inferSize={true}
class="w-full aspect-[1/.35] object-cover object-center"
inferSize
class="w-full lg:aspect-[1/.35] md:aspect-[1/.5] aspect-[1/.7] object-cover object-center"
quality={"max"}
format="jpeg"
/>
Expand Down
58 changes: 58 additions & 0 deletions src/components/Footer.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
import { Image } from "astro:assets";
import { FiInstagram } from "react-icons/fi";
import { TfiGithub } from "react-icons/tfi";
---

<footer
class="w-full bg-yellow-400 bg-opacity-75 px-6 py-3 flex flex-col md:gap-3 gap-6 pb-10"
>
<section class="md:grid w-full md:grid-cols-3 flex flex-col gap-4">
<div class="col-span-2 flex flex-col">
<Image
src={"/Logo.png"}
alt={"Logo"}
width={100}
height={100}
loading="eager"
/>
<div class="w-full">
<p class="text-xl">
Ini merupakan sebuah website movie dan tv show app yang dibuat dengan
<a
href="https://astro.build/"
target="_blank"
rel="noopener noreferrer">Astro Js</a
>, <a
href="https://tailwindcss.com/docs/installation"
target="_blank"
rel="noopener noreferrer">TailwindCSS</a
>, <a
href="https://react.dev/"
target="_blank"
rel="noopener noreferrer">React Js</a
>, dan <a
href="https://developer.themoviedb.org/docs/getting-started"
target="_blank"
rel="noopener noreferrer">TMDB API</a
>
</p>
</div>
</div>
<div class="col-span-1 h-full">
<h1 class="text-center mb-3">Developer Contact</h1>
<div class="flex justify-around items-center text-4xl h-full">
<a href="http://" target="_blank" rel="noopener noreferrer">
<FiInstagram />
</a>
<a href="http://" target="_blank" rel="noopener noreferrer">
<TfiGithub />
</a>
</div>
</div>
</section>
<div class="w-full h-1 bg-slate-700"></div>
<section class="w-full grid place-items-center py-4">
<h1>&copy; 2024 ~ Iqbal Muthahhary</h1>
</section>
</footer>
2 changes: 1 addition & 1 deletion src/components/Genre/List.astro
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const genre = searchParams.get("genre");
const { lists, type, customLists } = Astro.props;
---

<ul class="w-full py-5 px-2 flex flex-wrap gap-10">
<ul class="w-full py-5 px-2 flex flex-wrap lg:gap-10 gap-8">
{
lists.map((list) => (
<li>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Movie/Card.astro
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const { original_title, id, poster_path, release_date } = Astro.props;
---

<article
class="w-full card flex flex-col h-full rounded-md"
class="w-full card flex flex-col h-full rounded-md hover:scale-95 transition-transform ease-in-out duration-300"
transition:name={`movie ${id} card`}
>
<Link href={`/movie/${id}`} class="flex flex-col h-full">
Expand Down
2 changes: 1 addition & 1 deletion src/components/Movie/Homepage.astro
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const movies_discover = discover.results
>
{
movies_discover.map((movie) => (
<div class="w-1/4 flex-shrink-0">
<div class="md:w-1/4 w-1/2 flex-shrink-0">
<Card {...movie} />
</div>
))
Expand Down
1 change: 0 additions & 1 deletion src/components/Navbar.astro
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { SignIn } from "auth-astro/components";
import ProfileModal from "@/components/React/PorfileModal";
import { checkValidUser } from "@/lib/supabase/function";
import { getSession } from "auth-astro/server";
import { supabase } from "@/lib/supabase/supabase";
const session = await getSession(Astro.request);
Expand Down
6 changes: 3 additions & 3 deletions src/components/React/Carousel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import "react-responsive-carousel/lib/styles/carousel.min.css";

const CarouselSection = ({ movies }: { movies: Movies }) => {
return (
<section className="mb-14">
<section className="lg:mb-14">
<Carousel
autoPlay
infiniteLoop
className="w-full"
showArrows={true}
showArrows={false}
dynamicHeight
interval={5000}
transitionTime={2000}
Expand All @@ -26,7 +26,7 @@ const CarouselSection = ({ movies }: { movies: Movies }) => {
width={500}
height={500}
alt={movie.title}
className="object-cover object-center h-full lg:h-[26rem]"
className="object-cover object-center h-60 lg:h-96 peer"
/>
<div className="absolute top-0 left-0 w-full h-full bg-black bg-opacity-50 flex items-center justify-center text-white text-2xl font-bold cursor-pointer transition duration-300 ease-in-out hover:bg-opacity-20">
<h2>{movie.title}</h2>
Expand Down
4 changes: 2 additions & 2 deletions src/components/React/LikeAction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const LikeAction = ({
poster: string;
list_id: number;
release_list: string | Date;
type: "movie" | "tv";
type: "movie" | "tv" | "tv season" | "tv episode";
user_id: string;
};
id: number;
Expand All @@ -36,7 +36,7 @@ const LikeAction = ({

return (
<button
className="p-3 rounded-full text-xl border-2 border-white disabled:cursor-wait"
className="p-3 rounded-full lg:text-xl text-lg border-2 border-white disabled:cursor-wait"
disabled={isLoading}
onClick={async () => {
const findId = favorite.find((list) => list.list_id === id);
Expand Down
2 changes: 1 addition & 1 deletion src/components/Tv/Card.astro
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const { original_name, id, poster_path, first_air_date } = Astro.props;
---

<article
class="w-full card flex flex-col h-full rounded-md"
class="w-full card flex flex-col h-full rounded-md hover:scale-95 transition-transform ease-in-out duration-300"
transition:name={`tv ${id} card`}
>
<a href={`/tv/${id}`} class="flex flex-col h-full">
Expand Down
58 changes: 58 additions & 0 deletions src/components/Tv/Episode/Card.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
import { Image } from "astro:assets";
import { format } from "date-fns";
import Link from "@/components/ui/Link.astro";
type Props = { id_tv: number } & EpsiodeFromSeason;
const { name, still_path, air_date, id, episode_number, id_tv, season_number } =
Astro.props;
---

<article
class="w-full card flex flex-col h-full rounded-md hover:scale-95 transition-transform ease-in-out duration-300"
transition:name={`episode ${episode_number}~${season_number} card`}
>
<Link
href={`/tv/${id_tv}/seasons/${season_number}/${episode_number}`}
class="flex flex-col h-full"
>
{
still_path === undefined || still_path === null ? (
<div class="w-full aspect-[1/.75] rounded-t-md bg-white bg-opacity-50 text-black grid place-items-center font-bold">
Poster not found
</div>
) : (
<Image
src={`${import.meta.env.PUBLIC_TMDB_IMG_URL}${still_path}`}
alt="Poster"
inferSize
class="w-full aspect-auto rounded-t-md"
transition:name={`episode ${episode_number}~${season_number} poster`}
loading="eager"
/>
)
}
<div class="p-3 flex-grow">
<h1
transition:name={`episode ${episode_number}~${season_number} title`}
class="text-lg"
>
{name} ~ {episode_number}
</h1>
<p transition:name={`episode ${episode_number}~${season_number} date`}>
{format(air_date ? new Date(air_date) : new Date(), "MMMM dd, yyyy")}
</p>
</div>
</Link>
</article>
<style>
.card {
background: rgba(255, 255, 255, 0.2);
box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
backdrop-filter: blur(20px);
-webkit-backdrop-filter: blur(20px);
border: 1px solid rgba(255, 255, 255, 0.18);
min-height: 300px;
}
</style>
4 changes: 2 additions & 2 deletions src/components/Tv/Homepage.astro
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const shows_discover = discover.results
?.filter((data: Tv) => !popularIds.has(data.id)) as TvLists;
---

<main class="flex flex-col gap-7">
<main class="flex flex-col gap-7 mt-3">
<section class="w-full">
<div class="w-full flex justify-between items-center">
<h1 class="text-2xl font-bold">Tv Lists ( Animation )</h1>
Expand All @@ -41,7 +41,7 @@ const shows_discover = discover.results
>
{
shows_discover.map((movie) => (
<div class="w-1/4 flex-shrink-0">
<div class="md:w-1/4 w-1/2 flex-shrink-0">
<Card {...movie} />
</div>
))
Expand Down
40 changes: 40 additions & 0 deletions src/components/Tv/Season/SeasonSection.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
import type { Season } from "@/types/tv";
import { getSeasonData } from "@/utils/data";
import Card from "../Episode/Card.astro";
import Link from "@/components/ui/Link.astro";
type Props = { id_tv: number } & Season;
const { name, season_number, id_tv, episode_count } = Astro.props;
const episodes = await getSeasonData(id_tv, season_number);
---

<article class="px-4">
<div class="flex justify-between items-center">
<h1 class="text-2xl font-bold">{name}</h1>
<p class="text-lg font-semibold">
{episode_count}
{episode_count > 1 ? "episodes" : "episode"}
</p>
</div>
<section
class="w-full grid lg:grid-cols-4 md:grid-cols-3 grid-cols-2 gap-4 mt-4"
>
{
episodes.episodes
.splice(0, 5)
.map((episode: EpsiodeFromSeason) => (
<Card id_tv={id_tv} {...episode} />
))
}
<div
class="w-full h-full text-blue-600 text-2xl grid place-items-center rounded-md"
>
<Link
href={`/tv/${id_tv}/seasons/${season_number}`}
class="hover:scale-105 transition-transform ease-in-out duration-300"
>See more</Link
>
</div>
</section>
</article>
2 changes: 0 additions & 2 deletions src/layouts/AuthLayout.astro
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
---
import { ViewTransitions } from "astro:transitions";
interface Props {
title: string;
description: string;
Expand Down
6 changes: 3 additions & 3 deletions src/layouts/Layout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import SidebarLayout from "./SidebarLayout.astro";
import CarouselSection from "@/components/React/Carousel";
import { getDatas } from "@/utils/data";
import type { Movie } from "@/types/movie";
import Footer from "@/components/Footer.astro";
interface Props {
title: string;
Expand All @@ -20,8 +21,6 @@ const filteredMovies = moviesUpcoming.results
)
.splice(0, 3) as Movies;
const urlImg = import.meta.env.PUBLIC_TMDB_IMG_URL_ORIGINAL_SIZE;
const { title, description } = Astro.props;
const { pathname } = Astro.url;
---
Expand All @@ -45,7 +44,7 @@ const { pathname } = Astro.url;
)
}
<main
class={`max-w-layout w-full container ${pathname === "/signin" || pathname === "/favorite" ? "" : "grid grid-cols-5 gap-5 pb-10 pt-8"}`}
class={`max-w-layout w-full container ${pathname === "/signin" || pathname === "/favorite" ? "" : "lg:grid lg:grid-cols-5 gap-5 flex flex-col pb-10 pt-8"}`}
transition:animate="none"
>
{
Expand All @@ -57,5 +56,6 @@ const { pathname } = Astro.url;
}
<slot />
</main>
<Footer />
</body>
</html>
Loading

0 comments on commit de4ebdc

Please sign in to comment.