-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
47 lines (32 loc) · 1.09 KB
/
index.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
require('colors');
require("dotenv").config();
const { pause, readInput, showMenu, showChoiceMenu } = require('./helpers/inquirer');
const SearchEngine = require('./models/SearchEngine');
const main = async () => {
let option;
const searchEngine = new SearchEngine();
do {
option = (await showMenu()).option;
switch (option) {
case 1:
const search = await readInput(`Lugar: `);
const places = await searchEngine.searchPlaces(search);
const placeId = await showChoiceMenu(places);
if (placeId !== 0) {
const place = places.find((place) => { return place.id === placeId });
searchEngine.addToSearchHistory(place.name);
await place.printDetails();
}
break;
case 2:
searchEngine.printSearchHistory();
break;
default:
break;
}
await pause();
console.clear();
} while (option !== 0);
}
console.clear();
main();