From cfac59282da55f4791d6352f15887a15e9ff6ec5 Mon Sep 17 00:00:00 2001 From: Wolfboy248 <121288977+Wolfboy248@users.noreply.github.com> Date: Wed, 10 Jul 2024 21:51:25 +0200 Subject: Games page, maplist page (#153) Co-authored-by: Wolfboy248 <105884620+Wolfboy248@users.noreply.github.com> --- frontend/src/components/record.js | 57 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 frontend/src/components/record.js (limited to 'frontend/src/components/record.js') diff --git a/frontend/src/components/record.js b/frontend/src/components/record.js new file mode 100644 index 0000000..a01109c --- /dev/null +++ b/frontend/src/components/record.js @@ -0,0 +1,57 @@ +import React, { useEffect, useRef, useState } from 'react'; +import { useLocation, Link } from "react-router-dom"; + +import "./record.css" + +export default function Record({ name, place, portals, time, date }) { + // const {token} = prop; + const [record, setRecord] = useState(null); + const location = useLocation(); + + useEffect(() => { + console.log(name, place, portals, time, date); + }) + + function timeSince() { + const now = new Date(); + const dateNew = new Date(date); + + const secondsPast = Math.floor((now - dateNew) / 1000); + console.log('Seconds past:', secondsPast); + + if (secondsPast < 60) { + return `${secondsPast} seconds ago`; + } + if (secondsPast < 3600) { + const minutes = Math.floor(secondsPast / 60); + return `${minutes} minutes ago`; + } + if (secondsPast < 86400) { + const hours = Math.floor(secondsPast / 3600); + return `${hours} hours ago`; + } + if (secondsPast < 2592000) { + const days = Math.floor(secondsPast / 86400); + return `${days} days ago`; + } + if (secondsPast < 31536000) { + const months = Math.floor(secondsPast / 2592000); + return `${months} months ago`; + } + const years = Math.floor(secondsPast / 31536000); + return `${years} years ago`; + } + + return( +
+ {place} +
+ + {name} +
+ {portals} + {time} + {timeSince()} +
+ ) +} -- cgit v1.2.3