Skip to content

Commit

Permalink
fix: format document
Browse files Browse the repository at this point in the history
  • Loading branch information
nnivxix committed Oct 27, 2024
1 parent 882fa4e commit 2f5ddb2
Show file tree
Hide file tree
Showing 38 changed files with 1,318 additions and 1,250 deletions.
40 changes: 19 additions & 21 deletions app/discover/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,20 @@ import { cookies } from "next/headers";
import config from "@/config";
import { Metadata } from "next";

type Status = "idle" | "pending" | "success" | "error"

type Status = "idle" | "pending" | "success" | "error";

const { apiUrl, token } = config;


export const metadata: Metadata = {
title: "Vilm - Discover Movies and Tv Shows ",
description: 'Discover movies and tv shows.',
}
description: "Discover movies and tv shows.",
};

export default async function Page() {
const { data, status } = await getDiscover();

if (status === 'pending') {
return "Loading..."
if (status === "pending") {
return "Loading...";
}
return (
<div>
Expand All @@ -32,32 +30,33 @@ export default async function Page() {
);
}


async function getDiscover(): Promise<{ data: Response<MovieTv[]> | null, status: Status, error: string | null }> {
async function getDiscover(): Promise<{
data: Response<MovieTv[]> | null;
status: Status;
error: string | null;
}> {
const apiToken = cookies().get("API_TOKEN")?.value ?? token;
let status: Status = "idle";
let data: Response<MovieTv[]> | null = null;
let error: string | null = null;

status = "pending";
try {
const response = await fetch(`${apiUrl}/trending/all/day`,
{
method: "GET",
headers: {
"Content-Type": "application/json",
"Accept": "application/json",
Authorization: `Bearer ${apiToken}`,
},
});
const response = await fetch(`${apiUrl}/trending/all/day`, {
method: "GET",
headers: {
"Content-Type": "application/json",
Accept: "application/json",
Authorization: `Bearer ${apiToken}`,
},
});

if (!response.ok) {
throw new Error('Failed to fetch the movie data');
throw new Error("Failed to fetch the movie data");
}

data = await response.json();
status = "success";

} catch (err) {
console.error(err);
status = "error";
Expand All @@ -66,4 +65,3 @@ async function getDiscover(): Promise<{ data: Response<MovieTv[]> | null, status

return { data, status, error };
}

35 changes: 16 additions & 19 deletions app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,36 @@ import "../src/index.css";
import Navbar from "@/components/Navbar";
import Footer from "@/components/Footer";
import { Toaster } from "@/components/ui/toaster";
import { Metadata } from 'next';
import { Metadata } from "next";

export const metadata: Metadata = {
title: 'Vilm',
description: 'Get movies and tv shows information.',
title: "Vilm",
description: "Get movies and tv shows information.",
openGraph: {
siteName: 'Vilm',
type: 'website',
url: 'https://vilm-react.vercel.app/',
title: 'Vilm',
description: 'Get movies and tv shows information.',
siteName: "Vilm",
type: "website",
url: "https://vilm-react.vercel.app/",
title: "Vilm",
description: "Get movies and tv shows information.",
images: [
{
url: '/og-image.jpg',
url: "/og-image.jpg",
},
],
},
twitter: {
card: 'summary_large_image',
creator: '@nnivxix',
title: 'Get movies and tv shows information.',
description: 'Get movies and tv shows information.',
images: ['/og-image.jpg'],
card: "summary_large_image",
creator: "@nnivxix",
title: "Get movies and tv shows information.",
description: "Get movies and tv shows information.",
images: ["/og-image.jpg"],
},
};


export default function RootLayout({
children,
}: {
children: React.ReactNode
children: React.ReactNode;
}) {
return (
<html lang="en" className="dark">
Expand Down Expand Up @@ -72,8 +71,6 @@ export default function RootLayout({
href="/backdrop-fallback.png"
type="image/png"
/>


</head>
<body>
<Navbar />
Expand All @@ -83,4 +80,4 @@ export default function RootLayout({
</body>
</html>
);
}
}
24 changes: 16 additions & 8 deletions app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"use client"
"use client";
import type { FormEvent } from "react";
import { buttonVariants } from "@/components/ui/button";
import { cn } from "@/lib/utils";
import { Suspense, useState } from "react";
import { Input } from "@/components/ui/input"
import { Input } from "@/components/ui/input";
import Link from "next/link";
import { useSearchParams } from "next/navigation";
import { useRouter } from "next/navigation";
Expand Down Expand Up @@ -40,9 +40,11 @@ function SearchForm() {
}

export default function Page() {

return (
<div className="lg:bg-[url('/home-banner.jpg')] bg-[url('/home-banner-vertical.jpg')] bg-center bg-cover" data-bg-src="https://www.pexels.com/photo/three-friends-watching-at-a-movie-theater-while-eating-popcorn-8263318/">
<div
className="lg:bg-[url('/home-banner.jpg')] bg-[url('/home-banner-vertical.jpg')] bg-center bg-cover"
data-bg-src="https://www.pexels.com/photo/three-friends-watching-at-a-movie-theater-while-eating-popcorn-8263318/"
>
<div className="mx-auto max-w-4xl px-5 mt-5">
<div className="flex w-full lg:h-[63vh] h-[45vh] md:h-[56vh] justify-center flex-col gap-3 items-center">
<div className="text-center">
Expand All @@ -52,10 +54,16 @@ export default function Page() {
<Suspense>
<SearchForm />
</Suspense>
<p>
Or
</p>
<Link href='/discover' className={`lg:w-1/2 w-full ${cn(buttonVariants({ variant: "default" }))}`}> Discover </Link>
<p>Or</p>
<Link
href="/discover"
className={`lg:w-1/2 w-full ${cn(
buttonVariants({ variant: "default" })
)}`}
>
{" "}
Discover{" "}
</Link>
</div>
</div>
</div>
Expand Down
27 changes: 11 additions & 16 deletions app/search/page.tsx
Original file line number Diff line number Diff line change
@@ -1,38 +1,33 @@
import { SearchForm } from '@/components/SearchForm'
import { Suspense } from 'react'

import { SearchForm } from "@/components/SearchForm";
import { Suspense } from "react";

interface Props {
searchParams: { [key: string]: string | string[] | undefined }
searchParams: { [key: string]: string | string[] | undefined };
}


export async function generateMetadata({ searchParams }: Props) {
const title = searchParams.title;
const type = () => {
const paramType = searchParams.type;

if (paramType === 'tv') return "Tv Shows"
if (paramType === 'movie') return "Movies"
return ""
if (paramType === "tv") return "Tv Shows";
if (paramType === "movie") return "Movies";
return "";
};

if (title) {
return {
title: `Vilm - Search ${type()} for "${title}" `
}
title: `Vilm - Search ${type()} for "${title}" `,
};
}
return {
title: "Vilm - Search"
}

title: "Vilm - Search",
};
}
export default async function Page() {
return (
<Suspense>
<SearchForm />
</Suspense>
)
);
}


Loading

0 comments on commit 2f5ddb2

Please sign in to comment.