Dynamic group link for more than 2 user fixed (#2416)
This commit is contained in:
		
							parent
							
								
									173e7846e8
								
							
						
					
					
						commit
						a551919152
					
				
					 3 changed files with 17 additions and 6 deletions
				
			
		| 
						 | 
					@ -261,9 +261,15 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) =>
 | 
				
			||||||
  eventTypeObject.schedule = null;
 | 
					  eventTypeObject.schedule = null;
 | 
				
			||||||
  eventTypeObject.availability = [];
 | 
					  eventTypeObject.availability = [];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  const dynamicNames = isDynamicGroup
 | 
				
			||||||
 | 
					    ? users.map((user) => {
 | 
				
			||||||
 | 
					        return user.name || "";
 | 
				
			||||||
 | 
					      })
 | 
				
			||||||
 | 
					    : [];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const profile = isDynamicGroup
 | 
					  const profile = isDynamicGroup
 | 
				
			||||||
    ? {
 | 
					    ? {
 | 
				
			||||||
        name: getGroupName(usernameList),
 | 
					        name: getGroupName(dynamicNames),
 | 
				
			||||||
        image: null,
 | 
					        image: null,
 | 
				
			||||||
        slug: typeParam,
 | 
					        slug: typeParam,
 | 
				
			||||||
        theme: null,
 | 
					        theme: null,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -168,9 +168,15 @@ export async function getServerSideProps(context: GetServerSidePropsContext) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const isDynamicGroupBooking = users.length > 1;
 | 
					  const isDynamicGroupBooking = users.length > 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  const dynamicNames = isDynamicGroupBooking
 | 
				
			||||||
 | 
					    ? users.map((user) => {
 | 
				
			||||||
 | 
					        return user.name || "";
 | 
				
			||||||
 | 
					      })
 | 
				
			||||||
 | 
					    : [];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const profile = isDynamicGroupBooking
 | 
					  const profile = isDynamicGroupBooking
 | 
				
			||||||
    ? {
 | 
					    ? {
 | 
				
			||||||
        name: getGroupName(usernameList),
 | 
					        name: getGroupName(dynamicNames),
 | 
				
			||||||
        image: null,
 | 
					        image: null,
 | 
				
			||||||
        slug: eventTypeSlug,
 | 
					        slug: eventTypeSlug,
 | 
				
			||||||
        theme: null,
 | 
					        theme: null,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -126,11 +126,10 @@ export const getGroupName = (usernameList: string[]): string => {
 | 
				
			||||||
export const getUsernameSlugLink = ({ users, slug }: UsernameSlugLinkProps): string => {
 | 
					export const getUsernameSlugLink = ({ users, slug }: UsernameSlugLinkProps): string => {
 | 
				
			||||||
  let slugLink = ``;
 | 
					  let slugLink = ``;
 | 
				
			||||||
  if (users.length > 1) {
 | 
					  if (users.length > 1) {
 | 
				
			||||||
    let combinedUsername = ``;
 | 
					    let combinedUsername = `${users[0].username}`;
 | 
				
			||||||
    for (let i = 0; i < users.length - 1; i++) {
 | 
					    for (let i = 1; i < users.length; i++) {
 | 
				
			||||||
      combinedUsername = `${users[i].username}+`;
 | 
					      combinedUsername = `${combinedUsername}+${users[i].username}`;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    combinedUsername = `${combinedUsername}${users[users.length - 1].username}`;
 | 
					 | 
				
			||||||
    slugLink = `/${combinedUsername}/${slug}`;
 | 
					    slugLink = `/${combinedUsername}/${slug}`;
 | 
				
			||||||
  } else {
 | 
					  } else {
 | 
				
			||||||
    slugLink = `/${users[0].username}/${slug}`;
 | 
					    slugLink = `/${users[0].username}/${slug}`;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue