2025-12-22 02:36:48 +01:00
|
|
|
import { OrgApiServer } from '$features/org/api/org.server';
|
2023-09-14 06:42:16 +01:00
|
|
|
import { redirect } from '@sveltejs/kit';
|
|
|
|
|
|
|
|
|
|
export const load = async ({ params = { hash: '' } }) => {
|
|
|
|
|
try {
|
|
|
|
|
const courseHashData = atob(decodeURIComponent(params.hash));
|
|
|
|
|
console.log('courseHashData', courseHashData);
|
|
|
|
|
|
2024-07-10 21:53:34 +01:00
|
|
|
const { id, name, description, orgSiteName } = JSON.parse(courseHashData);
|
2023-09-14 06:42:16 +01:00
|
|
|
|
2024-07-10 21:53:34 +01:00
|
|
|
if (!id || !name || !description || !orgSiteName) {
|
2023-09-14 06:42:16 +01:00
|
|
|
throw 'Validation failed';
|
|
|
|
|
}
|
2025-12-02 09:54:38 +01:00
|
|
|
|
|
|
|
|
const currentOrg = await OrgApiServer.getOrgBySiteName(orgSiteName);
|
2023-09-14 06:42:16 +01:00
|
|
|
|
|
|
|
|
return {
|
2024-07-10 21:53:34 +01:00
|
|
|
id,
|
2023-09-14 06:42:16 +01:00
|
|
|
name,
|
|
|
|
|
description,
|
|
|
|
|
currentOrg
|
|
|
|
|
};
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('Error decoding course invite params.hash', error);
|
2025-11-01 15:49:29 +01:00
|
|
|
redirect(307, '/404');
|
2023-09-14 06:42:16 +01:00
|
|
|
}
|
|
|
|
|
};
|