touchups after refactor

This commit is contained in:
Christian Beutel
2025-01-03 00:13:59 +01:00
parent 871481a84e
commit 0d2e71c2f6
32 changed files with 1157 additions and 45 deletions

View File

@@ -1,4 +1,5 @@
import { pb } from "$lib/pocketbase";
import { handleError } from "$lib/util/api_util";
import { error, json, type RequestEvent } from "@sveltejs/kit";
import { z } from "zod";
@@ -13,7 +14,7 @@ export async function POST(event: RequestEvent) {
const r = await pb.collection('users').confirmPasswordReset(safeData.token, safeData.password, safeData.passwordConfirm);
return json(r);
} catch (e: any) {
throw error(e.status, e);
throw handleError(e);
}
}

View File

@@ -1,4 +1,5 @@
import { pb } from "$lib/pocketbase";
import { handleError } from "$lib/util/api_util";
import { error, json, type RequestEvent } from "@sveltejs/kit";
import { z } from "zod";
@@ -15,7 +16,7 @@ export async function POST(event: RequestEvent) {
const r = await pb.collection('users').authWithPassword(safeData.email ?? safeData.username!, data.password);
return json(r);
} catch (e: any) {
throw error(e.status, e);
throw handleError(e);
}
}

View File

@@ -4,6 +4,7 @@ import { env as private_env } from "$env/dynamic/private";
import { pb } from "$lib/pocketbase";
import { error, json, type RequestEvent } from "@sveltejs/kit";
import { z } from "zod";
import { handleError } from "$lib/util/api_util";
const redirectURL = private_env.ORIGIN + "/login/redirect"
@@ -18,7 +19,7 @@ export async function GET(event: RequestEvent) {
}
return json(r)
} catch (e: any) {
throw error(e.status, e);
throw handleError(e);
}
}
@@ -40,7 +41,7 @@ export async function POST(event: RequestEvent) {
)
return json(r)
} catch (e: any) {
throw error(e.status, e);
throw handleError(e);
}
}

View File

@@ -5,13 +5,13 @@ import { z } from "zod";
export async function GET(event: RequestEvent) {
const safeParams = z.object({
collection: z.string().length(15),
collection: z.string(),
record: z.string().length(15),
file: z.string()
}).safeParse(event.params)
if (!safeParams.success) {
throw error(400, 'Invalid params')
throw error(400, safeParams.error)
}
const parts = [];

View File

@@ -1,7 +1,7 @@
import type { Notification } from '$lib/models/notification';
import type { UserAnonymous } from '$lib/models/user';
import { pb } from '$lib/pocketbase';
import { Collection, list } from '$lib/util/api_util';
import { Collection, handleError, list } from '$lib/util/api_util';
import { error, json, type RequestEvent } from '@sveltejs/kit';
export async function GET(event: RequestEvent) {
@@ -17,6 +17,6 @@ export async function GET(event: RequestEvent) {
}
return json(r)
} catch (e: any) {
throw error(e.status, e);
throw handleError(e);
}
}

View File

@@ -152,10 +152,9 @@
$page.url.searchParams.has("lat") &&
$page.url.searchParams.has("lon")
) {
map.setCenter([
parseFloat($page.url.searchParams.get("lon")!),
parseFloat($page.url.searchParams.get("lat")!),
]);
const lat = $page.url.searchParams.get("lat");
const lon = $page.url.searchParams.get("lon");
map.setCenter([parseFloat(lon!), parseFloat(lat!)]);
map.setZoom(14);
} else if (settings && settings.mapFocus == "trails") {
const boundingBox: M.LngLatBoundsLike = [

View File

@@ -46,7 +46,7 @@
<div
class="grid grid-cols-1 lg:grid-cols-[356px_minmax(0,_1fr)] gap-4 max-w-6xl mx-auto items-start"
>
<div class="border border-input-border rounded-xl">
<div class="border border-input-border rounded-xl sticky top-8">
{#if data.user}
<div class="flex items-center gap-x-6 px-6 my-6">
<img

View File

@@ -217,7 +217,7 @@
async function loadSummitLogs() {
const logs = await summit_logs_index($page.params.id, filter);
summitLogs.set(logs);
summitLogs.set(logs.items);
}
</script>