// « Réactualiser depuis Grav » (spec §7.3) : supprime le snapshot figé ;
// la prochaine génération repartira du contenu live.
import { rm } from 'node:fs/promises'
import { join } from 'node:path'
import { getPortfolio, savePortfolio } from '../../../lib/portfolio-store'

export default defineEventHandler(async (event) => {
  const id = getRouterParam(event, 'id')!
  const portfolio = await getPortfolio(id)
  if (!portfolio) throw createError({ statusCode: 404, statusMessage: 'Portfolio introuvable' })

  portfolio.frozenContent = undefined
  await rm(join(useRuntimeConfig().dataDir, 'frozen', portfolio.id), { recursive: true, force: true })
  await savePortfolio(portfolio)
  return { ok: true }
})
