Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion src/routes/admin/search/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,11 @@
async function updateWallet(field: string, value: any) {
if (!wallet) return;

// Preserve current wallet data before update
const currentTransactions = wallet.transactions || [];
const currentCut = wallet.cut;
const currentBalance = wallet.balance;

try {
await patchIdByWalletsByAdmin({
path: { id: wallet._id },
Expand All @@ -207,7 +212,23 @@
headers: getAuthHeaders(),
});
if (response.data) {
wallet = response.data as AdminWallet;
const updatedWallet = response.data as AdminWallet;

// Preserve critical fields if the response doesn't include them
// This prevents frontend data loss even if backend response is incomplete
if (!updatedWallet.transactions || updatedWallet.transactions.length === 0) {
updatedWallet.transactions = currentTransactions;
}

if (updatedWallet.cut === undefined || updatedWallet.cut === null) {
updatedWallet.cut = currentCut;
}

if (!updatedWallet.balance) {
updatedWallet.balance = currentBalance;
}

wallet = updatedWallet;
}
} catch {
toast.show('Failed to update wallet', 'error');
Expand Down