1 00:00:00,590 --> 00:00:06,420 In the last section we applied some styling to our Hetter by hooking up materialized CSSA library and 2 00:00:06,450 --> 00:00:12,180 adding in some very special markup to our head or component that followed the documentation for making 3 00:00:12,180 --> 00:00:14,020 a nav bar essentially. 4 00:00:14,220 --> 00:00:17,200 There's just one little thing that I want to point out about the nav bar. 5 00:00:17,220 --> 00:00:22,740 You'll notice that the nav bar really sandwiches up against the side of the screen like that and the 6 00:00:22,740 --> 00:00:26,030 text that we have is really close to the left hand edge as well. 7 00:00:26,310 --> 00:00:29,400 So this is a slightly undocumented feature. 8 00:00:29,490 --> 00:00:34,680 I'm going to say undocumented just because the materialized library doesn't make it super clear but 9 00:00:34,680 --> 00:00:41,060 essentially materialized really requires you to have at least one root component in SA or one root element 10 00:00:41,070 --> 00:00:45,720 I should say inside of your application with a class name of container. 11 00:00:45,720 --> 00:00:50,370 A lot of the different elements and lots of different styling that materialized makes use of assumes 12 00:00:50,370 --> 00:00:54,690 that you have at least one root element with the class of container. 13 00:00:54,690 --> 00:00:55,880 So let's add this thing in. 14 00:00:55,890 --> 00:00:58,830 And I think you'll get a better idea of what I'm talking about. 15 00:00:59,070 --> 00:01:01,060 So I'm going to change over to my code editor. 16 00:01:01,200 --> 00:01:02,550 I'm going to find my app. 17 00:01:02,700 --> 00:01:04,260 Yes file. 18 00:01:04,530 --> 00:01:10,260 And inside the app thought jazz file you find the top level div and I'm going to give it a class name 19 00:01:10,800 --> 00:01:13,090 of container like so. 20 00:01:13,500 --> 00:01:17,910 So again this is something that materialized just kind of assumes that you have somewhere inside of 21 00:01:17,910 --> 00:01:21,700 your application on one of your higher level elements. 22 00:01:21,720 --> 00:01:26,850 So now when we flip back over you'll notice that we have a lot more nice styling or I should say spacing 23 00:01:27,060 --> 00:01:28,710 on the left and right hand sides. 24 00:01:28,860 --> 00:01:33,640 If I start to collapse the screen everything starts to kind of collapse nicely along with it. 25 00:01:33,770 --> 00:01:38,170 If I go back down to a reasonable zoomin level then everything gets even better. 26 00:01:38,420 --> 00:01:38,670 OK. 27 00:01:38,700 --> 00:01:41,180 So much better than what we had before. 28 00:01:41,850 --> 00:01:42,260 OK. 29 00:01:42,270 --> 00:01:44,070 So this is looking pretty good. 30 00:01:44,160 --> 00:01:48,050 Now I want to focus a little bit more on the header itself. 31 00:01:48,270 --> 00:01:53,580 At this point there's really a couple different ways in which it needs to be improved because it's pretty 32 00:01:53,580 --> 00:01:54,360 rough right now. 33 00:01:54,360 --> 00:01:57,930 Yes it looks good but there's not a lot of functionality around it. 34 00:01:57,930 --> 00:02:02,790 So first off the logo over here on the left hand side is not clickable. 35 00:02:02,790 --> 00:02:07,870 I would really expect that if you click on email over here it should take you back to like some route 36 00:02:07,870 --> 00:02:09,990 route inside the application. 37 00:02:09,990 --> 00:02:13,290 In addition the logging in with Google button over here. 38 00:02:13,290 --> 00:02:17,790 It looks like it's clickable But if you click it nothing actually happens. 39 00:02:17,790 --> 00:02:22,830 And then finally the entire goal of everything we're really trying to accomplish right now which is 40 00:02:22,830 --> 00:02:27,410 to change the content inside the header based on whether or not the user is logged in. 41 00:02:27,420 --> 00:02:30,930 Clearly we have not done really anything around that as well. 42 00:02:31,200 --> 00:02:33,220 So a couple of different areas to advance on. 43 00:02:33,390 --> 00:02:38,940 I think that the best place to get started right now is to make sure that the content shows the correct 44 00:02:39,210 --> 00:02:42,750 the header shows the correct content based on whether or not you are logged in. 45 00:02:42,750 --> 00:02:45,430 So essentially we're just going to stay the course here. 46 00:02:45,510 --> 00:02:50,040 We're going to acknowledge yes this stuff should be clickable but we're going to come back and address 47 00:02:50,040 --> 00:02:51,020 those items later. 48 00:02:51,120 --> 00:02:51,780 OK. 49 00:02:52,470 --> 00:02:58,050 So that leads us to how do we figure out if the current user is logged in. 50 00:02:58,050 --> 00:02:58,710 Great question. 51 00:02:58,710 --> 00:03:03,990 How do we figure out if the current user is logged in because that is how we decide what content to 52 00:03:03,990 --> 00:03:05,140 show in the header. 53 00:03:05,550 --> 00:03:10,530 Well I want to remind you of something that we put together on the server side of our application. 54 00:03:10,560 --> 00:03:18,960 A while ago if I go back to my root server directory open up the route's file or something route's directory 55 00:03:19,020 --> 00:03:21,170 and then open up the auth routes file. 56 00:03:21,360 --> 00:03:30,230 You might recall that we put one very little API handler in here called Current User if a current user 57 00:03:30,240 --> 00:03:35,010 or if a user is currently signed into the application of like the person who is making the request here 58 00:03:35,310 --> 00:03:37,100 is signed into the application. 59 00:03:37,170 --> 00:03:42,880 This route will respond back with the model represented the person who has signed it. 60 00:03:42,960 --> 00:03:48,660 And so this route right here is the exact way in which we are going to decide whether or not a user 61 00:03:48,660 --> 00:03:52,860 is signed into the application whenever our application first boots up. 62 00:03:52,860 --> 00:03:58,500 We're going to make a request to this route right here if it responds back with the user model. 63 00:03:58,500 --> 00:04:00,810 That means fantastic we must be logged in. 64 00:04:00,990 --> 00:04:04,010 But if it responds back with like undefined or no. 65 00:04:04,020 --> 00:04:09,910 Or just empty response then that must mean that nobody is actually logged into the application. 66 00:04:09,930 --> 00:04:10,470 OK. 67 00:04:10,770 --> 00:04:12,610 So that's how we're going to figure this out. 68 00:04:13,320 --> 00:04:19,890 So in short we want to make sure that the instant our application starts to boot up we make an API request 69 00:04:19,890 --> 00:04:22,570 to figure out whether or not the user is signed in. 70 00:04:22,710 --> 00:04:24,280 So that's our goal. 71 00:04:24,510 --> 00:04:30,030 Now before we just start kind of like diving in headfirst I want to remind you about exactly how we 72 00:04:30,030 --> 00:04:31,960 handle requesting data. 73 00:04:32,070 --> 00:04:35,450 Fetching data inside or react and redux application. 74 00:04:35,820 --> 00:04:42,780 Traditionally we will set up a react component to make sure that it calls an action creator in this 75 00:04:42,780 --> 00:04:48,630 action creator right here will be responsible for making some type of API request and then once we get 76 00:04:48,630 --> 00:04:52,600 a response back it will return or dispatch in action. 77 00:04:52,890 --> 00:04:58,440 That action will be sent to all of our different reducers of which one is our author reducer and so 78 00:04:58,440 --> 00:05:03,930 that author douceur is going to watch for an action that says hey here is a request that figures out 79 00:05:03,930 --> 00:05:10,200 whether or not the users logged in the reducer will then return some value that specifies whether or 80 00:05:10,200 --> 00:05:16,470 not the user signed in that will update all the state inside of a redux store and that redux store all 81 00:05:16,470 --> 00:05:20,870 the state inside of it will be sent back down to all of our re-act components. 82 00:05:21,480 --> 00:05:28,380 So in short what we really want to do right now is create an action creator that will make a Ajax request 83 00:05:28,740 --> 00:05:37,640 over to this I disclosed it or to go over to this route handler on our server right here. 84 00:05:37,640 --> 00:05:42,650 So this is going to be fantastic because it will be our first exposure to how we really do communication 85 00:05:42,650 --> 00:05:46,230 between the react and server side of our application. 86 00:05:46,550 --> 00:05:48,230 Now this is going to be pretty in-depth. 87 00:05:48,230 --> 00:05:49,580 The first time we go through it. 88 00:05:49,580 --> 00:05:50,890 So let's take a break right now. 89 00:05:50,960 --> 00:05:55,640 We'll come back in the next section and start working on our action creator. 90 00:05:55,640 --> 00:05:57,930 So I'll see you in just a second.