-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31 from HausDAO/daos-list
Daos list
- Loading branch information
Showing
8 changed files
with
97 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,50 @@ | ||
import Link from "next/link"; | ||
import Image from "next/image"; | ||
"use client"; | ||
|
||
import { Button } from "../ui/button"; | ||
import { useDao } from "@/hooks/useDao"; | ||
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"; | ||
import { Card } from "@/components/ui/card"; | ||
import { useActiveDaoProposals } from "@/hooks/useActiveDaoProposals"; | ||
import { useDao } from "@/hooks/useDao"; | ||
import Link from "next/link"; | ||
|
||
export const DaoListCard = ({ | ||
daoid, | ||
chainid, | ||
}: { | ||
interface DaoListCardProps { | ||
daoid: string; | ||
chainid: string; | ||
}) => { | ||
const { dao, isLoading } = useDao({ | ||
} | ||
|
||
export const DaoListCard = ({ daoid, chainid }: DaoListCardProps) => { | ||
const { dao, isLoading: daoLoading } = useDao({ | ||
chainid, | ||
daoid, | ||
}); | ||
const { proposals } = useActiveDaoProposals({ | ||
const { proposals, isLoading: proposalsLoading } = useActiveDaoProposals({ | ||
chainid, | ||
daoid, | ||
}); | ||
|
||
if (isLoading || !dao) return; | ||
if (daoLoading || !dao || proposalsLoading) return null; | ||
|
||
console.log("dao", dao); | ||
const imgSrc = dao.profile?.avatarImg || "/castle.svg"; | ||
const proposalCount = proposals?.length || 0; | ||
|
||
return ( | ||
<Link key={daoid} href={`/dao/${chainid}/${daoid}`}> | ||
<div> | ||
<Image src={imgSrc} width={45} height={45} alt="dao logo" priority /> | ||
|
||
<Button size="sm" variant="secondary"> | ||
{dao.name} | ||
</Button> | ||
{proposals && proposals.length > 0 && ( | ||
<p>active proposals: {proposals.length}</p> | ||
)} | ||
</div> | ||
<Link href={`/dao/${chainid}/${daoid}`} className="w-full"> | ||
<Card className="w-full bg-background border hover:bg-card transition-colors rounded-none"> | ||
<div className="flex items-center gap-3 p-4"> | ||
<Avatar className="h-10 w-10"> | ||
<AvatarImage src={imgSrc} alt={dao.name} /> | ||
<AvatarFallback>{dao.name[0]}</AvatarFallback> | ||
</Avatar> | ||
<div className="flex flex-col"> | ||
<span className="text-foreground font-medium truncate"> | ||
{dao.name.length > 25 ? `${dao.name.slice(0, 25)}...` : dao.name} | ||
</span> | ||
<span className="text-muted text-sm"> | ||
{proposalCount} Active Proposal | ||
{proposalCount !== 1 && "s"} | ||
</span> | ||
</div> | ||
</div> | ||
</Card> | ||
</Link> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
"use client"; | ||
|
||
import * as AvatarPrimitive from "@radix-ui/react-avatar"; | ||
import * as React from "react"; | ||
|
||
import { cn } from "@/lib/cn"; | ||
|
||
const Avatar = React.forwardRef< | ||
React.ElementRef<typeof AvatarPrimitive.Root>, | ||
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Root> | ||
>(({ className, ...props }, ref) => ( | ||
<AvatarPrimitive.Root | ||
ref={ref} | ||
className={cn( | ||
"relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full", | ||
className | ||
)} | ||
{...props} | ||
/> | ||
)); | ||
Avatar.displayName = AvatarPrimitive.Root.displayName; | ||
|
||
const AvatarImage = React.forwardRef< | ||
React.ElementRef<typeof AvatarPrimitive.Image>, | ||
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Image> | ||
>(({ className, ...props }, ref) => ( | ||
<AvatarPrimitive.Image | ||
ref={ref} | ||
className={cn("aspect-square h-full w-full", className)} | ||
{...props} | ||
/> | ||
)); | ||
AvatarImage.displayName = AvatarPrimitive.Image.displayName; | ||
|
||
const AvatarFallback = React.forwardRef< | ||
React.ElementRef<typeof AvatarPrimitive.Fallback>, | ||
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Fallback> | ||
>(({ className, ...props }, ref) => ( | ||
<AvatarPrimitive.Fallback | ||
ref={ref} | ||
className={cn( | ||
"flex h-full w-full items-center justify-center rounded-full bg-muted", | ||
className | ||
)} | ||
{...props} | ||
/> | ||
)); | ||
AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName; | ||
|
||
export { Avatar, AvatarFallback, AvatarImage }; |