RoundRobin Booking Error in a particular case (#2471)
* users can be array of user when roundrobin team booking is there with availablity of multiple people * Return empty array * Add comments * checktype fix * removed extra condition Co-authored-by: Syed Ali Shahbaz <alishahbaz7@gmail.com>
This commit is contained in:
parent
9d86039987
commit
75c2ccff96
2 changed files with 24 additions and 10 deletions
|
@ -223,7 +223,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
||||||
const reqBody = req.body as BookingCreateBody;
|
const reqBody = req.body as BookingCreateBody;
|
||||||
|
|
||||||
// handle dynamic user
|
// handle dynamic user
|
||||||
const dynamicUserList = getUsernameList(reqBody.user as string);
|
const dynamicUserList = getUsernameList(reqBody?.user);
|
||||||
const eventTypeSlug = reqBody.eventTypeSlug;
|
const eventTypeSlug = reqBody.eventTypeSlug;
|
||||||
const eventTypeId = reqBody.eventTypeId;
|
const eventTypeId = reqBody.eventTypeId;
|
||||||
const tAttendees = await getTranslation(reqBody.language ?? "en", "common");
|
const tAttendees = await getTranslation(reqBody.language ?? "en", "common");
|
||||||
|
|
|
@ -139,15 +139,29 @@ export const getUsernameSlugLink = ({ users, slug }: UsernameSlugLinkProps): str
|
||||||
return slugLink;
|
return slugLink;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getUsernameList = (users: string): string[] => {
|
export const getUsernameList = (users: string | string[] | undefined): string[] => {
|
||||||
return users
|
if (!users) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
if (!(users instanceof Array)) {
|
||||||
|
users = [users];
|
||||||
|
}
|
||||||
|
const allUsers: string[] = [];
|
||||||
|
// Multiple users can come in case of a team round-robin booking and in that case dynamic link won't be a user.
|
||||||
|
// So, even though this code handles even if individual user is dynamic link, that isn't a possibility right now.
|
||||||
|
users.forEach((user) => {
|
||||||
|
allUsers.push(
|
||||||
|
...user
|
||||||
?.toLowerCase()
|
?.toLowerCase()
|
||||||
.replace(/ /g, "+")
|
.replace(/ /g, "+")
|
||||||
.replace(/%20/g, "+")
|
.replace(/%20/g, "+")
|
||||||
.split("+")
|
.split("+")
|
||||||
.filter((el) => {
|
.filter((el) => {
|
||||||
return el.length != 0;
|
return el.length != 0;
|
||||||
|
})
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
return allUsers;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default defaultEvents;
|
export default defaultEvents;
|
||||||
|
|
Loading…
Reference in a new issue