public home page with community activity overview
This commit is contained in:
@@ -4,7 +4,7 @@ import { haversine } from '$lib/server/gpx';
|
||||
import type { Actions, PageServerLoad } from './$types';
|
||||
|
||||
export const load: PageServerLoad = ({ params, locals }) => {
|
||||
const activity = getActivity(Number(params.id), locals.user!.id);
|
||||
const activity = getActivity(Number(params.id));
|
||||
if (!activity) error(404, 'Activity not found');
|
||||
|
||||
const points = JSON.parse(activity.points) as {
|
||||
@@ -26,10 +26,11 @@ export const load: PageServerLoad = ({ params, locals }) => {
|
||||
if (points[i].ele !== null) profile.push({ d: dist, ele: points[i].ele! });
|
||||
}
|
||||
|
||||
const bagged = baggedPeaks(activity.id, locals.user!.id);
|
||||
const bagged = baggedPeaks(activity.id, activity.user_id);
|
||||
|
||||
return {
|
||||
activity: { ...activity, points: undefined },
|
||||
canDelete: locals.user?.id === activity.user_id,
|
||||
latlngs,
|
||||
profile,
|
||||
bagged: bagged.map((p) => ({
|
||||
@@ -45,7 +46,8 @@ export const load: PageServerLoad = ({ params, locals }) => {
|
||||
|
||||
export const actions: Actions = {
|
||||
delete: async ({ params, locals }) => {
|
||||
deleteActivity(Number(params.id), locals.user!.id);
|
||||
if (!locals.user) error(401, 'Not signed in');
|
||||
deleteActivity(Number(params.id), locals.user.id);
|
||||
redirect(303, '/activities');
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user