sdsads
This commit is contained in:
@@ -1280,6 +1280,51 @@
|
||||
return refreshed;
|
||||
}
|
||||
|
||||
function invalidateProjectBootstrapCache(key) {
|
||||
const prefix = `${key}:`;
|
||||
Array.from(bootstrapCacheRef.current.keys()).forEach((cacheKey) => {
|
||||
if (String(cacheKey).startsWith(prefix)) {
|
||||
bootstrapCacheRef.current.delete(cacheKey);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function applySavedPayout(savedPayout) {
|
||||
if (!savedPayout || typeof savedPayout !== 'object') {
|
||||
return;
|
||||
}
|
||||
|
||||
setPayload((previous) => {
|
||||
const current = previous || normalizeBootstrap(null, projectKey);
|
||||
const previousPayouts = Array.isArray(current.settings?.payouts) ? current.settings.payouts : [];
|
||||
const savedId = String(savedPayout.id ?? '');
|
||||
const payouts = previousPayouts
|
||||
.filter((row) => savedId === '' || String(row?.id ?? '') !== savedId)
|
||||
.concat(savedPayout)
|
||||
.sort((left, right) => String(left?.payout_at || '').localeCompare(String(right?.payout_at || '')));
|
||||
const totalCoins = payouts.reduce((sum, row) => {
|
||||
const amount = Number(row?.coins_amount);
|
||||
return Number.isFinite(amount) ? sum + amount : sum;
|
||||
}, 0);
|
||||
|
||||
return {
|
||||
...current,
|
||||
settings: {
|
||||
...(current.settings || {}),
|
||||
payouts,
|
||||
},
|
||||
summary: {
|
||||
...(current.summary || {}),
|
||||
payouts: {
|
||||
...(current.summary?.payouts || {}),
|
||||
total_count: payouts.length,
|
||||
total_coins: totalCoins,
|
||||
},
|
||||
},
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
loadBootstrap(projectKey);
|
||||
}, [projectKey, activeTab]);
|
||||
@@ -1755,16 +1800,19 @@
|
||||
event.preventDefault();
|
||||
setSaving(true);
|
||||
setError('');
|
||||
setMessage('');
|
||||
try {
|
||||
await request(`${apiBase}/projects/${encodeURIComponent(projectKey)}/payouts`, {
|
||||
const savedPayout = await request(`${apiBase}/projects/${encodeURIComponent(projectKey)}/payouts`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(payoutForm),
|
||||
timeoutMs: 8000,
|
||||
});
|
||||
applySavedPayout(savedPayout);
|
||||
invalidateProjectBootstrapCache(projectKey);
|
||||
setMessage('Auszahlung gespeichert.');
|
||||
setPayoutForm({ payout_at: '', coins_amount: '', payout_currency: currentSettings.crypto_currency || 'DOGE', note: '' });
|
||||
setPayoutModalOpen(false);
|
||||
await reloadBootstrapAfterMutation('Auszahlung gespeichert.');
|
||||
} catch (err) {
|
||||
setError(err.message);
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user