We're now able to save changes made in our edit form so we changed everything over to Jane.
We update the phone number update the shift save changes and we saw those changes reflected over and
firebase.
So that's what we have to do is flip open our action creator and Williger.
We want to say that after an employee has been successfully saved we're going to want to navigate them
back over to our employee list screen.
So we're going to first verify that we've imported our actions object up at the top.
Sure have.
That means that we can come on back down.
I'm going to replace the Cancellara statement here with actions dot employee list.
And again I want to make sure that when I navigate back to the employee list I'm not adding onto the
stack here.
I'm not going forward of you i'm back of you.
So I go back I'm going to reset my whole stack.
We did this once already with that type reset so we can as pass an option of type reset
and then if I load my list up again
let's add it Jane again because Jane is all I have.
So let's make it work on Friday now at least a little bit nicer.
I'll save changes and boom we're back over here now.
Sounds good right.
Well hey wait a minute wait a minute that's a big mistake.
After we edited Jane I clicked on the Add button and Jane's attributes were already in the form.
So remember our form reducer.
It holds all of the forms state and that form state is being used in multiple places now both in the
edit form and the create form.
So the instant that I am done modifying an employee I need to make sure that I clear out all of these
saved attributes on the form and what that really means is I need to reset the properties on my form
reducer.
We handle this once already with the Create case.
So if I scroll up a little bit here is employee create we we're dispatching an action that said employee
create and that let me know hey.
OK.
Time to reset all the attributes inside the form.
So let's do the same thing here as well.
We will dispatch an action of employees save success.
Once we get that action inside of the reducer we can we can reset all the forms attributes.
So first we will make sure that we get dispatch in here.
So here's our dispatch method and then we will dispatch an action after we have successfully saved this
employee.
So we will call that employee save success.
Of course we don't have this type available yet.
So I'm going to scroll up to the top.
We will add it as another type employee.
Saves access.
We have to add it as a type to our types file as well.
So export Konst employees saves excess
and I think you know where this is going we're going to flip over to our douceur the former douceur
that is all grab employees save success and then once I see this
gloire save success I will again return my initial state which is going to reset all the attributes
inside the form just of what we want it.
Now one thing I want to point out to you just a little reminder
if I flip back on my form right now and let's update this again to Thursday excuse me that's when they
create most going to go on Jane again I mean said Jane to Thursday I want to save changes.
No I cook Jane again you'll notice that Jane is now on Thursday.
Just to be really clear what's going on there inside of our employees fetch action creator remember
how we had that on value thing and I'd said any time we update or save a record we're going to automatically
get this event across.
Dispatch grabbed the new employees and load them up.
So that is why we're seeing that instant update for us when we just do the save.
All right.
When we just saved this record right here let's go to Wednesday and I click save changes.
Just changing the record by default doesn't actually change it in our state like nothing actually happens.
Just because I happen to set it here is specifically because we set up a watcher on the value of this
location on this list of employees right here.
It is only because of this right here that we get that updated model back from firebase.
So there's a lot of actions that are being dispatched automatically inside of our application.
We just have to kind of describe what we want to have happen and remarks and firebase take it from there.
I think that we are all set with editing employees now which means we get to move on to our next topic.
We need to be able to delete employees.
We also need to be able to text employees their updated schedule.
So let's start on both of those topics and the next section