Add role to summons and weapons detail pages
This commit is contained in:
parent
a8dfe28b07
commit
b71c2c2109
2 changed files with 12 additions and 4 deletions
|
|
@ -2,8 +2,11 @@ import type { PageServerLoad } from './$types'
|
||||||
import { get } from '$lib/api/core'
|
import { get } from '$lib/api/core'
|
||||||
import { error } from '@sveltejs/kit'
|
import { error } from '@sveltejs/kit'
|
||||||
|
|
||||||
export const load: PageServerLoad = async ({ params, fetch }) => {
|
export const load: PageServerLoad = async ({ params, fetch, parent }) => {
|
||||||
try {
|
try {
|
||||||
|
// Get parent data to access role
|
||||||
|
const parentData = await parent()
|
||||||
|
|
||||||
const summon = await get(fetch, `/summons/${params.id}`)
|
const summon = await get(fetch, `/summons/${params.id}`)
|
||||||
|
|
||||||
if (!summon) {
|
if (!summon) {
|
||||||
|
|
@ -11,7 +14,8 @@ export const load: PageServerLoad = async ({ params, fetch }) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
summon
|
summon,
|
||||||
|
role: parentData.role
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Failed to load summon:', err)
|
console.error('Failed to load summon:', err)
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,11 @@ import type { PageServerLoad } from './$types'
|
||||||
import { get } from '$lib/api/core'
|
import { get } from '$lib/api/core'
|
||||||
import { error } from '@sveltejs/kit'
|
import { error } from '@sveltejs/kit'
|
||||||
|
|
||||||
export const load: PageServerLoad = async ({ params, fetch }) => {
|
export const load: PageServerLoad = async ({ params, fetch, parent }) => {
|
||||||
try {
|
try {
|
||||||
|
// Get parent data to access role
|
||||||
|
const parentData = await parent()
|
||||||
|
|
||||||
const weapon = await get(fetch, `/weapons/${params.id}`)
|
const weapon = await get(fetch, `/weapons/${params.id}`)
|
||||||
|
|
||||||
if (!weapon) {
|
if (!weapon) {
|
||||||
|
|
@ -11,7 +14,8 @@ export const load: PageServerLoad = async ({ params, fetch }) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
weapon
|
weapon,
|
||||||
|
role: parentData.role
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Failed to load weapon:', err)
|
console.error('Failed to load weapon:', err)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue