Skip to content

Commit

Permalink
confirmation encounter form and encounter alerts changes
Browse files Browse the repository at this point in the history
  • Loading branch information
roberttullycarr committed Feb 28, 2025
1 parent a3639db commit 3839bea
Show file tree
Hide file tree
Showing 7 changed files with 210 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ export class EncounterCompetition extends Model<
@BelongsTo(() => Player, 'acceptedById')
acceptedBy?: Relation<Player>;

@Field(() => Boolean, { nullable: false })
@Column(DataType.BOOLEAN)
finished?: boolean;

@Field(() => Boolean, { nullable: false })
@Column(DataType.BOOLEAN)
homeCaptainPresent?: boolean;
Expand Down Expand Up @@ -313,9 +317,13 @@ export class EncounterCompetition extends Model<
getAway!: BelongsToGetAssociationMixin<Team>;
setAway!: BelongsToSetAssociationMixin<Team, string>;

// Belongs to Away
getAcceptedBy!: BelongsToGetAssociationMixin<Player>;
setAccdeptedBy!: BelongsToSetAssociationMixin<Player, string>;
// Belongs to player
getAcceptedBy!: BelongsToGetAssociationMixin<Player>;
setAcceptedBy!: BelongsToSetAssociationMixin<Player, string>;

// Belongs to player
getEnteredBy!: BelongsToGetAssociationMixin<Player>;
setEnteredBy!: BelongsToSetAssociationMixin<Player, string>;

// Has one EncounterChange
getEncounterChange!: HasOneGetAssociationMixin<EncounterChange>;
Expand Down Expand Up @@ -427,4 +435,13 @@ export class updateEncounterCompetitionInput {

@Field(() => Date, { nullable: true })
acceptedOn?: Date;

@Field(() => Boolean, { nullable: true })
finished?: boolean;

@Field(() => String, { nullable: true })
enteredById?: string;

@Field(() => Date, { nullable: true })
enteredOn?: Date;
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export class CommentResolver {
@Args('data') newCommentData: CommentNewInput,
@User() user: Player,
): Promise<Comment> {
this.logger.log('Adding or updating a comment');
const transaction = await this._sequelize.transaction();
try {
if (!newCommentData?.linkType) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ export class EncounterCompetitionResolver {
async encounterCompetitions(
@Args() listArgs: ListArgs,
): Promise<{ count: number; rows: EncounterCompetition[] }> {

return EncounterCompetition.findAndCountAll({
subQuery: false,
include: [
Expand Down Expand Up @@ -199,6 +200,11 @@ export class EncounterCompetitionResolver {
return encounter.getGameLeader();
}

@ResolveField(() => Player)
async enteredBy(@Parent() encounter: EncounterCompetition): Promise<Player> {
return encounter.getEnteredBy();
}

@ResolveField(() => Player)
async acceptedBy(@Parent() encounter: EncounterCompetition): Promise<Player> {
return encounter.getAcceptedBy();
Expand Down Expand Up @@ -379,18 +385,28 @@ export class EncounterCompetitionResolver {
@Args('encounterId') encounterId: string,
@Args('data') updateEncounterCompetitionData: updateEncounterCompetitionInput,
) {
const encounter = await EncounterCompetition.findByPk(encounterId);

if (!encounter) {
throw new NotFoundException(`${EncounterCompetition.name}: ${encounterId}`);
}

if (!(await user.hasAnyPermission(['change-any:encounter']) || encounter.gameLeaderId === user.id)) {
throw new UnauthorizedException(`You do not have permission to edit this encounter`);
this.logger.log('Updating encounter record with id:', encounterId);
const transaction = await this._sequelize.transaction();
try {
const encounter = await EncounterCompetition.findByPk(encounterId, {transaction});

if (!encounter) {
throw new NotFoundException(`${EncounterCompetition.name}: ${encounterId}`);
}

if (!(await user.hasAnyPermission(['change-any:encounter']) ||[`change-${encounterId}:encounter`]|| encounter.gameLeaderId === user.id)) {
throw new UnauthorizedException(`You do not have permission to edit this encounter`);
}

const result = await encounter.update(updateEncounterCompetitionData, {transaction});


await transaction.commit();
return result;
} catch (error) {
this.logger.error(error);
await transaction.rollback();
throw error;
}

await encounter.update(updateEncounterCompetitionData);

return encounter;
}
}
43 changes: 42 additions & 1 deletion libs/backend/translate/assets/i18n/en/all.json
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,43 @@
"tuesday": "Tuesday",
"wednesday": "Wednesday"
},
"confirmEncounterPage": {
"title": "Confirm encounter",
"sectionTitles": {
"teams": "Teams",
"confirmation": "Confirmation",
"results": "Results",
"information": "Information"
},
"positions": {
"captain": "Captain",
"gameLeader": "Game leader",
"homeCaptain": "Home captain",
"awayCaptain": "Away captain"
},
"buttons": {
"cancel": "Cancel",
"close": "Close",
"confirm": "Confirm",
"seeEncounter": "See encounter"
},
"messages": {
"timeToConfirm": "You have {hoursUntilExpiry} more hours to confirm or dispute encounter"
}
},
"encounterAlerts": {
"buttons": {
"seeEncounter": "See encounter",
"seeAllMessages": "show all messages ({amountOfAlerts})",
"hideMessages": "hide messages"
},
"messages": {
"confirmOrDisputeEncounter": "You have {hoursUntilExpiry} more hours to confirm or dispute encounter"
},
"details": {

}
},
"encounterFormPage": {
"title": "Encounter form",
"steps": {
Expand Down Expand Up @@ -462,6 +499,8 @@
"areComments": "{numberOfComments} comments",
"noComments": "No Comments",
"presenceUpdated": "{position} presence updated",
"confirmationUpdated": "{position} confirmation updated",
"encounterUpdated": "Encounter successfully updated",
"gameCreated": "Game successfully created",
"gameUpdated": "Game successfully updated"
},
Expand Down Expand Up @@ -500,8 +539,10 @@
},
"errors": {
"presenceNotUpdated": "{position} presence not updated",
"confirmationNotUpdated": "{position} confirmation not updated",
"errorCreatingGame": "Error creating game",
"errorUpdatingGame": "Error updating game"
"errorUpdatingGame": "Error updating game",
"encounterNotUpdated": "Error updating encounter"
}
},
"event": {
Expand Down
42 changes: 40 additions & 2 deletions libs/backend/translate/assets/i18n/fr_BE/all.json
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,39 @@
"tuesday": "Mardi",
"wednesday": "Mercredi"
},
"confirmEncounterPage": {
"title": "Confirmer la rencontre",
"sectionTitles": {
"teams": "Équipes",
"confirmation": "Confirmation",
"results": "Résultats",
"information": "Informations"
},
"positions": {
"captain": "Capitaine",
"gameLeader": "Chef de jeu",
"homeCaptain": "Capitaine à domicile",
"awayCaptain": "Capitaine à l'extérieur"
},
"buttons": {
"cancel": "Annuler",
"close": "Fermer",
"confirm": "Confirmer"
}
},
"encounterAlerts": {
"buttons": {
"seeEncounter": "Voir la rencontre",
"seeAllMessages": "voir tous les messages ({amountOfAlerts})",
"hideMessages": "masquer les messages"
},
"messages": {
"confirmOrDisputeEncounter": "Il vous reste {hoursUntilExpiry} heures pour confirmer ou contester la rencontre"
},
"details": {

}
},
"encounterFormPage": {
"title": "Formulaire de rencontre",
"steps": {
Expand Down Expand Up @@ -461,7 +494,10 @@
"areComments": "{numberOfComments} commentaires",
"noComments": "Pas de commentaires",
"gameCreated": "Le match a été créé",
"gameUpdated": "Le match a été mis à jour"
"gameUpdated": "Le match a été mis à jour",
"presenceUpdated": "Confirmation de présence de {position} mise à jour",
"confirmationUpdated": "Confirmation de {position} mise à jour",
"encounterUpdated": "Rencontre mise à jour"
},
"buttons": {
"back": "Retour",
Expand Down Expand Up @@ -497,8 +533,10 @@
},
"errors": {
"presenceNotUpdated": "présence du {position} non mise à jour",
"confirmationNotUpdated": "Confirmation de {position} non mise à jour",
"errorCreatingGame": "Erreur lors de la création du match",
"errorUpdatingGame": "Erreur lors de la mise à jour du match"
"errorUpdatingGame": "Erreur lors de la mise à jour du match",
"encounterNotUpdated": "Rencontre non mise à jour"
}
},
"event": {
Expand Down
42 changes: 40 additions & 2 deletions libs/backend/translate/assets/i18n/nl_BE/all.json
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,39 @@
"tuesday": "Dinsdag",
"wednesday": "Woensdag"
},
"confirmEncounterPage": {
"title": "bevestig ontmoeting",
"sectionTitles": {
"teams": "Ploegen",
"confirmation": "Bevestiging",
"results": "Uitslagen",
"information": "Informatie"
},
"positions": {
"captain": "Ploegkapitein",
"gameLeader": "Wedstrijdleider",
"homeCaptain": "thuis kapitein",
"awayCaptain": "uit kapitein"
},
"buttons": {
"cancel": "Annuleren",
"close": "Afsluiten",
"confirm": "Bevestigen"
}
},
"encounterAlerts": {
"buttons": {
"seeEncounter": "Bekijk ontmoeting",
"seeAllMessages": "bekijk alle berichten ({amountOfAlerts})",
"hideMessages": "berichten verbergen"
},
"messages": {
"confirmOrDisputeEncounter": "Je hebt nog {hoursUntilExpiry} uur om de ontmoeting te bevestigen of te betwisten"
},
"details": {

}
},
"encounterFormPage": {
"title": "Ontmoetingsformulier",
"steps": {
Expand Down Expand Up @@ -461,7 +494,10 @@
"areComments": "{numberOfComments} opmerkingen",
"noComments": "Geen opmerkingen",
"gameCreated": "Wedstrijd aangemaakt",
"gameUpdated": "Wedstrijd bijgewerkt"
"gameUpdated": "Wedstrijd bijgewerkt",
"presenceUpdated": "Aanwezigheid van {position} bijgewerkt",
"confirmationUpdated": "Bevestiging van {position} bijgewerkt",
"encounterUpdated": "Ontmoeting bijgewerkt"
},
"inputs": {
"present": "Aanwezig",
Expand Down Expand Up @@ -496,9 +532,11 @@
"awayCaptain": "uit kapitein"
},
"errors": {
"confirmationNotUpdated": "{position} bevestiging niet bijgewerkt",
"presenceNotUpdated": "{position} aanwezigheid niet bijgewerkt",
"errorCreatingGame": "Er is een fout opgetreden bij het aanmaken van de wedstrijd",
"errorUpdatingGame": "Er is een fout opgetreden bij het bijwerken van de wedstrijd"
"errorUpdatingGame": "Er is een fout opgetreden bij het bijwerken van de wedstrijd",
"encounterNotUpdated": "Ontmoeting niet bijgewerkt"

}
},
Expand Down
39 changes: 39 additions & 0 deletions libs/utils/src/lib/i18n.generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,41 @@ export type I18nTranslations = {
"tuesday": string;
"wednesday": string;
};
"confirmEncounterPage": {
"title": string;
"sectionTitles": {
"teams": string;
"confirmation": string;
"results": string;
"information": string;
};
"positions": {
"captain": string;
"gameLeader": string;
"homeCaptain": string;
"awayCaptain": string;
};
"buttons": {
"cancel": string;
"close": string;
"confirm": string;
"seeEncounter": string;
};
"messages": {
"timeToConfirm": string;
};
};
"encounterAlerts": {
"buttons": {
"seeEncounter": string;
"seeAllMessages": string;
"hideMessages": string;
};
"messages": {
"confirmOrDisputeEncounter": string;
};
"details": {};
};
"encounterFormPage": {
"title": string;
"steps": {
Expand Down Expand Up @@ -469,6 +504,8 @@ export type I18nTranslations = {
"areComments": string;
"noComments": string;
"presenceUpdated": string;
"confirmationUpdated": string;
"encounterUpdated": string;
"gameCreated": string;
"gameUpdated": string;
};
Expand Down Expand Up @@ -507,8 +544,10 @@ export type I18nTranslations = {
};
"errors": {
"presenceNotUpdated": string;
"confirmationNotUpdated": string;
"errorCreatingGame": string;
"errorUpdatingGame": string;
"encounterNotUpdated": string;
};
};
"event": {
Expand Down

0 comments on commit 3839bea

Please sign in to comment.