Downgrade node, replace friend references in timer names

This commit is contained in:
Elizabeth Hunt 2023-04-04 09:33:14 -06:00
parent a6ced3f22f
commit 6a1a270c94
Signed by: simponic
GPG Key ID: 52B3774857EB24B1
5 changed files with 28 additions and 9 deletions

View File

@ -1,4 +1,4 @@
FROM node:18.15.0-alpine AS development FROM node:16.20.0-alpine AS development
WORKDIR /app WORKDIR /app

View File

@ -1,6 +1,18 @@
import { ago } from "../utils/ago"; import { ago } from "../utils/ago";
import { useEffect, useState } from "react"; 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 }) { export default function TimerCard({ timer }) {
const [since, setSince] = useState(ago(timer.start)); const [since, setSince] = useState(ago(timer.start));
@ -20,7 +32,8 @@ export default function TimerCard({ timer }) {
return ( return (
<h1> <h1>
<code>{since}</code> since {timer.name} <code>{since}</code>{" "}
{replaceReferencedFriendsInName(timer.name, timer.referenced_friends)}
</h1> </h1>
); );
} }

View File

@ -45,12 +45,12 @@ export default function TimerHeader({ onSelect }) {
</div> </div>
<div className="nav-right"> <div className="nav-right">
<details className="dropdown"> <details className="dropdown">
<summary className="button outline">{friendName}</summary> <summary style={{ marginTop: "1rem" }} className="button outline">
<div className="card"> {friendName}
<a onClick={logout} className="text-error"> </summary>
Logout <a className="button outline text-error" onClick={logout}>
</a> Logout
</div> </a>
</details> </details>
</div> </div>
</nav> </nav>

6
package-lock.json generated Normal file
View File

@ -0,0 +1,6 @@
{
"name": "friends",
"lockfileVersion": 2,
"requires": true,
"packages": {}
}

View File

@ -1,4 +1,4 @@
FROM node:18.15.0-alpine AS development FROM node:16.20.0-alpine AS development
WORKDIR /usr/src/app WORKDIR /usr/src/app