Skip to content
This repository was archived by the owner on Oct 22, 2025. It is now read-only.

Commit 398af33

Browse files
committed
fix: register
1 parent 63d925e commit 398af33

File tree

4 files changed

+22
-7
lines changed

4 files changed

+22
-7
lines changed

src/routes/auth/+page.server.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,18 @@ export const actions: Actions = {
7575
}
7676

7777
try {
78+
const { confirmPassword, ...rest } = form.data;
79+
const requestBody = JSON.stringify({
80+
...rest,
81+
confirm_password: confirmPassword
82+
});
83+
7884
const response = await fetch(`${env.BACKEND_URL}/api/v1/auth/register`, {
7985
method: 'POST',
8086
headers: {
8187
'Content-Type': 'application/json'
8288
},
83-
body: JSON.stringify(form.data)
89+
body: requestBody
8490
});
8591

8692
if (!response.ok) {

src/routes/dashboard/+page.svelte

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212

1313
<div class="flex flex-1 items-center justify-center bg-gray-100">
1414
<div class="w-full max-w-md bg-white p-8 rounded-lg shadow-lg text-center">
15-
<!-- <h1 class="text-2xl font-semibold text-gray-700 mb-4">{m.hi()} {data.user.username}!</h1>
15+
<h1 class="text-2xl font-semibold text-gray-700 mb-4">{m.hi()} {data.localUser.username}!</h1>
1616
<p class="text-gray-600 mb-6">
17-
{m.your_user_id()} <span class="font-medium text-gray-800">{data.user.id}</span>.
18-
</p> -->
17+
{m.your_user_id()}: <span class="font-medium text-gray-800">{data.localUser.id}</span>.
18+
</p>
1919
<form method="post" action="?/logout" use:enhance>
2020
<Button class="w-full bg-red-600 rounded-lg hover:bg-red-700" type="submit"
2121
>{m.logout()}</Button

src/routes/dashboard/tasks/[taskId]/+page.server.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,11 @@ export const load: PageServerLoad = async ({ params, locals }) => {
5151
);
5252

5353
if (!taskDescriptionResponse.ok) {
54-
error(500, { message: 'Failed to fetch task description' });
54+
const errorResponse: ApiErrorResponse = await parse_error_response(taskDescriptionResponse);
55+
error(taskDescriptionResponse.status, {
56+
code: errorResponse.data.code,
57+
message: errorResponse.data.message
58+
});
5559
}
5660

5761
const availableLanguagesResponse = await fetch(`${env.BACKEND_URL}/api/v1/submission/languages`, {

src/routes/dashboard/tasks/[taskId]/submissions/+page.server.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { error } from '@sveltejs/kit';
22
import type { PageServerLoad } from './$types';
33
import { env } from '$env/dynamic/private';
4-
import type { GetAllSubmissionsResponse } from '$lib/backendSchemas';
4+
import type { ApiErrorResponse, GetAllSubmissionsResponse } from '$lib/backendSchemas';
5+
import { parse_error_response } from '$lib/server/utils';
56

67
export const load: PageServerLoad = async ({ params, locals }) => {
78
const { taskId } = params;
@@ -18,7 +19,11 @@ export const load: PageServerLoad = async ({ params, locals }) => {
1819
});
1920

2021
if (!submissionDataResponse.ok) {
21-
error(submissionDataResponse.status, 'Failed to fetch submission data');
22+
const errorResponse: ApiErrorResponse = await parse_error_response(submissionDataResponse);
23+
error(submissionDataResponse.status, {
24+
code: errorResponse.data.code,
25+
message: errorResponse.data.message
26+
});
2227
}
2328

2429
const submissionData: GetAllSubmissionsResponse = await submissionDataResponse.json();

0 commit comments

Comments
 (0)