In the last section we threw in an action creator to delete an employee.
The only thing we have to do with it is make sure that we call it with the idea of the employee that
we want to delete.
We reach out to our firebase data store groud the very particular employee out of all of our Jason data
and remove it.
And after that over to the employee list the last thing you have to do is hook this action creator up
to our employee component.
So back inside of employee at it I will first scroll all the way to the top find my import statement
from my action creators and I will import employee delete.
Then I need to make sure that I bind this action creator to the component itself and scroll all the
way down to the bottom Heres my connect statement.
I will add an employee delete as an action creator to be bound to the component.
So now the very last thing we have to do.
Very last thing whenever a user on the Confirm message or on a confirmed component whenever they press
that yes button whenever they say yes I wanted to leave this user that is going to call on except callback.
So inside of Onix set we need to make sure that we call the employee delete action creator.
It's going to scroll up to on except we will call this stop prop's employee delete.
And remember we have to call the thing with the ID of the employee that we want to delete.
So to get access to that Id We will look out the employee object on this on this component's props.
So say your ID is coming from this dot props dot employee.
Now we can pass this you ID into employee delete and that should be about it.
Do make sure that you pass in as an object.
So I should have you know curly braces you ID and make sure that over interaction creators well are
on on delete action creator receives that as an object ID.
All right I think we're all ready for some testing in here.
Now I took the liberty of adding another employee that we could just test around with as well.
And thats John.
So we just hired John but John is not going be working here for very long.
Here's John I'm going to fire John.
And tonight we're left with just Jane.
Perfect.
So I want to also test really quickly dismissing the motile as well.
So it open Jane back up you know fire the employee of a song say no.
Jenkins stick around and TA-DA the motile just goes back down to the bottom with a nice little animation
as well.
So that's pretty much it.
That's our whole application.
We've covered every type of resource or excuse me every type of operation we could take on this employee
resource so we can create them edit them delete them and of course just read them as well so just show
them up on the screen.
I think the most interesting part of this application was without a doubt making that decision about
how to split out the employee form between employee create an employee at it.
So I want to reiterate there that you know we decided to rip out just the input or excuse me the the
fields themselves.
So we can show it in both the Create an edit version that form.
I think this was ultimately a very good decision because if we ever come back with more custom behavior
for either the create or the added side of the equation we can keep on adding in more and more implementation
without really having to worry about disrupting anything that's going on with the you know create form
or the form or whichever one we're not working on.
The one thing I will say is that this all makes this assumption that the employee form or I should say
the fields that we're showing on here are never going to change.
So there definitely could be a situation in which we say well you know whenever I create an employee
their name is never really going to change.
So I should never let a user change the name of an employee.
That would definitely use case for splitting off two separate versions of the employee form or just
pulling all those fields into each of the edit and create components.
So only when the fields start to change when I start to really you know worry about not be able to make
reuse of this employee form component.
Anyways I thought that was a really interesting part of this application and I hope you've enjoyed putting
this out together.