1 00:00:01,110 --> 00:00:08,140 We're now able to save changes made in our edit form so we changed everything over to Jane. 2 00:00:08,190 --> 00:00:13,060 We update the phone number update the shift save changes and we saw those changes reflected over and 3 00:00:13,060 --> 00:00:13,940 firebase. 4 00:00:14,120 --> 00:00:18,750 So that's what we have to do is flip open our action creator and Williger. 5 00:00:18,780 --> 00:00:24,660 We want to say that after an employee has been successfully saved we're going to want to navigate them 6 00:00:24,660 --> 00:00:28,500 back over to our employee list screen. 7 00:00:28,830 --> 00:00:32,870 So we're going to first verify that we've imported our actions object up at the top. 8 00:00:33,100 --> 00:00:34,670 Sure have. 9 00:00:34,880 --> 00:00:37,320 That means that we can come on back down. 10 00:00:38,090 --> 00:00:44,620 I'm going to replace the Cancellara statement here with actions dot employee list. 11 00:00:44,750 --> 00:00:50,180 And again I want to make sure that when I navigate back to the employee list I'm not adding onto the 12 00:00:50,180 --> 00:00:50,660 stack here. 13 00:00:50,660 --> 00:00:53,570 I'm not going forward of you i'm back of you. 14 00:00:53,810 --> 00:00:56,770 So I go back I'm going to reset my whole stack. 15 00:00:56,840 --> 00:01:04,220 We did this once already with that type reset so we can as pass an option of type reset 16 00:01:06,880 --> 00:01:09,380 and then if I load my list up again 17 00:01:16,920 --> 00:01:19,910 let's add it Jane again because Jane is all I have. 18 00:01:20,280 --> 00:01:23,360 So let's make it work on Friday now at least a little bit nicer. 19 00:01:23,430 --> 00:01:27,310 I'll save changes and boom we're back over here now. 20 00:01:27,520 --> 00:01:28,270 Sounds good right. 21 00:01:28,290 --> 00:01:33,930 Well hey wait a minute wait a minute that's a big mistake. 22 00:01:33,930 --> 00:01:40,080 After we edited Jane I clicked on the Add button and Jane's attributes were already in the form. 23 00:01:40,110 --> 00:01:43,240 So remember our form reducer. 24 00:01:43,290 --> 00:01:48,420 It holds all of the forms state and that form state is being used in multiple places now both in the 25 00:01:48,450 --> 00:01:50,910 edit form and the create form. 26 00:01:50,940 --> 00:01:56,880 So the instant that I am done modifying an employee I need to make sure that I clear out all of these 27 00:01:56,880 --> 00:02:02,100 saved attributes on the form and what that really means is I need to reset the properties on my form 28 00:02:02,100 --> 00:02:04,090 reducer. 29 00:02:04,110 --> 00:02:07,130 We handle this once already with the Create case. 30 00:02:07,140 --> 00:02:12,060 So if I scroll up a little bit here is employee create we we're dispatching an action that said employee 31 00:02:12,060 --> 00:02:14,440 create and that let me know hey. 32 00:02:14,610 --> 00:02:15,360 OK. 33 00:02:15,500 --> 00:02:18,430 Time to reset all the attributes inside the form. 34 00:02:18,540 --> 00:02:20,760 So let's do the same thing here as well. 35 00:02:20,790 --> 00:02:25,840 We will dispatch an action of employees save success. 36 00:02:25,890 --> 00:02:32,710 Once we get that action inside of the reducer we can we can reset all the forms attributes. 37 00:02:32,760 --> 00:02:35,480 So first we will make sure that we get dispatch in here. 38 00:02:35,490 --> 00:02:41,040 So here's our dispatch method and then we will dispatch an action after we have successfully saved this 39 00:02:41,040 --> 00:02:41,990 employee. 40 00:02:42,120 --> 00:02:47,290 So we will call that employee save success. 41 00:02:47,420 --> 00:02:49,350 Of course we don't have this type available yet. 42 00:02:49,400 --> 00:02:51,690 So I'm going to scroll up to the top. 43 00:02:51,890 --> 00:02:55,200 We will add it as another type employee. 44 00:02:57,300 --> 00:02:59,980 Saves access. 45 00:03:00,200 --> 00:03:03,580 We have to add it as a type to our types file as well. 46 00:03:03,580 --> 00:03:07,830 So export Konst employees saves excess 47 00:03:12,250 --> 00:03:17,170 and I think you know where this is going we're going to flip over to our douceur the former douceur 48 00:03:17,170 --> 00:03:25,660 that is all grab employees save success and then once I see this 49 00:03:28,840 --> 00:03:36,260 gloire save success I will again return my initial state which is going to reset all the attributes 50 00:03:36,260 --> 00:03:39,350 inside the form just of what we want it. 51 00:03:39,350 --> 00:03:41,810 Now one thing I want to point out to you just a little reminder 52 00:03:44,570 --> 00:03:50,900 if I flip back on my form right now and let's update this again to Thursday excuse me that's when they 53 00:03:50,900 --> 00:03:56,510 create most going to go on Jane again I mean said Jane to Thursday I want to save changes. 54 00:03:56,690 --> 00:04:00,240 No I cook Jane again you'll notice that Jane is now on Thursday. 55 00:04:00,380 --> 00:04:07,460 Just to be really clear what's going on there inside of our employees fetch action creator remember 56 00:04:07,460 --> 00:04:14,150 how we had that on value thing and I'd said any time we update or save a record we're going to automatically 57 00:04:14,150 --> 00:04:15,790 get this event across. 58 00:04:15,830 --> 00:04:19,070 Dispatch grabbed the new employees and load them up. 59 00:04:19,220 --> 00:04:24,110 So that is why we're seeing that instant update for us when we just do the save. 60 00:04:24,110 --> 00:04:24,350 All right. 61 00:04:24,360 --> 00:04:28,490 When we just saved this record right here let's go to Wednesday and I click save changes. 62 00:04:28,730 --> 00:04:35,390 Just changing the record by default doesn't actually change it in our state like nothing actually happens. 63 00:04:35,390 --> 00:04:41,870 Just because I happen to set it here is specifically because we set up a watcher on the value of this 64 00:04:41,870 --> 00:04:44,030 location on this list of employees right here. 65 00:04:44,090 --> 00:04:48,850 It is only because of this right here that we get that updated model back from firebase. 66 00:04:48,890 --> 00:04:53,540 So there's a lot of actions that are being dispatched automatically inside of our application. 67 00:04:53,540 --> 00:04:58,380 We just have to kind of describe what we want to have happen and remarks and firebase take it from there. 68 00:05:00,190 --> 00:05:07,510 I think that we are all set with editing employees now which means we get to move on to our next topic. 69 00:05:07,510 --> 00:05:09,680 We need to be able to delete employees. 70 00:05:09,820 --> 00:05:13,820 We also need to be able to text employees their updated schedule. 71 00:05:13,900 --> 00:05:16,910 So let's start on both of those topics and the next section