2026-04-29 01:21:16 +12:00
|
|
|
import { getStoredClientSession, hasModuleAccess, hasStoredClientSession } from '$lib/session';
|
2026-04-25 22:51:36 +12:00
|
|
|
import { api } from '$lib/api';
|
|
|
|
|
|
2026-04-27 21:53:36 +12:00
|
|
|
export async function load({ fetch }) {
|
2026-04-25 22:51:36 +12:00
|
|
|
if (!hasStoredClientSession()) {
|
|
|
|
|
return {
|
|
|
|
|
rawMaterials: []
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-29 01:21:16 +12:00
|
|
|
const session = getStoredClientSession();
|
|
|
|
|
|
2026-04-25 22:51:36 +12:00
|
|
|
try {
|
|
|
|
|
return {
|
2026-04-29 01:21:16 +12:00
|
|
|
rawMaterials: hasModuleAccess(session, 'mix_master') && hasModuleAccess(session, 'raw_materials') ? await api.rawMaterials(fetch) : []
|
2026-04-25 22:51:36 +12:00
|
|
|
};
|
|
|
|
|
} catch {
|
|
|
|
|
return {
|
|
|
|
|
rawMaterials: []
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|