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
|
WORKDIR /app
|
||||||
|
|
||||||
|
@ -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>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -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>
|
||||||
|
<a className="button outline text-error" onClick={logout}>
|
||||||
Logout
|
Logout
|
||||||
</a>
|
</a>
|
||||||
</div>
|
|
||||||
</details>
|
</details>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</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
|
WORKDIR /usr/src/app
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user