fix: invalidate properties cache after listing creation
Without this, navigating to Meine Inserate within 5 min of visiting it previously would show a stale empty list. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { useState } from 'react'
|
||||
import { useLocation, useNavigate } from 'react-router'
|
||||
import { useQueryClient } from '@tanstack/react-query'
|
||||
import {
|
||||
Alert,
|
||||
Box,
|
||||
@@ -76,6 +77,7 @@ interface LocationState {
|
||||
|
||||
export default function NewListing() {
|
||||
const navigate = useNavigate()
|
||||
const qc = useQueryClient()
|
||||
const { state } = useLocation() as { state: LocationState | null }
|
||||
const pre = state?.prefill ?? {}
|
||||
|
||||
@@ -219,6 +221,7 @@ export default function NewListing() {
|
||||
|
||||
try {
|
||||
await propertyService.create(input)
|
||||
qc.invalidateQueries({ queryKey: ['properties'] })
|
||||
setCreated(true)
|
||||
} catch {
|
||||
setError('Fehler beim Erstellen des Inserats. Bitte erneut versuchen.')
|
||||
|
||||
Reference in New Issue
Block a user