all repos — caroster @ 2e4e192becc64475ea9245eb5fec57f72cb7088e

[Octree] Group carpool to your event https://caroster.io

frontend/lib/travels.ts (view raw)

 1import {TravelEntity} from '../generated/graphql';
 2
 3export const getTravelName = (
 4  travel: TravelEntity,
 5  canSeeFullName: boolean
 6) => {
 7  const hideName = (name: string) => (canSeeFullName ? name : `${name[0]}.`);
 8
 9  if (travel.attributes.firstname && travel.attributes.lastname)
10    return `${travel.attributes.firstname} ${hideName(
11      travel.attributes.lastname
12    )}`;
13
14  const linkedUser = travel.attributes?.user?.data?.attributes;
15  if (linkedUser?.firstName && linkedUser?.lastName)
16    return `${linkedUser.firstName} ${hideName(linkedUser.lastName)}`;
17
18  return travel.attributes.vehicleName;
19};