We've got our async action creator working just fine now but it's still missing a lot of that extra
stuff that we need for one.
The action itself is still a string rather than a true conc like we should be using now.
And we also are not starting any spinner creating accounts if one doesn't exist or showing any error
messages.
So in this section we're going to add some more robust handling around this log in user action Creator.
One thing to keep in mind as we work with redux thung is that because we have direct access to the dispatch
method now we can dispatch as many methods or Simi Dispatch as many actions as we would like from a
single action creator.
So even though we are already dispatching logging users access here we can dispatch many others as well.
OK so I think a good place to start is going to be to assign logging users access to an actual Konst
inside of our type's file.
That's a good easy place to start.
So let's do it.
I'm going to open up my type's file which is in my auctions directory and inside if you're going to
create the new Konst export Konst log in user success.
So this actually here is the type I should say is clearly meant to indicate to our inducers Hey something
really could just happen like the user just logged in successfully.
So now that I've got that type of flip back over to my action Kreator file I will import it at the top.
So logging user success and then in my log in user action creator rather than using the string will
use the type itself that costs the variable.
However you want to refer to it fine by me.
And now we can add this to our producer as well.
So I flip over to my order reducer and we can catch this action when it comes across.
So we've got e-mail changed password changed and also logged in users success.
Now that we've got this type in here we can also make use of it inside of our juicer itself.
So now comes the really interesting question.
What are the properties that we want to update when every user successfully logs in.
Well we know that we get that user in there.
Right we get that user model from firebase and we attach it as the payload to the action.
So by default I think a great place to start is going to be to make sure that we reflect the user model
on our user piece of state.
So whenever we successfully log in I'm going to return a new state object.
So I say take all the existing properties on our state object and also include action payload which
is our user.
So now we're introducing the user property here.
Again I'm going to to my initial state object as well just to tell any other engineers who look at this
that hey there is a user property in play somewhere inside of this reducer.
Cool.
So now when a user successfully logs in we will save that user model which has their email and their
I.D. on the state DOT off dot user piece of state.
That's going be really important later on because we are going to make use of the user model early the
user's I.D. and several other locations.
So we'll want to definitely remember that little factoid.
OK.
Let's get to the next section and make sure that we can also handle the creation of user accounts