Skip to content

Commit ab20045

Browse files
committed
formatering..
forandret etikett for profil siden, neste steg er å kunne gå til ander sine profiler Lagt til navnet mitt på webkom siden. (#2230) 🔥 Remove boomtown (#2233) Fix weird images (#2234) change href for happening tab (#2235) added name (#2236) Ekstern link til påmelding + navn i webkom medlemsliste (#2232) Update dependency jsdom to v25 (#2202) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Update dependency @tailwindcss/forms to v0.5.9 (#2229) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Update dependency @testing-library/react to v16.0.1 (#2217) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Update dependency @sanity/icons to v3.4.0 (#2194) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Update dependency tsx to v4.19.0 (#2198) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Update dependency @types/node to v20.16.5 (#2218) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Update dependency tsx to v4.19.1 (#2242) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> added tidspunkt to csv Update dependency @types/pg to v8.11.9 (#2237) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Update dependency @tailwindcss/typography to v0.5.15 (#2216) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Update pnpm to v9.10.0 (#2192) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Karo/phd (#2246) Update dependency @types/react to v18.3.5 (#2238) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Update dependency postcss to v8.4.45 (#2240) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Update dependency remove-markdown to v0.5.5 (#2241) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Update dependency tailwindcss to v3.4.11 (#2244) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Update dependency eslint-plugin-react to v7.36.1 (#2239) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Update dependency framer-motion to v11.5.4 (#2193) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Update dependency @playwright/test to v1.47.1 (#2248) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Add renovate schedule Update dependency styled-components to v6.1.13 (#2243) Update dependency eslint-plugin-jsx-a11y to v6.10.0 (#2251) Update dependency vite to ^5.4.5 (#2245) Update dependency eslint-plugin-import to v2.30.0 (#2250) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Update robots
1 parent 55072f9 commit ab20045

File tree

19 files changed

+1716
-1097
lines changed

19 files changed

+1716
-1097
lines changed

.env.example

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ NEXTAUTH_URL="http://localhost:3000"
2828
# --- Advent Of Code
2929
AOC_SESSION_COOKIE=""
3030

31-
# --- API
32-
API_PORT=8000
33-
NEXT_PUBLIC_API_URL=http://localhost:8000
31+
# --- Kaffe (can be found in the nano repository)
32+
# The URL of the Kaffe server
33+
#NEXT_PUBLIC_KAFFE_URL="http://localhost:8002"
3434

3535
# --- echogram (can be found in the nano repository)
3636
#NEXT_PUBLIC_ECHOGRAM_URL="http://localhost:8001"

apps/cms/package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@
2424
],
2525
"dependencies": {
2626
"@echo-webkom/lib": "workspace:*",
27-
"@sanity/client": "6.27.2",
28-
"@sanity/icons": "3.5.7",
29-
"@sanity/ui": "2.15.1",
30-
"@sanity/vision": "3.71.2",
31-
"nanoid": "5.0.9",
27+
"@sanity/client": "6.21.3",
28+
"@sanity/icons": "3.4.0",
29+
"@sanity/ui": "2.8.9",
30+
"@sanity/vision": "3.56.0",
31+
"nanoid": "5.0.7",
3232
"react": "18.3.1",
3333
"react-dom": "18.3.1",
3434
"react-is": "18.3.1",
@@ -41,7 +41,7 @@
4141
},
4242
"devDependencies": {
4343
"@sanity/eslint-config-studio": "4.0.0",
44-
"@types/react": "18.3.12",
44+
"@types/react": "18.3.5",
4545
"@types/styled-components": "5.1.34",
4646
"dotenv": "16.4.5",
4747
"eslint": "8.57.1",

apps/cms/sanity.types.ts

Lines changed: 18 additions & 149 deletions
Large diffs are not rendered by default.

apps/web/package.json

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,11 @@
4545
"clsx": "2.1.1",
4646
"date-fns": "4.1.0",
4747
"drizzle-orm": "0.33.0",
48-
"groq": "3.61.0",
49-
"ics": "3.8.1",
50-
"ky": "1.7.2",
51-
"lucide-react": "0.473.0",
52-
"motion": "11.15.0",
53-
"nanoid": "5.0.9",
54-
"next": "15.1.6",
48+
"framer-motion": "11.5.4",
49+
"groq": "3.56.0",
50+
"ics": "^3.7.6",
51+
"nanoid": "5.0.7",
52+
"next": "14.2.6",
5553
"next-auth": "4.24.7",
5654
"next-themes": "0.3.0",
5755
"nextjs-toploader": "3.7.15",
@@ -67,32 +65,31 @@
6765
"react-use-websocket": "4.9.0",
6866
"recharts": "2.15.0",
6967
"remark-gfm": "4.0.0",
70-
"remove-markdown": "0.6.0",
68+
"remove-markdown": "0.5.5",
7169
"sharp": "0.33.0",
7270
"tailwind-merge": "2.6.0",
7371
"zod": "3.23.8"
7472
},
7573
"devDependencies": {
76-
"@echo-webkom/cms": "workspace:*",
77-
"@tailwindcss/forms": "0.5.10",
78-
"@tailwindcss/typography": "0.5.16",
74+
"@echo-webkom/tsconfig": "workspace:*",
75+
"@tailwindcss/forms": "0.5.9",
76+
"@tailwindcss/typography": "0.5.15",
7977
"@testing-library/react": "16.0.1",
80-
"@types/node": "20.17.10",
81-
"@types/react": "19.0.3",
82-
"@types/react-dom": "19.0.2",
83-
"@vitejs/plugin-react": "4.3.3",
78+
"@types/node": "20.16.5",
79+
"@types/react": "18.3.5",
80+
"@types/react-dom": "18.3.0",
81+
"@vitejs/plugin-react": "4.3.1",
8482
"autoprefixer": "10.4.20",
8583
"dotenv-cli": "7.4.4",
8684
"eslint": "8.57.1",
8785
"eslint-config-webkom": "workspace:*",
88-
"jsdom": "25.0.1",
89-
"postcss": "8.4.49",
86+
"jsdom": "25.0.0",
87+
"postcss": "8.4.45",
9088
"server-only": "^0.0.1",
91-
"tailwindcss": "3.4.14",
89+
"tailwindcss": "3.4.11",
9290
"tailwindcss-animate": "1.0.7",
93-
"tailwindcss-react-aria-components": "^1.2.0",
94-
"typescript": "5.6.3",
95-
"vite": "5.4.9",
91+
"typescript": "5.5.4",
92+
"vite": "^5.4.5",
9693
"vite-tsconfig-paths": "4.3.1",
9794
"vitest": "2.1.9"
9895
},

apps/web/src/actions/register.ts

Lines changed: 141 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,17 @@
22

33
import { type z } from "zod";
44

5-
import { apiServer } from "@/api/server";
5+
import { db } from "@echo-webkom/db";
6+
import {
7+
answers,
8+
registrations,
9+
users,
10+
type AnswerInsert,
11+
type SpotRange,
12+
} from "@echo-webkom/db/schemas";
13+
14+
import { revalidateRegistrations } from "@/data/registrations/revalidate";
15+
import { isUserBannedFromBedpres } from "@/lib/ban-info";
616
import { getUser } from "@/lib/get-user";
717
import { type registrationFormSchema } from "@/lib/schemas/registration";
818

@@ -34,7 +44,136 @@ export const register = async (id: string, payload: z.infer<typeof registrationF
3444
})
3545
.json<{ success: boolean; message: string }>();
3646

37-
return resp;
47+
const canSkipSpotRange = doesIntersect(
48+
hostGroups,
49+
user.memberships.map((membership) => membership.group.id),
50+
);
51+
52+
/**
53+
* Get correct spot range for user
54+
*
55+
* If user is not in any spot range, return error
56+
*/
57+
const userSpotRange = getCorrectSpotrange(user.year, spotRanges, canSkipSpotRange);
58+
59+
if (!userSpotRange) {
60+
console.error("User is not in any spot range", {
61+
userId: user.id,
62+
happeningId: id,
63+
});
64+
return {
65+
success: false,
66+
message: "Du kan ikke melde deg på dette arrangementet",
67+
};
68+
}
69+
70+
const data = await registrationFormSchema.parseAsync(payload);
71+
72+
/**
73+
* Check if all questions are answered
74+
*/
75+
const allQuestionsAnswered = happening.questions.every((question) => {
76+
const questionExists = data.questions.find((q) => q.questionId === question.id);
77+
const questionAnswer = questionExists?.answer;
78+
79+
return question.required ? !!questionAnswer : true;
80+
});
81+
82+
if (!allQuestionsAnswered) {
83+
console.error("Not all questions are answered", {
84+
userId: user.id,
85+
happeningId: id,
86+
});
87+
return {
88+
success: false,
89+
message: "Du må svare på alle spørsmålene",
90+
};
91+
}
92+
93+
const { registration, isWaitlisted } = await db.transaction(
94+
async (tx) => {
95+
await tx.execute(sql`LOCK TABLE ${registrations} IN EXCLUSIVE MODE`);
96+
97+
const regs = await tx
98+
.select()
99+
.from(registrations)
100+
.where(
101+
and(
102+
eq(registrations.happeningId, id),
103+
lte(users.year, userSpotRange.maxYear),
104+
gte(users.year, userSpotRange.minYear),
105+
or(eq(registrations.status, "registered"), eq(registrations.status, "waiting")),
106+
),
107+
)
108+
.leftJoin(users, eq(registrations.userId, users.id));
109+
110+
const isInfiniteSpots = userSpotRange.spots === 0;
111+
const isWaitlisted = !isInfiniteSpots && regs.length >= userSpotRange.spots;
112+
113+
const registration = await tx
114+
.insert(registrations)
115+
.values({
116+
status: isWaitlisted ? "waiting" : "registered",
117+
happeningId: id,
118+
userId: user.id,
119+
changedBy: null,
120+
})
121+
.returning()
122+
.onConflictDoUpdate({
123+
target: [registrations.happeningId, registrations.userId],
124+
set: {
125+
status: isWaitlisted ? "waiting" : "registered",
126+
},
127+
})
128+
.then((res) => res[0] ?? null);
129+
130+
return {
131+
registration,
132+
isWaitlisted,
133+
};
134+
},
135+
{
136+
isolationLevel: "read committed",
137+
},
138+
);
139+
140+
revalidateRegistrations(id, user.id);
141+
142+
if (!registration) {
143+
throw new Error("Failed to update registration");
144+
}
145+
146+
/**
147+
* Insert answers
148+
*/
149+
const answersToInsert = data.questions.map(
150+
(question) =>
151+
({
152+
happeningId: happening.id,
153+
userId: user.id,
154+
questionId: question.questionId,
155+
answer: question.answer
156+
? {
157+
answer: question.answer,
158+
}
159+
: null,
160+
}) satisfies AnswerInsert,
161+
);
162+
163+
if (answersToInsert.length > 0) {
164+
await db.insert(answers).values(answersToInsert).onConflictDoNothing();
165+
}
166+
167+
console.info("Successful registration", {
168+
userId: user.id,
169+
happeningId: happening.id,
170+
isWaitlisted,
171+
});
172+
173+
return {
174+
success: true,
175+
message: isWaitlisted ? "Du er nå på venteliste" : "Du er nå påmeldt arrangementet",
176+
};
38177
} catch (error) {
39178
console.error("Failed to register");
40179

apps/web/src/app/(default)/hjem/page.tsx

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,26 @@ export default async function Home() {
1717
<Banner />
1818
<BirthdayBanner />
1919

20-
<div className="space-y-8 py-24">
21-
<Container layout="larger">
22-
<FPCalendar />
23-
</Container>
20+
<Container
21+
layout="larger"
22+
className="flex space-y-8 md:grid md:grid-cols-3 md:grid-rows-2 md:gap-8 md:space-y-0"
23+
>
24+
<ComingHappenings
25+
title="Arrangementer"
26+
href="/for-studenter/arrangementer?type=event"
27+
types={["external", "event"]}
28+
n={7}
29+
className="col-span-1 row-span-2"
30+
/>
31+
<ComingHappenings
32+
title="Bedpresser"
33+
href="/for-studenter/arrangementer?type=bedpres"
34+
types={["bedpres"]}
35+
n={3}
36+
className="col-span-2 row-span-1"
37+
/>
38+
<Posts className="col-span-2 row-span-1" />
39+
</Container>
2440

2541
<Container
2642
layout="larger"

apps/web/src/config.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,11 @@ export const PORT = process.env.PORT ?? 3000;
99
export const BASE_URL = dev
1010
? `http://localhost:${process.env.PORT ?? 3000}`
1111
: `https://${PRODUCTION_DOMAIN}`;
12+
13+
export const PROFILE_IMAGE_FUNCTION_URL = "https://echo-images.azurewebsites.net/api/images";
14+
15+
export const COOKIE_BANNER = "cookie-banner";
16+
17+
export const NUM_HAPPENINGS = !isNaN(Number(process.env.NUM_HAPPENINGS))
18+
? Number(process.env.NUM_HAPPENINGS)
19+
: 4;

apps/web/src/lib/get-user.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { cache } from "react";
2+
import { eq } from "drizzle-orm";
23

34
import { auth } from "@echo-webkom/auth";
4-
import { eq } from "drizzle-orm";
5-
import { users } from "@echo-webkom/db/schemas";
65
import { db } from "@echo-webkom/db";
6+
import { users } from "@echo-webkom/db/schemas";
77

88
/**
99
* Wraps the `auth` function in a "cache" to prevent
@@ -15,17 +15,17 @@ import { db } from "@echo-webkom/db";
1515
export const getUser = cache(auth);
1616

1717
export const getUserById = cache(async (id: string) => {
18-
const user = await db.query.users.findFirst({
19-
where: eq(users.id, id),
18+
const user = await db.query.users.findFirst({
19+
where: eq(users.id, id),
20+
with: {
21+
degree: true,
22+
memberships: {
2023
with: {
21-
degree: true,
22-
memberships: {
23-
with: {
24-
group: true,
25-
},
26-
},
27-
},
28-
});
24+
group: true,
25+
},
26+
},
27+
},
28+
});
2929

30-
return user;
30+
return user;
3131
});

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "echo-web",
33
"version": "1.0.0",
44
"private": true,
5-
"packageManager": "pnpm@9.12.2",
5+
"packageManager": "pnpm@9.10.0",
66
"scripts": {
77
"build": "turbo run build",
88
"dev": "turbo run dev",

packages/auth/package.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"name": "@echo-webkom/auth",
3+
"version": "0.1.0",
4+
"private": true,
5+
"main": "./src/index.ts",
6+
"scripts": {
7+
"clean": "rm -rf .turbo node_modules",
8+
"lint": "eslint .",
9+
"lint:fix": "eslint lint --fix",
10+
"typecheck": "tsc --noEmit"
11+
},
12+
"dependencies": {
13+
"@echo-webkom/db": "workspace:*",
14+
"drizzle-orm": "0.33.0",
15+
"next": "14.2.6",
16+
"next-auth": "4.24.7",
17+
"react": "18.3.1",
18+
"react-dom": "18.3.1"
19+
},
20+
"devDependencies": {
21+
"@echo-webkom/tsconfig": "workspace:*",
22+
"@types/node": "20.16.5",
23+
"eslint": "8.57.0",
24+
"eslint-config-webkom": "workspace:*",
25+
"typescript": "5.5.4"
26+
},
27+
"eslintConfig": {
28+
"root": true,
29+
"extends": [
30+
"webkom/base"
31+
]
32+
}
33+
}

0 commit comments

Comments
 (0)