Skip to content

Commit 8da3e4c

Browse files
committed
Fix here today and signatures
1 parent 5fcaf65 commit 8da3e4c

File tree

3 files changed

+4
-19
lines changed

3 files changed

+4
-19
lines changed

src/mocks/data/user.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export const MOCK_USER: User = {
1919
signatures: [
2020
{
2121
edition: MOCK_EVENT.id,
22-
day: new Date().toISOString(),
22+
day: new Date().getDate().toString(),
2323
redeemed: false,
2424
signatures: MOCK_ACHIEVEMENTS.filter(
2525
(a) => a.kind === "stand" && a.users?.includes("mock_user_id")
@@ -48,7 +48,7 @@ export const MOCK_OTHER_USER: User = {
4848
signatures: [
4949
{
5050
edition: MOCK_EVENT.id,
51-
day: new Date().toISOString(),
51+
day: new Date().getDate().toString(),
5252
redeemed: false,
5353
signatures: MOCK_ACHIEVEMENTS.filter(
5454
(a) => a.kind === "stand" && a.users?.includes("other_user_id_1")

src/utils/company.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
export function isHereToday(company: Company): boolean {
22
const today = new Date().toISOString().slice(0, 10);
3-
return company.stands?.some((s) => s.date === today) || false;
3+
return company.stands?.some((s) => s.date.slice(0, 10) === today) || false;
44
}

src/utils/utils.ts

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -124,21 +124,6 @@ export function getAchievementFromQRCode(data: string): string | null {
124124
return JSON.parse(atob(data.split("sinfo://")[1])).achievement as string;
125125
}
126126

127-
export function isToday(date: Date | string): boolean {
128-
if (typeof date === "string") {
129-
date = new Date(date);
130-
if (isNaN(date.getTime())) return false;
131-
}
132-
133-
const today = new Date();
134-
135-
return (
136-
date.getFullYear() === today.getFullYear() &&
137-
date.getMonth() === today.getMonth() &&
138-
date.getDate() === today.getDate()
139-
);
140-
}
141-
142127
export function getSessionColor(sessionKind: string) {
143128
switch (sessionKind) {
144129
case "Presentation":
@@ -154,7 +139,7 @@ export function getSessionColor(sessionKind: string) {
154139

155140
export function getUserActiveSignatureData(user: User, edition: string) {
156141
let relevantSignatures = user.signatures?.find(
157-
(s) => s.edition === edition && isToday(s.day)
142+
(s) => s.edition === edition && new Date().getDate().toString() === s.day,
158143
);
159144
if (!relevantSignatures) return null;
160145

0 commit comments

Comments
 (0)