memorium/routes/movies/index.tsx

39 lines
1.2 KiB
TypeScript
Raw Normal View History

2023-07-30 21:43:09 +02:00
import { Handlers, PageProps } from "$fresh/server.ts";
import { MainLayout } from "@components/layouts/main.tsx";
2023-08-01 17:50:00 +02:00
import { getAllMovies, Movie } from "@lib/resource/movies.ts";
2023-07-30 23:55:51 +02:00
import { MovieCard } from "@components/MovieCard.tsx";
2023-08-02 01:58:03 +02:00
import { Grid } from "@components/Grid.tsx";
2023-08-02 13:11:17 +02:00
import { IconArrowLeft } from "@components/icons.tsx";
import { KMenu } from "@islands/KMenu.tsx";
2023-07-30 23:55:51 +02:00
export const handler: Handlers<Movie[] | null> = {
2023-07-30 21:43:09 +02:00
async GET(_, ctx) {
2023-08-01 17:50:00 +02:00
const movies = await getAllMovies();
2023-07-30 23:55:51 +02:00
return ctx.render(movies);
2023-07-30 21:43:09 +02:00
},
};
2023-07-30 23:55:51 +02:00
export default function Greet(props: PageProps<Movie[] | null>) {
2023-07-30 21:43:09 +02:00
return (
2023-08-06 00:33:06 +02:00
<MainLayout url={props.url} title="Movies" context={{ type: "movie" }}>
2023-08-02 13:11:17 +02:00
<KMenu type="main" context={false} />
2023-07-30 21:43:09 +02:00
<header class="flex gap-4 items-center mb-5 md:hidden">
<a
class="px-4 ml-4 py-2 bg-gray-300 text-gray-800 rounded-lg flex items-center gap-1"
href="/"
>
<IconArrowLeft class="w-5 h-5" />
Back
</a>
2023-07-30 23:55:51 +02:00
<h3 class="text-2xl text-white font-light">🍿 Movies</h3>
2023-07-30 21:43:09 +02:00
</header>
2023-08-02 01:58:03 +02:00
<Grid>
2023-07-30 21:43:09 +02:00
{props.data?.map((doc) => {
2023-07-30 23:55:51 +02:00
return <MovieCard movie={doc} />;
2023-07-30 21:43:09 +02:00
})}
2023-08-02 01:58:03 +02:00
</Grid>
2023-07-30 21:43:09 +02:00
</MainLayout>
);
}