Downgrade node, replace friend references in timer names
This commit is contained in:
parent
a6ced3f22f
commit
6a1a270c94
@ -1,4 +1,4 @@
|
||||
FROM node:18.15.0-alpine AS development
|
||||
FROM node:16.20.0-alpine AS development
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
|
@ -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 (
|
||||
<h1>
|
||||
<code>{since}</code> since {timer.name}
|
||||
<code>{since}</code>{" "}
|
||||
{replaceReferencedFriendsInName(timer.name, timer.referenced_friends)}
|
||||
</h1>
|
||||
);
|
||||
}
|
||||
|
@ -45,12 +45,12 @@ export default function TimerHeader({ onSelect }) {
|
||||
</div>
|
||||
<div className="nav-right">
|
||||
<details className="dropdown">
|
||||
<summary className="button outline">{friendName}</summary>
|
||||
<div className="card">
|
||||
<a onClick={logout} className="text-error">
|
||||
Logout
|
||||
</a>
|
||||
</div>
|
||||
<summary style={{ marginTop: "1rem" }} className="button outline">
|
||||
{friendName}
|
||||
</summary>
|
||||
<a className="button outline text-error" onClick={logout}>
|
||||
Logout
|
||||
</a>
|
||||
</details>
|
||||
</div>
|
||||
</nav>
|
||||
|
6
package-lock.json
generated
Normal file
6
package-lock.json
generated
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"name": "friends",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
FROM node:18.15.0-alpine AS development
|
||||
FROM node:16.20.0-alpine AS development
|
||||
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user