Create teams when arbitrary details are changed

These teams have no weapons and won't show up anywhere but the user's profile. We should probably clean out completely empty teams every once in a while with a CRON job.
This commit is contained in:
Justin Edmund 2023-01-07 23:25:55 -08:00
parent 4a219378c7
commit 5de556b367

View file

@ -59,14 +59,30 @@ const Party = (props: Props) => {
} }
} }
function updateDetails(details: DetailsObject) { async function updateDetails(details: DetailsObject) {
if ( if (
appState.party.name !== details.name || appState.party.name !== details.name ||
appState.party.description !== details.description || appState.party.description !== details.description ||
appState.party.raid?.id !== details.raid?.id appState.party.raid?.id !== details.raid?.id
) { ) {
if (appState.party.id) if (!appState.party.id)
api.endpoints.parties await createParty().then((response) => {
// If the party has no ID, create a new party
const party = response.data.party
storeParty(party)
// Then, push the browser history to the new party's URL
if (props.pushHistory) props.pushHistory(`/p/${party.shortcode}`)
})
// Update the party
await sendUpdate(details)
}
}
async function sendUpdate(details: DetailsObject) {
if (appState.party.id) {
return await api.endpoints.parties
.update(appState.party.id, { .update(appState.party.id, {
party: { party: {
name: details.name, name: details.name,