Add cache invalidation to all project/round mutations platform-wide
Build and Push Docker Image / build (push) Successful in 8m21s
Details
Build and Push Docker Image / build (push) Successful in 8m21s
Details
Mutations for create, update, delete, import, filtering finalize, override, and reinstate now properly invalidate related queries so the UI updates without requiring a page refresh. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
56a44049d3
commit
db728830d4
|
|
@ -125,14 +125,19 @@ function EditProjectContent({ projectId }: { projectId: string }) {
|
||||||
})
|
})
|
||||||
|
|
||||||
// Mutations
|
// Mutations
|
||||||
|
const utils = trpc.useUtils()
|
||||||
const updateProject = trpc.project.update.useMutation({
|
const updateProject = trpc.project.update.useMutation({
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
|
utils.project.get.invalidate({ id: projectId })
|
||||||
|
utils.project.list.invalidate()
|
||||||
router.push(`/admin/projects/${projectId}`)
|
router.push(`/admin/projects/${projectId}`)
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const deleteProject = trpc.project.delete.useMutation({
|
const deleteProject = trpc.project.delete.useMutation({
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
|
utils.project.list.invalidate()
|
||||||
|
utils.round.get.invalidate()
|
||||||
router.push('/admin/projects')
|
router.push('/admin/projects')
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ import { ArrowLeft, FileSpreadsheet, AlertCircle, Database, FileText } from 'luc
|
||||||
|
|
||||||
function ImportPageContent() {
|
function ImportPageContent() {
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
const utils = trpc.useUtils()
|
||||||
const searchParams = useSearchParams()
|
const searchParams = useSearchParams()
|
||||||
const roundIdParam = searchParams.get('round')
|
const roundIdParam = searchParams.get('round')
|
||||||
|
|
||||||
|
|
@ -175,7 +176,8 @@ function ImportPageContent() {
|
||||||
roundId={selectedRoundId}
|
roundId={selectedRoundId}
|
||||||
roundName={selectedRound.name}
|
roundName={selectedRound.name}
|
||||||
onSuccess={() => {
|
onSuccess={() => {
|
||||||
// Optionally redirect after success
|
utils.project.list.invalidate()
|
||||||
|
utils.round.get.invalidate()
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</TabsContent>
|
</TabsContent>
|
||||||
|
|
@ -184,7 +186,8 @@ function ImportPageContent() {
|
||||||
roundId={selectedRoundId}
|
roundId={selectedRoundId}
|
||||||
roundName={selectedRound.name}
|
roundName={selectedRound.name}
|
||||||
onSuccess={() => {
|
onSuccess={() => {
|
||||||
// Optionally redirect after success
|
utils.project.list.invalidate()
|
||||||
|
utils.round.get.invalidate()
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</TabsContent>
|
</TabsContent>
|
||||||
|
|
@ -193,7 +196,8 @@ function ImportPageContent() {
|
||||||
roundId={selectedRoundId}
|
roundId={selectedRoundId}
|
||||||
roundName={selectedRound.name}
|
roundName={selectedRound.name}
|
||||||
onSuccess={() => {
|
onSuccess={() => {
|
||||||
// Optionally redirect after success
|
utils.project.list.invalidate()
|
||||||
|
utils.round.get.invalidate()
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</TabsContent>
|
</TabsContent>
|
||||||
|
|
|
||||||
|
|
@ -59,9 +59,12 @@ function NewProjectPageContent() {
|
||||||
})
|
})
|
||||||
|
|
||||||
// Create mutation
|
// Create mutation
|
||||||
|
const utils = trpc.useUtils()
|
||||||
const createProject = trpc.project.create.useMutation({
|
const createProject = trpc.project.create.useMutation({
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
toast.success('Project created successfully')
|
toast.success('Project created successfully')
|
||||||
|
utils.project.list.invalidate()
|
||||||
|
utils.round.get.invalidate()
|
||||||
router.push(`/admin/projects?round=${selectedRoundId}`)
|
router.push(`/admin/projects?round=${selectedRoundId}`)
|
||||||
},
|
},
|
||||||
onError: (error) => {
|
onError: (error) => {
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,7 @@ export default function FilteringDashboardPage({
|
||||||
trpc.filtering.getResultStats.useQuery({ roundId })
|
trpc.filtering.getResultStats.useQuery({ roundId })
|
||||||
const { data: rules } = trpc.filtering.getRules.useQuery({ roundId })
|
const { data: rules } = trpc.filtering.getRules.useQuery({ roundId })
|
||||||
|
|
||||||
|
const utils = trpc.useUtils()
|
||||||
const executeRules = trpc.filtering.executeRules.useMutation()
|
const executeRules = trpc.filtering.executeRules.useMutation()
|
||||||
const finalizeResults = trpc.filtering.finalizeResults.useMutation()
|
const finalizeResults = trpc.filtering.finalizeResults.useMutation()
|
||||||
|
|
||||||
|
|
@ -63,6 +64,8 @@ export default function FilteringDashboardPage({
|
||||||
`Finalized: ${result.passed} passed, ${result.filteredOut} filtered out`
|
`Finalized: ${result.passed} passed, ${result.filteredOut} filtered out`
|
||||||
)
|
)
|
||||||
refetchStats()
|
refetchStats()
|
||||||
|
utils.project.list.invalidate()
|
||||||
|
utils.round.get.invalidate({ id: roundId })
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
toast.error(
|
toast.error(
|
||||||
error instanceof Error ? error.message : 'Failed to finalize'
|
error instanceof Error ? error.message : 'Failed to finalize'
|
||||||
|
|
|
||||||
|
|
@ -105,6 +105,7 @@ export default function FilteringResultsPage({
|
||||||
perPage,
|
perPage,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const utils = trpc.useUtils()
|
||||||
const overrideResult = trpc.filtering.overrideResult.useMutation()
|
const overrideResult = trpc.filtering.overrideResult.useMutation()
|
||||||
const reinstateProject = trpc.filtering.reinstateProject.useMutation()
|
const reinstateProject = trpc.filtering.reinstateProject.useMutation()
|
||||||
|
|
||||||
|
|
@ -127,6 +128,7 @@ export default function FilteringResultsPage({
|
||||||
setOverrideDialog(null)
|
setOverrideDialog(null)
|
||||||
setOverrideReason('')
|
setOverrideReason('')
|
||||||
refetch()
|
refetch()
|
||||||
|
utils.project.list.invalidate()
|
||||||
} catch {
|
} catch {
|
||||||
toast.error('Failed to override result')
|
toast.error('Failed to override result')
|
||||||
}
|
}
|
||||||
|
|
@ -137,6 +139,7 @@ export default function FilteringResultsPage({
|
||||||
await reinstateProject.mutateAsync({ roundId, projectId })
|
await reinstateProject.mutateAsync({ roundId, projectId })
|
||||||
toast.success('Project reinstated')
|
toast.success('Project reinstated')
|
||||||
refetch()
|
refetch()
|
||||||
|
utils.project.list.invalidate()
|
||||||
} catch {
|
} catch {
|
||||||
toast.error('Failed to reinstate project')
|
toast.error('Failed to reinstate project')
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -76,6 +76,8 @@ function RoundDetailContent({ roundId }: { roundId: string }) {
|
||||||
const deleteRound = trpc.round.delete.useMutation({
|
const deleteRound = trpc.round.delete.useMutation({
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
toast.success('Round deleted')
|
toast.success('Round deleted')
|
||||||
|
utils.program.list.invalidate()
|
||||||
|
utils.round.list.invalidate()
|
||||||
router.push('/admin/rounds')
|
router.push('/admin/rounds')
|
||||||
},
|
},
|
||||||
onError: () => {
|
onError: () => {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue