diff --git a/client/Dockerfile.dev b/client/Dockerfile.dev index 11dad1d..30ae0e7 100644 --- a/client/Dockerfile.dev +++ b/client/Dockerfile.dev @@ -1,4 +1,4 @@ -FROM node:18.15.0-alpine AS development +FROM node:16.20.0-alpine AS development WORKDIR /app diff --git a/client/src/components/timerCard.tsx b/client/src/components/timerCard.tsx index 1afc1eb..89777b8 100644 --- a/client/src/components/timerCard.tsx +++ b/client/src/components/timerCard.tsx @@ -1,6 +1,18 @@ import { ago } from "../utils/ago"; import { useEffect, useState } from "react"; +const replaceReferencedFriendsInName = (name, referencedFriends) => { + const friendIdToFriend = referencedFriends.reduce((friendMap, friend) => { + friendMap[friend.id] = friend; + return friendMap; + }, {}); + return name.replaceAll( + /@\<(\d+)\>/g, + (_match, id) => friendIdToFriend[id].name + ); +}; +// name.replaceAll( + export default function TimerCard({ timer }) { const [since, setSince] = useState(ago(timer.start)); @@ -20,7 +32,8 @@ export default function TimerCard({ timer }) { return (
{since}
since {timer.name}
+ {since}
{" "}
+ {replaceReferencedFriendsInName(timer.name, timer.referenced_friends)}