fix: sync payments page state on URL param changes
All checks were successful
CI / update (push) Successful in 1m26s
All checks were successful
CI / update (push) Successful in 1m26s
$state() only captured initial data prop values, so navigating to different offset/limit params always showed the first page results.
This commit is contained in:
@@ -19,6 +19,14 @@
|
|||||||
let limit = $state(data.limit || 20);
|
let limit = $state(data.limit || 20);
|
||||||
let hasMore = $state(data.hasMore || false);
|
let hasMore = $state(data.hasMore || false);
|
||||||
|
|
||||||
|
// Re-sync local state when server data changes (e.g. URL param navigation)
|
||||||
|
$effect(() => {
|
||||||
|
payments = data.payments || [];
|
||||||
|
currentPage = Math.floor(data.currentOffset / data.limit);
|
||||||
|
limit = data.limit || 20;
|
||||||
|
hasMore = data.hasMore || false;
|
||||||
|
});
|
||||||
|
|
||||||
// Progressive enhancement: only load if JavaScript is available
|
// Progressive enhancement: only load if JavaScript is available
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
// Mark that JavaScript is loaded for CSS
|
// Mark that JavaScript is loaded for CSS
|
||||||
|
|||||||
Reference in New Issue
Block a user