Dynamic group link for more than 2 user fixed (#2416)

This commit is contained in:
Syed Ali Shahbaz 2022-04-07 19:11:26 +05:30 committed by GitHub
parent 173e7846e8
commit a551919152
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 6 deletions

View File

@ -261,9 +261,15 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) =>
eventTypeObject.schedule = null;
eventTypeObject.availability = [];
const dynamicNames = isDynamicGroup
? users.map((user) => {
return user.name || "";
})
: [];
const profile = isDynamicGroup
? {
name: getGroupName(usernameList),
name: getGroupName(dynamicNames),
image: null,
slug: typeParam,
theme: null,

View File

@ -168,9 +168,15 @@ export async function getServerSideProps(context: GetServerSidePropsContext) {
const isDynamicGroupBooking = users.length > 1;
const dynamicNames = isDynamicGroupBooking
? users.map((user) => {
return user.name || "";
})
: [];
const profile = isDynamicGroupBooking
? {
name: getGroupName(usernameList),
name: getGroupName(dynamicNames),
image: null,
slug: eventTypeSlug,
theme: null,

View File

@ -126,11 +126,10 @@ export const getGroupName = (usernameList: string[]): string => {
export const getUsernameSlugLink = ({ users, slug }: UsernameSlugLinkProps): string => {
let slugLink = ``;
if (users.length > 1) {
let combinedUsername = ``;
for (let i = 0; i < users.length - 1; i++) {
combinedUsername = `${users[i].username}+`;
let combinedUsername = `${users[0].username}`;
for (let i = 1; i < users.length; i++) {
combinedUsername = `${combinedUsername}+${users[i].username}`;
}
combinedUsername = `${combinedUsername}${users[users.length - 1].username}`;
slugLink = `/${combinedUsername}/${slug}`;
} else {
slugLink = `/${users[0].username}/${slug}`;