import { PLACEMENT_LABELS } from '~/utils/showcase.shared' import * as React from 'react' import { Link, createFileRoute } from '@tanstack/react-router' import { useQuery, useMutation } from '@tanstack/react-query' import { showcasesMutations, showcasesQueries } from '~/queries/showcases' import { libraries } from '~/libraries' import { useToast } from '~/components/ToastProvider' import { seo } from '~/utils/seo' import { PlusIcon, TrashIcon, ArrowSquareOutIcon, ClockIcon, CheckIcon, XIcon, PencilIcon, } from '@phosphor-icons/react' import type { Showcase } from '~/db/types' import { Badge, Button } from '~/ui' export const Route = createFileRoute('/account/submissions')({ loader: async ({ context: { queryClient } }) => { await queryClient.ensureQueryData( showcasesQueries.mineList({ pagination: { page: 1, pageSize: 20 }, }), ) }, component: AccountSubmissionsPage, head: () => ({ meta: seo({ title: 'My Submissions | Account | TanStack', description: 'View and manage your showcase submissions.', }), }), }) const libraryMap = new Map(libraries.map((lib) => [lib.id as string, lib])) function AccountSubmissionsPage() { const { notify } = useToast() const { data, isLoading } = useQuery( showcasesQueries.mineList({ pagination: { page: 1, pageSize: 20 }, }), ) const deleteMutation = useMutation( showcasesMutations.delete({ onSuccess: () => { notify(
Showcase deleted
, ) }, onError: (error) => { notify(
Delete failed
{error.message}
, ) }, }), ) const handleDelete = (showcaseId: string) => { if (confirm('Are you sure you want to delete this showcase?')) { deleteMutation.mutate({ data: { showcaseId } }) } } const getStatusBadge = (status: Showcase['status']) => { switch (status) { case 'pending': return ( Pending Review ) case 'approved': return ( Approved ) case 'denied': return ( Denied ) } } return (

View and manage your showcase submissions

{isLoading ? (
{[1, 2, 3].map((i) => (
))}
) : data?.showcases && data.showcases.length > 0 ? (
{data.showcases.map((showcase) => (
{/* Screenshot */}
{showcase.name}
{getStatusBadge(showcase.status)} {PLACEMENT_LABELS[showcase.placement]}
{/* Content */}

{showcase.name}

{showcase.tagline}

{getStatusBadge(showcase.status)} {PLACEMENT_LABELS[showcase.placement]}
{/* Libraries */}
{showcase.libraries.map((libId) => { const lib = libraryMap.get(libId) return ( {lib?.name?.replace('TanStack ', '') || libId} ) })}
{/* Moderation note */} {/* Actions */}
))}
) : (

You haven't submitted any showcases yet.

)}
) }