so let's continue implementing the state management for the login page of our real app we already implemented the forgot email password functionality now let's work on the logging itself the logging state is already defined with everything we need for it which are the error the as logged in and as logging in properties let's then create the actions of our login i'll export a constant called logging that will receive the create action from ngrx and will be identified with the string logging i also need an action for the success case which will be called when the
logging service returns a successful login so i'll export a constant called loggingsuccess that will receive the create action from ngrx and will be identified with this string logging success as we are actually interested in the response of the service this action will receive as parameter the user of the type user this type doesn't exist yet so let's create a new folder called model inside of this folder i'll create a new folder called user and inside of the user folder i'll create a new file called user.ts now i'll export a class called user for now output
as properties of that class the email as a string and the id as a string and now let's import this class on the action file alright i also need an action for the error case which will be called when the logging service returns some error response so i'll export a constant called login fail that will receive the create action from ngrx this action will be identified by the string login fail and we receive as parameter the error of the type any okay our actions are created let's now create the reducers for it let's start with
the tests i'll first tell npm to run my tests alright everything is passing so let's go to the login.store.spec.ts file and create a new test for the logging action i'll create a constant called initial state of the type logging state that will receive the app initial state for the logging now i'll create a constant called new state that will receive the login reducer with the initial state and the login action then i will expect that the new state is equal to the initial state plus the error equal to now plus the s logged in equal
to false plus d is logging in equal to true after i save this our test will fail it fails because i'm not doing anything in the login reducer for this action so on the login action i will execute a function that will receive as parameter the current state and we return an object based on the current state plus the error equal to now plus the logged in equal to false plus the is logging in property as true after i save this our test will pass now let's create a new test for the login success action
i'll just copy and paste the previous test change its name to login success now the initial state will be based on the app initial state for the login plus the is logging in as true the action should be called is the login success it receives a user as parameter so let's create a constant called user instantiate a new user and give it an id now let's just send the user as parameter to the action finally i'll expect that the new state is equal to the initial state plus the is logged in as true and plus
the is logging in as false after i save this our test will fail it fails because you're not doing anything on the reducer for this action so on the login success action i will execute a function that we receive as parameter the current state and we return an object based on the current state plus the is logged in as true plus the is logging in as false after i save this our test will pass now let's create the test for the login fail action i'll copy and paste the success action change its name to login
fail the initial state keeps being the same i will call the login fail action instead of the login success and the login favorite sees as parameter and error so i'll create a constant called error which is an object with some error property now i'll send it as parameter to the login fail action then i expect that the new state is equal to the initial state plus the error plus the is logged in as false plus the is logging in as false after i save this our test will fail it fails because we are not doing
anything on the reducer for this action so on the login fail action i will execute the function that we receive as parameter the current state and the action properties it will return an object based on the current state plus the error which will receive the error inside of the action plus the is logged in as false plus the is logging in as false after i save this our task will pass now let's create the code for the login page itself so we can actually do the state management of the login page by observing the logging
state and reacting to the changes on it something similar to what we did in the previous video for the forgot email password functionality currently when the user clicks on the login button what we do is to just send the user to the home page now what we have to do is to