+export const hasTournamentCrew = tournament => {
+ return getTournamentCrew(tournament).length > 0;
+};
+
+export const hasTournamentMonitors = tournament => {
+ return getTournamentMonitors(tournament).length > 0;
+};
+
+export const patchApplication = (tournament, application) => {
+ if (!tournament) return tournament;
+ if (!tournament.applications || !tournament.applications.length) {
+ return {
+ ...tournament,
+ applications: [application],
+ };
+ }
+ if (!tournament.applications.find(a => a.user_id == application.user_id)) {
+ return {
+ ...tournament,
+ applications: [...tournament.applications, application],
+ };
+ }
+ return {
+ ...tournament,
+ applications: tournament.applications.map(
+ a => a.user_id === application.user_id ? application : a,
+ ),
+ };
+};
+
+export const patchParticipant = (tournament, participant) => {
+ if (!tournament) return tournament;
+ if (!tournament.participants || !tournament.participants.length) {
+ return {
+ ...tournament,
+ participants: [participant],
+ };
+ }
+ if (!tournament.participants.find(p => p.id === participant.id)) {
+ return {
+ ...tournament,
+ participants: [...tournament.participants, participant],
+ };
+ }
+ return {
+ ...tournament,
+ participants: tournament.participants.map(
+ p => p.id === participant.id ? participant : p,
+ ),
+ };
+};
+