+ {({ methods }) => {
+ const idx = Wizard.utils.getIndex(methods.current.id)
+ const isLast = idx >= Wizard.steps.length - 1
+
+ return (
+
+ }
+ footerSlot={
+
+
+
+ {isLast ? (
+
+ ) : (
+
+ )}
+
+
+ }
+ >
+
+ {wizard.errorMessage ? (
+
+
+
+ {wizard.errorMessage}
+
+
+
+ ) : null}
+
+ {idx === 0 && (
+
+
+ setWizard((w) => ({
+ ...w,
+ metodo,
+ formato: null,
+ errorMessage: null,
+ }))
+ }
+ />
+
+ )}
+
+ {idx === 1 && (
+
+ {wizard.metodo === 'IA' ? (
+
+ setWizard((w) => ({
+ ...w,
+ ia: { ...w.ia, showConservacionTooltip: false },
+ }))
+ }
+ onChange={(patch) =>
+ setWizard((w) => ({
+ ...w,
+ ia: {
+ ...w.ia,
+ ...patch,
+ },
+ errorMessage: null,
+ }))
+ }
+ onGenerate={handleBuscarSugerencias}
+ />
+ ) : (
+
+ setWizard((w) => ({
+ ...w,
+ manual: { ...w.manual, draft },
+ errorMessage: null,
+ }))
+ }
+ onAddRef={(ref) =>
+ setWizard((w) => ({
+ ...w,
+ manual: {
+ ...w.manual,
+ refs: [...w.manual.refs, ref],
+ },
+ errorMessage: null,
+ }))
+ }
+ onRemoveRef={(id) =>
+ setWizard((w) => ({
+ ...w,
+ manual: {
+ ...w.manual,
+ refs: w.manual.refs.filter((r) => r.id !== id),
+ },
+ }))
+ }
+ />
+ )}
+
+ )}
+
+ {idx === 2 && (
+
+ {
+ setWizard((w) => ({ ...w, formato, errorMessage: null }))
+ if (formato) {
+ void generateCitasForFormato(formato, wizard.refs)
+ }
+ }}
+ onRegenerate={() => {
+ if (!wizard.formato) return
+ void generateCitasForFormato(
+ wizard.formato,
+ wizard.refs,
+ {
+ force: true,
+ },
+ )
+ }}
+ onChangeTipo={(id, tipo) =>
+ setWizard((w) => ({
+ ...w,
+ refs: w.refs.map((r) =>
+ r.id === id ? { ...r, tipo } : r,
+ ),
+ }))
+ }
+ onChangeCita={(id, value) => {
+ if (!wizard.formato) return
+ setWizard((w) => ({
+ ...w,
+ citaEdits: {
+ ...w.citaEdits,
+ [wizard.formato!]: {
+ ...w.citaEdits[wizard.formato!],
+ [id]: value,
+ },
+ },
+ }))
+ }}
+ />
+
+ )}
+
+ {idx === 3 && (
+
+
+
+ )}
+
+
+ )
+ }}
+
+ )
+}
+
+function MetodoStep({
+ metodo,
+ onChange,
+}: {
+ metodo: MetodoBibliografia
+ onChange: (metodo: MetodoBibliografia) => void
+}) {
+ const isSelected = (m: Exclude