Fix client-side cache staleness after proof of payment upload
Added cache revalidation to ensure ViewLocationCard reflects uploaded proof of payment when navigating back from ViewBillCard: - Server-side: Added revalidatePath() to upload actions in billActions and locationActions to invalidate Next.js server cache - Client-side: Added router.refresh() calls in ViewBillCard and ViewLocationCard to refresh client router cache after successful upload This maintains the current UX (no redirect on upload) while ensuring fresh data is displayed on navigation. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -5,6 +5,7 @@ import { BilledTo, BillingLocation, UserSettings } from "../lib/db-types";
|
||||
import { formatYearMonth } from "../lib/format";
|
||||
import { formatCurrency, formatIban } from "../lib/formatStrings";
|
||||
import { useTranslations } from "next-intl";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { ViewBillBadge } from "./ViewBillBadge";
|
||||
import { Pdf417Barcode } from "./Pdf417Barcode";
|
||||
import { EncodePayment, PaymentParams } from "hub-3a-payment-encoder";
|
||||
@@ -34,6 +35,7 @@ export const ViewLocationCard: FC<ViewLocationCardProps> = ({ location, userSett
|
||||
proofOfPaymentType,
|
||||
} = location;
|
||||
|
||||
const router = useRouter();
|
||||
const t = useTranslations("home-page.location-card");
|
||||
|
||||
const [isUploading, setIsUploading] = useState(false);
|
||||
@@ -64,6 +66,7 @@ export const ViewLocationCard: FC<ViewLocationCardProps> = ({ location, userSett
|
||||
if (result.success) {
|
||||
setAttachmentFilename(file.name);
|
||||
setAttachmentUploadedAt(new Date());
|
||||
router.refresh();
|
||||
} else {
|
||||
setUploadError(result.error || 'Upload failed');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user