fix(#63): Enforce mutually exclusive catch states

This commit is contained in:
Josh Creek
2026-01-09 20:51:33 +00:00
parent ca6831d10a
commit 35ee92df0c
2 changed files with 29 additions and 3 deletions
+9 -1
View File
@@ -104,6 +104,14 @@
async function updateACatch(event: any) {
if (!pokedexId) return;
const { catchRecord } = event.detail;
// Enforce mutual exclusivity (should be impossible to have both true).
const sanitizedCatchRecord: CatchRecord = { ...catchRecord };
if (sanitizedCatchRecord.caught) {
sanitizedCatchRecord.haveToEvolve = false;
}
if (sanitizedCatchRecord.haveToEvolve) {
sanitizedCatchRecord.caught = false;
}
if (!localUser?.id) {
alert('User not signed in');
return;
@@ -114,7 +122,7 @@
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(catchRecord),
body: JSON.stringify(sanitizedCatchRecord),
credentials: 'include' as RequestCredentials
};