Status Report Updates Not Refreshing in Server Components #1717
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Type of change
Description
#1676
Problem
When creating, updating, or deleting status report updates from client components, the data wouldn't refresh on pages that fetch data server-side (like the Overview page). This was because
queryClient.invalidateQueries()only works for client-side React Query fetches, not for Next.js Server Components that usefetchQuery.Solution
Added
router.refresh()calls to all status report update mutations. This triggers Next.js to re-fetch server components while keeping the existinginvalidateQueries()for client-side data.Changes
data-table.tsx: Addedrouter.refresh()to thecreateStatusReportUpdatemutationdata-table-row-actions.tsx: Addedrouter.refresh()to bothupdateStatusReportUpdateanddeleteStatusReportUpdatemutationsHow It Works Now
useQuery):invalidateQueries()triggers refetchfetchQuery):router.refresh()triggers re-renderBoth the dedicated Status Reports page and the Overview dashboard now properly update when status report updates are modified.
Testing
/overview)/status-pages/[id]/status-reports)A picture tells a thousand words (if any)
Before this PR
{Please add a screenshot here}
After this PR
{Please add a screenshot here}
Related Issue (optional)