Skip to content

Commit 4edaebd

Browse files
anees-asgharnalves599
authored andcommitted
Add mock achievements
1 parent 8481934 commit 4edaebd

File tree

6 files changed

+80
-5
lines changed

6 files changed

+80
-5
lines changed

src/app/(authenticated)/profile/achievements/page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ export default async function Achievements() {
2424
const kindAchievements = [...(acc[a.kind] || []), a];
2525
return { ...acc, [a.kind]: kindAchievements };
2626
},
27-
{} as Record<AchievementKind, Achievement[]>,
27+
{} as Record<AchievementKind, Achievement[]>
2828
);
2929
const sortedKinds = Object.keys(
30-
achievementsByKind,
30+
achievementsByKind
3131
).sort() as AchievementKind[];
3232

3333
return (

src/mocks/data/achievement.ts

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import { MOCK_COMPANIES } from "./company";
2+
3+
export const MOCK_ACHIEVEMENTS: Achievement[] = [
4+
{
5+
id: "achievement_cv_1",
6+
name: "Upload your CV",
7+
img: "https://sinfo.ams3.cdn.digitaloceanspaces.com/static/27-sinfo/achievements/cv/cv.webp",
8+
value: 1000,
9+
kind: "cv",
10+
description: "Upload your CV to be shared with the companies.",
11+
users: ["mock_user_id", "other_user_id_1", "other_user_id_2"],
12+
},
13+
{
14+
id: "achievement_stand_1",
15+
name: "Visit Microsoft",
16+
img: "https://sinfo.ams3.cdn.digitaloceanspaces.com/static/27-sinfo/achievements/stands/stands_mercedes-benz_1.png",
17+
value: 50,
18+
kind: "stand",
19+
description: "Visit Microsoft.",
20+
company: MOCK_COMPANIES[3],
21+
users: ["other_user_id_1"],
22+
},
23+
{
24+
id: "achievement_stand_2",
25+
name: "Visit Google",
26+
img: "https://sinfo.ams3.cdn.digitaloceanspaces.com/static/27-sinfo/achievements/stands/stands_freiheit.com-technologies-gmbh_1.png",
27+
value: 50,
28+
kind: "stand",
29+
description: "Visit Google.",
30+
company: MOCK_COMPANIES[4],
31+
users: ["mock_user_id", "other_user_id_2"],
32+
},
33+
{
34+
id: "achievement_stand_3",
35+
name: "Visit Bliss Applications",
36+
img: "https://sinfo.ams3.cdn.digitaloceanspaces.com/static/27-sinfo/achievements/stands/stands_talkdesk_1.png",
37+
value: 50,
38+
kind: "stand",
39+
description: "Visit Bliss Applications.",
40+
company: MOCK_COMPANIES[6],
41+
},
42+
{
43+
id: "achievement_stand_4",
44+
name: "Visit Cloudflare",
45+
img: "https://sinfo.ams3.cdn.digitaloceanspaces.com/static/27-sinfo/achievements/stands/stands_deloitte_1.png",
46+
value: 50,
47+
kind: "stand",
48+
description: "Visit Cloudflare.",
49+
company: MOCK_COMPANIES[9],
50+
users: ["other_user_id_1", "other_user_id_2", "mock_user_id"],
51+
},
52+
{
53+
id: "achievement_presentation_1",
54+
name: "Syone presentation",
55+
img: "https://sinfo.ams3.cdn.digitaloceanspaces.com/static/27-sinfo/achievements/presentations/syone-software-solutions-27-sinfo.webp",
56+
value: 150,
57+
kind: "presentation",
58+
description: "Get to know Syone.",
59+
},
60+
{
61+
id: "achievement_presentation_2",
62+
name: "Diconium presentation",
63+
img: "https://sinfo.ams3.cdn.digitaloceanspaces.com/static/27-sinfo/achievements/presentations/diconium-vw-one-true-love-27-sinfo.webp",
64+
value: 150,
65+
kind: "presentation",
66+
description: "Get to know Diconium.",
67+
users: ["mock_user_id"],
68+
},
69+
];

src/mocks/data/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ export * from "./company";
33
export * from "./speaker";
44
export * from "./event";
55
export * from "./session";
6+
export * from "./achievement";

src/mocks/handlers.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
MOCK_SPEAKER,
1111
MOCK_USER_QR_CODE,
1212
MOCK_SESSION_STATUS,
13+
MOCK_ACHIEVEMENTS,
1314
} from "./data";
1415

1516
const BACKEND_URL = process.env.CANNON_URL;
@@ -79,4 +80,8 @@ export const handlers = [
7980
http.get(`${BACKEND_URL}/session`, () => {
8081
return HttpResponse.json(MOCK_SESSIONS);
8182
}),
83+
// get all achievements for the edition
84+
http.get(`${BACKEND_URL}/achievements`, () => {
85+
return HttpResponse.json(MOCK_ACHIEVEMENTS);
86+
}),
8287
];

src/services/AchievementService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export const AchievementService = (() => {
1414

1515
const getAchievementBySession = async (
1616
cannonToken: string,
17-
sessionId: string,
17+
sessionId: string
1818
): Promise<Achievement | null> => {
1919
try {
2020
const resp = await fetch(`${achievementsEndpoint}/session/${sessionId}`, {

src/utils/utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export function trimText(text: string, n: number): string {
4040
export function generateTimeInterval(
4141
timestamp: string,
4242
durationMinutes: number,
43-
{ onlyHours }: { onlyHours?: boolean } = {},
43+
{ onlyHours }: { onlyHours?: boolean } = {}
4444
): string {
4545
// extract "HH:mm" from ISO string
4646
const formatTime = (date: Date) => date.toISOString().slice(11, 16);
@@ -92,7 +92,7 @@ export function getEventFullDate(date: string): string {
9292
// TODO: Implement this correctly
9393
export function isValidQRCode(
9494
data: string,
95-
kind?: "user" | "achievement",
95+
kind?: "user" | "achievement"
9696
): boolean {
9797
try {
9898
return (

0 commit comments

Comments
 (0)