Skip to content

Commit

Permalink
feat(detail): create back button
Browse files Browse the repository at this point in the history
  • Loading branch information
iqbalpa committed Jul 10, 2024
1 parent ed26b31 commit 3f5ebc5
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/modules/detailMovie/detailMovie.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
'use client';

import api from '@/api/api';
import { DetailMovie } from '@/constant/detailMovie';
import React, { useEffect, useState } from 'react';
import Image from 'next/image';
import { Skeleton } from '@/components/ui/skeleton';
import { CircleArrowLeft } from 'lucide-react';
import { useRouter } from 'next/navigation';

interface IDetailMovieModule {
id: string;
}

const DetailMovieModule: React.FC<IDetailMovieModule> = ({ id }) => {
const router = useRouter();
const [movie, setMovie] = useState<DetailMovie>();
const [isLoading, setIsLoading] = useState(true);

Expand All @@ -25,9 +30,18 @@ const DetailMovieModule: React.FC<IDetailMovieModule> = ({ id }) => {
fetchMovie();
}, [id]);

const handleBack = () => router.push('/');

return (
<div className="">
<div className="relative mt-16 h-[30rem] w-full">
<button
onClick={handleBack}
className="absolute left-5 top-5 z-50 flex flex-row gap-2 rounded-full bg-slate-600 bg-opacity-80 px-5 py-3 text-white duration-100 hover:scale-105 hover:cursor-pointer hover:bg-slate-800 hover:bg-opacity-95"
>
<CircleArrowLeft />
<p>Back</p>
</button>
<div className="absolute inset-0 z-20 bg-gradient-to-b from-transparent to-black"></div>
{isLoading && (
<Skeleton className="absolute inset-0 z-30 h-full w-full" />
Expand Down Expand Up @@ -57,7 +71,7 @@ const DetailMovieModule: React.FC<IDetailMovieModule> = ({ id }) => {
</p>
<h1 className="text-3xl font-bold">{movie.title}</h1>
<p>{movie.overview}</p>
<div className="flex flex-row gap-2 mt-2">
<div className="mt-2 flex flex-row gap-2">
{movie.genres.map((genre, index) => (
<div
key={genre.id}
Expand Down

0 comments on commit 3f5ebc5

Please sign in to comment.