fix(01): calendar slot merge in OutputReview for PN/Schwartz badges
GenerateResponse now includes calendar field from backend. OutputReview merges CalendarSlot into PostResult via slot_index, enabling BadgePN, BadgeSchwartz rendering and Retry button. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -10,7 +10,7 @@ from typing import Literal, Optional
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
from backend.schemas.calendar import CalendarSlot
|
||||
from backend.schemas.calendar import CalendarResponse, CalendarSlot
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
@@ -185,3 +185,7 @@ class GenerateResponse(BaseModel):
|
||||
ge=0,
|
||||
description="Numero di post falliti — esclusi dal CSV export",
|
||||
)
|
||||
calendar: Optional[CalendarResponse] = Field(
|
||||
default=None,
|
||||
description="Calendario con gli slot originali — usato dal frontend per badge PN/Schwartz",
|
||||
)
|
||||
|
||||
@@ -198,6 +198,7 @@ class GenerationPipeline:
|
||||
total=status.total,
|
||||
success_count=success_count,
|
||||
failed_count=failed_count,
|
||||
calendar=status.calendar,
|
||||
)
|
||||
|
||||
def generate_single(
|
||||
|
||||
@@ -25,10 +25,15 @@ export function OutputReview() {
|
||||
// Stato locale dei post — viene aggiornato da edit inline e rigenerazione
|
||||
const [localResults, setLocalResults] = useState<PostResult[]>([])
|
||||
|
||||
// Inizializza i risultati quando arrivano dal backend
|
||||
// Inizializza i risultati e merge con CalendarSlot dal calendario
|
||||
useEffect(() => {
|
||||
if (jobData?.results) {
|
||||
setLocalResults(jobData.results)
|
||||
const slots = jobData.calendar?.slots
|
||||
const merged = jobData.results.map((r) => ({
|
||||
...r,
|
||||
slot: slots?.find((s) => s.indice === r.slot_index) ?? r.slot,
|
||||
}))
|
||||
setLocalResults(merged)
|
||||
}
|
||||
}, [jobData])
|
||||
|
||||
|
||||
@@ -103,6 +103,7 @@ export interface GenerateResponse {
|
||||
total: number
|
||||
success_count: number
|
||||
failed_count: number
|
||||
calendar?: CalendarResponse | null
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user