Skip to content

Commit c866af9

Browse files
committed
flag new players
1 parent 7af4a68 commit c866af9

File tree

1 file changed

+30
-21
lines changed

1 file changed

+30
-21
lines changed

src/components/newPlayers.tsx

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -52,30 +52,39 @@ export const NewPlayers: React.FC = () => {
5252
</thead>
5353
<tbody>
5454
{newPlayers.map((player) => (
55-
<tr key={player.ckey}>
56-
<td>
57-
<NameExpand name={player.ckey} />
58-
</td>
59-
<td>
60-
{new Date(
61-
Date.parse(player.firstJoinDate!.replace(" ", "T"))
62-
).toLocaleString()}
63-
</td>
64-
<td>
65-
{new Date(
66-
Date.parse(player.byondAccountAge!.replace(" ", "T"))
67-
).toLocaleDateString()}
68-
</td>
69-
<td>
70-
<DetailedCid cid={player.lastKnownCid} />
71-
</td>
72-
<td>
73-
<DetailedIp ip={player.lastKnownIp} />{" "}
74-
</td>
75-
</tr>
55+
<RenderNewPlayer player={player} key={player.ckey} />
7656
))}
7757
</tbody>
7858
</table>
7959
</div>
8060
);
8161
};
62+
63+
const RenderNewPlayer = (props: { player: Player }) => {
64+
const { player } = props;
65+
66+
const firstJoin = new Date(
67+
Date.parse(player.firstJoinDate!.replace(" ", "T"))
68+
);
69+
70+
const byondAccountAge = new Date(Date.parse(player.byondAccountAge!));
71+
72+
const isNew =
73+
firstJoin.getMilliseconds() - byondAccountAge.getMilliseconds() < 86400000;
74+
75+
return (
76+
<tr className={isNew ? "border border-red-400 rounded" : ""}>
77+
<td>
78+
<NameExpand name={player.ckey} />
79+
</td>
80+
<td>{firstJoin.toLocaleString()}</td>
81+
<td>{byondAccountAge.toLocaleDateString()}</td>
82+
<td>
83+
<DetailedCid cid={player.lastKnownCid} />
84+
</td>
85+
<td>
86+
<DetailedIp ip={player.lastKnownIp} />{" "}
87+
</td>
88+
</tr>
89+
);
90+
};

0 commit comments

Comments
 (0)