"use client" import { useEffect, useState } from "react" import { useQuery, useQueryClient, useMutation } from "@tanstack/react-query" import api from "@/lib/api" import type { TimelineResponse, AssetResponse } from "@/lib/types" import { PhotoCard } from "@/components/photo-card" import { Button } from "@/components/ui/button" import { Spinner } from "@/components/ui/spinner" import { toast } from "sonner" import { RotateCcwIcon } from "lucide-react" export default function TrashPage() { const qc = useQueryClient() const { data, isLoading } = useQuery({ queryKey: ["trash"], queryFn: async () => { const { data } = await api.get("/assets/trash", { params: { limit: 100, offset: 0 }, }) return data }, }) const restore = useMutation({ mutationFn: async (assetId: string) => { await api.post(`/assets/${assetId}/restore`) }, onSuccess: () => { qc.invalidateQueries({ queryKey: ["trash"] }) qc.invalidateQueries({ queryKey: ["timeline"] }) qc.invalidateQueries({ queryKey: ["date-summary"] }) }, }) const assets = data?.assets ?? [] return (

Trash

{data && data.total > 0 && ( {data.total} items )}
{isLoading ? ( ) : assets.length === 0 ? (

Trash is empty

) : (
{assets.map((asset) => (
))}
)}
) }