feat(web): add profile management
Some checks failed
CI / validate (push) Successful in 19m25s
CI / validate (pull_request) Failing after 9m54s

Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
2026-08-20 19:24:50 +05:00
parent fc205c232f
commit 41f4633dca
12 changed files with 687 additions and 15 deletions

View File

@@ -1,4 +1,5 @@
import { requireCampaignAccess, requireStageTwoUser, stageTwoApiError, stageTwoDatabase, stageTwoUuid } from '~/server/utils/stage-two-supabase'
import { visibleProfile, type ProfileRecord } from '~/server/utils/profile'
export default defineEventHandler(async (event) => {
try {
@@ -30,11 +31,12 @@ export default defineEventHandler(async (event) => {
const round = openRounds[0] ?? fallbackRounds[0] ?? null
const userIds = [...new Set(members.map(member => String(member.user_id)))]
const profiles = userIds.length
? await stageTwoDatabase<Array<{ id: string; display_name: string }>>(
`profiles?select=id,display_name&id=in.(${userIds.join(',')})`,
? await stageTwoDatabase<ProfileRecord[]>(
`profiles?select=id,display_name,description,avatar_path,created_at,updated_at&id=in.(${userIds.join(',')})`,
)
: []
const profileById = new Map(profiles.map(profile => [profile.id, profile]))
const supabaseUrl = useRuntimeConfig().supabaseUrl
const profileById = new Map(profiles.map(profile => [profile.id, visibleProfile(profile, supabaseUrl)]))
const visibleMembers = members.map(member => ({ ...member, profile: profileById.get(String(member.user_id)) ?? null }))
const visibleRounds = rounds.slice().reverse()
const visibleRoundIds = visibleRounds.map(item => String(item.id))