aboutsummaryrefslogtreecommitdiffstats
path: root/src/helpers
diff options
context:
space:
mode:
authorPinapelz <yukais@pinapelz.com>2026-06-03 10:08:41 -0700
committerPinapelz <yukais@pinapelz.com>2026-06-03 10:08:41 -0700
commit01bdbf76024f51bbc1072e33ceffb0c59ae45032 (patch)
treee2d7ed9eb3f2facfdb05c45c1d004569b9f18e06 /src/helpers
parent88e2e3d62677f6af58b19d8e5d4d789b96d525db (diff)
move startDate to backend
Diffstat (limited to 'src/helpers')
-rw-r--r--src/helpers/fetchInfo.ts9
-rw-r--r--src/helpers/scoreToEmoji.ts7
2 files changed, 14 insertions, 2 deletions
diff --git a/src/helpers/fetchInfo.ts b/src/helpers/fetchInfo.ts
new file mode 100644
index 0000000..248cd98
--- /dev/null
+++ b/src/helpers/fetchInfo.ts
@@ -0,0 +1,9 @@
+
+import { Info } from "../types/info";
+
+export const fetchInfo = async (): Promise<Info> => {
+ const API_URL = process.env.REACT_APP_API_URL || "https://localhost:3000";
+ const response = await fetch(`${API_URL}/info`);
+ const data = await response.json();
+ return data as Info;
+};
diff --git a/src/helpers/scoreToEmoji.ts b/src/helpers/scoreToEmoji.ts
index cb525a8..5af1026 100644
--- a/src/helpers/scoreToEmoji.ts
+++ b/src/helpers/scoreToEmoji.ts
@@ -1,9 +1,12 @@
import { GuessType, GuessState } from "../types/guess";
-import { appName, startDate } from "../constants";
+import { appName } from "../constants";
+import { fetchInfo } from "./fetchInfo";
-export function scoreToEmoji(guesses: GuessType[]): string {
+export async function scoreToEmoji(guesses: GuessType[]): Promise<string> {
const msInDay = 86400000;
const todaysDate = new Date();
+ const info = await fetchInfo();
+ const startDate = new Date(info.startDate);
const index = Math.floor((todaysDate.getTime() - startDate.getTime() )/msInDay) + 1
const emojis = {
incorrect: "🟥",
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage