Skip to content

Commit

Permalink
Merge pull request #40 from Xitija/create-api-changes
Browse files Browse the repository at this point in the history
PS-1896 Refactor repeat code
  • Loading branch information
snehal0904 authored Sep 9, 2024
2 parents 4811adf + 1b574fb commit 6574abd
Show file tree
Hide file tree
Showing 3 changed files with 310 additions and 270 deletions.
12 changes: 9 additions & 3 deletions src/common/pipes/event-validation.pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,14 +160,20 @@ export class RecurringEndDateValidationPipe implements PipeTransform {
);
}

const endDateTime = endConditionValue.split('T');
const endDate = endDateTime[0]; // recurring end date

if (
endConditionValue.split('T')[1] !==
createEventDto.endDatetime.split('T')[1]
new Date(endConditionValue).getTime() !==
new Date(
endDate + 'T' + createEventDto.endDatetime.split('T')[1],
).getTime() // compare with current event end time
) {
throw new BadRequestException(
'Event End time does not match with Recurrence End time',
);
} // do for recurrence start time also in edit
}

// createEventDto.recurrencePattern.endCondition.value = endDate;
} else if (endConditionType === EndConditionType.occurrences) {
const occurrences = Number(endConditionValue);
Expand Down
20 changes: 11 additions & 9 deletions src/common/utils/functions.util.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
export const compareArrays = (a: any[], b: any[]): boolean => {
if (a.length !== b.length) return false;
else {
// Comparing each element of your array
for (let i = 0; i < a.length; i++) {
if (a[i] !== b[i]) {
return false;
}
export const compareArrays = (a: number[], b: number[]): boolean => {
if (a.length !== b.length) {
return false;
}
a.sort((a, b) => a - b);
b.sort((a, b) => a - b);
// Comparing each element of your array
for (let i = 0; i < a.length; i++) {
if (a[i] !== b[i]) {
return false;
}
return true;
}
return true;
};

export const getNextDay = (currentDate: Date): Date => {
Expand Down
Loading

0 comments on commit 6574abd

Please sign in to comment.