Use tRPC for recent groups page (#253)

* Use tRPC for recent groups page

* Use tRPC for adding group by URL

* Use tRPC for saving visited group

* Group context
This commit is contained in:
Sebastien Castiel
2024-10-20 17:43:42 -04:00
parent 39c1a2ffc6
commit 4db788680e
31 changed files with 314 additions and 260 deletions

View File

@@ -3,27 +3,27 @@
import { GroupTabs } from '@/app/groups/[groupId]/group-tabs'
import { ShareButton } from '@/app/groups/[groupId]/share-button'
import { Skeleton } from '@/components/ui/skeleton'
import { trpc } from '@/trpc/client'
import Link from 'next/link'
import { useCurrentGroup } from './current-group-context'
export const GroupHeader = ({ groupId }: { groupId: string }) => {
const { data, isLoading } = trpc.groups.get.useQuery({ groupId })
export const GroupHeader = () => {
const { isLoading, groupId, group } = useCurrentGroup()
return (
<div className="flex flex-col justify-between gap-3">
<h1 className="font-bold text-2xl">
<Link href={`/groups/${groupId}`}>
{isLoading || !data ? (
{isLoading ? (
<Skeleton className="mt-1.5 mb-1.5 h-5 w-32" />
) : (
<div className="flex">{data.group.name}</div>
<div className="flex">{group.name}</div>
)}
</Link>
</h1>
<div className="flex gap-2 justify-between">
<GroupTabs groupId={groupId} />
{data?.group && <ShareButton group={data.group} />}
{group && <ShareButton group={group} />}
</div>
</div>
)