feat: add created_at field to CreatedApiKeyResponse and update related handlers
Some checks failed
lint / lint (push) Successful in 16m47s
test / unit (push) Has been cancelled

This commit is contained in:
2026-07-04 15:04:16 +02:00
parent 8f69cfb011
commit c22bc68a8b
7 changed files with 35 additions and 11 deletions

View File

@@ -1,7 +1,9 @@
"use client"
import { useOptimistic, useRef } from "react"
import { followUser, unfollowUser } from "@/app/actions/social"
import { useRouter } from "next/navigation"
import { followUser, unfollowUser } from "@/lib/api"
import { useAuth } from "@/hooks/use-auth"
import { Button } from "@/components/ui/button"
import { toast } from "sonner"
import { UserPlus, UserMinus } from "lucide-react"
@@ -68,8 +70,11 @@ function burstParticles(canvas: HTMLCanvasElement) {
export function FollowButton({ username, isInitiallyFollowing }: FollowButtonProps) {
const [optimisticFollowing, setOptimisticFollowing] = useOptimistic(isInitiallyFollowing)
const canvasRef = useRef<HTMLCanvasElement>(null)
const { token } = useAuth()
const router = useRouter()
async function handleClick() {
if (!token) return
const next = !optimisticFollowing
setOptimisticFollowing(next)
@@ -78,7 +83,8 @@ export function FollowButton({ username, isInitiallyFollowing }: FollowButtonPro
}
try {
await (next ? followUser(username) : unfollowUser(username))
await (next ? followUser(username, token) : unfollowUser(username, token))
router.refresh()
} catch {
setOptimisticFollowing(!next)
toast.error(`Failed to ${next ? "follow" : "unfollow"} user.`)