11from colorama import Fore
22from infrastructure .switchlang import switch
33import infrastructure .state as state
4+ import servies .data_service as svc
45
56
67def run ():
@@ -14,8 +15,9 @@ def run():
1415
1516 with switch (action ) as s :
1617 s .case ('c' , create_account )
17- s .case ('a' , log_into_account )
18- s .case ('l' , list_cages )
18+ s .case ('a' , create_account )
19+ s .case ('l' , log_into_account )
20+ s .case ('y' , list_cages )
1921 s .case ('r' , register_cage )
2022 s .case ('u' , update_availability )
2123 s .case ('v' , view_bookings )
@@ -34,8 +36,9 @@ def run():
3436
3537def show_commands ():
3638 print ('What action would you like to take:' )
37- print ('[C]reate an account ' )
39+ print ('[C]reate an [a]ccount ' )
3840 print ('[L]ogin to your account' )
41+ print ('List [y]our cages' )
3942 print ('[R]egister a cage' )
4043 print ('[U]pdate cage availability' )
4144 print ('[V]iew your bookings' )
@@ -47,10 +50,17 @@ def show_commands():
4750
4851def create_account ():
4952 print (' ****************** REGISTER **************** ' )
50- # TODO: Get name & email
51- # TODO: Create account, set as logged in.
5253
53- print (" -------- NOT IMPLEMENTED -------- " )
54+ name = input ('What is your name? ' )
55+ email = input ('What is your email? ' )
56+
57+ old_account = svc .find_account_by_email (email )
58+ if old_account :
59+ error_msg (f"ERROR: Account with email { email } already exists." )
60+ return
61+
62+ state .active_account = svc .create_account (name , email )
63+ success_msg (f"Created new account with id { state .active_account .id } ." )
5464
5565
5666def log_into_account ():
0 commit comments