tods-competition-factory 2.3.1 → 2.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.mjs +9 -9
- package/dist/tods-competition-factory.d.ts +51 -6
- package/dist/tods-competition-factory.development.cjs.js +205 -9
- package/dist/tods-competition-factory.development.cjs.js.map +1 -1
- package/dist/tods-competition-factory.production.cjs.min.js +1 -1
- package/dist/tods-competition-factory.production.cjs.min.js.map +1 -1
- package/package.json +1 -1
|
@@ -1356,6 +1356,10 @@ declare const errorConditionConstants: {
|
|
|
1356
1356
|
message: string;
|
|
1357
1357
|
code: string;
|
|
1358
1358
|
};
|
|
1359
|
+
BOOKING_NOT_FOUND: {
|
|
1360
|
+
message: string;
|
|
1361
|
+
code: string;
|
|
1362
|
+
};
|
|
1359
1363
|
CANNOT_CHANGE_WINNING_SIDE: {
|
|
1360
1364
|
message: string;
|
|
1361
1365
|
code: string;
|
|
@@ -1388,6 +1392,10 @@ declare const errorConditionConstants: {
|
|
|
1388
1392
|
message: string;
|
|
1389
1393
|
code: string;
|
|
1390
1394
|
};
|
|
1395
|
+
EXISTING_MATCHUPS: {
|
|
1396
|
+
message: string;
|
|
1397
|
+
code: string;
|
|
1398
|
+
};
|
|
1391
1399
|
DRAW_DEFINITION_NOT_FOUND: {
|
|
1392
1400
|
message: string;
|
|
1393
1401
|
code: string;
|
|
@@ -4626,11 +4634,11 @@ declare function deleteFlightProfileAndFlightDraws({ autoPublish, tournamentReco
|
|
|
4626
4634
|
event: any;
|
|
4627
4635
|
force: any;
|
|
4628
4636
|
}): {
|
|
4629
|
-
error: any;
|
|
4630
|
-
} | {
|
|
4631
4637
|
success?: boolean;
|
|
4632
4638
|
error?: ErrorType;
|
|
4633
4639
|
info?: any;
|
|
4640
|
+
} | {
|
|
4641
|
+
error: any;
|
|
4634
4642
|
};
|
|
4635
4643
|
|
|
4636
4644
|
type ModifyEventMatchUpFormatTimingArgs = {
|
|
@@ -4644,13 +4652,13 @@ type ModifyEventMatchUpFormatTimingArgs = {
|
|
|
4644
4652
|
event?: Event$1;
|
|
4645
4653
|
};
|
|
4646
4654
|
declare function modifyEventMatchUpFormatTiming(params: ModifyEventMatchUpFormatTimingArgs): {
|
|
4647
|
-
success: boolean;
|
|
4648
|
-
error?: undefined;
|
|
4649
|
-
} | {
|
|
4650
4655
|
error: {
|
|
4651
4656
|
message: string;
|
|
4652
4657
|
code: string;
|
|
4653
4658
|
};
|
|
4659
|
+
} | {
|
|
4660
|
+
success: boolean;
|
|
4661
|
+
error?: undefined;
|
|
4654
4662
|
};
|
|
4655
4663
|
|
|
4656
4664
|
type RemoveEventMatchUpFormatTimingArgs = {
|
|
@@ -8456,10 +8464,11 @@ type SetSchedulingProfileArgs = {
|
|
|
8456
8464
|
};
|
|
8457
8465
|
declare function setSchedulingProfile({ tournamentRecords, tournamentRecord, schedulingProfile, }: SetSchedulingProfileArgs): any;
|
|
8458
8466
|
|
|
8459
|
-
declare function courtGridRows({ courtPrefix, minRowsCount, courtsData }: {
|
|
8467
|
+
declare function courtGridRows({ courtPrefix, minRowsCount, courtsData, scheduledDate }: {
|
|
8460
8468
|
courtPrefix?: string | undefined;
|
|
8461
8469
|
minRowsCount: any;
|
|
8462
8470
|
courtsData: any;
|
|
8471
|
+
scheduledDate: any;
|
|
8463
8472
|
}): {
|
|
8464
8473
|
error: {
|
|
8465
8474
|
message: string;
|
|
@@ -9448,6 +9457,31 @@ declare function findMatchUpFormatTiming({ defaultRecoveryMinutes, defaultAverag
|
|
|
9448
9457
|
error?: undefined;
|
|
9449
9458
|
};
|
|
9450
9459
|
|
|
9460
|
+
type AddCourtGridBookingArgs = {
|
|
9461
|
+
tournamentRecord: Tournament;
|
|
9462
|
+
disableNotice?: boolean;
|
|
9463
|
+
bookingType: string;
|
|
9464
|
+
courtOrder: number;
|
|
9465
|
+
scheduledDate: string;
|
|
9466
|
+
courtId: string;
|
|
9467
|
+
rowCount?: number;
|
|
9468
|
+
notes?: string;
|
|
9469
|
+
};
|
|
9470
|
+
declare function addCourtGridBooking(params: AddCourtGridBookingArgs): ResultType & {
|
|
9471
|
+
booking?: any;
|
|
9472
|
+
};
|
|
9473
|
+
|
|
9474
|
+
type RemoveCourtGridBookingArgs = {
|
|
9475
|
+
tournamentRecord: Tournament;
|
|
9476
|
+
disableNotice?: boolean;
|
|
9477
|
+
scheduledDate: string;
|
|
9478
|
+
courtOrder: number;
|
|
9479
|
+
courtId: string;
|
|
9480
|
+
};
|
|
9481
|
+
declare function removeCourtGridBooking(params: RemoveCourtGridBookingArgs): ResultType & {
|
|
9482
|
+
booking?: any;
|
|
9483
|
+
};
|
|
9484
|
+
|
|
9451
9485
|
type AddMatchUpScheduleItemsArgs = {
|
|
9452
9486
|
inContextMatchUps?: HydratedMatchUp[];
|
|
9453
9487
|
drawMatchUps?: HydratedMatchUp[];
|
|
@@ -9490,6 +9524,7 @@ declare function addMatchUpResumeTime({ removePriorValues, tournamentRecord, dra
|
|
|
9490
9524
|
resumeTime?: string;
|
|
9491
9525
|
}): any;
|
|
9492
9526
|
|
|
9527
|
+
declare const mutate$4_addCourtGridBooking: typeof addCourtGridBooking;
|
|
9493
9528
|
declare const mutate$4_addMatchUpCourtOrder: typeof addMatchUpCourtOrder;
|
|
9494
9529
|
declare const mutate$4_addMatchUpEndTime: typeof addMatchUpEndTime;
|
|
9495
9530
|
declare const mutate$4_addMatchUpOfficial: typeof addMatchUpOfficial;
|
|
@@ -9517,6 +9552,7 @@ declare const mutate$4_matchUpScheduleChange: typeof matchUpScheduleChange;
|
|
|
9517
9552
|
declare const mutate$4_modifyMatchUpFormatTiming: typeof modifyMatchUpFormatTiming;
|
|
9518
9553
|
declare const mutate$4_proAutoSchedule: typeof proAutoSchedule;
|
|
9519
9554
|
declare const mutate$4_proConflicts: typeof proConflicts;
|
|
9555
|
+
declare const mutate$4_removeCourtGridBooking: typeof removeCourtGridBooking;
|
|
9520
9556
|
declare const mutate$4_removeEventMatchUpFormatTiming: typeof removeEventMatchUpFormatTiming;
|
|
9521
9557
|
declare const mutate$4_removeMatchUpCourtAssignment: typeof removeMatchUpCourtAssignment;
|
|
9522
9558
|
declare const mutate$4_reorderUpcomingMatchUps: typeof reorderUpcomingMatchUps;
|
|
@@ -9529,6 +9565,7 @@ declare const mutate$4_toggleParticipantCheckInState: typeof toggleParticipantCh
|
|
|
9529
9565
|
declare const mutate$4_validateSchedulingProfile: typeof validateSchedulingProfile;
|
|
9530
9566
|
declare namespace mutate$4 {
|
|
9531
9567
|
export {
|
|
9568
|
+
mutate$4_addCourtGridBooking as addCourtGridBooking,
|
|
9532
9569
|
mutate$4_addMatchUpCourtOrder as addMatchUpCourtOrder,
|
|
9533
9570
|
mutate$4_addMatchUpEndTime as addMatchUpEndTime,
|
|
9534
9571
|
mutate$4_addMatchUpOfficial as addMatchUpOfficial,
|
|
@@ -9556,6 +9593,7 @@ declare namespace mutate$4 {
|
|
|
9556
9593
|
mutate$4_modifyMatchUpFormatTiming as modifyMatchUpFormatTiming,
|
|
9557
9594
|
mutate$4_proAutoSchedule as proAutoSchedule,
|
|
9558
9595
|
mutate$4_proConflicts as proConflicts,
|
|
9596
|
+
mutate$4_removeCourtGridBooking as removeCourtGridBooking,
|
|
9559
9597
|
mutate$4_removeEventMatchUpFormatTiming as removeEventMatchUpFormatTiming,
|
|
9560
9598
|
mutate$4_removeMatchUpCourtAssignment as removeMatchUpCourtAssignment,
|
|
9561
9599
|
mutate$4_reorderUpcomingMatchUps as reorderUpcomingMatchUps,
|
|
@@ -9569,6 +9607,7 @@ declare namespace mutate$4 {
|
|
|
9569
9607
|
};
|
|
9570
9608
|
}
|
|
9571
9609
|
|
|
9610
|
+
declare const index$7_addCourtGridBooking: typeof addCourtGridBooking;
|
|
9572
9611
|
declare const index$7_addMatchUpCourtOrder: typeof addMatchUpCourtOrder;
|
|
9573
9612
|
declare const index$7_addMatchUpEndTime: typeof addMatchUpEndTime;
|
|
9574
9613
|
declare const index$7_addMatchUpOfficial: typeof addMatchUpOfficial;
|
|
@@ -9605,6 +9644,7 @@ declare const index$7_modifyMatchUpFormatTiming: typeof modifyMatchUpFormatTimin
|
|
|
9605
9644
|
declare const index$7_proAutoSchedule: typeof proAutoSchedule;
|
|
9606
9645
|
declare const index$7_proConflicts: typeof proConflicts;
|
|
9607
9646
|
declare const index$7_publicFindCourt: typeof publicFindCourt;
|
|
9647
|
+
declare const index$7_removeCourtGridBooking: typeof removeCourtGridBooking;
|
|
9608
9648
|
declare const index$7_removeEventMatchUpFormatTiming: typeof removeEventMatchUpFormatTiming;
|
|
9609
9649
|
declare const index$7_removeMatchUpCourtAssignment: typeof removeMatchUpCourtAssignment;
|
|
9610
9650
|
declare const index$7_reorderUpcomingMatchUps: typeof reorderUpcomingMatchUps;
|
|
@@ -9617,6 +9657,7 @@ declare const index$7_toggleParticipantCheckInState: typeof toggleParticipantChe
|
|
|
9617
9657
|
declare const index$7_validateSchedulingProfile: typeof validateSchedulingProfile;
|
|
9618
9658
|
declare namespace index$7 {
|
|
9619
9659
|
export {
|
|
9660
|
+
index$7_addCourtGridBooking as addCourtGridBooking,
|
|
9620
9661
|
index$7_addMatchUpCourtOrder as addMatchUpCourtOrder,
|
|
9621
9662
|
index$7_addMatchUpEndTime as addMatchUpEndTime,
|
|
9622
9663
|
index$7_addMatchUpOfficial as addMatchUpOfficial,
|
|
@@ -9655,6 +9696,7 @@ declare namespace index$7 {
|
|
|
9655
9696
|
index$7_proConflicts as proConflicts,
|
|
9656
9697
|
index$7_publicFindCourt as publicFindCourt,
|
|
9657
9698
|
query$2 as query,
|
|
9699
|
+
index$7_removeCourtGridBooking as removeCourtGridBooking,
|
|
9658
9700
|
index$7_removeEventMatchUpFormatTiming as removeEventMatchUpFormatTiming,
|
|
9659
9701
|
index$7_removeMatchUpCourtAssignment as removeMatchUpCourtAssignment,
|
|
9660
9702
|
index$7_reorderUpcomingMatchUps as reorderUpcomingMatchUps,
|
|
@@ -12654,6 +12696,9 @@ declare const scheduleConstants: {
|
|
|
12654
12696
|
SCHEDULE_ERROR: string;
|
|
12655
12697
|
SCHEDULE_ISSUE: string;
|
|
12656
12698
|
SCHEDULE_STATE: string;
|
|
12699
|
+
BLOCKED: string;
|
|
12700
|
+
PRACTICE: string;
|
|
12701
|
+
MAINTENANCE: string;
|
|
12657
12702
|
};
|
|
12658
12703
|
|
|
12659
12704
|
declare const sortingConstants: {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
function factoryVersion() {
|
|
6
|
-
return '2.3.
|
|
6
|
+
return '2.3.3';
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
const SINGLES_MATCHUP = 'SINGLES';
|
|
@@ -989,6 +989,14 @@ const COURT_EXISTS = {
|
|
|
989
989
|
message: 'Court exists',
|
|
990
990
|
code: 'ERR_EXISTING_COURT',
|
|
991
991
|
};
|
|
992
|
+
const BOOKING_NOT_FOUND = {
|
|
993
|
+
message: 'Booking not found',
|
|
994
|
+
code: 'ERR_NOT_FOUND_BOOKING',
|
|
995
|
+
};
|
|
996
|
+
const EXISTING_MATCHUPS = {
|
|
997
|
+
message: 'Existing matchUps conflict with booking',
|
|
998
|
+
code: 'ERR_EXISTING_MATCHUPS',
|
|
999
|
+
};
|
|
992
1000
|
const VENUE_EXISTS = {
|
|
993
1001
|
message: 'Venue exists',
|
|
994
1002
|
code: 'ERR_EXISTING_VENUE',
|
|
@@ -1152,6 +1160,7 @@ const SCORES_PRESENT = {
|
|
|
1152
1160
|
};
|
|
1153
1161
|
const errorConditionConstants = {
|
|
1154
1162
|
ANACHRONISM,
|
|
1163
|
+
BOOKING_NOT_FOUND,
|
|
1155
1164
|
CANNOT_CHANGE_WINNING_SIDE,
|
|
1156
1165
|
CANNOT_MODIFY_TIEFORMAT,
|
|
1157
1166
|
CANNOT_MODIFY_PARTICIPANT_TYPE,
|
|
@@ -1160,6 +1169,7 @@ const errorConditionConstants = {
|
|
|
1160
1169
|
CATEGORY_MISMATCH,
|
|
1161
1170
|
COURT_EXISTS,
|
|
1162
1171
|
COURT_NOT_FOUND,
|
|
1172
|
+
EXISTING_MATCHUPS,
|
|
1163
1173
|
DRAW_DEFINITION_NOT_FOUND,
|
|
1164
1174
|
DRAW_ID_EXISTS,
|
|
1165
1175
|
DRAW_POSITION_ACTIVE,
|
|
@@ -9450,6 +9460,9 @@ const SCHEDULE_WARNING = 'WARNING';
|
|
|
9450
9460
|
const SCHEDULE_ERROR = 'ERROR';
|
|
9451
9461
|
const SCHEDULE_ISSUE = 'ISSUE';
|
|
9452
9462
|
const SCHEDULE_STATE = 'STATE';
|
|
9463
|
+
const BLOCKED = 'BLOCKED';
|
|
9464
|
+
const PRACTICE = 'PRACTICE';
|
|
9465
|
+
const MAINTENANCE = 'MAINTENANCE';
|
|
9453
9466
|
const scheduleConstants = {
|
|
9454
9467
|
SINGLES_DOUBLES,
|
|
9455
9468
|
DOUBLES_SINGLES,
|
|
@@ -9462,6 +9475,9 @@ const scheduleConstants = {
|
|
|
9462
9475
|
SCHEDULE_ERROR,
|
|
9463
9476
|
SCHEDULE_ISSUE,
|
|
9464
9477
|
SCHEDULE_STATE,
|
|
9478
|
+
BLOCKED,
|
|
9479
|
+
PRACTICE,
|
|
9480
|
+
MAINTENANCE,
|
|
9465
9481
|
};
|
|
9466
9482
|
|
|
9467
9483
|
function getMatchUpFormatTiming({ defaultAverageMinutes = 90, defaultRecoveryMinutes = 0, tournamentRecord, matchUpFormat, categoryName, categoryType, eventType, event, }) {
|
|
@@ -36681,7 +36697,31 @@ function getProfileRounds({ tournamentRecords, schedulingProfile, tournamentReco
|
|
|
36681
36697
|
return { profileRounds, segmentedRounds };
|
|
36682
36698
|
}
|
|
36683
36699
|
|
|
36684
|
-
function
|
|
36700
|
+
function getCourtDateAvailability({ court, date }) {
|
|
36701
|
+
const targetDateAvailability = date && court.dateAvailability.find((availability) => sameDay(availability.date, date));
|
|
36702
|
+
const defaultAvailability = court.dateAvailability.find((availability) => !availability.date);
|
|
36703
|
+
return targetDateAvailability || defaultAvailability;
|
|
36704
|
+
}
|
|
36705
|
+
|
|
36706
|
+
function getGridBookings({ court, date }) {
|
|
36707
|
+
const courtDate = getCourtDateAvailability({ court, date });
|
|
36708
|
+
const gridBookings = new Map();
|
|
36709
|
+
const timeBookings = [];
|
|
36710
|
+
(courtDate?.bookings || []).forEach((booking) => {
|
|
36711
|
+
if (typeof booking.courtOrder === 'number') {
|
|
36712
|
+
const rowCount = booking.rowCount || 1;
|
|
36713
|
+
for (let i = 0; i < rowCount; i++) {
|
|
36714
|
+
gridBookings.set(booking.courtOrder + i, booking);
|
|
36715
|
+
}
|
|
36716
|
+
}
|
|
36717
|
+
else {
|
|
36718
|
+
timeBookings.push(booking);
|
|
36719
|
+
}
|
|
36720
|
+
});
|
|
36721
|
+
return { gridBookings, timeBookings };
|
|
36722
|
+
}
|
|
36723
|
+
|
|
36724
|
+
function courtGridRows({ courtPrefix = 'C|', minRowsCount, courtsData, scheduledDate }) {
|
|
36685
36725
|
if (!Array.isArray(courtsData))
|
|
36686
36726
|
return { error: INVALID_VALUES };
|
|
36687
36727
|
const maxCourtOrder = courtsData?.reduce((order, court) => {
|
|
@@ -36694,6 +36734,20 @@ function courtGridRows({ courtPrefix = 'C|', minRowsCount, courtsData }) {
|
|
|
36694
36734
|
matchUps: generateRange(0, courtsData.length).map((courtIndex) => {
|
|
36695
36735
|
const courtInfo = courtsData[courtIndex];
|
|
36696
36736
|
const { courtId, venueId } = courtInfo;
|
|
36737
|
+
if (scheduledDate) {
|
|
36738
|
+
const { gridBookings } = getGridBookings({
|
|
36739
|
+
court: courtInfo,
|
|
36740
|
+
date: scheduledDate,
|
|
36741
|
+
});
|
|
36742
|
+
if (gridBookings.has(rowIndex + 1)) {
|
|
36743
|
+
const booking = gridBookings.get(rowIndex + 1);
|
|
36744
|
+
return {
|
|
36745
|
+
schedule: { courtOrder: rowIndex + 1, venueId, courtId },
|
|
36746
|
+
isBlocked: true,
|
|
36747
|
+
booking,
|
|
36748
|
+
};
|
|
36749
|
+
}
|
|
36750
|
+
}
|
|
36697
36751
|
return {
|
|
36698
36752
|
schedule: {
|
|
36699
36753
|
courtOrder: rowIndex + 1,
|
|
@@ -37563,8 +37617,10 @@ function competitionScheduleMatchUps(params) {
|
|
|
37563
37617
|
venues,
|
|
37564
37618
|
};
|
|
37565
37619
|
if (withCourtGridRows) {
|
|
37620
|
+
const scheduledDate = params.matchUpFilters?.scheduledDate;
|
|
37566
37621
|
const { rows, courtPrefix } = courtGridRows({
|
|
37567
37622
|
minRowsCount: Math.max(minCourtGridRows || 0, dateMatchUps.length || 0),
|
|
37623
|
+
scheduledDate,
|
|
37568
37624
|
courtsData,
|
|
37569
37625
|
});
|
|
37570
37626
|
result.courtPrefix = courtPrefix;
|
|
@@ -42091,12 +42147,6 @@ function generateCourts(params) {
|
|
|
42091
42147
|
return { ...SUCCESS, courts };
|
|
42092
42148
|
}
|
|
42093
42149
|
|
|
42094
|
-
function getCourtDateAvailability({ court, date }) {
|
|
42095
|
-
const targetDateAvailability = date && court.dateAvailability.find((availability) => sameDay(availability.date, date));
|
|
42096
|
-
const defaultAvailability = court.dateAvailability.find((availability) => !availability.date);
|
|
42097
|
-
return targetDateAvailability || defaultAvailability;
|
|
42098
|
-
}
|
|
42099
|
-
|
|
42100
42150
|
function generateTimeSlots(params) {
|
|
42101
42151
|
const paramsCheck = checkRequiredParameters(params, [{ courtDate: true, _ofType: OBJECT }]);
|
|
42102
42152
|
if (paramsCheck.error)
|
|
@@ -55110,7 +55160,7 @@ function proAutoSchedule({ scheduleCompletedMatchUps, tournamentRecords, schedul
|
|
|
55110
55160
|
}
|
|
55111
55161
|
}
|
|
55112
55162
|
});
|
|
55113
|
-
const availableCourts = Object.values(row).filter((c) => isObject(c) && !c.matchUpId);
|
|
55163
|
+
const availableCourts = Object.values(row).filter((c) => isObject(c) && !c.matchUpId && !c.isBlocked);
|
|
55114
55164
|
return gridRows.concat({
|
|
55115
55165
|
matchUpIds,
|
|
55116
55166
|
availableCourts,
|
|
@@ -56029,8 +56079,151 @@ function setMatchUpDailyLimits(params) {
|
|
|
56029
56079
|
return { ...SUCCESS };
|
|
56030
56080
|
}
|
|
56031
56081
|
|
|
56082
|
+
function addCourtGridBooking(params) {
|
|
56083
|
+
const { tournamentRecord, disableNotice, scheduledDate, bookingType, courtOrder, rowCount = 1, courtId, notes, } = params;
|
|
56084
|
+
if (!tournamentRecord) {
|
|
56085
|
+
return decorateResult({
|
|
56086
|
+
result: { error: INVALID_VALUES },
|
|
56087
|
+
info: 'tournamentRecord is required',
|
|
56088
|
+
});
|
|
56089
|
+
}
|
|
56090
|
+
if (!courtId) {
|
|
56091
|
+
return { error: COURT_NOT_FOUND };
|
|
56092
|
+
}
|
|
56093
|
+
if (!scheduledDate) {
|
|
56094
|
+
return decorateResult({
|
|
56095
|
+
result: { error: INVALID_VALUES },
|
|
56096
|
+
info: 'scheduledDate is required',
|
|
56097
|
+
});
|
|
56098
|
+
}
|
|
56099
|
+
if (!bookingType) {
|
|
56100
|
+
return decorateResult({
|
|
56101
|
+
result: { error: INVALID_VALUES },
|
|
56102
|
+
info: 'bookingType is required',
|
|
56103
|
+
});
|
|
56104
|
+
}
|
|
56105
|
+
if (courtOrder === undefined || courtOrder === null) {
|
|
56106
|
+
return decorateResult({
|
|
56107
|
+
result: { error: INVALID_VALUES },
|
|
56108
|
+
info: 'courtOrder is required',
|
|
56109
|
+
});
|
|
56110
|
+
}
|
|
56111
|
+
if (!Number.isInteger(courtOrder) || courtOrder < 1) {
|
|
56112
|
+
return decorateResult({
|
|
56113
|
+
result: { error: INVALID_VALUES },
|
|
56114
|
+
info: 'courtOrder must be a positive integer',
|
|
56115
|
+
});
|
|
56116
|
+
}
|
|
56117
|
+
if (!Number.isInteger(rowCount) || rowCount < 1) {
|
|
56118
|
+
return decorateResult({
|
|
56119
|
+
result: { error: INVALID_VALUES },
|
|
56120
|
+
info: 'rowCount must be a positive integer',
|
|
56121
|
+
});
|
|
56122
|
+
}
|
|
56123
|
+
const { court, venue } = findCourt({ tournamentRecord, courtId });
|
|
56124
|
+
if (!court)
|
|
56125
|
+
return { error: COURT_NOT_FOUND };
|
|
56126
|
+
const courtDate = getCourtDateAvailability({ court, date: scheduledDate });
|
|
56127
|
+
if (!courtDate) {
|
|
56128
|
+
if (!court.dateAvailability)
|
|
56129
|
+
court.dateAvailability = [];
|
|
56130
|
+
const newAvailability = {
|
|
56131
|
+
date: scheduledDate,
|
|
56132
|
+
bookings: [],
|
|
56133
|
+
};
|
|
56134
|
+
court.dateAvailability.push(newAvailability);
|
|
56135
|
+
}
|
|
56136
|
+
const targetCourtDate = getCourtDateAvailability({ court, date: scheduledDate });
|
|
56137
|
+
if (targetCourtDate.bookings) {
|
|
56138
|
+
for (const existingBooking of targetCourtDate.bookings) {
|
|
56139
|
+
if (typeof existingBooking.courtOrder === 'number') {
|
|
56140
|
+
const existingStart = existingBooking.courtOrder;
|
|
56141
|
+
const existingEnd = existingStart + (existingBooking.rowCount || 1) - 1;
|
|
56142
|
+
const newStart = courtOrder;
|
|
56143
|
+
const newEnd = courtOrder + rowCount - 1;
|
|
56144
|
+
if (newStart <= existingEnd && newEnd >= existingStart) {
|
|
56145
|
+
return decorateResult({
|
|
56146
|
+
result: { error: EXISTING_MATCHUPS },
|
|
56147
|
+
info: `Booking conflicts with existing booking at rows ${existingStart}-${existingEnd}`,
|
|
56148
|
+
});
|
|
56149
|
+
}
|
|
56150
|
+
}
|
|
56151
|
+
}
|
|
56152
|
+
}
|
|
56153
|
+
const booking = {
|
|
56154
|
+
courtOrder,
|
|
56155
|
+
rowCount,
|
|
56156
|
+
bookingType,
|
|
56157
|
+
notes,
|
|
56158
|
+
createdAt: new Date().toISOString(),
|
|
56159
|
+
};
|
|
56160
|
+
if (!targetCourtDate.bookings)
|
|
56161
|
+
targetCourtDate.bookings = [];
|
|
56162
|
+
targetCourtDate.bookings.push(booking);
|
|
56163
|
+
if (!disableNotice && venue) {
|
|
56164
|
+
addNotice({
|
|
56165
|
+
payload: { venue, tournamentId: tournamentRecord.tournamentId },
|
|
56166
|
+
topic: MODIFY_VENUE,
|
|
56167
|
+
key: venue.venueId,
|
|
56168
|
+
});
|
|
56169
|
+
}
|
|
56170
|
+
return { ...SUCCESS, booking };
|
|
56171
|
+
}
|
|
56172
|
+
|
|
56173
|
+
function removeCourtGridBooking(params) {
|
|
56174
|
+
const { tournamentRecord, disableNotice, scheduledDate, courtOrder, courtId, } = params;
|
|
56175
|
+
if (!tournamentRecord) {
|
|
56176
|
+
return decorateResult({
|
|
56177
|
+
result: { error: INVALID_VALUES },
|
|
56178
|
+
info: 'tournamentRecord is required',
|
|
56179
|
+
});
|
|
56180
|
+
}
|
|
56181
|
+
if (!courtId) {
|
|
56182
|
+
return { error: COURT_NOT_FOUND };
|
|
56183
|
+
}
|
|
56184
|
+
if (!scheduledDate) {
|
|
56185
|
+
return decorateResult({
|
|
56186
|
+
result: { error: INVALID_VALUES },
|
|
56187
|
+
info: 'scheduledDate is required',
|
|
56188
|
+
});
|
|
56189
|
+
}
|
|
56190
|
+
if (courtOrder === undefined || courtOrder === null) {
|
|
56191
|
+
return decorateResult({
|
|
56192
|
+
result: { error: INVALID_VALUES },
|
|
56193
|
+
info: 'courtOrder is required',
|
|
56194
|
+
});
|
|
56195
|
+
}
|
|
56196
|
+
const { court, venue } = findCourt({ tournamentRecord, courtId });
|
|
56197
|
+
if (!court)
|
|
56198
|
+
return { error: COURT_NOT_FOUND };
|
|
56199
|
+
const courtDate = getCourtDateAvailability({ court, date: scheduledDate });
|
|
56200
|
+
if (!courtDate?.bookings) {
|
|
56201
|
+
return decorateResult({
|
|
56202
|
+
result: { error: BOOKING_NOT_FOUND },
|
|
56203
|
+
info: 'No bookings found for this date',
|
|
56204
|
+
});
|
|
56205
|
+
}
|
|
56206
|
+
const bookingIndex = courtDate.bookings.findIndex((b) => b.courtOrder === courtOrder);
|
|
56207
|
+
if (bookingIndex === -1) {
|
|
56208
|
+
return decorateResult({
|
|
56209
|
+
result: { error: BOOKING_NOT_FOUND },
|
|
56210
|
+
info: `No booking found at row ${courtOrder}`,
|
|
56211
|
+
});
|
|
56212
|
+
}
|
|
56213
|
+
const removed = courtDate.bookings.splice(bookingIndex, 1)[0];
|
|
56214
|
+
if (!disableNotice && venue) {
|
|
56215
|
+
addNotice({
|
|
56216
|
+
payload: { venue, tournamentId: tournamentRecord.tournamentId },
|
|
56217
|
+
topic: MODIFY_VENUE,
|
|
56218
|
+
key: venue.venueId,
|
|
56219
|
+
});
|
|
56220
|
+
}
|
|
56221
|
+
return { ...SUCCESS, booking: removed };
|
|
56222
|
+
}
|
|
56223
|
+
|
|
56032
56224
|
var mutate$3 = {
|
|
56033
56225
|
__proto__: null,
|
|
56226
|
+
addCourtGridBooking: addCourtGridBooking,
|
|
56034
56227
|
addMatchUpCourtOrder: addMatchUpCourtOrder,
|
|
56035
56228
|
addMatchUpEndTime: addMatchUpEndTime,
|
|
56036
56229
|
addMatchUpOfficial: addMatchUpOfficial,
|
|
@@ -56058,6 +56251,7 @@ var mutate$3 = {
|
|
|
56058
56251
|
modifyMatchUpFormatTiming: modifyMatchUpFormatTiming,
|
|
56059
56252
|
proAutoSchedule: proAutoSchedule,
|
|
56060
56253
|
proConflicts: proConflicts,
|
|
56254
|
+
removeCourtGridBooking: removeCourtGridBooking,
|
|
56061
56255
|
removeEventMatchUpFormatTiming: removeEventMatchUpFormatTiming,
|
|
56062
56256
|
removeMatchUpCourtAssignment: removeMatchUpCourtAssignment,
|
|
56063
56257
|
reorderUpcomingMatchUps: reorderUpcomingMatchUps,
|
|
@@ -56072,6 +56266,7 @@ var mutate$3 = {
|
|
|
56072
56266
|
|
|
56073
56267
|
var index$5 = {
|
|
56074
56268
|
__proto__: null,
|
|
56269
|
+
addCourtGridBooking: addCourtGridBooking,
|
|
56075
56270
|
addMatchUpCourtOrder: addMatchUpCourtOrder,
|
|
56076
56271
|
addMatchUpEndTime: addMatchUpEndTime,
|
|
56077
56272
|
addMatchUpOfficial: addMatchUpOfficial,
|
|
@@ -56110,6 +56305,7 @@ var index$5 = {
|
|
|
56110
56305
|
proConflicts: proConflicts,
|
|
56111
56306
|
publicFindCourt: publicFindCourt,
|
|
56112
56307
|
query: query$4,
|
|
56308
|
+
removeCourtGridBooking: removeCourtGridBooking,
|
|
56113
56309
|
removeEventMatchUpFormatTiming: removeEventMatchUpFormatTiming,
|
|
56114
56310
|
removeMatchUpCourtAssignment: removeMatchUpCourtAssignment,
|
|
56115
56311
|
reorderUpcomingMatchUps: reorderUpcomingMatchUps,
|