Skip to content

Commit

Permalink
remove all filters button working
Browse files Browse the repository at this point in the history
  • Loading branch information
Jared Brown authored and Jared Brown committed Apr 30, 2023
1 parent f915f3e commit 9ac47e0
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 2 deletions.
30 changes: 30 additions & 0 deletions app/components/EmptyState.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
'use client'

import { useRouter } from "next/navigation";

import Heading from "./Heading";
import Button from "./Button";

interface EmptyState {
title?: string;
subtitle?: string;
showReset?: boolean;
}

const EmptyState: React.FC<EmptyState> = ({
title= "No exact matches",
subtitle = "Try changing or removing some of your filters",
showReset
}) => {
const router = useRouter()

return <div className="h-[60vh] flex flex-col gap-2 justify-center items-center"><Heading center title={title} subtitle={subtitle} />
<div className="w-48 mt-4">
{showReset && (
<Button outline label="Remove all filters" onClick={() => router.push('/')} />
)}
</div>
</div>;
}

export default EmptyState;
4 changes: 3 additions & 1 deletion app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ export default async function RootLayout({
<LoginModal />
<RegisterModal />
<Navbar currentUser={currentUser} />
{children}
<div className='pb-20 pt-28'>
{children}
</div>
</body>
</html>
);
Expand Down
19 changes: 18 additions & 1 deletion app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
import Container from "./components/Container";
import EmptyState from "./components/EmptyState";

export default function Home() {
return <div className="text-rose-500 text-2xl">Hello Airbnb!</div>;
const isEmpty = true;

if (isEmpty) {
return <EmptyState showReset />
}

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">
<div>
My future listings
</div>
</div>
</Container>
)
}

0 comments on commit 9ac47e0

Please sign in to comment.