fix: Giveaway bugs
This commit is contained in:
@@ -83,9 +83,18 @@ export function GiveawaysManager({ guildId, initialGiveaways }: GiveawaysManager
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ action })
|
||||
});
|
||||
const body = (await response.json().catch(() => null)) as (GiveawayDashboard & { error?: string }) | null;
|
||||
if (!response.ok || !body) {
|
||||
toast.error(body?.error ?? t('common.saveError'));
|
||||
const body = (await response.json().catch(() => null)) as
|
||||
| (GiveawayDashboard & { error?: string })
|
||||
| { error?: string }
|
||||
| null;
|
||||
if (!response.ok || !body || !('id' in body)) {
|
||||
toast.error(
|
||||
(body && 'error' in body && body.error) || t('common.saveError')
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (action === 'end' && !body.endedAt) {
|
||||
toast.error(t('common.saveError'));
|
||||
return;
|
||||
}
|
||||
setGiveaways((prev) => prev.map((entry) => (entry.id === giveaway.id ? body : entry)));
|
||||
|
||||
Reference in New Issue
Block a user