remove PartyService dependency from team detail server load
This commit is contained in:
parent
6800e50466
commit
6a6f642f3f
1 changed files with 4 additions and 9 deletions
|
|
@ -1,20 +1,16 @@
|
||||||
import type { PageServerLoad } from './$types'
|
import type { PageServerLoad } from './$types'
|
||||||
import { PartyService } from '$lib/services/party.service'
|
import { partyAdapter } from '$lib/api/adapters/party.adapter'
|
||||||
|
|
||||||
export const load: PageServerLoad = async ({ params, fetch, locals }) => {
|
export const load: PageServerLoad = async ({ params, locals }) => {
|
||||||
// Get auth data directly from locals instead of parent()
|
|
||||||
const authUserId = locals.session?.account?.userId
|
const authUserId = locals.session?.account?.userId
|
||||||
|
|
||||||
// Try to fetch party data on the server
|
|
||||||
const partyService = new PartyService()
|
|
||||||
|
|
||||||
let partyFound = false
|
let partyFound = false
|
||||||
let party = null
|
let party = null
|
||||||
let canEdit = false
|
let canEdit = false
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Fetch the party
|
// Fetch the party using adapter
|
||||||
party = await partyService.getByShortcode(params.id)
|
party = await partyAdapter.getByShortcode(params.id)
|
||||||
partyFound = true
|
partyFound = true
|
||||||
|
|
||||||
// Determine if user can edit
|
// Determine if user can edit
|
||||||
|
|
@ -23,7 +19,6 @@ export const load: PageServerLoad = async ({ params, fetch, locals }) => {
|
||||||
// Error is expected for test/invalid IDs
|
// Error is expected for test/invalid IDs
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return party data with explicit serialization
|
|
||||||
return {
|
return {
|
||||||
party: party ? structuredClone(party) : null,
|
party: party ? structuredClone(party) : null,
|
||||||
canEdit: Boolean(canEdit),
|
canEdit: Boolean(canEdit),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue