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.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,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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}`;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue