import { defineStore } from 'pinia'
import { useApi } from '../composables/useApi.js'

export const useThumbnailsStore = defineStore('thumbnails', () => {
  const api = useApi()

  // Returns { scanned, enqueued, ok, regenerated } — the API now runs
  // the scan synchronously so the operator gets immediate feedback
  // instead of just a Celery task id with no visible outcome.
  async function triggerBackfill () {
    return await api.post('/api/thumbnails/backfill')
  }

  return { triggerBackfill }
})
