-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
71 lines (55 loc) · 1.83 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
require('colors');
const { guardarDB, leerDB } = require('./helper/guardarArchivo');
const { inquirerMenu, pausa, leerInput, listadoTareasBorrar, confirmar, mostrarListadoChecklist } = require('./helper/inquirer');
const Tareas = require('./models/tareas');
console.log('\x1Bc');
const main = async () => {
let opt = '';
const tareas = new Tareas();
const tareasDB = leerDB();
if (tareasDB) {
// ESTABLECER LAS TAREAS
tareas.cargarTareasFromArray(tareasDB);
}
//await pausa();
do {
// IMPRIMIR EL MENU
opt = await inquirerMenu();
switch (opt) {
case '1':
// crear opcion
const desc = await leerInput('Descripción');
tareas.crearTarea(desc);
break;
case '2':
tareas.listadoCompleto();
break;
case '3':
// TAREAS COMPLETADAS
tareas.listarPendientesCompletadas();
break;
case '4':
// TAREAS INCOMPLETAS
tareas.listarPendientesCompletadas(false);
break;
case '5':
// COMPLETADO | PENDIENTE
const ids = await mostrarListadoChecklist(tareas.listadoArr);
tareas.toggleCompletadas(ids);
break;
case '6':
const id = await listadoTareasBorrar(tareas.listadoArr);
if (id !== '0') {
const okey = await confirmar("¿Estas seguro?");
if (okey) {
tareas.borrarTarea(id);
console.log("Tarea borrada".red);
}
}
break;
}
guardarDB(tareas.listadoArr);
await pausa();
} while (opt !== '0');
}
main();