11import { Suspense } from "react" ;
2+ import { BookOpen , Icon , Search } from "lucide-react" ;
23
34import type { ProcessedPub } from "contracts" ;
45import type { CommunitiesId , UsersId } from "db/public" ;
6+ import type { Button } from "ui/button" ;
7+ import {
8+ Empty ,
9+ EmptyContent ,
10+ EmptyDescription ,
11+ EmptyHeader ,
12+ EmptyMedia ,
13+ EmptyTitle ,
14+ } from "ui/empty" ;
515import { PubFieldProvider } from "ui/pubFields" ;
616import { Skeleton } from "ui/skeleton" ;
717import { stagesDAO , StagesProvider } from "ui/stages" ;
818import { cn } from "utils" ;
919
1020import type { AutoReturnType } from "~/lib/types" ;
21+ import { CreatePubButton } from "~/app/components/pubs/CreatePubButton" ;
1122import { PubCard } from "~/app/components/pubs/PubCard/PubCard" ;
23+ import { SkeletonButton } from "~/app/components/skeletons/SkeletonButton" ;
1224import {
25+ getCreatablePubTypes ,
1326 userCanArchiveAllPubs ,
27+ userCanCreatePub ,
1428 userCanEditAllPubs ,
1529 userCanMoveAllPubs ,
1630 userCanRunActionsAllPubs ,
@@ -20,6 +34,7 @@ import { getPubsCount, getPubsWithRelatedValues, getPubTypesForCommunity } from
2034import { getCommunitySlug } from "~/lib/server/cache/getCommunitySlug" ;
2135import { getPubFields } from "~/lib/server/pubFields" ;
2236import { getStages } from "~/lib/server/stages" ;
37+ import { PubClearSearchButton } from "./PubClearSearchButton" ;
2338import { getPubFilterParamsFromSearch , pubSearchParamsCache } from "./pubQuery" ;
2439import { PubSearchFooter } from "./PubSearchFooter" ;
2540import { PubSearch } from "./PubSearchInput" ;
@@ -71,8 +86,41 @@ const PaginatedPubListInner = async (
7186 userCanViewAllStages ( ) ,
7287 ] ) ;
7388
89+ const hasSearch =
90+ props . searchParams . query !== "" ||
91+ ( props . searchParams . pubTypes ?. length ?? 0 ) > 0 ||
92+ ( props . searchParams . stages ?. length ?? 0 ) > 0 ;
7493 return (
7594 < div className = "mr-auto flex flex-col gap-3 md:max-w-screen-lg" >
95+ { pubs . length === 0 && (
96+ < Empty className = "" >
97+ < EmptyHeader >
98+ < EmptyMedia variant = "icon" >
99+ < BookOpen size = { 16 } />
100+ </ EmptyMedia >
101+ < EmptyTitle > No Pubs Found</ EmptyTitle >
102+ { hasSearch && (
103+ < EmptyDescription >
104+ Try adjusting your filters or search query.
105+ </ EmptyDescription >
106+ ) }
107+ </ EmptyHeader >
108+ < EmptyContent >
109+ { hasSearch ? (
110+ < PubClearSearchButton />
111+ ) : (
112+ < Suspense fallback = { < SkeletonButton className = "w-20" /> } >
113+ < CreatePubButton
114+ communityId = { props . communityId }
115+ className = "bg-emerald-500 text-white hover:bg-emerald-600"
116+ text = "Create Pub"
117+ />
118+ </ Suspense >
119+ ) }
120+ </ EmptyContent >
121+ </ Empty >
122+ ) }
123+
76124 { pubs . map ( ( pub ) => {
77125 const stageForPub = stages . find ( ( stage ) => stage . id === pub . stage ?. id ) ;
78126
0 commit comments