import React, { useEffect, useState } from 'react'; import type { ReactElement } from 'react'; import Head from 'next/head'; import Link from 'next/link'; import axios from 'axios'; import { mdiMagnify, mdiBookOpenVariant, mdiCart, mdiChevronRight, mdiStar } from '@mdi/js'; import BaseIcon from '../components/BaseIcon'; import LayoutGuest from '../layouts/Guest'; import { getPageTitle } from '../config'; export default function LandingPage() { const [books, setBooks] = useState([]); const [loading, setLoading] = useState(true); const [searchQuery, setSearchQuery] = useState(''); useEffect(() => { const fetchBooks = async () => { try { // Fetch featured books or just first 8 books const response = await axios.get('/books', { params: { limit: 8, offset: 0 } }); setBooks(response.data.rows || []); } catch (error) { console.error('Failed to fetch books:', error); } finally { setLoading(false); } }; fetchBooks(); }, []); return (
{getPageTitle('Home')} {/* Navigation */} {/* Hero Section */}

Discover Your Next Favorite Book

Access thousands of digital books across all genres. Read anytime, anywhere on any device.

setSearchQuery(e.target.value)} />
{/* Featured Books */}

Featured Books

View All
{loading ? (
{[1, 2, 3, 4].map((i) => (
))}
) : (
{books.map((book: any) => (
{book.cover_images?.[0] ? ( {book.title} ) : (
)}
${book.price}

{book.title}

{book.author?.name || 'Unknown Author'}

4.8
))}
)}
{/* CTA Section */}

Start Your Reading Journey Today

Join thousands of readers and get access to the world's best eBooks. Free trial available for new members.

Get Started for Free View Plans
{/* Footer */}
); } LandingPage.getLayout = function getLayout(page: ReactElement) { return {page}; };