Skip to content

Commit

Permalink
Merge branch 'dev' into feat/permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
TeddyRoncin authored Nov 20, 2023
2 parents 847f757 + b7f2ebb commit 2937d24
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 6 deletions.
2 changes: 1 addition & 1 deletion assets/email/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<tr style="background-color: {{& style.text.color}}">
<td style="text-align: right">
<img
src="https://arena.utt.fr/images/logo.png"
src="https://arena.utt.fr/images/logo.webp"
alt="Logo UTT Arena"
title="Logo UTT Arena"
width="140"
Expand Down
6 changes: 3 additions & 3 deletions src/controllers/teams/createTeamRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ export default [
async (request: Request, response: Response, next: NextFunction) => {
try {
const team = await fetchTeam(request.params.teamId);
const { user } = getRequestInfo(response);

// Check if the team exists
if (!team) return notFound(response, ResponseError.TeamNotFound);

// Check if the team is not locked
if (team.lockedAt) return forbidden(response, ResponseError.TeamLocked);

const { user } = getRequestInfo(response);
if (team.lockedAt && request.body.userType !== UserType.coach)
return forbidden(response, ResponseError.TeamLocked);

// Check if the user is already asking for a team
if (user.askingTeamId) return forbidden(response, ResponseError.AlreadyAskedATeam);
Expand Down
6 changes: 4 additions & 2 deletions src/scripts/mails/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import { Mail } from '../../services/email/types';
import { EmailAttachement } from '../../types';
import logger from '../../utils/logger';
// import { ticketsGoal } from './tickets';
import { notPaidGoal } from './notpaid';
// import { notPaidGoal } from './notpaid';
import { notPaidSSBUGoal } from './notpaidssbu';
// import { discordGoal } from './discord';
// import { minorGoal } from './minor';
// import { unlockedPlayersGoal } from './unlocked';
Expand All @@ -22,7 +23,8 @@ const goals: Array<MailGoal> = [
// discordGoal, minorGoal,
// ticketsGoal,
// unlockedPlayersGoal
notPaidGoal,
// notPaidGoal,
notPaidSSBUGoal,
];

(async () => {
Expand Down
72 changes: 72 additions & 0 deletions src/scripts/mails/notpaidssbu.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import { MailGoal } from '.';
import database from '../../services/database';
import { EmailAttachement } from '../../types';

export const notPaidSSBUGoal: MailGoal = {
collector: () =>
database.user.findMany({
distinct: ['id'],
where: {
AND: [
{
OR: [
{
cartItems: {
some: {
AND: [
{
itemId: {
startsWith: 'ticket-',
},
forcePaid: false,
},
{
cart: {
transactionState: {
not: 'paid',
},
},
},
],
},
},
},
{
cartItems: {
none: {},
},
},
],
},
{
team: {
tournament: {
id: 'ssbu',
},
},
},
{
team: {
lockedAt: null,
},
},
],
},
}),
sections: [
{
title: "Ton inscription n'a pas été confirmée",
components: [
"L'UTT Arena approche à grand pas, et ton inscription pour le tournoi SSBU n'est pas encore confirmée. Pour verrouiller ta place, il ne te reste plus qu'à la payer en accédant à la boutique sur le site.",
"\nN'oublie pas que tu peux décider de ramener ta propre Nintendo Switch avec SSBU (all DLCs) pour bénéficier d'une *réduction de 3€* sur ta place ! Cela permet également au tournoi de s'enchaîner de façon plus fluide.",
"\nOn se retrouve le 1, 2, 3 décembre dans l'Arène !",
{
location: 'https://arena.utt.fr/dashboard/team',
name: 'Accéder à arena.utt.fr',
},
],
},
],
// eslint-disable-next-line require-await
attachments: async () => [] as EmailAttachement[],
};

0 comments on commit 2937d24

Please sign in to comment.