Skip to content

Commit 8d8cb21

Browse files
authored
fix: hot fix departments
* fix: hot fix departments * fix: unused vars
1 parent 62e3c20 commit 8d8cb21

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

backend/app/controllers/registrations_controller.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ export default class RegistrationsController {
1313
const departmentId = params.department_id as unknown;
1414

1515
if (typeof departmentId === "string") {
16+
const tmpDepId = decodeURIComponent(departmentId);
1617
return Registration.query()
17-
.where("departmentId", departmentId)
18+
.where("departmentId", tmpDepId)
1819
.andWhere("isActive", true)
1920
.orWhereNull("isActive");
2021
}

backend/config/cors.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import { defineConfig } from "@adonisjs/cors";
22

3-
import env from "#start/env";
4-
53
/**
64
* Configuration options to tweak the CORS policy. The following
75
* options are documented on the official documentation website.
@@ -10,7 +8,7 @@ import env from "#start/env";
108
*/
119
const corsConfig = defineConfig({
1210
enabled: true,
13-
origin: env.get("CORS_ORIGIN", "planer.solvro.pl").split(","), // ["http://localhost:3000", "http://localhost:8080"]
11+
origin: true,
1412
methods: ["GET", "HEAD", "POST", "PUT", "DELETE"],
1513
headers: true,
1614
exposeHeaders: [],

frontend/src/app/plans/edit/[id]/page.client.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,11 @@ export function CreateNewPlanPage({
7676
const plan = usePlan({ planId });
7777

7878
const registrations = useQuery({
79-
enabled: faculty !== null,
79+
enabled: faculty !== null && faculty !== "",
8080
queryKey: ["registrations", faculty],
8181
queryFn: async () => {
8282
const response = await fetch(
83-
`${env.NEXT_PUBLIC_API_URL}/departments/${faculty ?? ""}/registrations`,
83+
`${env.NEXT_PUBLIC_API_URL}/departments/${encodeURIComponent(faculty ?? "")}/registrations`,
8484
);
8585

8686
if (!response.ok) {
@@ -117,7 +117,7 @@ export function CreateNewPlanPage({
117117
mutationKey: ["courses"],
118118
mutationFn: async (registrationId: string) => {
119119
const response = await fetch(
120-
`${env.NEXT_PUBLIC_API_URL}/departments/${faculty?.toString() ?? ""}/registrations/${encodeURIComponent(registrationId)}/courses`,
120+
`${env.NEXT_PUBLIC_API_URL}/departments/${encodeURIComponent(faculty ?? "")}/registrations/${encodeURIComponent(registrationId)}/courses`,
121121
);
122122

123123
if (!response.ok) {

0 commit comments

Comments
 (0)