1
+ import chalk from 'chalk' ;
2
+ import readlineSync from 'readline-sync' ;
3
+ import { showData } from "./util" ;
4
+ import { submenuRouteToRecipient } from "./submenu/routeToRecipient" ;
5
+ import { submenuAllocateYield } from "./submenu/allocateYield" ;
6
+
7
+ export const showMenu = async ( ) => {
8
+ console . log ( chalk . magentaBright ( '\nChoose an option:' ) ) ;
9
+ console . log ( chalk . cyanBright ( '1) Refresh' ) ) ;
10
+ console . log ( chalk . cyanBright ( '2) Allocate Yield' ) ) ;
11
+ console . log ( chalk . cyanBright ( '3) Route Funds to Recipient' ) ) ;
12
+ console . log ( chalk . cyanBright ( '4) Update Proportions' ) ) ;
13
+ console . log ( chalk . cyanBright ( '5) Add Recipient' ) ) ;
14
+ console . log ( chalk . cyanBright ( '6) Remove Recipient' ) ) ;
15
+ console . log ( chalk . cyanBright ( '7) Quit' ) ) ;
16
+
17
+ const choice = readlineSync . keyIn ( chalk . yellow ( '\nEnter your choice: ' ) , { limit : '$<1-7>' } ) ;
18
+
19
+ switch ( choice ) {
20
+ case '1' :
21
+ console . log ( chalk . green ( 'Refreshing...' ) ) ;
22
+ await showData ( ) ;
23
+ break ;
24
+ case '2' :
25
+ await submenuAllocateYield ( ) ;
26
+ break ;
27
+ case '3' :
28
+ await submenuRouteToRecipient ( ) ;
29
+ break ;
30
+ case '4' :
31
+ console . log ( chalk . green ( 'Updating proportions...' ) ) ;
32
+ // Call your update proportions function here
33
+ break ;
34
+ case '5' :
35
+ console . log ( chalk . green ( 'Adding recipient...' ) ) ;
36
+ // Call your add recipient function here
37
+ break ;
38
+ case '6' :
39
+ console . log ( chalk . green ( 'Removing recipient...' ) ) ;
40
+ // Call your remove recipient function here
41
+ break ;
42
+ case '7' :
43
+ console . log ( chalk . green ( 'Exiting...' ) ) ;
44
+ process . exit ( 0 ) ;
45
+ break ;
46
+ default :
47
+ console . log ( chalk . red ( 'Invalid choice, please try again.' ) ) ;
48
+ showMenu ( ) ; // Re-display menu for invalid input
49
+ break ;
50
+ }
51
+ showMenu ( ) ;
52
+ } ;
0 commit comments