Skip to content

Commit

Permalink
Refactor Home component to use Prisma model and add type annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
GithmiHashara committed Sep 22, 2024
1 parent 3761010 commit 91894fa
Showing 1 changed file with 28 additions and 25 deletions.
53 changes: 28 additions & 25 deletions app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,44 +1,47 @@

import { TbCoinRupee } from 'react-icons/tb';
import Container from './components/Container';
import EmptyState from './components/EmptyState';
import getListings, { IListingsParams } from './actions/getListings';
import ListingCard from './components/listings/ListingCard';
import getCurrentUser from './actions/getCurrentUser';

interface HomeProps {
searchParams: IListingsParams
// types.ts

export interface SafeListing {
id: string;
title: string;
description: string;
price: number;
locationValue: string;
// Add all other fields that 'listing' might contain
createdAt: string; // Make sure to convert dates to string as you're doing in getListings
}

interface HomeProps {
searchParams: IListingsParams;
}

const Home = async ({searchParams}: HomeProps)=> {
const listings = await getListings(searchParams) ;
const Home = async ({ searchParams }: HomeProps) => {
const listings = await getListings(searchParams);
const currentUser = await getCurrentUser();


if(listings.length === 0) {
return (
<EmptyState showReset={true} />
)
if (listings.length === 0) {
return <EmptyState showReset={true} />;
}



return (

<Container>
<div className="pt-24 grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 2xl:grid-cols-6 gap-8">
{listings.map((listing) => (
<ListingCard
key={listing.id}
data={listing}
currentUser={currentUser}
/>
))}
</div>
{listings.map((listing: Listing) => (
<ListingCard
key={listing.id}
data={listing}
currentUser={currentUser}
/>
))}
</div>
</Container>

)
}
);
};

export default Home;
export default Home;

0 comments on commit 91894fa

Please sign in to comment.