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

@@ -9,14 +9,14 @@ import {
CardTitle,
} from '@/components/ui/card'
import { Skeleton } from '@/components/ui/skeleton'
import { trpc } from '@/trpc/client'
import { Pencil } from 'lucide-react'
import { useTranslations } from 'next-intl'
import Link from 'next/link'
import { useCurrentGroup } from '../current-group-context'
export default function GroupInformation({ groupId }: { groupId: string }) {
const t = useTranslations('Information')
const { data, isLoading } = trpc.groups.get.useQuery({ groupId })
const { isLoading, group } = useCurrentGroup()
return (
<>
@@ -35,13 +35,13 @@ export default function GroupInformation({ groupId }: { groupId: string }) {
</CardDescription>
</CardHeader>
<CardContent className="prose prose-sm sm:prose-base max-w-full whitespace-break-spaces">
{isLoading || !data ? (
{isLoading ? (
<div className="py-1 flex flex-col gap-2">
<Skeleton className="h-3 w-3/4" />
<Skeleton className="h-3 w-1/2" />
</div>
) : data.group.information ? (
<p className="text-foreground">{data.group.information}</p>
) : group.information ? (
<p className="text-foreground">{group.information}</p>
) : (
<p className="text-muted-foreground text-sm">{t('empty')}</p>
)}