Skip to content

Instantly share code, notes, and snippets.

@jquinter
Last active September 3, 2020 02:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jquinter/46bbcd03b3efd817677b7de43ec0e457 to your computer and use it in GitHub Desktop.
Save jquinter/46bbcd03b3efd817677b7de43ec0e457 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// - XState (all XState exports)
const antecedentes_ok = (context, event) => {
return event.visto_bueno_antecedentes && event.visto_bueno_antecedentes.length > 0;
};
const fetchMachine = Machine({
id: 'fetch',
initial: 'interesado',
context: {
num_postulaciones: 0
},
states: {
interesado: {
on: {
REGISTRO: 'registrado'
}
},
registrado: {
type: 'parallel',
onDone: 'esperando_validacion',
states: {
ingresando_documentos: {
initial: 'pendiente',
states: {
pendiente: {
on: {
docs_cargados: 'listo'
}
},
listo: {
type: 'final'
}
}
},
completando_formulario: {
initial: 'pendiente',
states: {
pendiente: {
on: {
formulario_completo: 'listo'
}
},
listo: {
type: 'final'
}
}
},
sugiriendo_recomendantes: {
initial: 'pendiente',
states: {
pendiente: {
on: {
recomendacion_lista: 'listo'
}
},
listo: {
type: 'final'
}
}
}
}
},
esperando_validacion: {
on: {
// REVISION_ANTECEDENTES: [{
// target: 'citado_a_entrevista',
// cond: antecedentes_ok
// },{
// target: 'postulando',
// cond: !antecedentes_ok
// }]
APTO: 'citado_a_entrevista',
APTO_CON_RESERVAS: 'citado_a_entrevista_excepcion',
NO_APTO: 'esperando_correcciones'
}
},
esperando_correcciones: {
type: 'parallel',
onDone: 'esperando_validacion',
states: {
ingresando_documentos: {
initial: 'pendiente',
states: {
pendiente: {
on: {
docs_cargados: 'listo'
}
},
listo: {
type: 'final'
}
}
},
completando_formulario: {
initial: 'pendiente',
states: {
pendiente: {
on: {
formulario_completo: 'listo'
}
},
listo: {
type: 'final'
}
}
},
sugiriendo_recomendantes: {
initial: 'pendiente',
states: {
pendiente: {
on: {
recomendacion_lista: 'listo'
}
},
listo: {
type: 'final'
}
}
}
}
},
citado_a_entrevista_excepcion: {
type: 'parallel',
onDone: 'evaluando_en_comite_academico',
states: {
citado_a_entrevista: {
initial: 'pendiente',
states: {
pendiente: {
on: {
APTO: 'listo',
APTO_CON_RESERVAS: 'listo',
NO_APTO: 'listo'
}
},
listo: {
type: 'final'
}
}
},
corrigiendo_antecedentes: {
initial: 'pendiente',
states: {
pendiente: {
on: {
completa: 'listo'
}
},
listo: {
type: 'final'
}
}
}
}
},
desierta: {
type: 'final',
on: {
REPOSTULA: {
target: 'registrado',
actions: assign({
num_postulaciones: (context, event) => context.num_postulaciones + 1
})
}
}
},
citado_a_entrevista: {
on:{
APTO: 'evaluando_en_comite_academico',
APTO_CON_RESERVAS: 'citado_a_segunda_entrevista',
NO_APTO: 'rechazado_en_entrevistas'
}
},
citado_a_segunda_entrevista: {
on:{
APTO: 'evaluando_en_comite_academico',
APTO_CON_RESERVAS: 'rechazado_en_entrevistas',
NO_APTO: 'rechazado_en_entrevistas'
}
},
rechazado_en_entrevistas: {
type: 'final'
},
evaluando_en_comite_academico: {
on: {
APTO: 'postulando_en_escuela_posgrado',
//MARCA INTERNA!
APTO_CON_RESERVAS: 'postulando_en_escuela_posgrado',
NO_APTO: 'rechazado_en_comite_academico'
}
},
rechazado_en_comite_academico: {
type: 'final'
},
postulando_en_escuela_posgrado: {
on: {
ACEPTADO: 'en_espera_aceptacion_alumno',
RECHAZADO: 'rechazado_escuela_posgrado'
}
},
rechazado_escuela_posgrado: {
type: 'final'
},
en_espera_aceptacion_alumno: {
on: {
ACEPTA: 'inicia_programa',
RECHAZA: 'posterga'
}
},
inicia_programa: {
type: 'final'
},
posterga: {
type: 'final'
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment