2026-04-25 22:51:36 +12:00
|
|
|
import { error } from '@sveltejs/kit';
|
|
|
|
|
import { api } from '$lib/api';
|
|
|
|
|
import { hasStoredClientSession } from '$lib/session';
|
|
|
|
|
|
2026-04-27 21:53:36 +12:00
|
|
|
export async function load({ params, fetch }) {
|
2026-04-25 22:51:36 +12:00
|
|
|
const mixId = Number(params.id);
|
|
|
|
|
|
|
|
|
|
if (!Number.isFinite(mixId)) {
|
|
|
|
|
throw error(404, 'Mix not found');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!hasStoredClientSession()) {
|
|
|
|
|
return {
|
|
|
|
|
mix: null,
|
|
|
|
|
rawMaterials: []
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
2026-04-27 21:53:36 +12:00
|
|
|
const [mix, rawMaterials] = await Promise.all([api.mix(mixId, fetch), api.rawMaterials(fetch)]);
|
2026-04-25 22:51:36 +12:00
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
mix,
|
|
|
|
|
rawMaterials
|
|
|
|
|
};
|
|
|
|
|
} catch {
|
|
|
|
|
throw error(404, 'Mix not found');
|
|
|
|
|
}
|
|
|
|
|
}
|