diff --git a/src/app/[id]/layout.tsx b/src/app/[id]/layout.tsx index af41863..bd147dc 100644 --- a/src/app/[id]/layout.tsx +++ b/src/app/[id]/layout.tsx @@ -1,4 +1,4 @@ -import { ScrollArea } from '@/components/ui/scroll-area'; +import BackButton from '@/components/backButton/backButton'; export default function DetailLayout({ children, @@ -6,7 +6,8 @@ export default function DetailLayout({ children: React.ReactNode; }>) { return ( -
+
+ {children}
); diff --git a/src/app/layout.tsx b/src/app/layout.tsx index 0979d2a..1c7a496 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -3,8 +3,6 @@ import { Inter } from 'next/font/google'; import './globals.css'; import Header from '@/components/header/header'; import GoTopButton from '@/components/goTopButton/goTopButton'; -import BackButton from '@/components/backButton/backButton'; -import { ScrollArea } from '@/components/ui/scroll-area'; import Sidebar from '@/components/sidebar/sidebar'; const inter = Inter({ subsets: ['latin'] }); @@ -32,7 +30,6 @@ export default function RootLayout({
- ); diff --git a/src/components/searchBar/searchBar.tsx b/src/components/searchBar/searchBar.tsx new file mode 100644 index 0000000..8418c3a --- /dev/null +++ b/src/components/searchBar/searchBar.tsx @@ -0,0 +1,28 @@ +import { Search } from 'lucide-react'; +import React, { ChangeEvent } from 'react'; + +interface ISearchBar { + query: string; + handleQueryChange: (e: ChangeEvent) => void; +} + +const SearchBar: React.FC = ({ query, handleQueryChange }) => { + return ( +
+
+ + +
+
+ ); +}; + +export default SearchBar; diff --git a/src/components/ui/input.tsx b/src/components/ui/input.tsx new file mode 100644 index 0000000..36d2659 --- /dev/null +++ b/src/components/ui/input.tsx @@ -0,0 +1,25 @@ +import * as React from 'react'; + +import { cn } from '@/lib/utils'; + +export interface InputProps + extends React.InputHTMLAttributes {} + +const Input = React.forwardRef( + ({ className, type, ...props }, ref) => { + return ( + + ); + }, +); +Input.displayName = 'Input'; + +export { Input }; diff --git a/src/modules/home/home.tsx b/src/modules/home/home.tsx index 86c13de..57efb87 100644 --- a/src/modules/home/home.tsx +++ b/src/modules/home/home.tsx @@ -1,13 +1,14 @@ 'use client'; -import React, { useEffect, useState } from 'react'; +import React, { ChangeEvent, useEffect, useState } from 'react'; import { getAllSurah } from '@/api/api'; import { ISurah } from '@/constant/surah.constant'; import Link from 'next/link'; -import { ScrollArea } from '@/components/ui/scroll-area'; +import SearchBar from '@/components/searchBar/searchBar'; const HomeModule: React.FC = () => { const [surahs, setSurahs] = useState([]); + const [query, setQuery] = useState(''); useEffect(() => { const fetchData = async () => { @@ -22,38 +23,44 @@ const HomeModule: React.FC = () => { fetchData(); }, []); + const handleQueryChange = (e: ChangeEvent) => + setQuery(e.target.value); + return (

Baca Al-Quran Online

+
- {surahs.map((surah, _index) => ( - -
-
-

- {surah.nomor} -

-
+ {surahs + .filter((surah) => surah.namaLatin.toLowerCase().includes(query)) + .map((surah, _index) => ( + +
+
+

+ {surah.nomor} +

+
-
-

{surah.namaLatin}

+
+

{surah.namaLatin}

+

+ {surah.arti} +

+
+
+
+

{surah.nama}

- {surah.arti} + {surah.jumlahAyat} ayat

-
-
-

{surah.nama}

-

- {surah.jumlahAyat} ayat -

-
- - ))} + + ))}
);