diff --git a/webapp/admin/add.tsx b/webapp/admin/add.tsx new file mode 100644 index 0000000..db20010 --- /dev/null +++ b/webapp/admin/add.tsx @@ -0,0 +1,93 @@ +import { useState } from 'react' +import { useMutation, useQueryClient } from '@tanstack/react-query' +import { Button } from '@/components/ui/button' +import { adminApi, errorText, shortSha, type AddResult } from './api' +import { Notice, PUBLISH_NOTE } from './app' + +const OUTCOME: Record = { + queued: 'new', + invalid_url: 'not an itch.io game URL', + duplicate_in_request: 'listed twice', + duplicate_catalog: 'already in the catalog', + duplicate_pending: 'already in the queue', + previously_deleted: 'removed before', + rejected: 'rejected before', +} + +export function AddPage() { + const [text, setText] = useState('') + const [override, setOverride] = useState(false) + const [result, setResult] = useState(null) + const [error, setError] = useState(null) + const client = useQueryClient() + const urls = text + .split(/\s+/) + .map((u) => u.trim()) + .filter(Boolean) + + const add = useMutation({ + mutationFn: () => adminApi.add(urls, override), + onSuccess: (r) => { + setResult(r) + setError(null) + if (r.results.some((x) => x.approved)) setText('') + void client.invalidateQueries({ queryKey: ['queue'] }) + }, + onError: (e) => setError(errorText(e)), + }) + + return ( +
+

Add games

+

+ Paste itch.io game URLs (one per line, up to 200). New ones are approved right away and scraped by the + ingest workflow; paid games are dropped there. +

+ +