All language subtitles for [English (auto-generated)] Build a COMPLETE Fullstack Responsive MERN App with Auth, Likes, Dark Mode _ React, MongoDB, MUI [DownSub.com]

af Afrikaans
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bn Bengali
bs Bosnian
bg Bulgarian
ca Catalan
ceb Cebuano
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
tl Filipino
fi Finnish
fr French
fy Frisian
gl Galician
ka Georgian
de German
el Greek
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
km Khmer
ko Korean
ku Kurdish (Kurmanji)
ky Kyrgyz
lo Lao
la Latin
lv Latvian
lt Lithuanian
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mn Mongolian
my Myanmar (Burmese)
ne Nepali
no Norwegian
ps Pashto
fa Persian
pl Polish
pt Portuguese
pa Punjabi
ro Romanian
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
st Sesotho
sn Shona
sd Sindhi
si Sinhala
sk Slovak
sl Slovenian
so Somali
es Spanish
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
te Telugu
th Thai
tr Turkish
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu
or Odia (Oriya)
rw Kinyarwanda
tk Turkmen
tt Tatar
ug Uyghur
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 00:00:00,000 --> 00:00:04,319 hey guys this is Ed Rowe today we are 2 00:00:04,319 --> 00:00:07,500 going to be building this complete full 3 00:00:07,500 --> 00:00:10,500 stack responsive social media 4 00:00:10,500 --> 00:00:13,920 application using myrn from complete 5 00:00:13,920 --> 00:00:16,740 scratch this social media application 6 00:00:16,740 --> 00:00:19,680 will consist of a register page with 7 00:00:19,680 --> 00:00:21,660 complete validation along with 8 00:00:21,660 --> 00:00:25,439 functionality to upload a user image for 9 00:00:25,439 --> 00:00:28,740 our profile we can register and we can 10 00:00:28,740 --> 00:00:32,279 then use what we registered to sign in 11 00:00:32,279 --> 00:00:35,100 and we can enter our home page and on 12 00:00:35,100 --> 00:00:37,920 our home page we have a very clean 13 00:00:37,920 --> 00:00:40,320 looking website that we can have we have 14 00:00:40,320 --> 00:00:42,059 a number of different widgets we have 15 00:00:42,059 --> 00:00:43,980 the user information everything about 16 00:00:43,980 --> 00:00:46,200 our current user that's signed in we are 17 00:00:46,200 --> 00:00:49,020 able to make posts over here some posts 18 00:00:49,020 --> 00:00:52,379 as well as add an image for this post we 19 00:00:52,379 --> 00:00:54,420 can edit delete and actually make the 20 00:00:54,420 --> 00:00:57,000 post and we can see the post that we 21 00:00:57,000 --> 00:00:59,160 have created and then we can also see 22 00:00:59,160 --> 00:01:02,219 the users news feed of all the posts 23 00:01:02,219 --> 00:01:05,159 that have been created from there then 24 00:01:05,159 --> 00:01:07,799 we can also actually like and dislike 25 00:01:07,799 --> 00:01:10,500 any posts that we want 26 00:01:10,500 --> 00:01:14,040 we can view the comments as well and 27 00:01:14,040 --> 00:01:16,619 from there for each post we can add a 28 00:01:16,619 --> 00:01:18,960 friend if we would like and the friend 29 00:01:18,960 --> 00:01:21,540 list will be updated over here we can 30 00:01:21,540 --> 00:01:24,840 add any amount of friends and we can 31 00:01:24,840 --> 00:01:27,299 remove them if we want to and then from 32 00:01:27,299 --> 00:01:30,540 here we can go to any of the users that 33 00:01:30,540 --> 00:01:32,520 we see over here we can click on their 34 00:01:32,520 --> 00:01:35,280 page and now you can see this person's 35 00:01:35,280 --> 00:01:37,320 friends he doesn't have any friends 36 00:01:37,320 --> 00:01:40,140 sadly then we have the ability for that 37 00:01:40,140 --> 00:01:42,299 person to write a post and then we can 38 00:01:42,299 --> 00:01:45,299 see their user post as well you can see 39 00:01:45,299 --> 00:01:48,119 their likes you can add them as well and 40 00:01:48,119 --> 00:01:50,520 go back you can go to this page and then 41 00:01:50,520 --> 00:01:53,159 from here we can change from light mode 42 00:01:53,159 --> 00:01:56,640 to dark mode and vice versa and more 43 00:01:56,640 --> 00:01:58,500 importantly everything is going to be 44 00:01:58,500 --> 00:02:01,200 completely fully responsive so we can 45 00:02:01,200 --> 00:02:03,899 see the exact same website on smaller 46 00:02:03,899 --> 00:02:06,899 screens with modified adjustments for 47 00:02:06,899 --> 00:02:09,479 everything most importantly everything 48 00:02:09,479 --> 00:02:12,239 on this page all the information that 49 00:02:12,239 --> 00:02:15,000 you see on this page is all coming from 50 00:02:15,000 --> 00:02:18,239 backend apis that we create from scratch 51 00:02:18,239 --> 00:02:20,459 which are retrieving information from 52 00:02:20,459 --> 00:02:22,680 the databases that we also created 53 00:02:22,680 --> 00:02:26,280 so everything from API calls for the 54 00:02:26,280 --> 00:02:28,440 information that we set the user 55 00:02:28,440 --> 00:02:30,780 interface that we create everything is 56 00:02:30,780 --> 00:02:34,020 coming from data that we have added and 57 00:02:34,020 --> 00:02:36,900 completely configured the technologies 58 00:02:36,900 --> 00:02:38,940 that we'll be using will include the 59 00:02:38,940 --> 00:02:41,220 mernstack which is represented by 60 00:02:41,220 --> 00:02:45,840 mongodatabase express.js react and node 61 00:02:45,840 --> 00:02:47,760 and more specifically for the front end 62 00:02:47,760 --> 00:02:49,620 we will be using react as our framework 63 00:02:49,620 --> 00:02:52,739 react rather for navigation formic and 64 00:02:52,739 --> 00:02:55,560 yup for form and form validation Redux 65 00:02:55,560 --> 00:02:57,720 toolkit for our state management with 66 00:02:57,720 --> 00:03:00,260 Redux persist to store in local storage 67 00:03:00,260 --> 00:03:03,720 and react drop zone for image uploads 68 00:03:03,720 --> 00:03:05,700 for the back end we are going to be 69 00:03:05,700 --> 00:03:08,760 using node.js as our runtime express.js 70 00:03:08,760 --> 00:03:11,099 as our backend framework Mongoose for 71 00:03:11,099 --> 00:03:13,620 managing our database Json web 72 00:03:13,620 --> 00:03:16,379 token for authentication and multer for 73 00:03:16,379 --> 00:03:19,080 file uploading now this tutorial is the 74 00:03:19,080 --> 00:03:21,300 complete package with everything built 75 00:03:21,300 --> 00:03:24,239 but even with all this this tutorial is 76 00:03:24,239 --> 00:03:26,580 dedicated for both beginners who are 77 00:03:26,580 --> 00:03:28,140 looking to practice their project 78 00:03:28,140 --> 00:03:30,480 building skills and placing this project 79 00:03:30,480 --> 00:03:33,540 into your portfolio but also dedicated 80 00:03:33,540 --> 00:03:35,580 for experienced developers who are 81 00:03:35,580 --> 00:03:36,959 looking into building and learning about 82 00:03:36,959 --> 00:03:39,000 best practices and various different 83 00:03:39,000 --> 00:03:41,700 Tech that may be used at your job or 84 00:03:41,700 --> 00:03:44,159 provided for your clients as a tech lead 85 00:03:44,159 --> 00:03:46,319 in the industry I will be create trading 86 00:03:46,319 --> 00:03:48,360 from complete scratch explaining 87 00:03:48,360 --> 00:03:50,700 everything as I go while using best 88 00:03:50,700 --> 00:03:52,980 practices and Enterprise level packages 89 00:03:52,980 --> 00:03:55,560 so you can get up to speed and familiar 90 00:03:55,560 --> 00:03:59,099 with industry standards lastly like all 91 00:03:59,099 --> 00:04:01,319 my other applications this website uses 92 00:04:01,319 --> 00:04:03,780 free images sourced from unsplashed 93 00:04:03,780 --> 00:04:05,879 meaning it is all free to use and the 94 00:04:05,879 --> 00:04:08,220 website is completely designed all by me 95 00:04:08,220 --> 00:04:09,720 so you don't have to worry about any 96 00:04:09,720 --> 00:04:12,720 copyright issues be free to use parts or 97 00:04:12,720 --> 00:04:15,180 even the whole project for your 98 00:04:15,180 --> 00:04:17,760 portfolio hope you enjoy let's get 99 00:04:17,760 --> 00:04:19,440 started so to start building our backend 100 00:04:19,440 --> 00:04:22,560 we are going to be using node.js so 101 00:04:22,560 --> 00:04:25,259 nodejs is a JavaScript runtime built on 102 00:04:25,259 --> 00:04:27,479 Chrome's V8 JavaScript engine which 103 00:04:27,479 --> 00:04:30,600 basically means we can use JavaScript in 104 00:04:30,600 --> 00:04:32,880 the laptop or computer that you are 105 00:04:32,880 --> 00:04:35,280 using I have node installed but feel 106 00:04:35,280 --> 00:04:36,960 free to go to the description link below 107 00:04:36,960 --> 00:04:38,639 follow these instructions to install 108 00:04:38,639 --> 00:04:41,460 node on your machine and then you can go 109 00:04:41,460 --> 00:04:44,040 to npx package we're going to install 110 00:04:44,040 --> 00:04:46,380 this particular package so we can run 111 00:04:46,380 --> 00:04:49,680 npx commands so you can run npm I MPX 112 00:04:49,680 --> 00:04:52,080 and after that I want you to go to 113 00:04:52,080 --> 00:04:54,300 visual studio code and you can install 114 00:04:54,300 --> 00:04:56,880 this particular text editor but you can 115 00:04:56,880 --> 00:04:59,639 install whatever text editor you want so 116 00:04:59,639 --> 00:05:02,340 I've already done these three steps just 117 00:05:02,340 --> 00:05:03,780 make sure you have these things 118 00:05:03,780 --> 00:05:06,360 installed that I'm going to be in vs 119 00:05:06,360 --> 00:05:08,280 code I'm going to open up the terminal 120 00:05:08,280 --> 00:05:10,800 and I'm going to run a few commands the 121 00:05:10,800 --> 00:05:13,139 first one is I'm going to 122 00:05:13,139 --> 00:05:14,780 run 123 00:05:14,780 --> 00:05:18,900 mkdir server so we're creating a file 124 00:05:18,900 --> 00:05:20,940 called server or a folder called server 125 00:05:20,940 --> 00:05:24,360 and I'm going to do CD server so we go 126 00:05:24,360 --> 00:05:27,900 into that particular folder and here I'm 127 00:05:27,900 --> 00:05:31,979 going to run some npm commands so npmi-g 128 00:05:31,979 --> 00:05:33,900 node mod 129 00:05:33,900 --> 00:05:35,759 I'm going to install this so what we're 130 00:05:35,759 --> 00:05:37,460 doing is we're installing node men 131 00:05:37,460 --> 00:05:40,199 globally so we have access to installing 132 00:05:40,199 --> 00:05:42,780 or running our node 133 00:05:42,780 --> 00:05:44,759 through a live service so it refreshes 134 00:05:44,759 --> 00:05:47,340 every time we save 135 00:05:47,340 --> 00:05:48,960 and then we're also going to run a lot 136 00:05:48,960 --> 00:05:51,300 of different packages in this folder so 137 00:05:51,300 --> 00:05:53,460 we're going to run npmi 138 00:05:53,460 --> 00:05:55,500 Express 139 00:05:55,500 --> 00:05:57,360 for our library 140 00:05:57,360 --> 00:06:01,220 body parser to process the request body 141 00:06:01,220 --> 00:06:06,000 be Crypt or password encryption 142 00:06:06,000 --> 00:06:09,240 course for cross-origin requests 143 00:06:09,240 --> 00:06:12,900 dot EnV for environment variables 144 00:06:12,900 --> 00:06:15,300 grid FS Dash 145 00:06:15,300 --> 00:06:17,280 let me spell that correctly create FS 146 00:06:17,280 --> 00:06:18,900 stream 147 00:06:18,900 --> 00:06:21,419 for file upload 148 00:06:21,419 --> 00:06:25,740 as well as multir and multer grid 149 00:06:25,740 --> 00:06:29,160 FS storage so we can upload our files 150 00:06:29,160 --> 00:06:30,840 locally and then we're going to have 151 00:06:30,840 --> 00:06:34,080 helmet Force request safety 152 00:06:34,080 --> 00:06:36,840 Morgan for logging 153 00:06:36,840 --> 00:06:41,699 Json web token for authentication and 154 00:06:41,699 --> 00:06:45,539 Mongoose for mongodb access 155 00:06:45,539 --> 00:06:47,039 after you have that make sure you type 156 00:06:47,039 --> 00:06:48,479 this correctly and we're going to be 157 00:06:48,479 --> 00:06:50,039 installing all those packages and we're 158 00:06:50,039 --> 00:06:52,740 going to be waiting for that to finish 159 00:06:52,740 --> 00:06:55,620 packages have installed I'm going to run 160 00:06:55,620 --> 00:06:57,900 some one more command it's going to be 161 00:06:57,900 --> 00:07:00,120 npm and knit Dash 162 00:07:00,120 --> 00:07:02,340 why 163 00:07:02,340 --> 00:07:05,100 and once we have that that will set up 164 00:07:05,100 --> 00:07:07,620 our package Json in this folder and if 165 00:07:07,620 --> 00:07:09,479 you open up your folder directory you're 166 00:07:09,479 --> 00:07:11,580 going to see package Json you're going 167 00:07:11,580 --> 00:07:14,160 to see node modules in here 168 00:07:14,160 --> 00:07:16,380 now don't worry about this vs code 169 00:07:16,380 --> 00:07:18,360 folder this is my own separate 170 00:07:18,360 --> 00:07:20,759 preference settings that I added but you 171 00:07:20,759 --> 00:07:23,280 can just ignore this 172 00:07:23,280 --> 00:07:26,940 and so in our package Json file I'm 173 00:07:26,940 --> 00:07:30,240 going to add one line of code so under 174 00:07:30,240 --> 00:07:32,099 main actually it doesn't really matter 175 00:07:32,099 --> 00:07:33,780 just as long as it's a property you're 176 00:07:33,780 --> 00:07:35,160 going to write type 177 00:07:35,160 --> 00:07:37,680 colon module 178 00:07:37,680 --> 00:07:40,620 so this is so we can use 179 00:07:40,620 --> 00:07:43,440 things like import statements instead of 180 00:07:43,440 --> 00:07:45,000 require statements 181 00:07:45,000 --> 00:07:47,039 it's your preference I'm just going to 182 00:07:47,039 --> 00:07:49,620 have that I'm going to do a new file add 183 00:07:49,620 --> 00:07:52,800 an index.js 184 00:07:52,979 --> 00:07:56,759 and inside our index.js 185 00:07:56,759 --> 00:07:58,380 actually let me close the terminal so we 186 00:07:58,380 --> 00:07:59,460 have more space 187 00:07:59,460 --> 00:08:01,380 we're going to run area we're going to 188 00:08:01,380 --> 00:08:03,539 add a lot of import statements so that 189 00:08:03,539 --> 00:08:05,520 we can install our packages so I'm going 190 00:08:05,520 --> 00:08:08,220 to import Express from 191 00:08:08,220 --> 00:08:13,259 Express like so import body parser from 192 00:08:13,259 --> 00:08:15,000 body parser 193 00:08:15,000 --> 00:08:18,900 import Mongoose and as you can see 194 00:08:18,900 --> 00:08:21,599 your intellisense will tell you what you 195 00:08:21,599 --> 00:08:23,940 can import and when you have this option 196 00:08:23,940 --> 00:08:26,280 you should just click on it or hit enter 197 00:08:26,280 --> 00:08:28,379 and it automatically types it for you 198 00:08:28,379 --> 00:08:30,000 it's very convenient so I highly 199 00:08:30,000 --> 00:08:31,740 recommend you use it it also prevents 200 00:08:31,740 --> 00:08:33,479 bugs because you won't be able to 201 00:08:33,479 --> 00:08:35,399 mistype it it'll automatically do it for 202 00:08:35,399 --> 00:08:37,979 you to the proper package that comes in 203 00:08:37,979 --> 00:08:39,659 so cores 204 00:08:39,659 --> 00:08:42,899 from cores in this case 205 00:08:42,899 --> 00:08:44,760 the intellisense wasn't showing so 206 00:08:44,760 --> 00:08:47,399 import dot EnV 207 00:08:47,399 --> 00:08:50,700 from dot EnV 208 00:08:50,700 --> 00:08:53,100 import motor 209 00:08:53,100 --> 00:08:55,560 that one popped up 210 00:08:55,560 --> 00:08:57,959 and then import helmet 211 00:08:57,959 --> 00:08:59,820 from helmet 212 00:08:59,820 --> 00:09:03,720 import Morgan from Morgan 213 00:09:03,720 --> 00:09:05,519 and 214 00:09:05,519 --> 00:09:07,440 a few native packages I'm going to 215 00:09:07,440 --> 00:09:10,260 import which is import path 216 00:09:10,260 --> 00:09:11,760 from 217 00:09:11,760 --> 00:09:15,240 path so this comes with node already so 218 00:09:15,240 --> 00:09:16,860 you don't need we didn't have to install 219 00:09:16,860 --> 00:09:18,480 this 220 00:09:18,480 --> 00:09:21,839 and I'm going to import file URL to path 221 00:09:21,839 --> 00:09:23,760 from URL so this will 222 00:09:23,760 --> 00:09:26,459 these two will allow us to properly set 223 00:09:26,459 --> 00:09:28,980 the paths when we 224 00:09:28,980 --> 00:09:33,800 configure directories later on 225 00:09:34,440 --> 00:09:36,000 all right and then from here I'm going 226 00:09:36,000 --> 00:09:37,500 to create a comment and I'm going to say 227 00:09:37,500 --> 00:09:40,019 configuration so this will include all 228 00:09:40,019 --> 00:09:42,060 the middleware configurations as well as 229 00:09:42,060 --> 00:09:44,519 different package configurations so 230 00:09:44,519 --> 00:09:46,500 middleware is basically something that 231 00:09:46,500 --> 00:09:48,300 runs in between 232 00:09:48,300 --> 00:09:51,240 different requests basically 233 00:09:51,240 --> 00:09:53,459 little like basically functions that run 234 00:09:53,459 --> 00:09:56,459 in between different things 235 00:09:56,459 --> 00:09:58,440 it's just a fancy term 236 00:09:58,440 --> 00:09:59,820 and then from here we're going to do 237 00:09:59,820 --> 00:10:04,140 const file name equals file URL to path 238 00:10:04,140 --> 00:10:07,140 and we're going to do import.meta dot 239 00:10:07,140 --> 00:10:08,040 URL 240 00:10:08,040 --> 00:10:09,600 so this 241 00:10:09,600 --> 00:10:13,080 configuration is so we can grab the file 242 00:10:13,080 --> 00:10:14,399 URL 243 00:10:14,399 --> 00:10:17,399 and it's specifically when you use 244 00:10:17,399 --> 00:10:19,440 um the modules 245 00:10:19,440 --> 00:10:21,300 so for example when we did this module 246 00:10:21,300 --> 00:10:24,360 we actually need to use these 247 00:10:24,360 --> 00:10:27,660 this configuration so we grab we can use 248 00:10:27,660 --> 00:10:29,700 directory name which is the next name 249 00:10:29,700 --> 00:10:33,420 we're going to create const their name 250 00:10:33,420 --> 00:10:36,600 equals path dot their name 251 00:10:36,600 --> 00:10:39,300 under underscore file name 252 00:10:39,300 --> 00:10:41,940 so this is only when you use the type 253 00:10:41,940 --> 00:10:44,459 modules 254 00:10:44,459 --> 00:10:47,700 next we're going to Dot enp.config 255 00:10:47,700 --> 00:10:49,440 and we're going to invoke that so we can 256 00:10:49,440 --> 00:10:51,420 use dot EMV files 257 00:10:51,420 --> 00:10:53,459 then we're going to do const app is 258 00:10:53,459 --> 00:10:55,019 equal to express 259 00:10:55,019 --> 00:10:58,140 so we invoke our express application so 260 00:10:58,140 --> 00:11:00,959 we can use our middleware so we're going 261 00:11:00,959 --> 00:11:03,860 to app.use 262 00:11:05,779 --> 00:11:07,560 express.json 263 00:11:07,560 --> 00:11:09,660 and invoke that 264 00:11:09,660 --> 00:11:11,700 and then app.use 265 00:11:11,700 --> 00:11:13,500 helmet 266 00:11:13,500 --> 00:11:16,100 and invoke that 267 00:11:16,100 --> 00:11:19,320 app.use helmet 268 00:11:19,320 --> 00:11:21,540 cross 269 00:11:21,540 --> 00:11:26,040 origin resource policy 270 00:11:26,040 --> 00:11:29,360 and I'm going to put the policy 271 00:11:29,820 --> 00:11:33,480 of cross origin 272 00:11:33,480 --> 00:11:35,880 like so 273 00:11:35,880 --> 00:11:38,240 and then I'm going to do app.use Morgan 274 00:11:38,240 --> 00:11:41,959 and passing common 275 00:11:43,860 --> 00:11:45,360 app.use 276 00:11:45,360 --> 00:11:47,160 body parser 277 00:11:47,160 --> 00:11:51,120 Json and we're going to have a limit of 278 00:11:51,120 --> 00:11:54,060 30 megabyte so we don't have any issues 279 00:11:54,060 --> 00:11:56,040 and we're going to do extended 280 00:11:56,040 --> 00:11:59,480 colon Troop 281 00:11:59,760 --> 00:12:02,220 and then we're going to do app.use body 282 00:12:02,220 --> 00:12:04,920 parser.url 283 00:12:04,920 --> 00:12:08,579 encoded I'm going to set a limit 284 00:12:08,579 --> 00:12:10,380 of 30 285 00:12:10,380 --> 00:12:13,320 megabytes as well 286 00:12:13,320 --> 00:12:15,120 extended 287 00:12:15,120 --> 00:12:16,740 golden true 288 00:12:16,740 --> 00:12:18,839 a lot of these settings are on the 289 00:12:18,839 --> 00:12:20,700 website so 290 00:12:20,700 --> 00:12:22,920 you can find all these packages and 291 00:12:22,920 --> 00:12:24,540 their separate GitHub repo and you can 292 00:12:24,540 --> 00:12:26,220 see what a lot of these configurations 293 00:12:26,220 --> 00:12:27,720 kind of do 294 00:12:27,720 --> 00:12:30,959 the next thing is going to be app.use of 295 00:12:30,959 --> 00:12:32,100 course 296 00:12:32,100 --> 00:12:34,140 so this will invoke our cross origin 297 00:12:34,140 --> 00:12:36,420 resource sharing policies 298 00:12:36,420 --> 00:12:39,120 and finally we're going to do app.use 299 00:12:39,120 --> 00:12:42,300 slash assets 300 00:12:42,300 --> 00:12:45,300 express.static 301 00:12:45,420 --> 00:12:48,060 path dot join 302 00:12:48,060 --> 00:12:51,500 underscore underscore 303 00:12:51,660 --> 00:12:53,519 their name 304 00:12:53,519 --> 00:12:55,440 and in here 305 00:12:55,440 --> 00:12:58,560 I'm going to comma and set this 306 00:12:58,560 --> 00:13:00,959 as public 307 00:13:00,959 --> 00:13:03,060 slash assets 308 00:13:03,060 --> 00:13:06,180 and I close these parentheses like this 309 00:13:06,180 --> 00:13:08,519 so what here what this is right here is 310 00:13:08,519 --> 00:13:11,940 doing is going to set the directory of 311 00:13:11,940 --> 00:13:14,820 where we keep our Assets in in our case 312 00:13:14,820 --> 00:13:16,980 it'll be the images that we store so 313 00:13:16,980 --> 00:13:19,680 we're going to store this locally in a 314 00:13:19,680 --> 00:13:21,480 real live production app we would want 315 00:13:21,480 --> 00:13:24,420 to store it in an actual storage file 316 00:13:24,420 --> 00:13:27,959 directory or a storage a cloud storage 317 00:13:27,959 --> 00:13:31,200 like S3 but in this case we're going to 318 00:13:31,200 --> 00:13:33,000 want to keep things simple because this 319 00:13:33,000 --> 00:13:35,700 is going to be a long course we want to 320 00:13:35,700 --> 00:13:38,100 make sure we store this locally and 321 00:13:38,100 --> 00:13:40,139 that'll help simplify a lot of the 322 00:13:40,139 --> 00:13:42,660 things that will happen 323 00:13:42,660 --> 00:13:44,940 and so next thing is we're going to set 324 00:13:44,940 --> 00:13:47,779 up the file storage 325 00:13:49,139 --> 00:13:51,120 configurations as well so we're going to 326 00:13:51,120 --> 00:13:54,120 do const storage equals malter dot disk 327 00:13:54,120 --> 00:13:55,800 storage 328 00:13:55,800 --> 00:13:58,620 and we're going to set the destination 329 00:13:58,620 --> 00:14:00,120 and we're going to set that as a 330 00:14:00,120 --> 00:14:01,139 function 331 00:14:01,139 --> 00:14:05,820 Rec file CB or the params 332 00:14:05,820 --> 00:14:09,180 and all we have to do is pass CB no 333 00:14:09,180 --> 00:14:13,800 comma public slash assets 334 00:14:13,800 --> 00:14:17,000 colon like this 335 00:14:17,100 --> 00:14:19,680 and then we're going to set file name 336 00:14:19,680 --> 00:14:21,180 function 337 00:14:21,180 --> 00:14:22,500 wreck 338 00:14:22,500 --> 00:14:23,579 file 339 00:14:23,579 --> 00:14:25,440 CB like so 340 00:14:25,440 --> 00:14:29,639 CB null file dot original 341 00:14:29,639 --> 00:14:32,120 name 342 00:14:32,519 --> 00:14:34,620 so a lot of these configurations are 343 00:14:34,620 --> 00:14:37,980 coming from the package instructions so 344 00:14:37,980 --> 00:14:40,260 basically I got all of this information 345 00:14:40,260 --> 00:14:42,660 from 346 00:14:42,660 --> 00:14:45,959 the GitHub repo of malter 347 00:14:45,959 --> 00:14:48,600 so this is how you can save your files 348 00:14:48,600 --> 00:14:51,480 so anytime someone uploads a file onto 349 00:14:51,480 --> 00:14:53,399 your website then it's going to say 350 00:14:53,399 --> 00:14:55,740 destination it's going to be saved into 351 00:14:55,740 --> 00:14:58,880 this particular folder 352 00:14:59,100 --> 00:15:00,300 and then from here we're going to say 353 00:15:00,300 --> 00:15:04,260 const upload is equal to multi 354 00:15:04,260 --> 00:15:07,260 curly braces storage so that will help 355 00:15:07,260 --> 00:15:07,980 us 356 00:15:07,980 --> 00:15:10,800 save it and anytime we need to upload a 357 00:15:10,800 --> 00:15:13,019 file we're going to be using this 358 00:15:13,019 --> 00:15:14,940 variable 359 00:15:14,940 --> 00:15:16,139 and from here we're going to actually 360 00:15:16,139 --> 00:15:18,240 set up our Monger database 361 00:15:18,240 --> 00:15:20,279 so we're going to go to mongodb.com 362 00:15:20,279 --> 00:15:22,260 which is in the link in the description 363 00:15:22,260 --> 00:15:24,600 below and we're going to hit start free 364 00:15:24,600 --> 00:15:27,240 to set up our account and we're going to 365 00:15:27,240 --> 00:15:28,500 be signing this up 366 00:15:28,500 --> 00:15:30,480 and once you sign up I'm going to hit 367 00:15:30,480 --> 00:15:32,940 create your Atlas account 368 00:15:32,940 --> 00:15:35,040 after it loads it's going to ask you to 369 00:15:35,040 --> 00:15:37,079 send a verification email 370 00:15:37,079 --> 00:15:39,839 and already set up my email and verified 371 00:15:39,839 --> 00:15:42,360 it so I'm going to hit continue 372 00:15:42,360 --> 00:15:44,220 just going to fill this out 373 00:15:44,220 --> 00:15:46,800 it doesn't really matter 374 00:15:46,800 --> 00:15:48,360 other 375 00:15:48,360 --> 00:15:51,019 test 376 00:15:52,199 --> 00:15:54,300 for language JavaScript we're going to 377 00:15:54,300 --> 00:15:55,800 hit finish 378 00:15:55,800 --> 00:15:58,320 and we're going to hit free so we're 379 00:15:58,320 --> 00:15:59,940 going to create a free 380 00:15:59,940 --> 00:16:02,220 database cluster we're going to go down 381 00:16:02,220 --> 00:16:03,959 you're going to choose the one that's 382 00:16:03,959 --> 00:16:05,820 very close to you I'm going to choose 383 00:16:05,820 --> 00:16:06,959 Oregon 384 00:16:06,959 --> 00:16:08,820 go down here 385 00:16:08,820 --> 00:16:11,880 everything should be left to default 386 00:16:11,880 --> 00:16:13,680 after that 387 00:16:13,680 --> 00:16:16,740 we're going to hit create cluster 388 00:16:16,740 --> 00:16:19,880 and this all should be free 389 00:16:19,880 --> 00:16:21,720 all right and then from here you're 390 00:16:21,720 --> 00:16:23,160 going to see this security quick start 391 00:16:23,160 --> 00:16:24,360 so we're going to fill this out real 392 00:16:24,360 --> 00:16:27,779 quick so we're going to say dummy user 393 00:16:27,779 --> 00:16:31,199 dummy user123 394 00:16:31,199 --> 00:16:33,899 I'm going to create the user 395 00:16:33,899 --> 00:16:35,820 and then from here I'm going to hit my 396 00:16:35,820 --> 00:16:37,680 local environment and I'm just going to 397 00:16:37,680 --> 00:16:40,380 hit add my current IP address what this 398 00:16:40,380 --> 00:16:42,120 will allow you to do is be able to 399 00:16:42,120 --> 00:16:44,399 connect to the database from your IP 400 00:16:44,399 --> 00:16:46,860 address so later on you can change these 401 00:16:46,860 --> 00:16:48,360 settings you can make it everything 402 00:16:48,360 --> 00:16:50,940 different if you want 403 00:16:50,940 --> 00:16:53,399 and go to database 404 00:16:53,399 --> 00:16:55,440 close this 405 00:16:55,440 --> 00:16:58,560 let's close it so now you can go in you 406 00:16:58,560 --> 00:17:00,300 can see that you have browse collections 407 00:17:00,300 --> 00:17:02,759 you can see that this will be the 408 00:17:02,759 --> 00:17:05,339 location of where you have your database 409 00:17:05,339 --> 00:17:07,679 and your information on those databases 410 00:17:07,679 --> 00:17:10,339 and if you wanted to change your network 411 00:17:10,339 --> 00:17:13,740 access so is over here database access 412 00:17:13,740 --> 00:17:16,199 as well this is for the user so you can 413 00:17:16,199 --> 00:17:18,119 set whatever you want in these two 414 00:17:18,119 --> 00:17:20,520 settings but we've already set it up so 415 00:17:20,520 --> 00:17:22,679 we're pretty much good to go 416 00:17:22,679 --> 00:17:25,859 and from here I'm going to go to connect 417 00:17:25,859 --> 00:17:27,660 I'm going to hit connect your 418 00:17:27,660 --> 00:17:29,040 application 419 00:17:29,040 --> 00:17:31,559 and I'm going to go in I'm going to copy 420 00:17:31,559 --> 00:17:32,760 this guy 421 00:17:32,760 --> 00:17:34,799 right here 422 00:17:34,799 --> 00:17:38,160 and I'm going to create a DOT EnV file 423 00:17:38,160 --> 00:17:41,880 in our server folder dot EnV 424 00:17:41,880 --> 00:17:45,240 and I'm going to write underscore 425 00:17:45,240 --> 00:17:47,900 URL 426 00:17:48,660 --> 00:17:50,580 equals 427 00:17:50,580 --> 00:17:52,679 in quotation we're going to put 428 00:17:52,679 --> 00:17:55,080 everything that we have over here 429 00:17:55,080 --> 00:17:57,720 and we do have to add our password so 430 00:17:57,720 --> 00:18:00,240 I'm going to be doing that off screen 431 00:18:00,240 --> 00:18:02,460 have added the password to the URL 432 00:18:02,460 --> 00:18:07,320 I'm going to add Port equals 3001. 433 00:18:07,320 --> 00:18:08,640 we're going to have the front end 434 00:18:08,640 --> 00:18:11,460 running on Port 3000 and the backend 435 00:18:11,460 --> 00:18:14,400 running on Port 3001 that's what this is 436 00:18:14,400 --> 00:18:16,440 for we're going to save that we're going 437 00:18:16,440 --> 00:18:17,700 to close this 438 00:18:17,700 --> 00:18:20,520 I'm going to open this up 439 00:18:20,520 --> 00:18:22,380 and we're going to now be setting our 440 00:18:22,380 --> 00:18:23,880 mongoose 441 00:18:23,880 --> 00:18:25,980 so from here I'm going to create another 442 00:18:25,980 --> 00:18:28,919 comment I'm going to say mongoose 443 00:18:28,919 --> 00:18:31,380 setup 444 00:18:31,380 --> 00:18:34,440 and I'm going to say const Port is equal 445 00:18:34,440 --> 00:18:36,080 to 446 00:18:36,080 --> 00:18:39,960 process.env dot port 447 00:18:39,960 --> 00:18:41,520 and if it doesn't work we're going to 448 00:18:41,520 --> 00:18:45,960 say the port should go to 601. 449 00:18:45,960 --> 00:18:47,940 so this is a backup just in case if this 450 00:18:47,940 --> 00:18:49,320 port doesn't work for some reason we're 451 00:18:49,320 --> 00:18:50,640 going to have that 452 00:18:50,640 --> 00:18:53,280 and then we're going to do mongoose 453 00:18:53,280 --> 00:18:55,200 dot connect 454 00:18:55,200 --> 00:18:57,299 and now what we're doing is we're going 455 00:18:57,299 --> 00:18:59,760 to connect to 456 00:18:59,760 --> 00:19:03,179 the actual database from the node server 457 00:19:03,179 --> 00:19:05,820 and we're going to use 458 00:19:05,820 --> 00:19:09,419 our URL that we just created 459 00:19:09,419 --> 00:19:12,840 and we're going to pass and use new you 460 00:19:12,840 --> 00:19:16,039 RL parser 461 00:19:16,559 --> 00:19:20,340 and we're going to also pass use Unified 462 00:19:20,340 --> 00:19:21,780 top 463 00:19:21,780 --> 00:19:24,260 ology 464 00:19:25,679 --> 00:19:28,500 and then on the next slide 465 00:19:28,500 --> 00:19:30,960 I'm going to say dot then 466 00:19:30,960 --> 00:19:32,880 so this is what's going to happen after 467 00:19:32,880 --> 00:19:36,179 we connect we're going to app.listen and 468 00:19:36,179 --> 00:19:38,340 we're going to put our port 469 00:19:38,340 --> 00:19:40,559 and we're going to do a callback 470 00:19:40,559 --> 00:19:44,160 function we're going to say console.log 471 00:19:44,160 --> 00:19:46,860 server 472 00:19:46,860 --> 00:19:48,120 port 473 00:19:48,120 --> 00:19:50,280 and we're going to give 474 00:19:50,280 --> 00:19:52,980 our Port that we just wrote just to make 475 00:19:52,980 --> 00:19:54,720 sure and confirm that we are sending 476 00:19:54,720 --> 00:19:56,900 that 477 00:19:58,440 --> 00:20:00,059 I'm going to keep that and we're going 478 00:20:00,059 --> 00:20:02,460 to add a catch just in case if we have 479 00:20:02,460 --> 00:20:04,940 an error 480 00:20:06,480 --> 00:20:10,580 I'm going to say console.lag error 481 00:20:13,140 --> 00:20:15,840 did not connect 482 00:20:15,840 --> 00:20:19,080 so save it 483 00:20:19,080 --> 00:20:22,320 and now we can open up our terminal and 484 00:20:22,320 --> 00:20:24,419 we can try and running it 485 00:20:24,419 --> 00:20:26,640 use new URL parts to not support oh 486 00:20:26,640 --> 00:20:29,160 that's because this should be parser so 487 00:20:29,160 --> 00:20:31,440 make sure you have the r at the end so 488 00:20:31,440 --> 00:20:33,179 I'm going to save it and it's going to 489 00:20:33,179 --> 00:20:36,059 restart and now we can see our server is 490 00:20:36,059 --> 00:20:38,340 being run on this particular 491 00:20:38,340 --> 00:20:40,919 Port perfect 492 00:20:40,919 --> 00:20:43,440 server setup there's actually one thing 493 00:20:43,440 --> 00:20:46,260 we should be doing before we jump in and 494 00:20:46,260 --> 00:20:49,080 writing our apis and that is we can take 495 00:20:49,080 --> 00:20:51,600 a look at the final build or we can take 496 00:20:51,600 --> 00:20:54,120 a look at mocks whatever you have and 497 00:20:54,120 --> 00:20:56,580 you want to see how you're going to 498 00:20:56,580 --> 00:20:59,520 organize your data models what data 499 00:20:59,520 --> 00:21:01,740 models are are ways of organizing your 500 00:21:01,740 --> 00:21:04,740 data in nice succinct categories and 501 00:21:04,740 --> 00:21:06,539 making sure they are separate from each 502 00:21:06,539 --> 00:21:08,400 other and we can make relations between 503 00:21:08,400 --> 00:21:10,799 each other we're going to be using 504 00:21:10,799 --> 00:21:13,020 DB which is a little more freeform 505 00:21:13,020 --> 00:21:14,419 compared to 506 00:21:14,419 --> 00:21:17,220 SQL type database where everything is 507 00:21:17,220 --> 00:21:19,559 about relations but still it's important 508 00:21:19,559 --> 00:21:21,660 to try and organize your data beforehand 509 00:21:21,660 --> 00:21:25,080 so that when you go into code you have a 510 00:21:25,080 --> 00:21:27,900 very good structure and you can save so 511 00:21:27,900 --> 00:21:30,179 much time by doing this so if you take a 512 00:21:30,179 --> 00:21:32,940 look at this build we want to categorize 513 00:21:32,940 --> 00:21:34,740 into few things there's a few things you 514 00:21:34,740 --> 00:21:37,140 would notice is that we can organize it 515 00:21:37,140 --> 00:21:40,080 via user this was pretty fairly obvious 516 00:21:40,080 --> 00:21:42,059 but this is a user and they're going to 517 00:21:42,059 --> 00:21:44,280 have a location associated with them the 518 00:21:44,280 --> 00:21:46,799 occupation some number of views 519 00:21:46,799 --> 00:21:48,780 impressions as well as their social 520 00:21:48,780 --> 00:21:51,780 profiles so this is one data model that 521 00:21:51,780 --> 00:21:54,780 we can keep as well as posts 522 00:21:54,780 --> 00:21:57,299 is another one we have a user we have 523 00:21:57,299 --> 00:22:00,059 their description of the post whether 524 00:22:00,059 --> 00:22:02,460 they're friends or not with the post and 525 00:22:02,460 --> 00:22:05,700 the user profile as well and the image 526 00:22:05,700 --> 00:22:09,059 number of likes and comments like that 527 00:22:09,059 --> 00:22:12,120 so what we want to do is we can take the 528 00:22:12,120 --> 00:22:13,860 chart you can use whatever chart you 529 00:22:13,860 --> 00:22:15,360 want or you could just write it straight 530 00:22:15,360 --> 00:22:16,679 up in the code 531 00:22:16,679 --> 00:22:18,480 you want to be able to organize 532 00:22:18,480 --> 00:22:22,380 everything via different objects and 533 00:22:22,380 --> 00:22:24,600 relations so for example user we're 534 00:22:24,600 --> 00:22:28,020 going to have an ID first name last name 535 00:22:28,020 --> 00:22:31,200 a list of friends email password 536 00:22:31,200 --> 00:22:33,480 the link to the picture 537 00:22:33,480 --> 00:22:36,840 location occupation the number of views 538 00:22:36,840 --> 00:22:39,120 Impressions I'm going to do the same 539 00:22:39,120 --> 00:22:42,299 thing for post as well so this is a lot 540 00:22:42,299 --> 00:22:44,460 of things that you kind of want to look 541 00:22:44,460 --> 00:22:46,200 at beforehand and make sure you 542 00:22:46,200 --> 00:22:48,360 structure this so that you know how to 543 00:22:48,360 --> 00:22:50,940 keep your models clean if you don't do 544 00:22:50,940 --> 00:22:52,700 this you're going to waste so much time 545 00:22:52,700 --> 00:22:55,080 refactoring your models and trying to do 546 00:22:55,080 --> 00:22:56,280 all this 547 00:22:56,280 --> 00:22:59,460 this this will save you so much time and 548 00:22:59,460 --> 00:23:01,440 from here you also want to make sure you 549 00:23:01,440 --> 00:23:04,080 know what the relations are so for 550 00:23:04,080 --> 00:23:06,720 example friends arrays of object 551 00:23:06,720 --> 00:23:09,720 meaning we want to be able to create 552 00:23:09,720 --> 00:23:12,600 an array of these type of objects within 553 00:23:12,600 --> 00:23:16,200 the friends list so we're going to have 554 00:23:16,200 --> 00:23:19,320 an array of this type of objects so an 555 00:23:19,320 --> 00:23:21,360 array of ID first name last name picture 556 00:23:21,360 --> 00:23:23,880 path occupation location now there is a 557 00:23:23,880 --> 00:23:25,860 couple things that are up for your 558 00:23:25,860 --> 00:23:27,840 interpretation to figure out whether you 559 00:23:27,840 --> 00:23:30,120 want to do it this way or another way so 560 00:23:30,120 --> 00:23:32,460 for example what I could have done with 561 00:23:32,460 --> 00:23:34,620 the friends is I could have put an array 562 00:23:34,620 --> 00:23:37,620 of IDs so I get a list of arrays of IDs 563 00:23:37,620 --> 00:23:41,100 that refer back to itself because 564 00:23:41,100 --> 00:23:43,020 friends 565 00:23:43,020 --> 00:23:45,120 could be a user as well 566 00:23:45,120 --> 00:23:47,880 so we can instead put friends of IDs 567 00:23:47,880 --> 00:23:52,320 however mongodb always suggested to 568 00:23:52,320 --> 00:23:55,860 prefer to keep sub-documents whenever 569 00:23:55,860 --> 00:24:00,419 you can so that allows you to have 570 00:24:00,419 --> 00:24:04,260 information more easily accessible 571 00:24:04,260 --> 00:24:07,799 and you only want to do referrals of IDs 572 00:24:07,799 --> 00:24:10,260 if you need to so this is just a little 573 00:24:10,260 --> 00:24:12,720 bit more of an advanced tip but this is 574 00:24:12,720 --> 00:24:14,640 how you would structure your database 575 00:24:14,640 --> 00:24:17,100 you're going to have to continue making 576 00:24:17,100 --> 00:24:19,380 this I've already created all the 577 00:24:19,380 --> 00:24:21,480 relations so I'm going to link this in 578 00:24:21,480 --> 00:24:23,700 the description below but these are all 579 00:24:23,700 --> 00:24:25,740 the relations a little crazy but it's 580 00:24:25,740 --> 00:24:27,480 pretty self 581 00:24:27,480 --> 00:24:29,520 explanatory but the picture path was 582 00:24:29,520 --> 00:24:32,159 going to refer to the images this is 583 00:24:32,159 --> 00:24:34,200 where all the images are located same 584 00:24:34,200 --> 00:24:35,460 with the friends they have a picture 585 00:24:35,460 --> 00:24:37,740 path same with the post they also have 586 00:24:37,740 --> 00:24:39,840 picture paths as well 587 00:24:39,840 --> 00:24:42,059 and then user ID is going to refer to 588 00:24:42,059 --> 00:24:44,100 this user so there's a lot of relations 589 00:24:44,100 --> 00:24:45,600 between but it's 590 00:24:45,600 --> 00:24:47,700 very nice to keep this mapped out 591 00:24:47,700 --> 00:24:50,460 beforehand before you code so it gives 592 00:24:50,460 --> 00:24:52,440 you a very good idea of how you write 593 00:24:52,440 --> 00:24:53,880 the code I know this is a lot of talking 594 00:24:53,880 --> 00:24:56,400 a lot of thinking but this saves you a 595 00:24:56,400 --> 00:24:59,159 lot of time and this gives you a good 596 00:24:59,159 --> 00:25:02,340 overview of how you set up your database 597 00:25:02,340 --> 00:25:03,780 and it's very important to do that 598 00:25:03,780 --> 00:25:06,059 beforehand 599 00:25:06,059 --> 00:25:07,679 really don't understand this right now 600 00:25:07,679 --> 00:25:09,960 that's okay we're going to be referring 601 00:25:09,960 --> 00:25:12,360 this diagram as we create these models 602 00:25:12,360 --> 00:25:14,880 so let's actually now we can jump back 603 00:25:14,880 --> 00:25:17,280 into our code 604 00:25:17,280 --> 00:25:18,900 here I'm going to close the terminal so 605 00:25:18,900 --> 00:25:20,760 you can see better and the first thing 606 00:25:20,760 --> 00:25:21,900 we're going to do is we're going to 607 00:25:21,900 --> 00:25:25,080 tackle authentication and authorization 608 00:25:25,080 --> 00:25:27,720 which is going to be arguably the 609 00:25:27,720 --> 00:25:30,240 hardest part of this application so now 610 00:25:30,240 --> 00:25:31,020 there's a difference between 611 00:25:31,020 --> 00:25:33,140 authentication and authorization 612 00:25:33,140 --> 00:25:35,159 authentication is basically when you 613 00:25:35,159 --> 00:25:37,260 register and then log in that's 614 00:25:37,260 --> 00:25:40,380 authentication authorization is when you 615 00:25:40,380 --> 00:25:42,360 want to make sure someone's logged in so 616 00:25:42,360 --> 00:25:45,299 you can perform certain actions so only 617 00:25:45,299 --> 00:25:48,120 users that are logged in can get their 618 00:25:48,120 --> 00:25:49,740 list of friends 619 00:25:49,740 --> 00:25:53,520 or they can only get their list of posts 620 00:25:53,520 --> 00:25:55,860 if they're logged in so things like that 621 00:25:55,860 --> 00:25:59,100 is what you would use authorization for 622 00:25:59,100 --> 00:26:00,299 so we're going to start with 623 00:26:00,299 --> 00:26:02,400 authentication so we're going to go down 624 00:26:02,400 --> 00:26:04,860 here and we're going to write 625 00:26:04,860 --> 00:26:08,279 our auth register function so under file 626 00:26:08,279 --> 00:26:11,400 storage I'm going to go down 627 00:26:11,400 --> 00:26:14,460 and then write app.post 628 00:26:14,460 --> 00:26:15,960 actually let me write a comment over 629 00:26:15,960 --> 00:26:18,299 here and I'm going to say routes 630 00:26:18,299 --> 00:26:21,179 with files and I'll show you what that 631 00:26:21,179 --> 00:26:24,900 means so app.post is going to have a 632 00:26:24,900 --> 00:26:28,080 path of auth Slash register 633 00:26:28,080 --> 00:26:29,820 so if they want to register you're going 634 00:26:29,820 --> 00:26:32,520 to call this API from the front end 635 00:26:32,520 --> 00:26:34,799 and we're going to say upload 636 00:26:34,799 --> 00:26:37,440 dot single and we're going to name this 637 00:26:37,440 --> 00:26:38,820 picture 638 00:26:38,820 --> 00:26:42,480 and then comma register 639 00:26:42,480 --> 00:26:45,900 so let me explain what's Happening Here 640 00:26:45,900 --> 00:26:48,240 so typically you have a route and this 641 00:26:48,240 --> 00:26:51,559 is the route that we're going to hit 642 00:26:51,900 --> 00:26:53,760 from there we're going to use a 643 00:26:53,760 --> 00:26:55,500 middleware oh I spelled this wrong so 644 00:26:55,500 --> 00:26:57,679 this would be picture we're going to do 645 00:26:57,679 --> 00:27:00,179 upload.single picture so what this will 646 00:27:00,179 --> 00:27:02,760 do is we're going to upload our picture 647 00:27:02,760 --> 00:27:05,700 locally into the public slash assets 648 00:27:05,700 --> 00:27:07,679 folder and this is what's called a 649 00:27:07,679 --> 00:27:10,380 middleware because it's in between 650 00:27:10,380 --> 00:27:14,460 and occurs before our actual logic so 651 00:27:14,460 --> 00:27:16,620 this is what's the logic of saving our 652 00:27:16,620 --> 00:27:18,539 user into our database and all the 653 00:27:18,539 --> 00:27:21,299 functionality relevant to register but 654 00:27:21,299 --> 00:27:23,460 this is a middleware function that we 655 00:27:23,460 --> 00:27:27,000 can run before it hits that endpoint so 656 00:27:27,000 --> 00:27:29,840 this is what we do 657 00:27:30,419 --> 00:27:31,860 and we're going to be creating this 658 00:27:31,860 --> 00:27:34,380 register controller as well 659 00:27:34,380 --> 00:27:35,940 and with that we're going to make sure 660 00:27:35,940 --> 00:27:38,400 we're going to now treat this function 661 00:27:38,400 --> 00:27:40,020 this is this function is actually called 662 00:27:40,020 --> 00:27:42,480 a controller is what people term it but 663 00:27:42,480 --> 00:27:43,919 basically this is the logic of the 664 00:27:43,919 --> 00:27:46,080 endpoint and we're going to create an 665 00:27:46,080 --> 00:27:48,179 import that represents that so we're 666 00:27:48,179 --> 00:27:51,360 going to import register 667 00:27:51,360 --> 00:27:52,799 from 668 00:27:52,799 --> 00:27:56,900 slash dot slash controllers slash auth 669 00:27:56,900 --> 00:28:00,120 dot JS so we haven't created this file 670 00:28:00,120 --> 00:28:02,700 yet so I'm going to open up the Explorer 671 00:28:02,700 --> 00:28:05,820 and in our server folder I'm going to 672 00:28:05,820 --> 00:28:07,799 create a new folder called as 673 00:28:07,799 --> 00:28:09,299 controllers 674 00:28:09,299 --> 00:28:11,460 and I create new file in that 675 00:28:11,460 --> 00:28:13,380 controllers folder and this is going to 676 00:28:13,380 --> 00:28:17,279 be called off JS so typically this is 677 00:28:17,279 --> 00:28:19,260 how you organize your code 678 00:28:19,260 --> 00:28:22,200 using these kind of methods 679 00:28:22,200 --> 00:28:24,720 and in here we're going to import a 680 00:28:24,720 --> 00:28:25,919 number of things we're going to import 681 00:28:25,919 --> 00:28:27,299 bcrypt 682 00:28:27,299 --> 00:28:29,760 let me close this 683 00:28:29,760 --> 00:28:33,779 from decrypt so this will allow us to 684 00:28:33,779 --> 00:28:35,700 encrypt our password we're going to 685 00:28:35,700 --> 00:28:38,159 import JWT 686 00:28:38,159 --> 00:28:42,299 from Json web token so this will give us 687 00:28:42,299 --> 00:28:45,240 a way to send a user a web token that 688 00:28:45,240 --> 00:28:48,419 they can use for authorization 689 00:28:48,419 --> 00:28:53,039 and then we can do import user from dot 690 00:28:53,039 --> 00:28:56,400 dot slash models slash user.js so we 691 00:28:56,400 --> 00:29:00,779 have not created this user model 692 00:29:00,779 --> 00:29:03,299 and so let's go to our models so we're 693 00:29:03,299 --> 00:29:05,460 going to create a new folder called 694 00:29:05,460 --> 00:29:07,440 models 695 00:29:07,440 --> 00:29:09,299 and inside this folder we're going to 696 00:29:09,299 --> 00:29:13,559 create a file called user.js 697 00:29:14,279 --> 00:29:17,720 so now this is where we can actually use 698 00:29:17,720 --> 00:29:21,059 the information that we created with 699 00:29:21,059 --> 00:29:25,380 this schema so we have this basically uh 700 00:29:25,380 --> 00:29:28,380 entire object that we want to place in 701 00:29:28,380 --> 00:29:30,539 here so we're going to be doing that 702 00:29:30,539 --> 00:29:33,600 slowly so I'm going to import Mongoose 703 00:29:33,600 --> 00:29:34,820 from 704 00:29:34,820 --> 00:29:38,039 Mongoose so this will help us set up our 705 00:29:38,039 --> 00:29:39,299 model 706 00:29:39,299 --> 00:29:42,360 I'm going to call this const user schema 707 00:29:42,360 --> 00:29:45,419 equals new mongoose 708 00:29:45,419 --> 00:29:48,779 dot schema like so and we're going to 709 00:29:48,779 --> 00:29:51,360 pass in an object 710 00:29:51,360 --> 00:29:54,539 so now this is kind of close to what you 711 00:29:54,539 --> 00:29:56,520 write with an object except there's some 712 00:29:56,520 --> 00:29:58,080 parameters that we're going to be 713 00:29:58,080 --> 00:29:59,760 setting so for example we're going to 714 00:29:59,760 --> 00:30:01,559 set first name we're going to say type 715 00:30:01,559 --> 00:30:02,880 string 716 00:30:02,880 --> 00:30:05,760 require equals true 717 00:30:05,760 --> 00:30:11,340 Min of two Max of 50. so 718 00:30:11,340 --> 00:30:13,320 what this will do is that we're going to 719 00:30:13,320 --> 00:30:16,260 have a first name that has these 720 00:30:16,260 --> 00:30:17,940 properties so it's going to be a type of 721 00:30:17,940 --> 00:30:19,020 string 722 00:30:19,020 --> 00:30:22,200 and it's has to be required with a 723 00:30:22,200 --> 00:30:24,659 minimum of two values and a maximum of 724 00:30:24,659 --> 00:30:28,260 50 values so we can set what we want for 725 00:30:28,260 --> 00:30:31,140 this user and have validation checks if 726 00:30:31,140 --> 00:30:33,960 we wanted to to confirm that this is a 727 00:30:33,960 --> 00:30:35,460 case 728 00:30:35,460 --> 00:30:36,840 and then we're going to do the same 729 00:30:36,840 --> 00:30:38,340 thing with the last name so I'm just 730 00:30:38,340 --> 00:30:40,260 going to copy this over 731 00:30:40,260 --> 00:30:42,179 and call this 732 00:30:42,179 --> 00:30:45,480 last name 733 00:30:45,480 --> 00:30:47,159 we're going to do the same thing with 734 00:30:47,159 --> 00:30:49,399 email 735 00:30:56,100 --> 00:30:58,860 and we're going to say Max of we're 736 00:30:58,860 --> 00:31:00,539 going to get rid of the Min and we're 737 00:31:00,539 --> 00:31:02,220 going to say unique 738 00:31:02,220 --> 00:31:04,799 is true so you cannot have duplicate 739 00:31:04,799 --> 00:31:06,539 emails 740 00:31:06,539 --> 00:31:09,679 and that would make sense 741 00:31:10,500 --> 00:31:12,539 I could apologize for the typos but 742 00:31:12,539 --> 00:31:16,320 these should be required with the D 743 00:31:16,320 --> 00:31:18,659 so make sure you have that and then 744 00:31:18,659 --> 00:31:20,279 we're going to continue on we're going 745 00:31:20,279 --> 00:31:21,179 to say 746 00:31:21,179 --> 00:31:23,340 we're going to copy the same thing we're 747 00:31:23,340 --> 00:31:26,460 going to have password type string that 748 00:31:26,460 --> 00:31:29,340 should be required to be true and the 749 00:31:29,340 --> 00:31:32,399 minimum of five now normally you would 750 00:31:32,399 --> 00:31:34,080 have much more configurations for 751 00:31:34,080 --> 00:31:36,360 password but we're just going to keep it 752 00:31:36,360 --> 00:31:38,279 simple 753 00:31:38,279 --> 00:31:40,320 I'm going to copy this down say picture 754 00:31:40,320 --> 00:31:41,460 path 755 00:31:41,460 --> 00:31:44,580 type string this is not required we can 756 00:31:44,580 --> 00:31:48,960 just say default is empty string 757 00:31:48,960 --> 00:31:52,320 and then we can have friends 758 00:31:52,320 --> 00:31:55,320 and this should be a type of array 759 00:31:55,320 --> 00:31:59,700 default of empty array 760 00:31:59,700 --> 00:32:01,980 and we're going to have location 761 00:32:01,980 --> 00:32:03,299 string 762 00:32:03,299 --> 00:32:06,360 occupation string 763 00:32:06,360 --> 00:32:09,360 viewed profile 764 00:32:09,360 --> 00:32:11,899 number 765 00:32:12,120 --> 00:32:13,919 impressions 766 00:32:13,919 --> 00:32:15,779 number 767 00:32:15,779 --> 00:32:18,600 and then that should be good 768 00:32:18,600 --> 00:32:21,360 for our first object 769 00:32:21,360 --> 00:32:23,520 so we're going to have this as our main 770 00:32:23,520 --> 00:32:26,100 object but we're also going to put comma 771 00:32:26,100 --> 00:32:28,200 after this object 772 00:32:28,200 --> 00:32:30,779 and we're going to put timestamps 773 00:32:30,779 --> 00:32:33,840 colon true so this will give us like 774 00:32:33,840 --> 00:32:36,360 automatic dates for when it's created 775 00:32:36,360 --> 00:32:38,760 when it's updated things like that it's 776 00:32:38,760 --> 00:32:40,320 kind of kind of convenient 777 00:32:40,320 --> 00:32:42,840 we're not going to really use those but 778 00:32:42,840 --> 00:32:45,120 just to show you and then from here I'm 779 00:32:45,120 --> 00:32:49,320 going to say const user equals mongoose 780 00:32:49,320 --> 00:32:50,880 dot model 781 00:32:50,880 --> 00:32:54,120 user and we're going to put user 782 00:32:54,120 --> 00:32:57,840 actually let me it's Capital user schema 783 00:32:57,840 --> 00:33:00,360 so when you create a mongoose model you 784 00:33:00,360 --> 00:33:01,799 want to create this Mongoose schema 785 00:33:01,799 --> 00:33:02,700 first 786 00:33:02,700 --> 00:33:05,460 and then we pass it into mongoose.model 787 00:33:05,460 --> 00:33:07,980 and we pass it into user and that should 788 00:33:07,980 --> 00:33:09,960 be how you go about it and we're going 789 00:33:09,960 --> 00:33:13,200 to do export default user 790 00:33:13,200 --> 00:33:15,480 now if you look at this this closely 791 00:33:15,480 --> 00:33:18,000 aligns to the object we created right 792 00:33:18,000 --> 00:33:21,120 here so this is going to be 793 00:33:21,120 --> 00:33:23,700 are Mongoose schema so this is why this 794 00:33:23,700 --> 00:33:25,740 is very important later on if you mess 795 00:33:25,740 --> 00:33:27,360 this up your data is all messed up so 796 00:33:27,360 --> 00:33:28,679 we're gonna have to reset the data 797 00:33:28,679 --> 00:33:30,539 you're gonna have to redo everything and 798 00:33:30,539 --> 00:33:32,220 you're going to refactor just waste a 799 00:33:32,220 --> 00:33:34,260 lot of time give you lots of headaches 800 00:33:34,260 --> 00:33:36,120 so that's why it's important to set up 801 00:33:36,120 --> 00:33:37,980 your model beforehand 802 00:33:37,980 --> 00:33:39,539 and then with that we're going to go 803 00:33:39,539 --> 00:33:43,200 back to our auth folder or auth file and 804 00:33:43,200 --> 00:33:44,940 we're going to continue writing this so 805 00:33:44,940 --> 00:33:48,840 I'm going to say register user 806 00:33:48,840 --> 00:33:50,519 and I'm going to create our register 807 00:33:50,519 --> 00:33:52,919 function that we were originally doing 808 00:33:52,919 --> 00:33:54,299 so we're going to do export cons 809 00:33:54,299 --> 00:33:59,159 register async Rec res 810 00:33:59,159 --> 00:34:00,740 and we're going to do a callback 811 00:34:00,740 --> 00:34:03,240 function like this 812 00:34:03,240 --> 00:34:05,100 so now let me explain this is this has 813 00:34:05,100 --> 00:34:06,419 to be asynchronous because we're going 814 00:34:06,419 --> 00:34:08,760 to be calling database and when 815 00:34:08,760 --> 00:34:10,859 you make a call to database that's 816 00:34:10,859 --> 00:34:12,179 going to be asynchronous so it's 817 00:34:12,179 --> 00:34:14,159 essentially like an API call that you do 818 00:34:14,159 --> 00:34:16,500 from front end to backend then back into 819 00:34:16,500 --> 00:34:21,359 a database and Rec res so this will 820 00:34:21,359 --> 00:34:24,480 provide us with the rec request body 821 00:34:24,480 --> 00:34:27,239 that we get from the front end 822 00:34:27,239 --> 00:34:29,879 and the response is what we are going to 823 00:34:29,879 --> 00:34:32,339 be sending back to the front end so this 824 00:34:32,339 --> 00:34:34,440 provides us those type of 825 00:34:34,440 --> 00:34:36,719 functionalities and express provides 826 00:34:36,719 --> 00:34:39,060 this by default 827 00:34:39,060 --> 00:34:41,099 and then we're going to have a try catch 828 00:34:41,099 --> 00:34:44,040 block so we're going to do try catch 829 00:34:44,040 --> 00:34:46,080 error like so 830 00:34:46,080 --> 00:34:48,780 and we're going to attempt to do this 831 00:34:48,780 --> 00:34:51,480 logic in here 832 00:34:51,480 --> 00:34:54,418 and then from here I'm going to do const 833 00:34:54,418 --> 00:35:00,300 first name last name email password 834 00:35:00,300 --> 00:35:03,960 picture path friends 835 00:35:03,960 --> 00:35:05,640 location 836 00:35:05,640 --> 00:35:09,240 I spelled friends wrong with I 837 00:35:09,240 --> 00:35:10,740 occupation 838 00:35:10,740 --> 00:35:12,839 and we're going to grab this from the 839 00:35:12,839 --> 00:35:14,460 rec.body 840 00:35:14,460 --> 00:35:16,200 so basically we're just structuring 841 00:35:16,200 --> 00:35:19,440 these parameters from the request body 842 00:35:19,440 --> 00:35:21,240 so on the front end we're going to have 843 00:35:21,240 --> 00:35:24,480 to send an object that has these 844 00:35:24,480 --> 00:35:26,599 parameters or 845 00:35:26,599 --> 00:35:29,400 arguments as you call it and you're 846 00:35:29,400 --> 00:35:31,859 going to grab this and use this in this 847 00:35:31,859 --> 00:35:33,540 function so right now we haven't created 848 00:35:33,540 --> 00:35:35,760 the front end 849 00:35:35,760 --> 00:35:39,420 um we can do this and set this up 850 00:35:39,420 --> 00:35:41,280 so that in the future when we create the 851 00:35:41,280 --> 00:35:43,980 front end we can basically take it so 852 00:35:43,980 --> 00:35:46,140 here we're going to do cons salt 853 00:35:46,140 --> 00:35:49,020 and we're going to await B Crypt 854 00:35:49,020 --> 00:35:52,740 dot gen salt so what this is going to do 855 00:35:52,740 --> 00:35:54,900 is we're going to create a random salt 856 00:35:54,900 --> 00:35:57,480 provided by B Crypt so this is basically 857 00:35:57,480 --> 00:35:59,579 encryption and we're going to use this 858 00:35:59,579 --> 00:36:02,400 salt to encrypt our password so we're 859 00:36:02,400 --> 00:36:03,540 going to take 860 00:36:03,540 --> 00:36:05,280 another variable I'm going to call this 861 00:36:05,280 --> 00:36:07,920 password hash and we're going to await 862 00:36:07,920 --> 00:36:10,140 decrypt 863 00:36:10,140 --> 00:36:13,980 dot hash and pass in our password 864 00:36:13,980 --> 00:36:16,140 and provide the salt 865 00:36:16,140 --> 00:36:19,200 so to encrypt our password so that the 866 00:36:19,200 --> 00:36:22,500 password is not exposed we can create a 867 00:36:22,500 --> 00:36:24,780 salt pass it in and hash this together 868 00:36:24,780 --> 00:36:28,560 so we get the password hash with that 869 00:36:28,560 --> 00:36:31,140 and in here we're going to use const new 870 00:36:31,140 --> 00:36:34,140 user equals new user we're going to pass 871 00:36:34,140 --> 00:36:35,099 in 872 00:36:35,099 --> 00:36:36,599 in 873 00:36:36,599 --> 00:36:38,880 object in here and this is where we're 874 00:36:38,880 --> 00:36:41,880 going to create our user so now just FYI 875 00:36:41,880 --> 00:36:44,160 the way this register function will work 876 00:36:44,160 --> 00:36:45,240 is that we're going to encrypt the 877 00:36:45,240 --> 00:36:47,640 password we're going to save it and then 878 00:36:47,640 --> 00:36:50,880 after we save it when the user tries to 879 00:36:50,880 --> 00:36:52,980 log in we're going to provide the 880 00:36:52,980 --> 00:36:54,480 password or they're going to provide the 881 00:36:54,480 --> 00:36:56,280 password we're going to solve that again 882 00:36:56,280 --> 00:36:58,380 and we're going to make sure that's the 883 00:36:58,380 --> 00:36:59,700 correct one and we're going to give them 884 00:36:59,700 --> 00:37:02,640 a Json web token so that is exactly the 885 00:37:02,640 --> 00:37:05,040 flow that we are looking at and we'll 886 00:37:05,040 --> 00:37:08,359 cover this shortly 887 00:37:08,579 --> 00:37:10,200 and so I'm going to pass in first name 888 00:37:10,200 --> 00:37:12,540 in here last name 889 00:37:12,540 --> 00:37:15,480 actually we can copy all of this to make 890 00:37:15,480 --> 00:37:16,560 this easier 891 00:37:16,560 --> 00:37:19,859 so I'm gonna replace all that first name 892 00:37:19,859 --> 00:37:22,440 last name email password but the 893 00:37:22,440 --> 00:37:23,640 password is going to be the password 894 00:37:23,640 --> 00:37:26,280 hash so we don't even store the real 895 00:37:26,280 --> 00:37:27,839 password in there 896 00:37:27,839 --> 00:37:29,700 we're gonna have Patrick picture path 897 00:37:29,700 --> 00:37:32,280 friends location occupation 898 00:37:32,280 --> 00:37:34,380 and 899 00:37:34,380 --> 00:37:37,680 we had viewed profile so this we're just 900 00:37:37,680 --> 00:37:39,420 going to give it some dummy value so 901 00:37:39,420 --> 00:37:40,920 this we're not actually writing the 902 00:37:40,920 --> 00:37:42,540 functionality we're just going to give 903 00:37:42,540 --> 00:37:44,400 it some random value 904 00:37:44,400 --> 00:37:45,720 in here 905 00:37:45,720 --> 00:37:47,460 so the for the sake of Simplicity 906 00:37:47,460 --> 00:37:48,660 because this is a pretty big project 907 00:37:48,660 --> 00:37:51,300 already so we want to simplify it so 908 00:37:51,300 --> 00:37:53,400 we're going to have Impressions and I'm 909 00:37:53,400 --> 00:37:55,079 going to copy this math.floor 910 00:37:55,079 --> 00:37:56,460 math.random 911 00:37:56,460 --> 00:37:58,440 times a thousand so it's just going to 912 00:37:58,440 --> 00:38:01,320 give it a random number between 0 or 1 913 00:38:01,320 --> 00:38:04,460 through 10 000. 914 00:38:05,099 --> 00:38:06,599 and then after that we're going to do 915 00:38:06,599 --> 00:38:09,839 const saved user and we're going to 916 00:38:09,839 --> 00:38:12,500 await new 917 00:38:12,500 --> 00:38:14,160 user.save 918 00:38:14,160 --> 00:38:16,200 so we're going to save this user 919 00:38:16,200 --> 00:38:19,680 and we're finally going to use the res 920 00:38:19,680 --> 00:38:22,980 argument that's provided by 921 00:38:22,980 --> 00:38:25,200 Express and we're going to do res dot 922 00:38:25,200 --> 00:38:26,700 status 923 00:38:26,700 --> 00:38:28,500 201 924 00:38:28,500 --> 00:38:30,540 dot Json 925 00:38:30,540 --> 00:38:33,900 saved user 926 00:38:33,900 --> 00:38:36,060 so what we're doing is we're going to 927 00:38:36,060 --> 00:38:38,700 send the user back if all of this 928 00:38:38,700 --> 00:38:40,920 doesn't error out 929 00:38:40,920 --> 00:38:43,079 we're going to send the send the user a 930 00:38:43,079 --> 00:38:45,540 status of 201 which is the status code 931 00:38:45,540 --> 00:38:48,180 meaning something has been created so 932 00:38:48,180 --> 00:38:49,440 make sure you understand the status 933 00:38:49,440 --> 00:38:52,140 codes you can look those up but 934 00:38:52,140 --> 00:38:53,640 you want to send the user back the 935 00:38:53,640 --> 00:38:55,560 correct status we're going to create a 936 00:38:55,560 --> 00:38:58,740 Json version of the saved user so that 937 00:38:58,740 --> 00:39:03,359 the front end can receive this response 938 00:39:03,359 --> 00:39:06,720 and just as a front-end engineer you 939 00:39:06,720 --> 00:39:08,400 always want to look at and make sure 940 00:39:08,400 --> 00:39:10,380 they're getting the correct response so 941 00:39:10,380 --> 00:39:12,260 this is a lot of where back end 942 00:39:12,260 --> 00:39:14,400 Engineers need to spend a lot of time 943 00:39:14,400 --> 00:39:16,380 making sure the data coming back from 944 00:39:16,380 --> 00:39:18,599 the back end is correct and in the 945 00:39:18,599 --> 00:39:20,940 proper structure that the front end can 946 00:39:20,940 --> 00:39:23,099 use otherwise it creates much more work 947 00:39:23,099 --> 00:39:25,680 for the front end as well as well as 948 00:39:25,680 --> 00:39:28,440 backend if you have to refactor this 949 00:39:28,440 --> 00:39:30,780 so in this case we're sending back the 950 00:39:30,780 --> 00:39:33,960 exact save user in the correct format 951 00:39:33,960 --> 00:39:36,420 and the front end will also use the same 952 00:39:36,420 --> 00:39:39,300 format as well now if you work at some 953 00:39:39,300 --> 00:39:40,560 companies they're going to have 954 00:39:40,560 --> 00:39:43,140 different naming conventions and that's 955 00:39:43,140 --> 00:39:46,079 okay it's just kind of annoying 956 00:39:46,079 --> 00:39:47,640 but if you have the same naving 957 00:39:47,640 --> 00:39:49,619 commissions you can use the exact data 958 00:39:49,619 --> 00:39:51,720 that's being sent from the back end so 959 00:39:51,720 --> 00:39:53,040 that would be perfect otherwise you're 960 00:39:53,040 --> 00:39:55,260 going to have to find ways to write code 961 00:39:55,260 --> 00:39:58,079 that will convert it 962 00:39:58,079 --> 00:39:59,880 and then from here in our catch function 963 00:39:59,880 --> 00:40:02,119 we're going to write res dot status 964 00:40:02,119 --> 00:40:05,579 500 so this is what happens when 965 00:40:05,579 --> 00:40:07,500 something goes wrong we're just going to 966 00:40:07,500 --> 00:40:10,020 send the front end a status code of 500 967 00:40:10,020 --> 00:40:13,920 with an error message of whatever the 968 00:40:13,920 --> 00:40:16,740 mongodb database has returned so that's 969 00:40:16,740 --> 00:40:19,260 what this is particularly doing in this 970 00:40:19,260 --> 00:40:20,280 case 971 00:40:20,280 --> 00:40:22,500 so if there's an error front end is 972 00:40:22,500 --> 00:40:23,820 going to get this error message with the 973 00:40:23,820 --> 00:40:27,200 status code of 500. 974 00:40:27,540 --> 00:40:30,420 and with this we have the register 975 00:40:30,420 --> 00:40:33,420 complete there was one thing to note 976 00:40:33,420 --> 00:40:35,820 make sure you use your intellisense and 977 00:40:35,820 --> 00:40:36,900 then 978 00:40:36,900 --> 00:40:39,480 you would realize I spelled b Crypt 979 00:40:39,480 --> 00:40:42,780 wrong so I had an extra R so make sure 980 00:40:42,780 --> 00:40:46,440 you erase that so we save it and what 981 00:40:46,440 --> 00:40:49,980 I'm going to do is what I opened up is a 982 00:40:49,980 --> 00:40:51,180 separate 983 00:40:51,180 --> 00:40:53,579 front end package I already have the 984 00:40:53,579 --> 00:40:55,800 front end deployed and ready and it's 985 00:40:55,800 --> 00:40:56,579 running 986 00:40:56,579 --> 00:40:58,619 the back end is what we're currently 987 00:40:58,619 --> 00:41:00,359 working on so what we're going to do is 988 00:41:00,359 --> 00:41:01,920 we're going to write 989 00:41:01,920 --> 00:41:03,720 this form out and we're going to make 990 00:41:03,720 --> 00:41:06,780 sure our endpoint works and before we do 991 00:41:06,780 --> 00:41:09,599 that let me make sure that I have this 992 00:41:09,599 --> 00:41:12,480 clear I added this folder off screen 993 00:41:12,480 --> 00:41:15,540 this is the assets folder with all the 994 00:41:15,540 --> 00:41:18,599 images that we use for this website so 995 00:41:18,599 --> 00:41:20,820 make sure you have this 996 00:41:20,820 --> 00:41:24,240 input into your server so it works it is 997 00:41:24,240 --> 00:41:26,520 in the GitHub repo it's in the link in 998 00:41:26,520 --> 00:41:28,020 the description below so make sure you 999 00:41:28,020 --> 00:41:30,839 place this in the proper folders so you 1000 00:41:30,839 --> 00:41:33,540 will have access to the images and now 1001 00:41:33,540 --> 00:41:35,400 if you go over here we're going to write 1002 00:41:35,400 --> 00:41:38,339 sum name something like that or actually 1003 00:41:38,339 --> 00:41:41,339 let's call this fake person and we're 1004 00:41:41,339 --> 00:41:43,560 going to say fake location fake 1005 00:41:43,560 --> 00:41:45,660 occupation 1006 00:41:45,660 --> 00:41:49,079 give it some random picture from our 1007 00:41:49,079 --> 00:41:51,240 images so I'm just going to give one of 1008 00:41:51,240 --> 00:41:53,460 the random images I'm going to say fake 1009 00:41:53,460 --> 00:41:56,160 person at gmail.com 1010 00:41:56,160 --> 00:41:58,380 and add a password we're going to 1011 00:41:58,380 --> 00:41:59,520 register 1012 00:41:59,520 --> 00:42:01,740 and what's going to happen is if we 1013 00:42:01,740 --> 00:42:05,359 check our Network tab 1014 00:42:05,400 --> 00:42:07,079 I've already made several calls before 1015 00:42:07,079 --> 00:42:10,619 but if you check we have a payload that 1016 00:42:10,619 --> 00:42:13,260 sends all this information we can see 1017 00:42:13,260 --> 00:42:15,599 the response it gives us or in the 1018 00:42:15,599 --> 00:42:17,640 preview tab over here so make sure you 1019 00:42:17,640 --> 00:42:19,260 see the network tab this is where you 1020 00:42:19,260 --> 00:42:21,660 can see all your API calls and you can 1021 00:42:21,660 --> 00:42:23,760 see all the information the backend is 1022 00:42:23,760 --> 00:42:26,520 giving you as you can see we have email 1023 00:42:26,520 --> 00:42:28,740 first name last name and all the values 1024 00:42:28,740 --> 00:42:31,320 that we've set but also the timestamps 1025 00:42:31,320 --> 00:42:35,520 with this created ID updated that and as 1026 00:42:35,520 --> 00:42:38,339 well as an underscore ID that we did not 1027 00:42:38,339 --> 00:42:41,579 create so mongodatabase creates a random 1028 00:42:41,579 --> 00:42:45,180 unique ID for every model or every data 1029 00:42:45,180 --> 00:42:46,740 that we create 1030 00:42:46,740 --> 00:42:48,900 and we can see that we've created this 1031 00:42:48,900 --> 00:42:50,520 perfectly and then we go to 1032 00:42:50,520 --> 00:42:52,920 mongodatabase and you can check over 1033 00:42:52,920 --> 00:42:55,859 here to see if you have your data so we 1034 00:42:55,859 --> 00:42:58,440 can go the browse collections 1035 00:42:58,440 --> 00:43:00,839 and then we can see the users I've 1036 00:43:00,839 --> 00:43:03,380 already created one before off screen 1037 00:43:03,380 --> 00:43:06,359 and then you can see the one we just 1038 00:43:06,359 --> 00:43:08,579 created this is how it looks like now 1039 00:43:08,579 --> 00:43:10,560 they say object ID but this is basically 1040 00:43:10,560 --> 00:43:13,859 a string this is everything that we need 1041 00:43:13,859 --> 00:43:17,220 and we created our user successfully 1042 00:43:17,220 --> 00:43:19,980 that now we can go back to our index.js 1043 00:43:19,980 --> 00:43:22,020 and now we are going to work on our 1044 00:43:22,020 --> 00:43:24,599 login information so the first thing I 1045 00:43:24,599 --> 00:43:26,819 want to do is I'm going to go to the top 1046 00:43:26,819 --> 00:43:30,480 and I'm going to write import auth 1047 00:43:30,480 --> 00:43:33,420 routes from 1048 00:43:33,420 --> 00:43:37,220 double quotation dot slash routes slash 1049 00:43:37,220 --> 00:43:39,839 auth Js 1050 00:43:39,839 --> 00:43:42,180 so we have not created this this is 1051 00:43:42,180 --> 00:43:44,640 going to be a route folder where we have 1052 00:43:44,640 --> 00:43:48,660 the path and the routes for every type 1053 00:43:48,660 --> 00:43:50,220 of feature so in this case it would be 1054 00:43:50,220 --> 00:43:52,079 auth feature 1055 00:43:52,079 --> 00:43:54,000 and the reason why we didn't do it for 1056 00:43:54,000 --> 00:43:56,339 this particular one this should normally 1057 00:43:56,339 --> 00:44:00,119 be in that route file this is what you 1058 00:44:00,119 --> 00:44:02,700 would consist of for those route files 1059 00:44:02,700 --> 00:44:04,380 the reason why we don't have that is 1060 00:44:04,380 --> 00:44:06,480 because we need the upload 1061 00:44:06,480 --> 00:44:08,339 variable right 1062 00:44:08,339 --> 00:44:10,500 underneath or right above we need to set 1063 00:44:10,500 --> 00:44:12,900 this in the index file that's why we 1064 00:44:12,900 --> 00:44:15,240 cannot move this into its separate file 1065 00:44:15,240 --> 00:44:17,160 so that's why we have this separate 1066 00:44:17,160 --> 00:44:20,160 section only when we need to upload a 1067 00:44:20,160 --> 00:44:21,960 file for the other routes we can keep 1068 00:44:21,960 --> 00:44:24,660 them separate so we can save routes 1069 00:44:24,660 --> 00:44:28,140 and over here we're going to say app.use 1070 00:44:28,140 --> 00:44:30,960 slash auth and we're going to pass in 1071 00:44:30,960 --> 00:44:33,000 auth routes 1072 00:44:33,000 --> 00:44:35,339 so this will help us set up routes 1073 00:44:35,339 --> 00:44:38,160 routes and keep our files organized and 1074 00:44:38,160 --> 00:44:39,000 clean 1075 00:44:39,000 --> 00:44:41,160 and now if I go back I'm going to close 1076 00:44:41,160 --> 00:44:43,380 everything over here 1077 00:44:43,380 --> 00:44:45,240 and I'm going to open up our directory 1078 00:44:45,240 --> 00:44:47,760 we're going to go to server we're going 1079 00:44:47,760 --> 00:44:49,859 to create a new folder and we're going 1080 00:44:49,859 --> 00:44:51,540 to call this 1081 00:44:51,540 --> 00:44:54,200 routes 1082 00:44:54,420 --> 00:44:57,180 excuse me routes like that and then in 1083 00:44:57,180 --> 00:44:58,680 here I'm going to create a file called 1084 00:44:58,680 --> 00:45:01,680 auth.js 1085 00:45:02,040 --> 00:45:03,300 and this is where we're going to create 1086 00:45:03,300 --> 00:45:05,819 the routes so we're going to first 1087 00:45:05,819 --> 00:45:09,119 import Express 1088 00:45:09,119 --> 00:45:10,319 from 1089 00:45:10,319 --> 00:45:13,099 Express 1090 00:45:13,680 --> 00:45:15,540 then I'm going to import 1091 00:45:15,540 --> 00:45:18,540 login which is going to be a controller 1092 00:45:18,540 --> 00:45:20,819 which we have not created dot dot slash 1093 00:45:20,819 --> 00:45:25,220 controller slash auth Js 1094 00:45:25,740 --> 00:45:28,560 and we are doing we're going to set up 1095 00:45:28,560 --> 00:45:30,839 our router 1096 00:45:30,839 --> 00:45:34,500 this piece of code will allow Express to 1097 00:45:34,500 --> 00:45:38,520 identify that these routes will all be 1098 00:45:38,520 --> 00:45:40,560 configured and it allows us to have 1099 00:45:40,560 --> 00:45:43,560 these in separate files to keep us 1100 00:45:43,560 --> 00:45:46,440 organized so instead of doing app.use 1101 00:45:46,440 --> 00:45:49,380 we're doing router.post instead 1102 00:45:49,380 --> 00:45:52,740 so we're going to do logging comma login 1103 00:45:52,740 --> 00:45:54,839 and we're going to do export default 1104 00:45:54,839 --> 00:45:56,220 router 1105 00:45:56,220 --> 00:46:00,440 now here I've not specified auth 1106 00:46:00,480 --> 00:46:02,640 like here in this case this would be 1107 00:46:02,640 --> 00:46:05,900 auth register but when we do this route 1108 00:46:05,900 --> 00:46:08,940 we have slash auth 1109 00:46:08,940 --> 00:46:12,119 that identifies that this will be prefix 1110 00:46:12,119 --> 00:46:14,099 onto login 1111 00:46:14,099 --> 00:46:16,380 because we are using auth routes here so 1112 00:46:16,380 --> 00:46:19,079 anytime we specify here this is going to 1113 00:46:19,079 --> 00:46:23,099 be auth login not just slash login so we 1114 00:46:23,099 --> 00:46:25,619 have that set up and now we can finally 1115 00:46:25,619 --> 00:46:28,560 go back to our controllers file and this 1116 00:46:28,560 --> 00:46:31,200 is we're going to be setting our login 1117 00:46:31,200 --> 00:46:33,599 function 1118 00:46:33,599 --> 00:46:35,400 all right and then from here we're going 1119 00:46:35,400 --> 00:46:38,099 to go below the register and we're going 1120 00:46:38,099 --> 00:46:40,980 to say logging in 1121 00:46:40,980 --> 00:46:42,180 and we're going to create a function 1122 00:46:42,180 --> 00:46:46,319 export const login equals async 1123 00:46:46,319 --> 00:46:49,640 Rec res 1124 00:46:50,400 --> 00:46:53,780 and we're going to do a try 1125 00:46:53,940 --> 00:46:57,000 catch block again 1126 00:46:57,000 --> 00:46:59,220 error 1127 00:46:59,220 --> 00:47:01,859 and we're going to copy the catch error 1128 00:47:01,859 --> 00:47:03,420 from before because that's going to be 1129 00:47:03,420 --> 00:47:05,640 the same thing 1130 00:47:05,640 --> 00:47:08,339 now you can customize the error messages 1131 00:47:08,339 --> 00:47:10,140 for this simple app we're not going to 1132 00:47:10,140 --> 00:47:11,760 do that 1133 00:47:11,760 --> 00:47:13,800 and here we're going to destructure 1134 00:47:13,800 --> 00:47:15,300 email 1135 00:47:15,300 --> 00:47:17,160 and password 1136 00:47:17,160 --> 00:47:19,980 from rec.body 1137 00:47:19,980 --> 00:47:21,859 so we're grabbing the email and password 1138 00:47:21,859 --> 00:47:26,099 when the user tries to log in 1139 00:47:26,099 --> 00:47:28,800 and we're going to say const user await 1140 00:47:28,800 --> 00:47:30,839 user oh 1141 00:47:30,839 --> 00:47:33,000 don't forget the equal sign 1142 00:47:33,000 --> 00:47:37,760 oh wait user dot find one 1143 00:47:38,339 --> 00:47:42,119 email colon email 1144 00:47:42,119 --> 00:47:44,339 so here what this is doing is we're 1145 00:47:44,339 --> 00:47:47,220 going to use Mongoose to try to find the 1146 00:47:47,220 --> 00:47:50,099 one that has the specified email and 1147 00:47:50,099 --> 00:47:52,040 I'll bring back all the user information 1148 00:47:52,040 --> 00:47:55,200 over here 1149 00:47:55,200 --> 00:47:57,359 and we're going to say if the user does 1150 00:47:57,359 --> 00:48:00,540 not exist we're going to return 1151 00:48:00,540 --> 00:48:04,740 res dot status 400 Dot 1152 00:48:04,740 --> 00:48:08,760 dot Json and say message 1153 00:48:08,760 --> 00:48:10,140 user 1154 00:48:10,140 --> 00:48:12,960 does not exist 1155 00:48:12,960 --> 00:48:14,880 so this is what happens when the user 1156 00:48:14,880 --> 00:48:17,520 cannot be found so if they put an 1157 00:48:17,520 --> 00:48:20,160 improper email this is the this is going 1158 00:48:20,160 --> 00:48:23,339 to return the error right here 1159 00:48:23,339 --> 00:48:25,020 and then next we're going to say is 1160 00:48:25,020 --> 00:48:27,060 match so this is going to determine if 1161 00:48:27,060 --> 00:48:30,599 we match the password so the way we do 1162 00:48:30,599 --> 00:48:34,020 this is we're going to use bcrypt 1163 00:48:34,020 --> 00:48:36,920 to compare 1164 00:48:37,980 --> 00:48:40,140 password they just sent 1165 00:48:40,140 --> 00:48:43,319 and the user password 1166 00:48:43,319 --> 00:48:46,680 that's been saved inside the database 1167 00:48:46,680 --> 00:48:49,619 and they're gonna both use the same salt 1168 00:48:49,619 --> 00:48:51,240 so what's going to happen is going to 1169 00:48:51,240 --> 00:48:53,700 use the same salt to compare whether 1170 00:48:53,700 --> 00:48:58,800 those two turned out to be the same hash 1171 00:48:58,800 --> 00:49:01,440 and we're going to say if is match is 1172 00:49:01,440 --> 00:49:04,560 not true we're going to return res dot 1173 00:49:04,560 --> 00:49:06,119 status again 1174 00:49:06,119 --> 00:49:08,700 just going to copy this over 1175 00:49:08,700 --> 00:49:13,400 and instead say invalid credentials 1176 00:49:16,859 --> 00:49:18,720 this is how you validate whether the 1177 00:49:18,720 --> 00:49:22,260 user is writing the correct user and 1178 00:49:22,260 --> 00:49:25,140 password or correct email and password 1179 00:49:25,140 --> 00:49:27,300 then we're going to do a const token so 1180 00:49:27,300 --> 00:49:29,640 this is where we're going to use 1181 00:49:29,640 --> 00:49:31,260 jot tokens 1182 00:49:31,260 --> 00:49:33,660 so we're going to sign this 1183 00:49:33,660 --> 00:49:36,060 with the ID 1184 00:49:36,060 --> 00:49:37,619 the user 1185 00:49:37,619 --> 00:49:39,720 ID 1186 00:49:39,720 --> 00:49:42,839 and we're going to pass in 1187 00:49:42,839 --> 00:49:46,140 a secret string 1188 00:49:46,140 --> 00:49:48,900 and we're going to write this 1189 00:49:48,900 --> 00:49:50,880 secret string 1190 00:49:50,880 --> 00:49:52,200 over here 1191 00:49:52,200 --> 00:49:54,960 and we're going to write that in our EnV 1192 00:49:54,960 --> 00:49:56,460 file 1193 00:49:56,460 --> 00:49:59,700 so in our EnV file we're going to do jot 1194 00:49:59,700 --> 00:50:01,859 Secret 1195 00:50:01,859 --> 00:50:05,180 I believe that's how it's spelled 1196 00:50:06,240 --> 00:50:08,520 yeah jotsecret so we're going to go back 1197 00:50:08,520 --> 00:50:12,119 to our DOT EnV file and what you're 1198 00:50:12,119 --> 00:50:14,520 going to do is this could be anything 1199 00:50:14,520 --> 00:50:17,400 you want so there's going to be some 1200 00:50:17,400 --> 00:50:19,140 some super 1201 00:50:19,140 --> 00:50:22,740 hard string to guess 1202 00:50:22,740 --> 00:50:25,500 but to be fair this could be any type of 1203 00:50:25,500 --> 00:50:27,980 string 1204 00:50:28,500 --> 00:50:30,540 as long as it's not guessable so 1205 00:50:30,540 --> 00:50:32,280 typically you probably don't want to use 1206 00:50:32,280 --> 00:50:33,660 that kind of string but you want to make 1207 00:50:33,660 --> 00:50:36,180 sure your string is a secure one that 1208 00:50:36,180 --> 00:50:38,339 you can keep 1209 00:50:38,339 --> 00:50:40,460 and then with that we're going to do 1210 00:50:40,460 --> 00:50:42,540 user.password we're going to delete the 1211 00:50:42,540 --> 00:50:44,880 password so it doesn't get sent back to 1212 00:50:44,880 --> 00:50:47,400 the front end we just want to make sure 1213 00:50:47,400 --> 00:50:50,040 that's kept safe and we're going to do 1214 00:50:50,040 --> 00:50:52,740 res dot status 200 1215 00:50:52,740 --> 00:50:55,140 dot Json 1216 00:50:55,140 --> 00:50:58,380 passing token and then user 1217 00:50:58,380 --> 00:51:00,540 like so 1218 00:51:00,540 --> 00:51:03,180 and with that we have our logging Now 1219 00:51:03,180 --> 00:51:06,780 set up now just FYI typically when you 1220 00:51:06,780 --> 00:51:08,280 work at a company 1221 00:51:08,280 --> 00:51:10,680 you're going to have either two 1222 00:51:10,680 --> 00:51:13,020 situations that happen either there the 1223 00:51:13,020 --> 00:51:14,579 company is going to be using a third 1224 00:51:14,579 --> 00:51:15,660 party 1225 00:51:15,660 --> 00:51:17,579 authentication which is most likely 1226 00:51:17,579 --> 00:51:18,960 they're going to have some kind of 1227 00:51:18,960 --> 00:51:20,460 different 1228 00:51:20,460 --> 00:51:22,559 authentication being handled by some 1229 00:51:22,559 --> 00:51:24,900 third-party company who's very good with 1230 00:51:24,900 --> 00:51:27,180 security which is way more secure than 1231 00:51:27,180 --> 00:51:28,619 something like this 1232 00:51:28,619 --> 00:51:31,020 and generally those are preferred in 1233 00:51:31,020 --> 00:51:33,240 production level application for big 1234 00:51:33,240 --> 00:51:34,800 companies because 1235 00:51:34,800 --> 00:51:37,140 authentication is really big and there's 1236 00:51:37,140 --> 00:51:40,200 lots of ways to hack this 1237 00:51:40,200 --> 00:51:42,240 an alternative is they either have a 1238 00:51:42,240 --> 00:51:44,819 they have a team that will 1239 00:51:44,819 --> 00:51:47,040 do the authentication themselves and 1240 00:51:47,040 --> 00:51:49,020 they will make sure everything is secure 1241 00:51:49,020 --> 00:51:51,960 so those two are usually what happens at 1242 00:51:51,960 --> 00:51:53,940 real companies this is a very basic 1243 00:51:53,940 --> 00:51:56,700 setup you cannot verify that this will 1244 00:51:56,700 --> 00:51:59,520 be very secure for many use cases 1245 00:51:59,520 --> 00:52:03,000 but this is the basic way of how 1246 00:52:03,000 --> 00:52:05,339 authentication works so this is very 1247 00:52:05,339 --> 00:52:08,520 good to understand what's happening when 1248 00:52:08,520 --> 00:52:11,460 you register and then you log in it 1249 00:52:11,460 --> 00:52:13,200 gives you some kind of token or some 1250 00:52:13,200 --> 00:52:16,140 kind of validation and then you the user 1251 00:52:16,140 --> 00:52:19,020 can use that to sign in and that is used 1252 00:52:19,020 --> 00:52:22,160 as verification 1253 00:52:23,579 --> 00:52:25,619 this now that we have the login function 1254 00:52:25,619 --> 00:52:28,260 complete we can go back to our website 1255 00:52:28,260 --> 00:52:32,520 we can say fakeperson gmail.com 1256 00:52:32,520 --> 00:52:35,880 but then the password we can say login 1257 00:52:35,880 --> 00:52:38,819 and as you can see we can now see the 1258 00:52:38,819 --> 00:52:39,839 home page 1259 00:52:39,839 --> 00:52:41,760 now if you see we have a lot of 1260 00:52:41,760 --> 00:52:44,160 different red Network meaning they're 1261 00:52:44,160 --> 00:52:45,839 they're failing because we have not 1262 00:52:45,839 --> 00:52:47,700 created these endpoints and the front 1263 00:52:47,700 --> 00:52:49,740 end is sending all these endpoints as 1264 00:52:49,740 --> 00:52:52,619 well so when you take a look at this 1265 00:52:52,619 --> 00:52:54,180 login 1266 00:52:54,180 --> 00:52:56,339 this is going to be the payload the 1267 00:52:56,339 --> 00:52:58,680 email on the password and then the 1268 00:52:58,680 --> 00:53:01,859 preview is going to be token 1269 00:53:01,859 --> 00:53:04,559 user is going to send back the user 1270 00:53:04,559 --> 00:53:06,780 information to the front end so this is 1271 00:53:06,780 --> 00:53:08,700 what's being sent back to the front end 1272 00:53:08,700 --> 00:53:11,760 and as you can see with the login home 1273 00:53:11,760 --> 00:53:13,980 it's taking us to this page because we 1274 00:53:13,980 --> 00:53:17,819 successfully logged in perfect 1275 00:53:17,819 --> 00:53:20,520 the authentication being set up now we 1276 00:53:20,520 --> 00:53:22,920 have to worry about authorization so 1277 00:53:22,920 --> 00:53:26,099 authorization is basically when the user 1278 00:53:26,099 --> 00:53:28,619 is logged in they have functions or they 1279 00:53:28,619 --> 00:53:31,380 can do things that a non-logged in users 1280 00:53:31,380 --> 00:53:35,099 can do so they can hit API endpoints 1281 00:53:35,099 --> 00:53:37,680 that a normal user would not be able to 1282 00:53:37,680 --> 00:53:40,440 and the way to do this is we're going to 1283 00:53:40,440 --> 00:53:42,599 create a new folder 1284 00:53:42,599 --> 00:53:45,000 in server and we're going to call this 1285 00:53:45,000 --> 00:53:46,980 middle 1286 00:53:46,980 --> 00:53:48,599 middleware 1287 00:53:48,599 --> 00:53:51,300 and in this middleware folder we're 1288 00:53:51,300 --> 00:53:54,000 going to create a folder called 1289 00:53:54,000 --> 00:53:58,520 let's see auth Js 1290 00:53:59,760 --> 00:54:01,920 if I can do this properly oh that's JS 1291 00:54:01,920 --> 00:54:04,980 there we go and in here we're going to 1292 00:54:04,980 --> 00:54:08,640 import a few or import 1293 00:54:08,640 --> 00:54:10,140 JWT 1294 00:54:10,140 --> 00:54:11,579 from 1295 00:54:11,579 --> 00:54:14,520 Json web token 1296 00:54:14,520 --> 00:54:16,020 and we're going to create a function 1297 00:54:16,020 --> 00:54:19,440 called export const verify 1298 00:54:19,440 --> 00:54:20,940 token 1299 00:54:20,940 --> 00:54:23,160 equals async 1300 00:54:23,160 --> 00:54:26,579 we're going to have Rec res and one 1301 00:54:26,579 --> 00:54:29,640 optional parameter called next so this 1302 00:54:29,640 --> 00:54:32,640 next parameter will allow us to have the 1303 00:54:32,640 --> 00:54:34,500 function continue and I'll show you what 1304 00:54:34,500 --> 00:54:35,640 that means 1305 00:54:35,640 --> 00:54:37,980 but let's write this first so we're 1306 00:54:37,980 --> 00:54:40,800 going to have try 1307 00:54:40,800 --> 00:54:43,200 and then catch 1308 00:54:43,200 --> 00:54:45,359 I'm going to pass an error 1309 00:54:45,359 --> 00:54:47,339 and like before we're going to write the 1310 00:54:47,339 --> 00:54:48,480 same error 1311 00:54:48,480 --> 00:54:51,900 as usual to just keep it simple but in a 1312 00:54:51,900 --> 00:54:53,640 real application you want to make sure 1313 00:54:53,640 --> 00:54:56,280 you handle all these errors properly it 1314 00:54:56,280 --> 00:54:59,339 just takes too much time to do it 1315 00:54:59,339 --> 00:55:01,140 in this project 1316 00:55:01,140 --> 00:55:03,720 so here we're going to do try in here 1317 00:55:03,720 --> 00:55:05,460 we're going to say let token equals 1318 00:55:05,460 --> 00:55:07,800 wreck dot Heather 1319 00:55:07,800 --> 00:55:11,880 and we're going to pass in authorization 1320 00:55:12,240 --> 00:55:14,640 so what we're doing is from the request 1321 00:55:14,640 --> 00:55:16,920 from the front end we're grabbing the 1322 00:55:16,920 --> 00:55:20,280 authorization header and that's where 1323 00:55:20,280 --> 00:55:23,099 the token will be set on the front end 1324 00:55:23,099 --> 00:55:24,660 or the front end will be setting this 1325 00:55:24,660 --> 00:55:26,400 and then we can grab it in the back end 1326 00:55:26,400 --> 00:55:28,500 through this 1327 00:55:28,500 --> 00:55:30,980 key 1328 00:55:31,319 --> 00:55:34,260 and if token does not exist 1329 00:55:34,260 --> 00:55:36,300 we're just going to say return 1330 00:55:36,300 --> 00:55:39,859 res dot status 1331 00:55:40,200 --> 00:55:42,420 403 1332 00:55:42,420 --> 00:55:45,780 dot send access denied so basically this 1333 00:55:45,780 --> 00:55:47,460 handles a case where the token doesn't 1334 00:55:47,460 --> 00:55:49,559 even exist so that means they're not 1335 00:55:49,559 --> 00:55:51,420 even sending it 1336 00:55:51,420 --> 00:55:53,400 and then if token 1337 00:55:53,400 --> 00:55:56,520 dot starts with 1338 00:55:56,520 --> 00:55:57,960 Bearer 1339 00:55:57,960 --> 00:56:00,000 so we need to make sure it starts with 1340 00:56:00,000 --> 00:56:03,300 the bearer token or Bearer string and 1341 00:56:03,300 --> 00:56:05,700 we're just going to grab token.slice 1342 00:56:05,700 --> 00:56:10,500 from 7 to tokens dot length and we're 1343 00:56:10,500 --> 00:56:11,940 going to trim 1344 00:56:11,940 --> 00:56:14,400 left 1345 00:56:14,400 --> 00:56:16,740 like so actually this should be singular 1346 00:56:16,740 --> 00:56:18,240 so token 1347 00:56:18,240 --> 00:56:20,160 and we're going to have that 1348 00:56:20,160 --> 00:56:22,559 so what this is doing is basically 1349 00:56:22,559 --> 00:56:24,839 we want the token to be starting with 1350 00:56:24,839 --> 00:56:26,700 Bearer so again this is going to be set 1351 00:56:26,700 --> 00:56:28,559 on the front end and we're going to take 1352 00:56:28,559 --> 00:56:29,640 everything 1353 00:56:29,640 --> 00:56:32,579 from the right side of this Bearer so 1354 00:56:32,579 --> 00:56:35,579 the token will be placed after 1355 00:56:35,579 --> 00:56:38,040 a space in the bear so that's what 1356 00:56:38,040 --> 00:56:39,660 that's how we're grabbing the actual 1357 00:56:39,660 --> 00:56:41,220 token 1358 00:56:41,220 --> 00:56:42,780 and then from here we're going to 1359 00:56:42,780 --> 00:56:44,099 actually this is where we're actually 1360 00:56:44,099 --> 00:56:46,559 going to check with JWT when we created 1361 00:56:46,559 --> 00:56:49,079 it earlier so we're going to do JWT 1362 00:56:49,079 --> 00:56:50,400 verify 1363 00:56:50,400 --> 00:56:55,140 the token and we're going to pass in 1364 00:56:55,140 --> 00:56:57,059 our jot 1365 00:56:57,059 --> 00:56:58,740 Secret 1366 00:56:58,740 --> 00:57:00,300 like so 1367 00:57:00,300 --> 00:57:02,160 so this is where again we're using that 1368 00:57:02,160 --> 00:57:04,079 secret string that you don't want other 1369 00:57:04,079 --> 00:57:05,880 people to know 1370 00:57:05,880 --> 00:57:07,400 and we're going to say 1371 00:57:07,400 --> 00:57:11,660 rec.user is going to be verified 1372 00:57:12,839 --> 00:57:15,119 and then finally we're going to run the 1373 00:57:15,119 --> 00:57:17,880 next function so for middleware this 1374 00:57:17,880 --> 00:57:20,579 next function is what we have to use so 1375 00:57:20,579 --> 00:57:24,000 that the next one will proceed to the 1376 00:57:24,000 --> 00:57:26,579 next step of the function 1377 00:57:26,579 --> 00:57:28,680 now the way you would use this we're not 1378 00:57:28,680 --> 00:57:31,740 going to use it just yet we have no apis 1379 00:57:31,740 --> 00:57:34,859 to put this but typically for example if 1380 00:57:34,859 --> 00:57:36,839 you were to set it on this particular 1381 00:57:36,839 --> 00:57:39,119 route you can put it 1382 00:57:39,119 --> 00:57:41,460 before this or you can put it after this 1383 00:57:41,460 --> 00:57:43,559 but you just always want it before the 1384 00:57:43,559 --> 00:57:46,559 last logic and you can say verify token 1385 00:57:46,559 --> 00:57:47,940 like this 1386 00:57:47,940 --> 00:57:50,040 so if you wanted to protect this route 1387 00:57:50,040 --> 00:57:53,160 then you would have this verify token 1388 00:57:53,160 --> 00:57:55,260 function middleware 1389 00:57:55,260 --> 00:57:57,119 for the register 1390 00:57:57,119 --> 00:57:58,859 but because this is the register 1391 00:57:58,859 --> 00:58:00,480 function we don't want they're not 1392 00:58:00,480 --> 00:58:02,880 verified yet they don't have a username 1393 00:58:02,880 --> 00:58:05,160 so we don't want to put that there but 1394 00:58:05,160 --> 00:58:07,440 for the routes that we create 1395 00:58:07,440 --> 00:58:10,500 in the following moments we will need 1396 00:58:10,500 --> 00:58:12,720 verify token so that is author 1397 00:58:12,720 --> 00:58:15,960 authorization for you 1398 00:58:15,960 --> 00:58:18,240 with all that being done now we can go 1399 00:58:18,240 --> 00:58:19,980 I'm going to close all this we're going 1400 00:58:19,980 --> 00:58:22,319 to go back to our index.js and now we're 1401 00:58:22,319 --> 00:58:26,099 going to create the user's routes now 1402 00:58:26,099 --> 00:58:28,200 before we write the routes let me 1403 00:58:28,200 --> 00:58:30,720 discuss what those user routes will 1404 00:58:30,720 --> 00:58:33,300 represent so if I go over here 1405 00:58:33,300 --> 00:58:35,819 the user route we're going to need one 1406 00:58:35,819 --> 00:58:38,099 user route where we grab the particular 1407 00:58:38,099 --> 00:58:42,240 user and also if we go to an individual 1408 00:58:42,240 --> 00:58:44,880 page we should be able to grab that 1409 00:58:44,880 --> 00:58:47,400 user's routes as well or user's 1410 00:58:47,400 --> 00:58:49,380 information so we're going to have to 1411 00:58:49,380 --> 00:58:51,599 make that versatile enough so we can 1412 00:58:51,599 --> 00:58:54,000 grab any user 1413 00:58:54,000 --> 00:58:57,720 via probably just their ID 1414 00:58:57,720 --> 00:58:59,579 and then from there we're also going to 1415 00:58:59,579 --> 00:59:02,220 have get user friends so we want the 1416 00:59:02,220 --> 00:59:04,440 friends list as well 1417 00:59:04,440 --> 00:59:07,319 and then finally we want one more route 1418 00:59:07,319 --> 00:59:11,220 where we can add or remove friends so 1419 00:59:11,220 --> 00:59:13,200 there's three routes we want to create 1420 00:59:13,200 --> 00:59:16,020 under user route so if we go back to our 1421 00:59:16,020 --> 00:59:16,980 code 1422 00:59:16,980 --> 00:59:21,180 in this index.js we're going to set up 1423 00:59:21,180 --> 00:59:24,180 a separate routes for our app 1424 00:59:24,180 --> 00:59:27,059 for our Express router to use so in this 1425 00:59:27,059 --> 00:59:29,040 case we're going to do users 1426 00:59:29,040 --> 00:59:33,599 and then comma user routes like so 1427 00:59:33,599 --> 00:59:35,700 make sure you capitalize the second r 1428 00:59:35,700 --> 00:59:38,420 and then up here we're going to import 1429 00:59:38,420 --> 00:59:41,780 user routes 1430 00:59:42,540 --> 00:59:47,460 user routes from dot slash routes slash 1431 00:59:47,460 --> 00:59:50,460 users.js 1432 00:59:51,839 --> 00:59:53,520 and then we're going to go 1433 00:59:53,520 --> 00:59:55,380 to our routes folder we're going to 1434 00:59:55,380 --> 01:00:00,240 create a new file call this users.js 1435 01:00:00,599 --> 01:00:03,540 and in here we're going to import a 1436 01:00:03,540 --> 01:00:05,400 number of items I'm going to import 1437 01:00:05,400 --> 01:00:09,599 Express from Express 1438 01:00:09,599 --> 01:00:11,640 import 1439 01:00:11,640 --> 01:00:14,160 we're going to import preemptively the 1440 01:00:14,160 --> 01:00:16,260 controllers which we have not created 1441 01:00:16,260 --> 01:00:18,599 we're going to call this get user get 1442 01:00:18,599 --> 01:00:20,700 user friends 1443 01:00:20,700 --> 01:00:23,640 add remove 1444 01:00:23,640 --> 01:00:26,640 friend 1445 01:00:29,160 --> 01:00:33,200 if we get the capital and then from 1446 01:00:33,240 --> 01:00:38,940 dot dot slash controllers slash users.js 1447 01:00:39,540 --> 01:00:41,760 and we're also going to import verify 1448 01:00:41,760 --> 01:00:42,780 token 1449 01:00:42,780 --> 01:00:45,420 which is what we created 1450 01:00:45,420 --> 01:00:47,760 verified token 1451 01:00:47,760 --> 01:00:51,720 from dot dot slash middleware slash 1452 01:00:51,720 --> 01:00:54,359 auth.js 1453 01:00:54,359 --> 01:00:56,520 that's going to be this particular guide 1454 01:00:56,520 --> 01:01:00,299 that we created export cons verify token 1455 01:01:00,299 --> 01:01:02,520 you sure that's important now we have 1456 01:01:02,520 --> 01:01:04,440 everything we need so we're going to do 1457 01:01:04,440 --> 01:01:07,500 const rather equals Express 1458 01:01:07,500 --> 01:01:10,200 dot rather 1459 01:01:10,200 --> 01:01:12,900 and we're going to create read the read 1460 01:01:12,900 --> 01:01:15,660 routes the read routes represent routes 1461 01:01:15,660 --> 01:01:17,880 where we grab information we're not 1462 01:01:17,880 --> 01:01:20,160 actually saving anything to the database 1463 01:01:20,160 --> 01:01:22,079 we're not updating or changing anything 1464 01:01:22,079 --> 01:01:24,000 in the database so that's what a read 1465 01:01:24,000 --> 01:01:26,640 route is so if you are familiar with 1466 01:01:26,640 --> 01:01:31,680 crud which is create read update delete 1467 01:01:31,680 --> 01:01:34,319 the read is the r part 1468 01:01:34,319 --> 01:01:36,960 now with the users we're not going to 1469 01:01:36,960 --> 01:01:39,059 follow crud to the T 1470 01:01:39,059 --> 01:01:41,579 because we want to keep the 1471 01:01:41,579 --> 01:01:43,859 functionality Limited 1472 01:01:43,859 --> 01:01:46,980 so we can have a limited application so 1473 01:01:46,980 --> 01:01:48,240 we don't have to go through the entire 1474 01:01:48,240 --> 01:01:49,740 application if we have all those 1475 01:01:49,740 --> 01:01:51,599 features it's going to take forever and 1476 01:01:51,599 --> 01:01:53,400 forever but I want to get through the 1477 01:01:53,400 --> 01:01:55,460 main routes so here we're going to say 1478 01:01:55,460 --> 01:01:58,200 slash ID 1479 01:01:58,200 --> 01:02:01,319 comma verify token 1480 01:02:01,319 --> 01:02:05,520 comma get user so what's happening is 1481 01:02:05,520 --> 01:02:08,640 since we created this particular route 1482 01:02:08,640 --> 01:02:10,500 with users 1483 01:02:10,500 --> 01:02:14,099 this route is going to be users slash 1484 01:02:14,099 --> 01:02:18,780 sum ID so this syntax represents 1485 01:02:18,780 --> 01:02:21,960 if the user or the front end is sending 1486 01:02:21,960 --> 01:02:25,740 a particular user ID over here we can 1487 01:02:25,740 --> 01:02:29,220 grab this ID and call 1488 01:02:29,220 --> 01:02:33,059 our database with that particular ID So 1489 01:02:33,059 --> 01:02:35,579 This Is How We Do query strings from the 1490 01:02:35,579 --> 01:02:37,200 front that's what it's called you can 1491 01:02:37,200 --> 01:02:39,599 put a query string that will grab the 1492 01:02:39,599 --> 01:02:41,880 particular ID 1493 01:02:41,880 --> 01:02:44,819 and then we're going to have router.get 1494 01:02:44,819 --> 01:02:50,400 and do colon slash ID slash friends 1495 01:02:50,400 --> 01:02:53,099 we're going to verify token 1496 01:02:53,099 --> 01:02:57,020 get user friends like so 1497 01:02:57,480 --> 01:03:00,359 this will basically just this will get 1498 01:03:00,359 --> 01:03:02,339 the user and this will just grab the 1499 01:03:02,339 --> 01:03:04,140 user friends if we need to call this 1500 01:03:04,140 --> 01:03:06,839 separately 1501 01:03:06,839 --> 01:03:08,520 and then here we're going to have one 1502 01:03:08,520 --> 01:03:11,460 more and we're going to say update 1503 01:03:11,460 --> 01:03:13,859 we're going to say rather dot patch this 1504 01:03:13,859 --> 01:03:15,480 time because this is an update function 1505 01:03:15,480 --> 01:03:18,000 update function you want to use patch 1506 01:03:18,000 --> 01:03:19,920 instead 1507 01:03:19,920 --> 01:03:22,380 and in here we're going to pass an ID 1508 01:03:22,380 --> 01:03:23,640 again 1509 01:03:23,640 --> 01:03:25,760 but this time we're going to do friend 1510 01:03:25,760 --> 01:03:29,700 ID so we need both the current user who 1511 01:03:29,700 --> 01:03:32,880 is logged in and the friend ID of who we 1512 01:03:32,880 --> 01:03:35,520 want to add or remove as part of our 1513 01:03:35,520 --> 01:03:36,420 friend 1514 01:03:36,420 --> 01:03:38,579 and just note this is more like Facebook 1515 01:03:38,579 --> 01:03:40,559 where you have friends you have a friend 1516 01:03:40,559 --> 01:03:42,540 list you can remove them less like 1517 01:03:42,540 --> 01:03:44,579 Twitter where you have followers and you 1518 01:03:44,579 --> 01:03:45,780 follow them 1519 01:03:45,780 --> 01:03:47,700 so keep that in mind 1520 01:03:47,700 --> 01:03:50,400 so add remove friend and we're going to 1521 01:03:50,400 --> 01:03:52,260 just do export default 1522 01:03:52,260 --> 01:03:55,619 router so that Express knows 1523 01:03:55,619 --> 01:03:57,780 we're going to save this 1524 01:03:57,780 --> 01:03:59,460 and now we're going to set up our 1525 01:03:59,460 --> 01:04:01,859 controllers which is where all our logic 1526 01:04:01,859 --> 01:04:03,180 is going to be so we're going to create 1527 01:04:03,180 --> 01:04:05,299 a new file we're going to call this 1528 01:04:05,299 --> 01:04:08,280 users.js in controllers 1529 01:04:08,280 --> 01:04:12,839 and in here we're going to import user 1530 01:04:13,079 --> 01:04:15,299 actually 1531 01:04:15,299 --> 01:04:17,339 our intellisense is showing where the 1532 01:04:17,339 --> 01:04:19,200 model is coming from and we're going to 1533 01:04:19,200 --> 01:04:20,280 do 1534 01:04:20,280 --> 01:04:22,020 read 1535 01:04:22,020 --> 01:04:24,240 and we're gonna 1536 01:04:24,240 --> 01:04:25,799 create our first 1537 01:04:25,799 --> 01:04:29,040 function called get user 1538 01:04:29,040 --> 01:04:33,380 async Rec res 1539 01:04:33,480 --> 01:04:35,640 and creative function 1540 01:04:35,640 --> 01:04:39,200 now we're going to do try catch 1541 01:04:41,339 --> 01:04:45,839 and we're going to Res dot status 404 1542 01:04:46,319 --> 01:04:48,900 Json 1543 01:04:48,900 --> 01:04:50,280 message 1544 01:04:50,280 --> 01:04:52,680 error.message 1545 01:04:52,680 --> 01:04:55,200 we're going to have an error 1546 01:04:55,200 --> 01:04:57,359 this should be 1547 01:04:57,359 --> 01:04:59,460 like that 1548 01:04:59,460 --> 01:05:01,079 and in here 1549 01:05:01,079 --> 01:05:03,420 we're going to grab the ID from the 1550 01:05:03,420 --> 01:05:06,000 rec.param so like the query string we 1551 01:05:06,000 --> 01:05:08,940 can grab the ID from that particular 1552 01:05:08,940 --> 01:05:10,020 string 1553 01:05:10,020 --> 01:05:12,240 and we can use 1554 01:05:12,240 --> 01:05:17,000 that particular ID to grab 1555 01:05:18,359 --> 01:05:23,040 the information of the user that we need 1556 01:05:23,040 --> 01:05:25,079 and for this get user this is all we 1557 01:05:25,079 --> 01:05:27,420 need we just need to send back to the 1558 01:05:27,420 --> 01:05:28,799 front end 1559 01:05:28,799 --> 01:05:30,559 everything 1560 01:05:30,559 --> 01:05:33,960 relevant to this user after we found it 1561 01:05:33,960 --> 01:05:36,180 so this is all we need to do for this 1562 01:05:36,180 --> 01:05:37,859 particular function 1563 01:05:37,859 --> 01:05:39,180 and then from here we're going to do 1564 01:05:39,180 --> 01:05:41,339 export const get 1565 01:05:41,339 --> 01:05:43,500 user friends 1566 01:05:43,500 --> 01:05:45,119 and this is going to be the next 1567 01:05:45,119 --> 01:05:46,260 function 1568 01:05:46,260 --> 01:05:48,420 this will grab all the user friends 1569 01:05:48,420 --> 01:05:52,680 related to the ID that you specified 1570 01:05:52,680 --> 01:05:54,960 so again we're going to copy const ID 1571 01:05:54,960 --> 01:05:57,180 Rec params like this 1572 01:05:57,180 --> 01:05:58,619 paste it in 1573 01:05:58,619 --> 01:06:00,660 and I'm also going to find the user as 1574 01:06:00,660 --> 01:06:02,220 well 1575 01:06:02,220 --> 01:06:05,940 and from here I want to grab the friends 1576 01:06:05,940 --> 01:06:08,359 which we are going to use 1577 01:06:08,359 --> 01:06:10,319 promise.all because we're going to make 1578 01:06:10,319 --> 01:06:11,480 multiple 1579 01:06:11,480 --> 01:06:15,839 excuse me make multiple API calls to the 1580 01:06:15,839 --> 01:06:17,460 database 1581 01:06:17,460 --> 01:06:18,780 so we're going to do that by doing 1582 01:06:18,780 --> 01:06:21,299 userfriends.map 1583 01:06:21,299 --> 01:06:23,700 grab each ID 1584 01:06:23,700 --> 01:06:26,039 that the user has and we're going to do 1585 01:06:26,039 --> 01:06:31,160 user find by ID 1586 01:06:31,740 --> 01:06:34,440 and grab all the information from the 1587 01:06:34,440 --> 01:06:37,280 friend IDs 1588 01:06:37,859 --> 01:06:40,619 and with that we're going to make sure 1589 01:06:40,619 --> 01:06:43,140 that we can format this in the proper 1590 01:06:43,140 --> 01:06:46,280 way for the front end 1591 01:06:49,859 --> 01:06:52,140 so we're going to do friends.map 1592 01:06:52,140 --> 01:06:54,299 and we're going to pass in 1593 01:06:54,299 --> 01:06:56,880 and set up all the information that we 1594 01:06:56,880 --> 01:07:00,059 need to set so that front end will need 1595 01:07:00,059 --> 01:07:02,900 so in this case we kind of wanted to 1596 01:07:02,900 --> 01:07:06,839 modify our schema a little bit before we 1597 01:07:06,839 --> 01:07:10,039 send it back to the front end 1598 01:07:11,039 --> 01:07:12,900 and we're going to give it all these 1599 01:07:12,900 --> 01:07:14,160 parameters 1600 01:07:14,160 --> 01:07:16,940 picture path 1601 01:07:17,700 --> 01:07:20,039 and I'm just going to copy this 1602 01:07:20,039 --> 01:07:22,400 because 1603 01:07:22,500 --> 01:07:24,660 we are just going to return an object 1604 01:07:24,660 --> 01:07:27,299 with all those things that we just 1605 01:07:27,299 --> 01:07:30,260 grabbed 1606 01:07:31,859 --> 01:07:34,440 so now our four friends are all 1607 01:07:34,440 --> 01:07:36,780 formatted we have all the users all the 1608 01:07:36,780 --> 01:07:38,579 information that we need 1609 01:07:38,579 --> 01:07:41,760 and we're going to be sending this 1610 01:07:41,760 --> 01:07:44,599 to the front end 1611 01:07:44,700 --> 01:07:46,980 or matted friends like so 1612 01:07:46,980 --> 01:07:49,319 I did forget to do a try catch block 1613 01:07:49,319 --> 01:07:51,900 here so I'm going to do try 1614 01:07:51,900 --> 01:07:55,260 I'm going to cut everything in here move 1615 01:07:55,260 --> 01:08:00,140 it inside I'm going to catch 1616 01:08:00,420 --> 01:08:03,539 error like so and I'm just going to copy 1617 01:08:03,539 --> 01:08:06,119 the same error that we did before 1618 01:08:06,119 --> 01:08:08,280 now I'm going to save it save it once it 1619 01:08:08,280 --> 01:08:12,380 saves prettier we'll format 1620 01:08:13,200 --> 01:08:14,819 and then finally we're going to do the 1621 01:08:14,819 --> 01:08:17,460 update like so 1622 01:08:17,460 --> 01:08:21,000 and we're going to do add remove friend 1623 01:08:21,000 --> 01:08:22,979 so this one's kind of long so we're just 1624 01:08:22,979 --> 01:08:25,319 going to do export const add remove 1625 01:08:25,319 --> 01:08:28,560 friend and I'll show you 1626 01:08:28,560 --> 01:08:30,120 how 1627 01:08:30,120 --> 01:08:33,600 we can grab our user friends as needed 1628 01:08:33,600 --> 01:08:37,500 so I'm going to do try 1629 01:08:37,500 --> 01:08:39,359 catch 1630 01:08:39,359 --> 01:08:42,238 error again 1631 01:08:42,238 --> 01:08:45,960 to Res dot status 404 pass it in and 1632 01:08:45,960 --> 01:08:47,759 then from here we're going to do const 1633 01:08:47,759 --> 01:08:52,380 ID friend ID so we're grabbing both 1634 01:08:52,380 --> 01:08:54,920 those 1635 01:08:55,560 --> 01:08:57,899 we're going to grab the user using a 1636 01:08:57,899 --> 01:08:59,000 weight 1637 01:08:59,000 --> 01:09:01,500 user dot find 1638 01:09:01,500 --> 01:09:05,219 by ID and passing an ID so we're 1639 01:09:05,219 --> 01:09:07,920 grabbing the current user 1640 01:09:07,920 --> 01:09:10,859 as well all their all that information 1641 01:09:10,859 --> 01:09:12,899 but also we want to grab the friend 1642 01:09:12,899 --> 01:09:14,880 information so we're going to do 1643 01:09:14,880 --> 01:09:16,799 user.find by 1644 01:09:16,799 --> 01:09:19,738 ID and then passing in friend 1645 01:09:19,738 --> 01:09:21,420 ID 1646 01:09:21,420 --> 01:09:23,520 so now from here we're going to have to 1647 01:09:23,520 --> 01:09:24,779 do some 1648 01:09:24,779 --> 01:09:27,600 kind of tenuous logic a little bit 1649 01:09:27,600 --> 01:09:30,479 but we can make it work so users.friends 1650 01:09:30,479 --> 01:09:32,339 we're going to see 1651 01:09:32,339 --> 01:09:36,540 if the friend ID is included in the main 1652 01:09:36,540 --> 01:09:38,939 user's friend's ID 1653 01:09:38,939 --> 01:09:41,819 if so if they're included we want to 1654 01:09:41,819 --> 01:09:42,899 make sure 1655 01:09:42,899 --> 01:09:45,359 they are removed so if the friend is 1656 01:09:45,359 --> 01:09:46,439 already 1657 01:09:46,439 --> 01:09:49,020 if the friend ID is already part of the 1658 01:09:49,020 --> 01:09:51,779 main user's friends list we want them to 1659 01:09:51,779 --> 01:09:54,179 be removed and we do that by doing 1660 01:09:54,179 --> 01:09:56,160 user.frends 1661 01:09:56,160 --> 01:10:00,000 dot filter and we're going to pass in ID 1662 01:10:00,000 --> 01:10:01,980 and we're going to say ID does not equal 1663 01:10:01,980 --> 01:10:03,360 to friend 1664 01:10:03,360 --> 01:10:05,460 ID 1665 01:10:05,460 --> 01:10:07,980 so filter function again is a JavaScript 1666 01:10:07,980 --> 01:10:10,920 function where we can just say we're 1667 01:10:10,920 --> 01:10:12,960 going to copy this basically the same 1668 01:10:12,960 --> 01:10:16,140 array anytime this is not equal to that 1669 01:10:16,140 --> 01:10:19,500 so we're basically removing when ID is 1670 01:10:19,500 --> 01:10:22,340 equal to friend ID 1671 01:10:22,380 --> 01:10:23,940 and then we're going to say friends dot 1672 01:10:23,940 --> 01:10:25,199 friends 1673 01:10:25,199 --> 01:10:29,340 okay so sorry friend singular dot 1674 01:10:29,340 --> 01:10:32,219 friends so this friend has to you have 1675 01:10:32,219 --> 01:10:35,219 to remove their 1676 01:10:35,219 --> 01:10:38,040 the user from 1677 01:10:38,040 --> 01:10:40,380 their friends list so we do that by 1678 01:10:40,380 --> 01:10:42,960 using the same filter function except 1679 01:10:42,960 --> 01:10:47,159 we're just going to set this as ID 1680 01:10:47,159 --> 01:10:48,540 like so 1681 01:10:48,540 --> 01:10:50,940 so we're grabbing we're checking if the 1682 01:10:50,940 --> 01:10:53,580 current ID in this friend list is equal 1683 01:10:53,580 --> 01:10:55,140 to that one 1684 01:10:55,140 --> 01:10:58,860 and if so we're going to remove them 1685 01:10:58,860 --> 01:11:02,340 all right so now if they're not included 1686 01:11:02,340 --> 01:11:03,659 we're gonna 1687 01:11:03,659 --> 01:11:06,679 add them to the friend list by doing 1688 01:11:06,679 --> 01:11:10,140 user.friends.push friend ID and we also 1689 01:11:10,140 --> 01:11:12,900 want to do it from the friend as well 1690 01:11:12,900 --> 01:11:15,360 push ID 1691 01:11:15,360 --> 01:11:18,360 so essentially we're adding both of them 1692 01:11:18,360 --> 01:11:21,060 so we're doing what Facebook is doing if 1693 01:11:21,060 --> 01:11:24,540 one of them removes each other then both 1694 01:11:24,540 --> 01:11:26,100 of them will be removed the same with 1695 01:11:26,100 --> 01:11:28,440 the opposite one of them adds them it 1696 01:11:28,440 --> 01:11:29,940 gets added to both 1697 01:11:29,940 --> 01:11:33,900 so we're going to do a weight user.save 1698 01:11:33,900 --> 01:11:37,800 a weight friend dot save to make sure we 1699 01:11:37,800 --> 01:11:40,739 save this updated 1700 01:11:40,739 --> 01:11:42,900 like updated list 1701 01:11:42,900 --> 01:11:44,400 and then what we're going to do is we're 1702 01:11:44,400 --> 01:11:46,800 going to format it once again because we 1703 01:11:46,800 --> 01:11:49,260 want the friends list to be formatted as 1704 01:11:49,260 --> 01:11:52,199 we did before so we're going to grab all 1705 01:11:52,199 --> 01:11:54,900 of what we had from get user friends so 1706 01:11:54,900 --> 01:11:56,100 we're copying 1707 01:11:56,100 --> 01:11:58,980 line 19 through 26. 1708 01:11:58,980 --> 01:12:02,280 we're going to go down paste it 1709 01:12:02,280 --> 01:12:04,679 and we're gonna 1710 01:12:04,679 --> 01:12:07,260 have everything everything yeah 1711 01:12:07,260 --> 01:12:09,600 everything should be basically the same 1712 01:12:09,600 --> 01:12:11,420 so we're just going to get 1713 01:12:11,420 --> 01:12:13,679 user.friends.map we're going to call 1714 01:12:13,679 --> 01:12:15,300 each of the users we're just going to 1715 01:12:15,300 --> 01:12:17,640 grab it and then format the friends to 1716 01:12:17,640 --> 01:12:19,380 the front end so that the front end can 1717 01:12:19,380 --> 01:12:20,280 use it 1718 01:12:20,280 --> 01:12:23,219 now we're going to do 200 1719 01:12:23,219 --> 01:12:24,780 Dot 1720 01:12:24,780 --> 01:12:26,280 Json 1721 01:12:26,280 --> 01:12:28,679 formatted friends 1722 01:12:28,679 --> 01:12:31,440 and we're going to pass that in 1723 01:12:31,440 --> 01:12:33,900 and we're going to save it and now we 1724 01:12:33,900 --> 01:12:35,820 should be able to 1725 01:12:35,820 --> 01:12:38,520 have users grab users get their friends 1726 01:12:38,520 --> 01:12:40,920 list be able to add and remove so we're 1727 01:12:40,920 --> 01:12:42,060 gonna 1728 01:12:42,060 --> 01:12:44,760 our user routes all taken care of we're 1729 01:12:44,760 --> 01:12:47,100 going to go back to index.js and we're 1730 01:12:47,100 --> 01:12:49,080 going to handle the final set of routes 1731 01:12:49,080 --> 01:12:51,780 which is going to be the posts so we're 1732 01:12:51,780 --> 01:12:53,699 going to do app.use 1733 01:12:53,699 --> 01:12:57,000 slash posts in our index 1734 01:12:57,000 --> 01:12:58,440 file again 1735 01:12:58,440 --> 01:13:01,140 and I'm going to say post routes 1736 01:13:01,140 --> 01:13:02,880 and we're going to make sure we import 1737 01:13:02,880 --> 01:13:05,159 those so 1738 01:13:05,159 --> 01:13:08,159 if we go up I'm going to do import post 1739 01:13:08,159 --> 01:13:10,140 routes from 1740 01:13:10,140 --> 01:13:14,940 dot slash routes slash post dot Js 1741 01:13:14,940 --> 01:13:17,159 from a file we haven't created 1742 01:13:17,159 --> 01:13:19,140 and what I need 1743 01:13:19,140 --> 01:13:22,260 we need a routes with files so when we 1744 01:13:22,260 --> 01:13:25,440 create the post we need to allow the 1745 01:13:25,440 --> 01:13:28,140 user to be able to upload a picture and 1746 01:13:28,140 --> 01:13:30,060 that's why we need to create 1747 01:13:30,060 --> 01:13:32,580 post route over here so we're going to 1748 01:13:32,580 --> 01:13:35,460 say app.post 1749 01:13:35,460 --> 01:13:37,320 slash posts 1750 01:13:37,320 --> 01:13:39,120 and I'm going to give it a middleware 1751 01:13:39,120 --> 01:13:41,640 verify token again 1752 01:13:41,640 --> 01:13:43,080 and I'm going to make sure we import 1753 01:13:43,080 --> 01:13:44,820 that 1754 01:13:44,820 --> 01:13:46,739 if you noticed 1755 01:13:46,739 --> 01:13:48,719 when I was writing it the intellisense 1756 01:13:48,719 --> 01:13:51,300 came up so if you see this you want to 1757 01:13:51,300 --> 01:13:53,100 make sure you click it so that the 1758 01:13:53,100 --> 01:13:56,159 import comes in as well 1759 01:13:56,159 --> 01:13:58,980 all right so now going back to it I'm 1760 01:13:58,980 --> 01:14:03,900 going to do upload single that picture 1761 01:14:03,900 --> 01:14:07,320 and what this is doing is that when we 1762 01:14:07,320 --> 01:14:09,060 send from the front end the picture 1763 01:14:09,060 --> 01:14:10,380 image 1764 01:14:10,380 --> 01:14:13,560 this will grab the picture property so 1765 01:14:13,560 --> 01:14:15,300 this is the property that you're setting 1766 01:14:15,300 --> 01:14:17,880 so if you set picture and that's where 1767 01:14:17,880 --> 01:14:20,400 the image is actually located in the 1768 01:14:20,400 --> 01:14:22,500 HTTP call 1769 01:14:22,500 --> 01:14:26,040 then this will grab it and upload it 1770 01:14:26,040 --> 01:14:28,199 into the local that's what this is 1771 01:14:28,199 --> 01:14:30,179 particularly doing so you can change 1772 01:14:30,179 --> 01:14:31,800 this to whatever you want make sure 1773 01:14:31,800 --> 01:14:33,659 whatever from the front end 1774 01:14:33,659 --> 01:14:36,900 that aligns with the same property 1775 01:14:36,900 --> 01:14:39,600 and here we're going to do create post 1776 01:14:39,600 --> 01:14:41,880 and that's going to be a controller that 1777 01:14:41,880 --> 01:14:44,880 we're going to be setting as well 1778 01:14:44,880 --> 01:14:47,040 so we haven't created that yet so I'm 1779 01:14:47,040 --> 01:14:49,760 going to do import 1780 01:14:51,300 --> 01:14:53,880 post from 1781 01:14:53,880 --> 01:14:56,480 dot slash controller 1782 01:14:56,480 --> 01:15:00,480 slash post.js 1783 01:15:00,960 --> 01:15:03,679 like that 1784 01:15:04,380 --> 01:15:07,199 and then from here we can now go to our 1785 01:15:07,199 --> 01:15:08,880 routes we're going to create a new file 1786 01:15:08,880 --> 01:15:14,000 we're going to call this post dot Js 1787 01:15:15,179 --> 01:15:17,520 and here I'm going to import a number of 1788 01:15:17,520 --> 01:15:19,860 items import Express 1789 01:15:19,860 --> 01:15:23,159 from Express actually I don't want that 1790 01:15:23,159 --> 01:15:25,380 I want it to be lowercase 1791 01:15:25,380 --> 01:15:27,719 I don't want it to come from Express 1792 01:15:27,719 --> 01:15:30,900 and here I'm going to import get feed 1793 01:15:30,900 --> 01:15:35,520 posts get user posts like post so these 1794 01:15:35,520 --> 01:15:37,739 are controllers we have not created dot 1795 01:15:37,739 --> 01:15:39,480 dot slash controllers 1796 01:15:39,480 --> 01:15:42,960 slash post.js 1797 01:15:43,199 --> 01:15:47,040 and I'm going to import verified token 1798 01:15:47,040 --> 01:15:49,739 and this time the intellisense popped up 1799 01:15:49,739 --> 01:15:52,440 so we have the import we're going to say 1800 01:15:52,440 --> 01:15:55,920 router it's equal to Express dot rather 1801 01:15:55,920 --> 01:15:57,659 like before 1802 01:15:57,659 --> 01:16:00,920 and I'm going to set up read 1803 01:16:00,920 --> 01:16:05,580 and I'm going to set up update 1804 01:16:05,760 --> 01:16:08,040 and in the read I'm going to do route 1805 01:16:08,040 --> 01:16:10,140 doc router.get 1806 01:16:10,140 --> 01:16:11,699 slash 1807 01:16:11,699 --> 01:16:14,280 comma verify token 1808 01:16:14,280 --> 01:16:18,719 comma get feed posts 1809 01:16:19,560 --> 01:16:22,679 so this is going to grab the user feed 1810 01:16:22,679 --> 01:16:25,260 when we're on the home page the home 1811 01:16:25,260 --> 01:16:28,260 page is going to curate all the posts 1812 01:16:28,260 --> 01:16:30,000 actually it won't curate it's just going 1813 01:16:30,000 --> 01:16:31,860 to take every single post that exists in 1814 01:16:31,860 --> 01:16:33,239 the database and I'm just going to give 1815 01:16:33,239 --> 01:16:35,760 you every single one and obviously in 1816 01:16:35,760 --> 01:16:37,560 the production level app you want this 1817 01:16:37,560 --> 01:16:39,659 to be curated you'll have an algorithm a 1818 01:16:39,659 --> 01:16:41,760 very sophisticated algorithm nowadays 1819 01:16:41,760 --> 01:16:43,800 they're using Ai and machine learning to 1820 01:16:43,800 --> 01:16:46,739 make sure those feeds are relevant and 1821 01:16:46,739 --> 01:16:49,679 providing value for the advertisers and 1822 01:16:49,679 --> 01:16:52,260 things like that too but this is 1823 01:16:52,260 --> 01:16:53,400 basically 1824 01:16:53,400 --> 01:16:55,560 just sending all the feeds for our case 1825 01:16:55,560 --> 01:16:58,739 is to keep it simple and we also need a 1826 01:16:58,739 --> 01:17:00,420 second route 1827 01:17:00,420 --> 01:17:04,080 and this one is going to be 1828 01:17:04,080 --> 01:17:08,179 involving user ID 1829 01:17:12,000 --> 01:17:16,020 because we want to grab only the user 1830 01:17:16,020 --> 01:17:19,080 this relevant users post only 1831 01:17:19,080 --> 01:17:21,780 so that's relevant to if you go to the 1832 01:17:21,780 --> 01:17:23,760 final app build and if I click Steve 1833 01:17:23,760 --> 01:17:24,780 Ralph 1834 01:17:24,780 --> 01:17:27,420 it's only going to grab his post and in 1835 01:17:27,420 --> 01:17:29,820 his case he only has one post this will 1836 01:17:29,820 --> 01:17:32,580 show only his post on his page 1837 01:17:32,580 --> 01:17:34,140 if you go back this is going to show 1838 01:17:34,140 --> 01:17:36,120 every single post that we have in the 1839 01:17:36,120 --> 01:17:38,340 database 1840 01:17:38,340 --> 01:17:40,440 so that's the difference 1841 01:17:40,440 --> 01:17:41,640 and then from here we're going to do 1842 01:17:41,640 --> 01:17:44,520 rather.patch 1843 01:17:44,520 --> 01:17:47,699 and we're going to say slash colon ID 1844 01:17:47,699 --> 01:17:49,980 slash like 1845 01:17:49,980 --> 01:17:51,960 verify token 1846 01:17:51,960 --> 01:17:55,020 oops verify token 1847 01:17:55,020 --> 01:17:58,140 and then do like post 1848 01:17:58,140 --> 01:18:00,840 so this is for liking the post and 1849 01:18:00,840 --> 01:18:03,560 unliking it 1850 01:18:04,380 --> 01:18:06,719 and that represents obviously right here 1851 01:18:06,719 --> 01:18:09,120 you can see that it gets selected it 1852 01:18:09,120 --> 01:18:10,679 goes up and down 1853 01:18:10,679 --> 01:18:14,280 and it gets saved if you liked it 1854 01:18:14,280 --> 01:18:17,100 so I'm going to save that and now we can 1855 01:18:17,100 --> 01:18:19,739 go to our controllers we can create a 1856 01:18:19,739 --> 01:18:22,980 file called post.js and this is where 1857 01:18:22,980 --> 01:18:25,020 we're going to write our controllers 1858 01:18:25,020 --> 01:18:27,480 like we did before 1859 01:18:27,480 --> 01:18:29,880 so the post is a little more complicated 1860 01:18:29,880 --> 01:18:32,820 than the users but we should be able to 1861 01:18:32,820 --> 01:18:36,000 make through so we're going to import 1862 01:18:36,000 --> 01:18:39,000 post from 1863 01:18:39,000 --> 01:18:42,239 dot dot slash models 1864 01:18:42,239 --> 01:18:45,000 slash post 1865 01:18:45,000 --> 01:18:47,699 .js now we have not created this model 1866 01:18:47,699 --> 01:18:49,980 so we're going to do that 1867 01:18:49,980 --> 01:18:52,020 I'm going to open up our directory we're 1868 01:18:52,020 --> 01:18:54,120 going to go to the models folder we're 1869 01:18:54,120 --> 01:18:57,840 going to create a new file post Dot JS 1870 01:18:57,840 --> 01:19:01,320 and again we can refer back to our data 1871 01:19:01,320 --> 01:19:03,120 model and these are all the properties 1872 01:19:03,120 --> 01:19:05,580 that it has it has 1873 01:19:05,580 --> 01:19:08,340 its own ID so this is something we don't 1874 01:19:08,340 --> 01:19:09,960 have to specify this is either generated 1875 01:19:09,960 --> 01:19:13,320 by mongodb user ID is going to be the 1876 01:19:13,320 --> 01:19:15,420 user who posted it so we need a 1877 01:19:15,420 --> 01:19:18,179 reference then the first name last name 1878 01:19:18,179 --> 01:19:20,760 location as well 1879 01:19:20,760 --> 01:19:23,280 and then the description represents the 1880 01:19:23,280 --> 01:19:25,980 actual description of the post as well 1881 01:19:25,980 --> 01:19:28,560 as the path to the user because we have 1882 01:19:28,560 --> 01:19:31,800 the user image and then the picture 1883 01:19:31,800 --> 01:19:34,440 uh picture URL as well 1884 01:19:34,440 --> 01:19:37,679 as well as the likes so the way we store 1885 01:19:37,679 --> 01:19:39,380 the likes is going to be a little more 1886 01:19:39,380 --> 01:19:41,219 complicated we're going to have an 1887 01:19:41,219 --> 01:19:43,199 object 1888 01:19:43,199 --> 01:19:46,020 and in this object we're going to have a 1889 01:19:46,020 --> 01:19:49,440 reference of who liked it and it's just 1890 01:19:49,440 --> 01:19:51,060 going to represent a Boolean so this is 1891 01:19:51,060 --> 01:19:52,620 going to be an object and I'll show you 1892 01:19:52,620 --> 01:19:54,659 how this will be mapped out and the 1893 01:19:54,659 --> 01:19:55,980 comments is just going to be array of 1894 01:19:55,980 --> 01:19:57,480 strings now normally you would have 1895 01:19:57,480 --> 01:19:59,820 comments you could create another model 1896 01:19:59,820 --> 01:20:03,179 if you wanted to be more specific for 1897 01:20:03,179 --> 01:20:05,159 example each comment could have the 1898 01:20:05,159 --> 01:20:07,500 number of its own likes like on YouTube 1899 01:20:07,500 --> 01:20:09,540 you can have a comment and that can be 1900 01:20:09,540 --> 01:20:11,699 liked and that can have its own reply so 1901 01:20:11,699 --> 01:20:13,560 you would create a separate model for 1902 01:20:13,560 --> 01:20:16,140 that but in our case we have a very 1903 01:20:16,140 --> 01:20:18,900 simple idea which is just posting the 1904 01:20:18,900 --> 01:20:21,480 string we I did that because it makes it 1905 01:20:21,480 --> 01:20:23,820 simpler 1906 01:20:23,820 --> 01:20:26,280 but typically if you're trying to make a 1907 01:20:26,280 --> 01:20:27,960 real social media application you 1908 01:20:27,960 --> 01:20:29,699 probably want to separate that into 1909 01:20:29,699 --> 01:20:32,699 model so again data modeling is kind of 1910 01:20:32,699 --> 01:20:34,980 like you have to kind of know a little 1911 01:20:34,980 --> 01:20:36,780 bit it's a little bit more advanced so 1912 01:20:36,780 --> 01:20:38,580 if you don't fully understand how to go 1913 01:20:38,580 --> 01:20:41,219 about correctly it's a lot of trial and 1914 01:20:41,219 --> 01:20:42,659 error and then you start to see 1915 01:20:42,659 --> 01:20:44,940 different patterns 1916 01:20:44,940 --> 01:20:46,679 so I'm going to show you how the both 1917 01:20:46,679 --> 01:20:48,540 the likes and comments are set up 1918 01:20:48,540 --> 01:20:50,159 because that's those are the two most 1919 01:20:50,159 --> 01:20:51,960 complicated things here but everything 1920 01:20:51,960 --> 01:20:54,179 else is pretty self-explanatory 1921 01:20:54,179 --> 01:20:57,179 and with that let's jump into it so 1922 01:20:57,179 --> 01:20:59,880 we're going to do import mongoose from 1923 01:20:59,880 --> 01:21:01,260 mongoose 1924 01:21:01,260 --> 01:21:04,440 we're going to do a const post schema 1925 01:21:04,440 --> 01:21:07,920 I'm going to say Mongoose dot schema 1926 01:21:07,920 --> 01:21:09,540 like we did before we're going to pass 1927 01:21:09,540 --> 01:21:12,239 into the object we're going to say user 1928 01:21:12,239 --> 01:21:14,040 ID 1929 01:21:14,040 --> 01:21:16,400 and we're going to say type is string 1930 01:21:16,400 --> 01:21:20,179 required is true 1931 01:21:21,540 --> 01:21:25,219 I'm going to copy this and we're gonna 1932 01:21:26,640 --> 01:21:29,100 copy paste over here we're going to say 1933 01:21:29,100 --> 01:21:32,159 first name 1934 01:21:32,159 --> 01:21:35,040 last name 1935 01:21:35,040 --> 01:21:36,300 and over here we're going to say 1936 01:21:36,300 --> 01:21:38,600 location 1937 01:21:42,960 --> 01:21:45,199 actually this one doesn't have to be a 1938 01:21:45,199 --> 01:21:49,140 string or required we can just say 1939 01:21:49,140 --> 01:21:51,480 string like that 1940 01:21:51,480 --> 01:21:54,840 description should be a string picture 1941 01:21:54,840 --> 01:21:57,480 path should be 1942 01:21:57,480 --> 01:21:59,699 a string 1943 01:21:59,699 --> 01:22:02,040 because that's just a URL same with user 1944 01:22:02,040 --> 01:22:03,900 picture path so this represents a 1945 01:22:03,900 --> 01:22:05,640 profile image 1946 01:22:05,640 --> 01:22:08,699 it's going to be string likes is going 1947 01:22:08,699 --> 01:22:10,260 to be 1948 01:22:10,260 --> 01:22:13,860 a map so now typically you use an object 1949 01:22:13,860 --> 01:22:15,960 but this is going to be a map that's how 1950 01:22:15,960 --> 01:22:18,659 mongodb saves it and we're going to have 1951 01:22:18,659 --> 01:22:21,480 a value of Boolean 1952 01:22:21,480 --> 01:22:23,760 so all we need to do is check if the 1953 01:22:23,760 --> 01:22:27,000 user ID exists in this map and the value 1954 01:22:27,000 --> 01:22:30,300 is going to be true always if it exists 1955 01:22:30,300 --> 01:22:33,360 so if you like it you're going to add to 1956 01:22:33,360 --> 01:22:35,040 this map 1957 01:22:35,040 --> 01:22:37,380 if you don't like it you're going to 1958 01:22:37,380 --> 01:22:40,560 remove that map and the reason why I did 1959 01:22:40,560 --> 01:22:44,100 not use an array where I could store it 1960 01:22:44,100 --> 01:22:46,679 an array of strings of the user ID 1961 01:22:46,679 --> 01:22:49,080 strings to see if they liked it or not 1962 01:22:49,080 --> 01:22:50,340 but 1963 01:22:50,340 --> 01:22:52,500 if you use a map it's much more 1964 01:22:52,500 --> 01:22:55,440 efficient it's just more performant in 1965 01:22:55,440 --> 01:22:57,060 this case it won't make a deal because 1966 01:22:57,060 --> 01:22:58,560 there's not that many likes but if you 1967 01:22:58,560 --> 01:22:59,340 have 1968 01:22:59,340 --> 01:23:02,100 someone who has like 20 000 likes you're 1969 01:23:02,100 --> 01:23:04,440 gonna have to go through and loop 1970 01:23:04,440 --> 01:23:06,300 through every single one until you find 1971 01:23:06,300 --> 01:23:08,760 the ID that you're looking for 1972 01:23:08,760 --> 01:23:11,219 otherwise in our case we can just go 1973 01:23:11,219 --> 01:23:13,560 straight in an object so it's a 1974 01:23:13,560 --> 01:23:17,100 dictionary in python or whatever 1975 01:23:17,100 --> 01:23:18,420 um 1976 01:23:18,420 --> 01:23:20,940 it's basically o of one if you 1977 01:23:20,940 --> 01:23:23,400 understand those uh 1978 01:23:23,400 --> 01:23:26,699 of it's O of n versus o of one is what 1979 01:23:26,699 --> 01:23:28,080 you kind of 1980 01:23:28,080 --> 01:23:30,600 have to think of it 1981 01:23:30,600 --> 01:23:32,400 but anyways we're going to do comments 1982 01:23:32,400 --> 01:23:34,920 we're going to say type array we're 1983 01:23:34,920 --> 01:23:36,540 going to say default is going to be an 1984 01:23:36,540 --> 01:23:37,980 empty array 1985 01:23:37,980 --> 01:23:39,659 so the default value for comments is 1986 01:23:39,659 --> 01:23:41,580 going to be empty array and then here 1987 01:23:41,580 --> 01:23:43,920 I'm going to add one more 1988 01:23:43,920 --> 01:23:45,840 object this is just going to be time 1989 01:23:45,840 --> 01:23:47,760 stamps 1990 01:23:47,760 --> 01:23:50,100 sure so we have the timestamps here as 1991 01:23:50,100 --> 01:23:52,280 well 1992 01:23:53,520 --> 01:23:54,840 and 1993 01:23:54,840 --> 01:23:57,780 just like we do this is just basically 1994 01:23:57,780 --> 01:24:00,179 the Mongoose template so we do mongoose 1995 01:24:00,179 --> 01:24:03,420 dot model we say post and we're going to 1996 01:24:03,420 --> 01:24:07,440 do Post schema like so and we're going 1997 01:24:07,440 --> 01:24:10,080 to do export default post and now we 1998 01:24:10,080 --> 01:24:12,780 have our post model 1999 01:24:12,780 --> 01:24:16,260 and then from here we can go back 2000 01:24:16,260 --> 01:24:18,360 and we can continue writing the 2001 01:24:18,360 --> 01:24:19,440 functions 2002 01:24:19,440 --> 01:24:21,780 so I'm going to have a crate 2003 01:24:21,780 --> 01:24:23,640 functions 2004 01:24:23,640 --> 01:24:25,440 so this is going to be export cons 2005 01:24:25,440 --> 01:24:28,440 create post so this is going to handle 2006 01:24:28,440 --> 01:24:30,020 the function that we created on the 2007 01:24:30,020 --> 01:24:33,480 index.js file this will actually have an 2008 01:24:33,480 --> 01:24:36,900 image getting passed through 2009 01:24:36,900 --> 01:24:38,640 to the middleware 2010 01:24:38,640 --> 01:24:40,860 but obviously it doesn't make it past 2011 01:24:40,860 --> 01:24:42,600 the middleware because the middleware 2012 01:24:42,600 --> 01:24:44,940 handles the picture here in this point 2013 01:24:44,940 --> 01:24:47,820 this is just the logic of creating the 2014 01:24:47,820 --> 01:24:49,500 post 2015 01:24:49,500 --> 01:24:52,320 and okay I don't want to forget the try 2016 01:24:52,320 --> 01:24:55,620 and catch block so try catch 2017 01:24:55,620 --> 01:24:58,340 error 2018 01:24:58,560 --> 01:25:01,199 and we're going to say res dot status 2019 01:25:01,199 --> 01:25:03,360 409 2020 01:25:03,360 --> 01:25:05,340 for when we error out here I'm going to 2021 01:25:05,340 --> 01:25:09,780 say jot Json say message error 2022 01:25:09,780 --> 01:25:12,239 that message 2023 01:25:12,239 --> 01:25:14,699 so we have an error handling 2024 01:25:14,699 --> 01:25:18,739 so we can do user ID description 2025 01:25:18,739 --> 01:25:21,840 path so this is all that the front end 2026 01:25:21,840 --> 01:25:23,640 is going to send us 2027 01:25:23,640 --> 01:25:25,679 we just need a description we just need 2028 01:25:25,679 --> 01:25:27,840 the user who's posting it and the 2029 01:25:27,840 --> 01:25:29,040 picture 2030 01:25:29,040 --> 01:25:33,000 URL that the users or a picture 2031 01:25:33,000 --> 01:25:36,179 of the post image that they want 2032 01:25:36,179 --> 01:25:37,980 I'm going to say cons user is going to 2033 01:25:37,980 --> 01:25:42,900 be a weight user dot find by ID 2034 01:25:42,900 --> 01:25:45,420 and as you can see I imported the user 2035 01:25:45,420 --> 01:25:46,800 just now 2036 01:25:46,800 --> 01:25:48,840 because I forgot to import that and 2037 01:25:48,840 --> 01:25:51,480 we're going to have user ID like so 2038 01:25:51,480 --> 01:25:53,400 so we want to make sure we grab the user 2039 01:25:53,400 --> 01:25:54,960 information 2040 01:25:54,960 --> 01:25:56,760 and then we're going to create our new 2041 01:25:56,760 --> 01:26:00,540 post into our database using new post 2042 01:26:00,540 --> 01:26:02,100 like this 2043 01:26:02,100 --> 01:26:06,719 so we're going to say user ID first name 2044 01:26:06,719 --> 01:26:08,340 and the first name is going to be user 2045 01:26:08,340 --> 01:26:10,920 first name like so 2046 01:26:10,920 --> 01:26:15,300 last name same thing user dot last name 2047 01:26:15,300 --> 01:26:16,620 location 2048 01:26:16,620 --> 01:26:19,620 with user dot location 2049 01:26:19,620 --> 01:26:22,159 description 2050 01:26:22,440 --> 01:26:24,060 user picture 2051 01:26:24,060 --> 01:26:26,460 path and that comes from the user as 2052 01:26:26,460 --> 01:26:29,400 well because they have the profile image 2053 01:26:29,400 --> 01:26:31,380 and then we're also going to pass in the 2054 01:26:31,380 --> 01:26:33,540 post picture path which is just going to 2055 01:26:33,540 --> 01:26:35,520 be picture path 2056 01:26:35,520 --> 01:26:37,620 the likes is just going to be an empty 2057 01:26:37,620 --> 01:26:40,560 object because it starts with zero likes 2058 01:26:40,560 --> 01:26:43,500 if and again like I mentioned you're 2059 01:26:43,500 --> 01:26:45,719 going to have some ID over here and it's 2060 01:26:45,719 --> 01:26:47,340 going to look like this 2061 01:26:47,340 --> 01:26:51,000 so this determines if someone's liked it 2062 01:26:51,000 --> 01:26:53,100 or not if they're not listed that means 2063 01:26:53,100 --> 01:26:55,800 they have not liked it 2064 01:26:55,800 --> 01:26:58,860 and comments going to be an empty object 2065 01:26:58,860 --> 01:27:01,260 as well 2066 01:27:01,260 --> 01:27:04,560 and then here we're going to say 2067 01:27:04,560 --> 01:27:08,340 a weight new post dot save to make sure 2068 01:27:08,340 --> 01:27:09,840 we save that 2069 01:27:09,840 --> 01:27:11,940 into the mongodb 2070 01:27:11,940 --> 01:27:14,520 we're going to say con post 2071 01:27:14,520 --> 01:27:19,100 equals await post dot find 2072 01:27:21,120 --> 01:27:23,400 so basically we save the post we're 2073 01:27:23,400 --> 01:27:26,159 going to make sure we grab the post then 2074 01:27:26,159 --> 01:27:29,120 we can return it 2075 01:27:33,600 --> 01:27:35,400 because we want to be able to save 2076 01:27:35,400 --> 01:27:37,920 everything that's needed and by doing so 2077 01:27:37,920 --> 01:27:41,659 we can grab it just to make sure 2078 01:27:41,699 --> 01:27:44,520 and once that post is done 2079 01:27:44,520 --> 01:27:46,199 actually sorry sorry this is not 2080 01:27:46,199 --> 01:27:47,880 actually grabbing this particular post 2081 01:27:47,880 --> 01:27:51,900 this is grabbing all the posts 2082 01:27:51,900 --> 01:27:55,920 because once we add this post we need 2083 01:27:55,920 --> 01:27:58,500 all the posts to be returned to the 2084 01:27:58,500 --> 01:28:01,080 front end so the front end has a list of 2085 01:28:01,080 --> 01:28:03,780 the updated posts so now the news feed 2086 01:28:03,780 --> 01:28:07,560 is updated with that person's post 2087 01:28:07,560 --> 01:28:09,659 so you always have to consider what to 2088 01:28:09,659 --> 01:28:12,120 return and how the front end is going to 2089 01:28:12,120 --> 01:28:14,580 be affected by that return and that's 2090 01:28:14,580 --> 01:28:16,560 where a lot of a lot of people 2091 01:28:16,560 --> 01:28:18,960 see front end as something easy but this 2092 01:28:18,960 --> 01:28:21,659 is where things get hard because you 2093 01:28:21,659 --> 01:28:24,179 have to consider what the back end is 2094 01:28:24,179 --> 01:28:27,360 sending you you have to format that 2095 01:28:27,360 --> 01:28:31,020 and make sure that when the back end 2096 01:28:31,020 --> 01:28:32,520 sends you the information you're going 2097 01:28:32,520 --> 01:28:33,780 to have to update the front end 2098 01:28:33,780 --> 01:28:35,340 accordingly 2099 01:28:35,340 --> 01:28:37,679 so a lot of time 2100 01:28:37,679 --> 01:28:39,719 the hard parts of a big Enterprise 2101 01:28:39,719 --> 01:28:42,179 application is going to be dealing with 2102 01:28:42,179 --> 01:28:44,880 the apis how they're sending it and how 2103 01:28:44,880 --> 01:28:46,199 you're grabbing it and how you're 2104 01:28:46,199 --> 01:28:48,719 formatting it and sometimes you have 2105 01:28:48,719 --> 01:28:50,219 different restrictions because of that 2106 01:28:50,219 --> 01:28:51,960 and you know that's where things get 2107 01:28:51,960 --> 01:28:53,400 hurry 2108 01:28:53,400 --> 01:28:55,320 just a point 2109 01:28:55,320 --> 01:28:56,639 and then from here we're going to have 2110 01:28:56,639 --> 01:28:58,199 read 2111 01:28:58,199 --> 01:29:01,560 and we're going to handle the get feed 2112 01:29:01,560 --> 01:29:03,840 post function so now this is going to 2113 01:29:03,840 --> 01:29:07,440 grab all the posts of everyone so we can 2114 01:29:07,440 --> 01:29:09,659 have basically something that rep 2115 01:29:09,659 --> 01:29:11,820 represents 2116 01:29:11,820 --> 01:29:15,360 like uh news uh news feed 2117 01:29:15,360 --> 01:29:16,800 for a user 2118 01:29:16,800 --> 01:29:19,260 so again we're going to try 2119 01:29:19,260 --> 01:29:22,380 catch error 2120 01:29:22,380 --> 01:29:25,860 and this actually let's 2121 01:29:25,860 --> 01:29:28,860 change that we're going to copy this 2122 01:29:28,860 --> 01:29:31,860 409 is for the error of creating it here 2123 01:29:31,860 --> 01:29:35,239 we're going to give a 404. 2124 01:29:36,960 --> 01:29:38,820 and what we're going to do 2125 01:29:38,820 --> 01:29:40,860 is I'm just going to grab the post 2126 01:29:40,860 --> 01:29:43,020 because this is basically grabbing the 2127 01:29:43,020 --> 01:29:44,040 news feed 2128 01:29:44,040 --> 01:29:45,600 so we're going to do the same exact 2129 01:29:45,600 --> 01:29:47,760 thing and in this case we're doing 200 2130 01:29:47,760 --> 01:29:50,460 201 represents you created something 200 2131 01:29:50,460 --> 01:29:53,040 is just a successful request so this is 2132 01:29:53,040 --> 01:29:57,120 how we did a get feed very easy 2133 01:29:57,120 --> 01:29:59,340 and similarly pretty easy is going to be 2134 01:29:59,340 --> 01:30:03,780 get user feeds or get user posts 2135 01:30:03,780 --> 01:30:09,139 I'm going to say async wreck res 2136 01:30:09,179 --> 01:30:10,980 and this is going to be pretty similar 2137 01:30:10,980 --> 01:30:12,659 so I'm just going to copy the try catch 2138 01:30:12,659 --> 01:30:14,340 block like so 2139 01:30:14,340 --> 01:30:16,860 but instead what I want to do is grab 2140 01:30:16,860 --> 01:30:19,100 the user ID 2141 01:30:19,100 --> 01:30:20,880 rec.params 2142 01:30:20,880 --> 01:30:23,820 and we're going to do away post.find we 2143 01:30:23,820 --> 01:30:28,980 want to pass in user ID inside the post 2144 01:30:28,980 --> 01:30:31,380 and send the posts back 2145 01:30:31,380 --> 01:30:33,060 so we can just 2146 01:30:33,060 --> 01:30:35,100 but this is singular 2147 01:30:35,100 --> 01:30:37,020 to be consistent 2148 01:30:37,020 --> 01:30:38,940 so this will only grab the user feed 2149 01:30:38,940 --> 01:30:42,360 post because by using find just sending 2150 01:30:42,360 --> 01:30:44,699 the user ID it'll only match the post 2151 01:30:44,699 --> 01:30:48,780 that have this requirement 2152 01:30:48,780 --> 01:30:50,699 and then finally the last one is going 2153 01:30:50,699 --> 01:30:52,560 to be read which is probably the hardest 2154 01:30:52,560 --> 01:30:54,060 part 2155 01:30:54,060 --> 01:30:57,540 so we're going to have an update comment 2156 01:30:57,540 --> 01:30:59,940 and we're going to have export const 2157 01:30:59,940 --> 01:31:05,719 like post async Rec res 2158 01:31:06,900 --> 01:31:10,260 and inside here I'm just gonna 2159 01:31:10,260 --> 01:31:12,600 paste everything that we have 2160 01:31:12,600 --> 01:31:14,940 just so I don't have to 2161 01:31:14,940 --> 01:31:17,040 rewrite this 2162 01:31:17,040 --> 01:31:19,380 so I'm going to delete that I'm going to 2163 01:31:19,380 --> 01:31:21,000 keep this blank so I can write that 2164 01:31:21,000 --> 01:31:23,219 later 2165 01:31:23,219 --> 01:31:25,080 this is all good 2166 01:31:25,080 --> 01:31:27,600 and now here we can do the like so we're 2167 01:31:27,600 --> 01:31:30,239 going to grab the ID from the rec params 2168 01:31:30,239 --> 01:31:33,960 so we can grab the particular user 2169 01:31:33,960 --> 01:31:36,239 or actually grab the 2170 01:31:36,239 --> 01:31:38,580 relevant post 2171 01:31:38,580 --> 01:31:40,320 then we're also going to grab the user 2172 01:31:40,320 --> 01:31:41,100 ID 2173 01:31:41,100 --> 01:31:43,679 this time from the rec body because 2174 01:31:43,679 --> 01:31:45,420 that's how we'll be sending it from the 2175 01:31:45,420 --> 01:31:46,320 front end 2176 01:31:46,320 --> 01:31:49,380 so the ID comes from the query string 2177 01:31:49,380 --> 01:31:52,020 user ID comes from the body of the 2178 01:31:52,020 --> 01:31:54,239 request so we're going to say const the 2179 01:31:54,239 --> 01:31:57,480 body or post sorry 2180 01:31:57,480 --> 01:32:00,060 fix that const post is equal to await 2181 01:32:00,060 --> 01:32:04,080 post dot find by ID and we're going to 2182 01:32:04,080 --> 01:32:06,179 pass an ID like this 2183 01:32:06,179 --> 01:32:10,440 const is liked equals post dot likes dot 2184 01:32:10,440 --> 01:32:11,159 get 2185 01:32:11,159 --> 01:32:15,139 where we're passing in user ID like so 2186 01:32:20,580 --> 01:32:23,040 so this what this is going to do is 2187 01:32:23,040 --> 01:32:25,139 we're going to check in the likes that 2188 01:32:25,139 --> 01:32:27,620 if the user ID exists if the user ID 2189 01:32:27,620 --> 01:32:30,179 exists that means that post has been 2190 01:32:30,179 --> 01:32:32,820 liked by that particular person 2191 01:32:32,820 --> 01:32:34,800 and if so 2192 01:32:34,800 --> 01:32:36,540 we're going to say if is liked we're 2193 01:32:36,540 --> 01:32:39,600 going to say post dot likes dot delete 2194 01:32:39,600 --> 01:32:41,520 user ID 2195 01:32:41,520 --> 01:32:43,739 so again like I said there is an object 2196 01:32:43,739 --> 01:32:46,500 that includes a list 2197 01:32:46,500 --> 01:32:48,900 or as the keys is going to have all the 2198 01:32:48,900 --> 01:32:50,280 IDS 2199 01:32:50,280 --> 01:32:52,739 and if that exists we're going to delete 2200 01:32:52,739 --> 01:32:53,580 it 2201 01:32:53,580 --> 01:32:55,380 and if it doesn't exist we're going to 2202 01:32:55,380 --> 01:32:56,360 say 2203 01:32:56,360 --> 01:32:58,800 post.likes.set we're going to set user 2204 01:32:58,800 --> 01:33:01,580 ID to true 2205 01:33:06,480 --> 01:33:07,739 so again 2206 01:33:07,739 --> 01:33:10,560 deletes if it already exists sets it if 2207 01:33:10,560 --> 01:33:13,080 it doesn't exist 2208 01:33:13,080 --> 01:33:15,239 and then finally we're going to do const 2209 01:33:15,239 --> 01:33:17,760 updated post we're going to say await 2210 01:33:17,760 --> 01:33:23,580 post dot find by ID and update 2211 01:33:23,580 --> 01:33:26,400 and we're going to pass in ID 2212 01:33:26,400 --> 01:33:29,699 pass in likes of post dot likes 2213 01:33:29,699 --> 01:33:33,719 so this is how we're going to update 2214 01:33:33,719 --> 01:33:36,900 a specific post so we pass an ID we're 2215 01:33:36,900 --> 01:33:39,600 going to pass in likes to our new post 2216 01:33:39,600 --> 01:33:42,060 that we have been modifying so this is 2217 01:33:42,060 --> 01:33:43,679 going to be 2218 01:33:43,679 --> 01:33:48,179 the list of likes that we modified 2219 01:33:48,179 --> 01:33:50,100 and we're going to say new is going to 2220 01:33:50,100 --> 01:33:53,880 be true so we just want a new object 2221 01:33:53,880 --> 01:33:56,100 and we're going to say status 200 and 2222 01:33:56,100 --> 01:33:58,139 we're going to pass in the updated post 2223 01:33:58,139 --> 01:34:01,100 once we have that 2224 01:34:01,260 --> 01:34:03,060 so this 2225 01:34:03,060 --> 01:34:05,940 to recap we're grabbing the post 2226 01:34:05,940 --> 01:34:08,460 information we're grabbing whether the 2227 01:34:08,460 --> 01:34:10,380 user has liked it or not 2228 01:34:10,380 --> 01:34:12,000 and if it is liked we're going to delete 2229 01:34:12,000 --> 01:34:14,940 the user if it 2230 01:34:14,940 --> 01:34:17,280 is non-existent then we're going to set 2231 01:34:17,280 --> 01:34:18,300 it 2232 01:34:18,300 --> 01:34:21,540 and finally depending on what this post 2233 01:34:21,540 --> 01:34:23,400 thought likes is we're going to update 2234 01:34:23,400 --> 01:34:27,120 our post by finding it first and passing 2235 01:34:27,120 --> 01:34:28,800 it the new likes 2236 01:34:28,800 --> 01:34:30,239 there's a lot to take in and then 2237 01:34:30,239 --> 01:34:32,340 finally we pass in the updated post so 2238 01:34:32,340 --> 01:34:34,679 that we can update the front end 2239 01:34:34,679 --> 01:34:36,360 and just remember we always have to 2240 01:34:36,360 --> 01:34:38,460 update the front end once you hit the 2241 01:34:38,460 --> 01:34:40,139 like button 2242 01:34:40,139 --> 01:34:42,480 so this is how you clarify it on the 2243 01:34:42,480 --> 01:34:44,780 front end 2244 01:34:46,080 --> 01:34:47,940 all right that was a little bit of a 2245 01:34:47,940 --> 01:34:52,620 handful but we have now completed 2246 01:34:52,620 --> 01:34:55,080 our backend we have all the routes we 2247 01:34:55,080 --> 01:34:57,540 have everything we basically need 2248 01:34:57,540 --> 01:34:59,280 and we have most of the information 2249 01:34:59,280 --> 01:35:01,920 going to be set so then we are almost 2250 01:35:01,920 --> 01:35:04,199 ready for the front end 2251 01:35:04,199 --> 01:35:07,620 with that let's open up our terminal and 2252 01:35:07,620 --> 01:35:10,560 it seems like we have an error because 2253 01:35:10,560 --> 01:35:15,860 if I go back I go to let's say 2254 01:35:17,219 --> 01:35:20,520 users controllers users.js 2255 01:35:20,520 --> 01:35:22,739 we have the typo 2256 01:35:22,739 --> 01:35:25,260 I'm going to put user.js we should save 2257 01:35:25,260 --> 01:35:26,100 it 2258 01:35:26,100 --> 01:35:27,840 I'm going to start it and now it's 2259 01:35:27,840 --> 01:35:29,940 running 2260 01:35:29,940 --> 01:35:32,159 and after that if we go we can see the 2261 01:35:32,159 --> 01:35:35,100 front end if I refresh it I get all the 2262 01:35:35,100 --> 01:35:37,080 information that we need now we don't 2263 01:35:37,080 --> 01:35:38,820 see the post we don't see the friend 2264 01:35:38,820 --> 01:35:40,139 list because 2265 01:35:40,139 --> 01:35:43,199 this is the only person that exists on 2266 01:35:43,199 --> 01:35:46,440 this platform so what we're going to do 2267 01:35:46,440 --> 01:35:48,659 is we're going to go back if you'll see 2268 01:35:48,659 --> 01:35:50,400 the link in the description I have a 2269 01:35:50,400 --> 01:35:54,780 link to the data section of this app 2270 01:35:54,780 --> 01:35:57,960 but basically I have this folder called 2271 01:35:57,960 --> 01:36:00,360 Data 2272 01:36:00,360 --> 01:36:04,940 and I have a file called index 2273 01:36:05,820 --> 01:36:08,760 file called index.js 2274 01:36:08,760 --> 01:36:10,679 and what I'm going to do I'm going to 2275 01:36:10,679 --> 01:36:13,860 copy over from you can copy it from the 2276 01:36:13,860 --> 01:36:18,120 repo I'm going to paste it this has 2277 01:36:18,120 --> 01:36:21,780 a lot of mock data that will pass in 2278 01:36:21,780 --> 01:36:24,540 fake information about the user about 2279 01:36:24,540 --> 01:36:26,820 different users so we don't start with 2280 01:36:26,820 --> 01:36:29,820 the bank blank slate 2281 01:36:29,820 --> 01:36:33,600 so to do this and to pass this in this 2282 01:36:33,600 --> 01:36:36,120 is just a data file so we're going to go 2283 01:36:36,120 --> 01:36:39,000 to our index.js file 2284 01:36:39,000 --> 01:36:41,520 and we're going to import some of those 2285 01:36:41,520 --> 01:36:44,040 things in here so I'm going to import 2286 01:36:44,040 --> 01:36:45,960 user 2287 01:36:45,960 --> 01:36:48,800 from 2288 01:36:50,040 --> 01:36:53,340 slash models we need to pass in the 2289 01:36:53,340 --> 01:36:55,380 models 2290 01:36:55,380 --> 01:36:58,260 make sure we have the dot JS as well 2291 01:36:58,260 --> 01:37:01,020 we're going to import post 2292 01:37:01,020 --> 01:37:03,600 using intellisense and then we're also 2293 01:37:03,600 --> 01:37:05,460 going to import 2294 01:37:05,460 --> 01:37:09,659 users and posts from 2295 01:37:09,659 --> 01:37:14,040 the data file or data folder we created 2296 01:37:14,040 --> 01:37:16,080 JS like so 2297 01:37:16,080 --> 01:37:18,780 so that exists over here there's a user 2298 01:37:18,780 --> 01:37:20,340 section there's also 2299 01:37:20,340 --> 01:37:22,620 a post section down there 2300 01:37:22,620 --> 01:37:25,679 and what we're going to do is when we 2301 01:37:25,679 --> 01:37:29,760 start this up we're going to manually 2302 01:37:29,760 --> 01:37:32,460 inject this information and we're going 2303 01:37:32,460 --> 01:37:34,880 to do that 2304 01:37:35,100 --> 01:37:37,920 doing user dot insert 2305 01:37:37,920 --> 01:37:40,520 many 2306 01:37:40,620 --> 01:37:42,840 we're going to pass in users 2307 01:37:42,840 --> 01:37:46,380 and then post dot insert many 2308 01:37:46,380 --> 01:37:48,780 posts now what you have to be careful of 2309 01:37:48,780 --> 01:37:51,179 is that you only want to 2310 01:37:51,179 --> 01:37:54,380 add this data 2311 01:37:54,600 --> 01:37:56,100 one time 2312 01:37:56,100 --> 01:37:57,719 so right here 2313 01:37:57,719 --> 01:38:00,659 I'm going to save it 2314 01:38:00,659 --> 01:38:03,360 and it's going to insert all the data 2315 01:38:03,360 --> 01:38:06,000 but if I save it again it's going to 2316 01:38:06,000 --> 01:38:07,320 restart it's gonna 2317 01:38:07,320 --> 01:38:09,179 add duplicate information so I'm going 2318 01:38:09,179 --> 01:38:11,340 to comment this out so only when I need 2319 01:38:11,340 --> 01:38:13,139 to I'll use it 2320 01:38:13,139 --> 01:38:15,960 let's save it now if I go to mongodb 2321 01:38:15,960 --> 01:38:18,719 before we go and check I'm going to 2322 01:38:18,719 --> 01:38:21,320 refresh 2323 01:38:22,560 --> 01:38:25,080 and we when we refresh 2324 01:38:25,080 --> 01:38:28,320 we should be able to see 2325 01:38:28,320 --> 01:38:32,179 all the documents that exists 2326 01:38:33,000 --> 01:38:34,739 all right and then as you can see we 2327 01:38:34,739 --> 01:38:37,080 have six pieces of information these are 2328 01:38:37,080 --> 01:38:40,320 different posts and then we go to users 2329 01:38:40,320 --> 01:38:42,900 we have 10 different users 2330 01:38:42,900 --> 01:38:44,940 perfect so that's how you can manually 2331 01:38:44,940 --> 01:38:48,480 input data into the database just 2332 01:38:48,480 --> 01:38:50,880 for you know like use usability purposes 2333 01:38:50,880 --> 01:38:53,100 you want some fake data so that you can 2334 01:38:53,100 --> 01:38:54,840 actually use the app 2335 01:38:54,840 --> 01:38:57,239 and so if I go to my app now and I 2336 01:38:57,239 --> 01:38:59,699 refresh the page now we should be able 2337 01:38:59,699 --> 01:39:01,320 to see 2338 01:39:01,320 --> 01:39:03,000 all our posts 2339 01:39:03,000 --> 01:39:04,739 and what we can do we still don't have 2340 01:39:04,739 --> 01:39:06,300 friends for this person but we can add 2341 01:39:06,300 --> 01:39:09,480 friend like that we can add them as well 2342 01:39:09,480 --> 01:39:11,820 we're going to add them as well and we 2343 01:39:11,820 --> 01:39:13,980 can go and click onto that particular 2344 01:39:13,980 --> 01:39:16,380 user we can see their friends 2345 01:39:16,380 --> 01:39:18,540 we can see their friend list which is us 2346 01:39:18,540 --> 01:39:20,880 and then we can see their posts as well 2347 01:39:20,880 --> 01:39:23,460 we can like it 2348 01:39:23,460 --> 01:39:24,659 and such 2349 01:39:24,659 --> 01:39:26,699 all right so if you go here there is a 2350 01:39:26,699 --> 01:39:29,400 bug that I just found so if I hit this 2351 01:39:29,400 --> 01:39:31,560 it's going to break that's because if 2352 01:39:31,560 --> 01:39:33,420 you go to the Post model I accidentally 2353 01:39:33,420 --> 01:39:35,880 had a plural for the types so we're 2354 01:39:35,880 --> 01:39:37,800 going to delete that I'm going to save 2355 01:39:37,800 --> 01:39:38,880 this 2356 01:39:38,880 --> 01:39:43,139 and if I go back to my database I 2357 01:39:43,139 --> 01:39:45,000 want to 2358 01:39:45,000 --> 01:39:46,860 I'm going to delete both of these 2359 01:39:46,860 --> 01:39:48,780 because it's going to mess up the data 2360 01:39:48,780 --> 01:39:50,699 so as you can see 2361 01:39:50,699 --> 01:39:53,040 if you have a bug sometimes you have to 2362 01:39:53,040 --> 01:39:55,199 redo it so you have a fresh fresh 2363 01:39:55,199 --> 01:39:57,120 collection so I'm going to delete both 2364 01:39:57,120 --> 01:39:58,500 of these 2365 01:39:58,500 --> 01:40:00,960 by dropping them 2366 01:40:00,960 --> 01:40:04,560 and I'm going to re-insert 2367 01:40:04,560 --> 01:40:07,560 this information right here 2368 01:40:07,560 --> 01:40:10,800 so I'm going to uncomment this out 2369 01:40:10,800 --> 01:40:13,460 save it 2370 01:40:13,860 --> 01:40:16,980 and then you comment it out again you 2371 01:40:16,980 --> 01:40:19,500 can save it now the information should 2372 01:40:19,500 --> 01:40:23,120 now be there if you hit refresh 2373 01:40:23,520 --> 01:40:27,710 and there you go and if we refresh it 2374 01:40:27,710 --> 01:40:30,810 [Music] 2375 01:40:32,940 --> 01:40:37,020 and because I have an application or 2376 01:40:37,020 --> 01:40:40,460 I have persist storage 2377 01:40:40,980 --> 01:40:45,320 and so I have to recreate the user 2378 01:40:47,100 --> 01:40:48,960 application big 2379 01:40:48,960 --> 01:40:51,560 a patient 2380 01:40:52,380 --> 01:40:56,639 I'm just going to add a random user fake 2381 01:40:56,639 --> 01:40:59,219 person make sure this is spelled 2382 01:40:59,219 --> 01:41:00,239 correctly 2383 01:41:00,239 --> 01:41:04,440 fake person we're gonna register and 2384 01:41:04,440 --> 01:41:05,580 we're gonna 2385 01:41:05,580 --> 01:41:08,480 log in again 2386 01:41:10,800 --> 01:41:13,380 and now we should see the comment all 2387 01:41:13,380 --> 01:41:14,699 right perfect 2388 01:41:14,699 --> 01:41:16,739 sorry for the mistakes 2389 01:41:16,739 --> 01:41:18,960 there we go we have a friends list we 2390 01:41:18,960 --> 01:41:22,380 have everything all set up 2391 01:41:22,380 --> 01:41:24,420 with the back end everything's good 2392 01:41:24,420 --> 01:41:27,600 everything works we can now finally move 2393 01:41:27,600 --> 01:41:30,000 on to the front end 2394 01:41:30,000 --> 01:41:32,580 that we have everything set up on our 2395 01:41:32,580 --> 01:41:35,100 back end we have all the entire folder 2396 01:41:35,100 --> 01:41:38,880 completed out now we can start finally 2397 01:41:38,880 --> 01:41:41,280 on our front end so I'm going to go back 2398 01:41:41,280 --> 01:41:43,380 I'm actually just going to close a bunch 2399 01:41:43,380 --> 01:41:46,080 of these folders so we can keep this 2400 01:41:46,080 --> 01:41:48,060 clean 2401 01:41:48,060 --> 01:41:50,460 close all of this and we're just going 2402 01:41:50,460 --> 01:41:53,520 to have our terminal open up like this 2403 01:41:53,520 --> 01:41:55,619 and what I'm going to do is I'm going to 2404 01:41:55,619 --> 01:41:58,500 go into the Parent Directory 2405 01:41:58,500 --> 01:42:02,280 we're going to write MPX create react 2406 01:42:02,280 --> 01:42:05,880 app client however if you do not have 2407 01:42:05,880 --> 01:42:08,520 MPX installed 2408 01:42:08,520 --> 01:42:10,500 I will write the command where you can 2409 01:42:10,500 --> 01:42:12,300 install it so since we have node 2410 01:42:12,300 --> 01:42:14,900 installed we can run this so 2411 01:42:14,900 --> 01:42:18,480 npmi-g MPX so if you don't have MPX 2412 01:42:18,480 --> 01:42:20,100 installed just type that command and 2413 01:42:20,100 --> 01:42:22,199 it's going to install the MPX package 2414 01:42:22,199 --> 01:42:24,360 for you so I'm just going to delete that 2415 01:42:24,360 --> 01:42:26,219 and I'm going to run npx create 2416 01:42:26,219 --> 01:42:28,500 react.client 2417 01:42:28,500 --> 01:42:30,300 and we're going to wait for that to 2418 01:42:30,300 --> 01:42:31,619 finish 2419 01:42:31,619 --> 01:42:33,840 that's installed we're going to go into 2420 01:42:33,840 --> 01:42:35,820 our client directory 2421 01:42:35,820 --> 01:42:37,440 and we're going to be installing a 2422 01:42:37,440 --> 01:42:39,420 number of packages so I'm going to be 2423 01:42:39,420 --> 01:42:42,360 installing react Redux Redux being the 2424 01:42:42,360 --> 01:42:44,040 most popular Enterprise level State 2425 01:42:44,040 --> 01:42:48,840 Management tool in an at Redux JS slash 2426 01:42:48,840 --> 01:42:51,239 toolkit 2427 01:42:51,239 --> 01:42:54,000 toolkit being a very easy way to use 2428 01:42:54,000 --> 01:42:56,760 Redux it's a wrapper around Redux that 2429 01:42:56,760 --> 01:42:58,619 makes it very very easy and highly 2430 01:42:58,619 --> 01:43:01,560 recommend as the main State Management 2431 01:43:01,560 --> 01:43:04,380 library that you can use and then I'm 2432 01:43:04,380 --> 01:43:07,800 going to use Redux persist so that you 2433 01:43:07,800 --> 01:43:09,960 can store the state selectively store 2434 01:43:09,960 --> 01:43:13,679 State into local storage if you need to 2435 01:43:13,679 --> 01:43:16,560 so if we want to save our user and token 2436 01:43:16,560 --> 01:43:18,780 information into local state so that 2437 01:43:18,780 --> 01:43:20,760 when the user closes the tab and they 2438 01:43:20,760 --> 01:43:22,619 come back the information is still there 2439 01:43:22,619 --> 01:43:24,719 in the browser 2440 01:43:24,719 --> 01:43:27,360 and then react Drop Zones so this is a 2441 01:43:27,360 --> 01:43:29,100 component that will handle 2442 01:43:29,100 --> 01:43:32,280 file upload and file handling on the 2443 01:43:32,280 --> 01:43:33,840 front end so we can send it to the back 2444 01:43:33,840 --> 01:43:35,100 end 2445 01:43:35,100 --> 01:43:39,179 dot EnV for environment variables formic 2446 01:43:39,179 --> 01:43:41,760 for form handling and then yup with 2447 01:43:41,760 --> 01:43:43,199 validation 2448 01:43:43,199 --> 01:43:47,639 react router Dom at six for handling 2449 01:43:47,639 --> 01:43:49,380 react rather 2450 01:43:49,380 --> 01:43:52,139 different routes and different pages and 2451 01:43:52,139 --> 01:43:55,380 finally material UI so material UI has a 2452 01:43:55,380 --> 01:43:56,760 number of packages that we need to 2453 01:43:56,760 --> 01:43:58,020 install 2454 01:43:58,020 --> 01:44:01,440 first is going to be at mui material at 2455 01:44:01,440 --> 01:44:03,360 emotion slash react 2456 01:44:03,360 --> 01:44:06,119 at emotion styled 2457 01:44:06,119 --> 01:44:11,400 at m-u-y slash icons material 2458 01:44:11,400 --> 01:44:12,719 we're going to hit enter I'm going to 2459 01:44:12,719 --> 01:44:14,699 wait for that to install 2460 01:44:14,699 --> 01:44:16,320 and then one thing I want to get out of 2461 01:44:16,320 --> 01:44:18,239 the way is I'm going to open up or 2462 01:44:18,239 --> 01:44:20,580 explore I'm going to go to server I'm 2463 01:44:20,580 --> 01:44:22,380 going to go to public and then see the 2464 01:44:22,380 --> 01:44:23,940 assets 2465 01:44:23,940 --> 01:44:26,400 I'm going to click on the LinkedIn and 2466 01:44:26,400 --> 01:44:28,679 the Twitter 2467 01:44:28,679 --> 01:44:30,840 I'm going to click both 2468 01:44:30,840 --> 01:44:32,699 I'm going to copy 2469 01:44:32,699 --> 01:44:35,580 and Insider client in our public I'm 2470 01:44:35,580 --> 01:44:38,340 going to create a folder called assets 2471 01:44:38,340 --> 01:44:40,199 and I'm going to paste it here 2472 01:44:40,199 --> 01:44:41,639 we're going to be needing these two 2473 01:44:41,639 --> 01:44:43,860 images on the front end and this makes 2474 01:44:43,860 --> 01:44:46,380 it very convenient 2475 01:44:46,380 --> 01:44:48,420 I'm going to close these 2476 01:44:48,420 --> 01:44:51,540 and then go back to our source and in 2477 01:44:51,540 --> 01:44:53,520 here I'm going to be deleting a number 2478 01:44:53,520 --> 01:44:57,060 of files set up tests report web vitals 2479 01:44:57,060 --> 01:44:59,900 logo SVG 2480 01:44:59,900 --> 01:45:01,460 app.test.js 2481 01:45:01,460 --> 01:45:04,320 app.css we're going to be deleting all 2482 01:45:04,320 --> 01:45:05,639 these files 2483 01:45:05,639 --> 01:45:08,699 we're going to go to index.js after 2484 01:45:08,699 --> 01:45:10,380 we're going to delete this comment and 2485 01:45:10,380 --> 01:45:12,239 the function invocation 2486 01:45:12,239 --> 01:45:14,460 and as well as the import of report web 2487 01:45:14,460 --> 01:45:16,139 vitals 2488 01:45:16,139 --> 01:45:18,719 save that go to app.js I'm going to 2489 01:45:18,719 --> 01:45:21,060 delete everything in the header 2490 01:45:21,060 --> 01:45:23,219 lowercase this app 2491 01:45:23,219 --> 01:45:25,380 delete this logo 2492 01:45:25,380 --> 01:45:28,320 and we should be good to go for here 2493 01:45:28,320 --> 01:45:31,560 I'm going to import some Google fonts so 2494 01:45:31,560 --> 01:45:33,179 I'm going to go to fonts.google.com 2495 01:45:33,179 --> 01:45:35,340 which is in the link in the description 2496 01:45:35,340 --> 01:45:37,860 below and we're going to search up a 2497 01:45:37,860 --> 01:45:41,060 font called Rubik 2498 01:45:41,520 --> 01:45:43,980 Rubik is a pretty nice balanced font 2499 01:45:43,980 --> 01:45:46,020 which is a Sans serif 2500 01:45:46,020 --> 01:45:48,119 and provides us with a little bit of a 2501 01:45:48,119 --> 01:45:50,159 different Unique Style than you know the 2502 01:45:50,159 --> 01:45:53,100 regular ones you see like open sense 2503 01:45:53,100 --> 01:45:55,739 so we're going to grab 2504 01:45:55,739 --> 01:45:58,139 400 500 2505 01:45:58,139 --> 01:46:01,380 and 700. 2506 01:46:01,380 --> 01:46:04,500 we're going to open up this tab and 2507 01:46:04,500 --> 01:46:06,659 we're going to see at import we're going 2508 01:46:06,659 --> 01:46:09,239 to copy everything in between the styles 2509 01:46:09,239 --> 01:46:10,920 copy that 2510 01:46:10,920 --> 01:46:13,679 go into our index.css 2511 01:46:13,679 --> 01:46:16,199 we're going to delete everything in here 2512 01:46:16,199 --> 01:46:18,659 and we're going to do we're just going 2513 01:46:18,659 --> 01:46:22,020 to paste everything we copied 2514 01:46:22,020 --> 01:46:24,719 and in here I'm going to write some 2515 01:46:24,719 --> 01:46:27,540 CSS just this is the only CSS we're 2516 01:46:27,540 --> 01:46:29,820 going to be writing globally so we're 2517 01:46:29,820 --> 01:46:32,219 going to HTML comma 2518 01:46:32,219 --> 01:46:34,440 #root 2519 01:46:34,440 --> 01:46:35,820 dot app 2520 01:46:35,820 --> 01:46:38,219 and we're going to do hate height 100 2521 01:46:38,219 --> 01:46:39,600 percent 2522 01:46:39,600 --> 01:46:43,080 width of hundred percent and a font 2523 01:46:43,080 --> 01:46:44,760 family 2524 01:46:44,760 --> 01:46:46,920 of Rubik 2525 01:46:46,920 --> 01:46:50,580 I'm gonna give it a Sans serve as backup 2526 01:46:50,580 --> 01:46:52,679 and we're going to be saving that 2527 01:46:52,679 --> 01:46:54,960 that we're going to add one more file to 2528 01:46:54,960 --> 01:46:55,860 client 2529 01:46:55,860 --> 01:46:57,719 and this is going to be called 2530 01:46:57,719 --> 01:47:00,500 Js 2531 01:47:01,340 --> 01:47:04,260 config dot Json 2532 01:47:04,260 --> 01:47:05,820 and what we're going to do is we're 2533 01:47:05,820 --> 01:47:07,619 going to add compiler 2534 01:47:07,619 --> 01:47:10,260 options 2535 01:47:10,260 --> 01:47:12,780 and do base URL 2536 01:47:12,780 --> 01:47:14,639 and we're going to add this as Source 2537 01:47:14,639 --> 01:47:17,699 directory and we're going to do 2538 01:47:17,699 --> 01:47:19,800 include 2539 01:47:19,800 --> 01:47:21,840 colon 2540 01:47:21,840 --> 01:47:25,020 source and now what this is doing is 2541 01:47:25,020 --> 01:47:27,540 that when you import different files 2542 01:47:27,540 --> 01:47:30,780 into other files you can just do 2543 01:47:30,780 --> 01:47:33,360 you can just start from source 2544 01:47:33,360 --> 01:47:35,760 that means when we code it up it's 2545 01:47:35,760 --> 01:47:37,560 pretty simple to understand it makes our 2546 01:47:37,560 --> 01:47:39,540 lives a little bit easier so we're going 2547 01:47:39,540 --> 01:47:41,580 to save that and close that 2548 01:47:41,580 --> 01:47:42,719 and 2549 01:47:42,719 --> 01:47:45,239 the next thing we want to talk about is 2550 01:47:45,239 --> 01:47:48,000 our react Redux file folder architecture 2551 01:47:48,000 --> 01:47:51,719 and react router setup so the way we're 2552 01:47:51,719 --> 01:47:53,280 going to set this up is we're going to 2553 01:47:53,280 --> 01:47:56,880 set it up based on scenes or essentially 2554 01:47:56,880 --> 01:48:00,420 how the UI looks so in this case if I go 2555 01:48:00,420 --> 01:48:02,880 back to the completed application we're 2556 01:48:02,880 --> 01:48:05,520 going to have a home page like this 2557 01:48:05,520 --> 01:48:07,739 then we're also going to have a separate 2558 01:48:07,739 --> 01:48:09,659 page called we're going to call this 2559 01:48:09,659 --> 01:48:12,179 profile page as well and then if you log 2560 01:48:12,179 --> 01:48:13,080 out 2561 01:48:13,080 --> 01:48:16,440 this will be the login page and we're 2562 01:48:16,440 --> 01:48:18,000 also going to have a nav bar which is 2563 01:48:18,000 --> 01:48:19,380 going to be a separate thing because it 2564 01:48:19,380 --> 01:48:21,300 exists globally 2565 01:48:21,300 --> 01:48:22,500 and then we're also going to have 2566 01:48:22,500 --> 01:48:26,280 components that are shared and inside of 2567 01:48:26,280 --> 01:48:28,800 each one we're going to have these 2568 01:48:28,800 --> 01:48:32,219 things I'll call these widgets so the 2569 01:48:32,219 --> 01:48:34,619 widgets you saw with the posts a single 2570 01:48:34,619 --> 01:48:36,659 post will be its own widget we're going 2571 01:48:36,659 --> 01:48:38,760 to have the user widget you're going to 2572 01:48:38,760 --> 01:48:40,500 have the friend list widget 2573 01:48:40,500 --> 01:48:42,119 as well as like that 2574 01:48:42,119 --> 01:48:44,219 but we're also going to organize via the 2575 01:48:44,219 --> 01:48:46,199 pages as well and the way we're going to 2576 01:48:46,199 --> 01:48:47,580 do this is we're going to create a new 2577 01:48:47,580 --> 01:48:48,540 folder 2578 01:48:48,540 --> 01:48:51,119 we're going to call this 2579 01:48:51,119 --> 01:48:53,520 scenes 2580 01:48:53,520 --> 01:48:54,840 and we're going to create a folder 2581 01:48:54,840 --> 01:48:57,420 called home page 2582 01:48:57,420 --> 01:48:59,340 another folder called 2583 01:48:59,340 --> 01:49:02,360 login page 2584 01:49:03,000 --> 01:49:06,980 folder called profile page 2585 01:49:07,560 --> 01:49:09,179 file called 2586 01:49:09,179 --> 01:49:12,000 navbar 2587 01:49:12,000 --> 01:49:15,659 and a scene is called widgets 2588 01:49:15,659 --> 01:49:19,139 so these home page login page navbar 2589 01:49:19,139 --> 01:49:21,119 profile page these are 2590 01:49:21,119 --> 01:49:24,179 basically portals into which we set up 2591 01:49:24,179 --> 01:49:26,340 the layouts or sections where we set up 2592 01:49:26,340 --> 01:49:29,040 the layouts for our components 2593 01:49:29,040 --> 01:49:30,900 then we're going to have another folder 2594 01:49:30,900 --> 01:49:32,460 outside the scenes folder called 2595 01:49:32,460 --> 01:49:34,800 components so these are components that 2596 01:49:34,800 --> 01:49:37,920 we can reuse throughout so if any time 2597 01:49:37,920 --> 01:49:39,780 we're we're using a component that's 2598 01:49:39,780 --> 01:49:41,280 going to be used in multiple locations 2599 01:49:41,280 --> 01:49:43,260 we can put this into components they're 2600 01:49:43,260 --> 01:49:45,900 going to be separate idea from widgets 2601 01:49:45,900 --> 01:49:47,580 and then finally we're going to have 2602 01:49:47,580 --> 01:49:50,219 another folder called State and this is 2603 01:49:50,219 --> 01:49:53,159 where we're going to have our Redux and 2604 01:49:53,159 --> 01:49:55,500 toolkit information and that's going to 2605 01:49:55,500 --> 01:49:57,480 be separate as well to keep your data 2606 01:49:57,480 --> 01:49:59,400 and the component separate is usually 2607 01:49:59,400 --> 01:50:02,280 ideal sometimes you have to connect them 2608 01:50:02,280 --> 01:50:04,619 together but in this case it's very nice 2609 01:50:04,619 --> 01:50:07,139 to have them separate so we're going to 2610 01:50:07,139 --> 01:50:10,020 have an index.js over here 2611 01:50:10,020 --> 01:50:12,300 just to set these things up I'm going to 2612 01:50:12,300 --> 01:50:14,880 create an index.js in our home page 2613 01:50:14,880 --> 01:50:18,000 actually this should be jsx just FYI the 2614 01:50:18,000 --> 01:50:20,580 difference between JS and jsx is that 2615 01:50:20,580 --> 01:50:23,760 jsx represents comp files that have 2616 01:50:23,760 --> 01:50:26,100 components react components in them 2617 01:50:26,100 --> 01:50:28,320 but it's just more of a syntactic sugar 2618 01:50:28,320 --> 01:50:31,500 what that means is just it just a 2619 01:50:31,500 --> 01:50:33,960 different way to identify what file has 2620 01:50:33,960 --> 01:50:37,020 components other files don't and in here 2621 01:50:37,020 --> 01:50:38,820 we're just going to do const 2622 01:50:38,820 --> 01:50:40,199 home 2623 01:50:40,199 --> 01:50:43,860 page capitalized 2624 01:50:43,980 --> 01:50:46,500 and I'm just going to do return 2625 01:50:46,500 --> 01:50:49,560 and I'm just going to say div 2626 01:50:49,560 --> 01:50:51,300 I'm just going to put a div in here and 2627 01:50:51,300 --> 01:50:54,900 say home page 2628 01:50:54,900 --> 01:50:58,199 I'm going to do export default home page 2629 01:50:58,199 --> 01:51:00,360 so right now I am just setting up the 2630 01:51:00,360 --> 01:51:04,080 skeleton just so we can 2631 01:51:04,080 --> 01:51:06,420 have a non-error when we import it so 2632 01:51:06,420 --> 01:51:07,800 I'm going to do this I'm going to copy 2633 01:51:07,800 --> 01:51:08,699 this 2634 01:51:08,699 --> 01:51:11,580 create another one in the login page 2635 01:51:11,580 --> 01:51:16,580 like this paste it I'm going to 2636 01:51:16,679 --> 01:51:18,480 select both of those I'm going to change 2637 01:51:18,480 --> 01:51:19,619 this to 2638 01:51:19,619 --> 01:51:22,739 login page same thing 2639 01:51:22,739 --> 01:51:25,400 over here 2640 01:51:25,860 --> 01:51:28,619 and copy and paste it 2641 01:51:28,619 --> 01:51:31,440 index.js or actually 2642 01:51:31,440 --> 01:51:34,159 jsx 2643 01:51:34,320 --> 01:51:37,139 we're going to paste it 2644 01:51:37,139 --> 01:51:39,420 I'm just going to call this profile page 2645 01:51:39,420 --> 01:51:41,119 with capitalize doesn't really matter 2646 01:51:41,119 --> 01:51:43,860 this will be a temporary and we're going 2647 01:51:43,860 --> 01:51:46,739 to do the same thing for navbar 2648 01:51:46,739 --> 01:51:49,380 as a temporary placeholder 2649 01:51:49,380 --> 01:51:50,639 so we're gonna 2650 01:51:50,639 --> 01:51:52,440 do that nav 2651 01:51:52,440 --> 01:51:53,820 bar 2652 01:51:53,820 --> 01:51:56,699 like so I didn't save this one so I'm 2653 01:51:56,699 --> 01:51:59,719 going to close all of these 2654 01:52:00,600 --> 01:52:02,699 and now we should be 2655 01:52:02,699 --> 01:52:05,880 pretty much set for our layout 2656 01:52:05,880 --> 01:52:07,619 and with this we're going to go to our 2657 01:52:07,619 --> 01:52:10,440 app.js file I'm going to close this and 2658 01:52:10,440 --> 01:52:12,060 actually we can just delete the import 2659 01:52:12,060 --> 01:52:15,300 from App CSS because we deleted that and 2660 01:52:15,300 --> 01:52:17,159 we're going to be importing a number of 2661 01:52:17,159 --> 01:52:19,040 items so we're going to import 2662 01:52:19,040 --> 01:52:21,659 browser router 2663 01:52:21,659 --> 01:52:23,580 navigate 2664 01:52:23,580 --> 01:52:25,199 routes 2665 01:52:25,199 --> 01:52:32,179 and Route all from react router Dom 2666 01:52:33,239 --> 01:52:35,520 and then we're going to import home page 2667 01:52:35,520 --> 01:52:38,940 from the scene we created and by the way 2668 01:52:38,940 --> 01:52:40,739 this is the whole purpose of the JS 2669 01:52:40,739 --> 01:52:44,880 config Json this allows us to reference 2670 01:52:44,880 --> 01:52:47,280 scenes instead of having to do a lot of 2671 01:52:47,280 --> 01:52:49,440 relative Imports just like that 2672 01:52:49,440 --> 01:52:52,020 so this makes it very convenient in many 2673 01:52:52,020 --> 01:52:54,420 cases this is not that important over 2674 01:52:54,420 --> 01:52:56,100 here but in other cases this will be 2675 01:52:56,100 --> 01:52:58,380 quite useful keeps it very clean and 2676 01:52:58,380 --> 01:53:00,540 then we're going to import login page as 2677 01:53:00,540 --> 01:53:01,260 well 2678 01:53:01,260 --> 01:53:06,179 and then import profile page from that 2679 01:53:06,179 --> 01:53:08,340 then I'm going to go into our component 2680 01:53:08,340 --> 01:53:11,460 I'm going to write const mode 2681 01:53:11,460 --> 01:53:13,679 equals 2682 01:53:13,679 --> 01:53:16,280 use 2683 01:53:56,639 --> 01:53:58,860 all right and then from here I'm going 2684 01:53:58,860 --> 01:54:00,840 to go into our component 2685 01:54:00,840 --> 01:54:03,480 and I'm going to go into our between our 2686 01:54:03,480 --> 01:54:07,800 div I'm going to put browser router 2687 01:54:07,800 --> 01:54:10,800 like so close it 2688 01:54:10,800 --> 01:54:13,139 so we can use our routes 2689 01:54:13,139 --> 01:54:16,800 and we can set up our routes as well 2690 01:54:16,800 --> 01:54:18,659 I'm gonna have that and we're going to 2691 01:54:18,659 --> 01:54:20,040 put our route 2692 01:54:20,040 --> 01:54:23,400 of path equals 2693 01:54:23,400 --> 01:54:26,100 slash and we're going to say element 2694 01:54:26,100 --> 01:54:29,100 is going to be login 2695 01:54:29,100 --> 01:54:31,080 page 2696 01:54:31,080 --> 01:54:33,060 and I'm going to close this route so 2697 01:54:33,060 --> 01:54:35,580 this will essentially be our login page 2698 01:54:35,580 --> 01:54:38,280 so that's the page people will 2699 01:54:38,280 --> 01:54:40,500 come back I'm going to copy and paste 2700 01:54:40,500 --> 01:54:41,940 this 2701 01:54:41,940 --> 01:54:43,679 one I'm going to say this should be 2702 01:54:43,679 --> 01:54:45,060 slash home 2703 01:54:45,060 --> 01:54:47,159 and in here it's going to be 2704 01:54:47,159 --> 01:54:48,719 home page 2705 01:54:48,719 --> 01:54:50,400 and we're going to do this one more time 2706 01:54:50,400 --> 01:54:53,520 and we're going to set this for each 2707 01:54:53,520 --> 01:54:55,080 profile so this one is going to be a 2708 01:54:55,080 --> 01:54:55,980 little different we're going to say 2709 01:54:55,980 --> 01:55:01,260 profile slash user ID so this is a param 2710 01:55:01,260 --> 01:55:04,679 that we can set so if a profile if you 2711 01:55:04,679 --> 01:55:06,960 go to profile slash to whatever user ID 2712 01:55:06,960 --> 01:55:11,460 then you can hit this route 2713 01:55:11,460 --> 01:55:14,639 and we're going to say profile page 2714 01:55:14,639 --> 01:55:18,000 so and then that will be how we set our 2715 01:55:18,000 --> 01:55:19,139 routes 2716 01:55:19,139 --> 01:55:21,780 now let's actually set up our 2717 01:55:21,780 --> 01:55:24,000 Redux toolkit state 2718 01:55:24,000 --> 01:55:26,219 so I'm going to go into the state folder 2719 01:55:26,219 --> 01:55:28,500 into index.js and I'm going to be 2720 01:55:28,500 --> 01:55:31,560 importing create 2721 01:55:31,560 --> 01:55:36,540 slice from reduxjs toolkit 2722 01:55:36,540 --> 01:55:40,199 const initial state is what I'm going to 2723 01:55:40,199 --> 01:55:41,340 be setting up 2724 01:55:41,340 --> 01:55:43,619 this essentially will be the state that 2725 01:55:43,619 --> 01:55:45,600 will be stored in our Global state so 2726 01:55:45,600 --> 01:55:47,940 this type of information this basically 2727 01:55:47,940 --> 01:55:50,280 this data will be accessible throughout 2728 01:55:50,280 --> 01:55:52,800 our entire application and we can grab 2729 01:55:52,800 --> 01:55:55,440 it anywhere we want so we don't have to 2730 01:55:55,440 --> 01:55:56,880 pass in 2731 01:55:56,880 --> 01:55:59,340 State and properties down to different 2732 01:55:59,340 --> 01:56:01,260 components 2733 01:56:01,260 --> 01:56:03,900 now again I really highly recommend 2734 01:56:03,900 --> 01:56:05,699 Redux and toolkit 2735 01:56:05,699 --> 01:56:07,560 if you're using Redux you should always 2736 01:56:07,560 --> 01:56:10,139 use toolkit now and 2737 01:56:10,139 --> 01:56:12,900 among all the State Management libraries 2738 01:56:12,900 --> 01:56:13,980 I know 2739 01:56:13,980 --> 01:56:16,920 what was it recoil was a real call I 2740 01:56:16,920 --> 01:56:19,320 forgot or no Joe Tai 2741 01:56:19,320 --> 01:56:20,940 one of those is getting a lot of 2742 01:56:20,940 --> 01:56:23,460 popularity personally I still recommend 2743 01:56:23,460 --> 01:56:26,400 Redux simply just because 2744 01:56:26,400 --> 01:56:28,920 Redux is just proven for a long period 2745 01:56:28,920 --> 01:56:31,139 of time most people know Redux they 2746 01:56:31,139 --> 01:56:33,360 might know the old way but the toolkit 2747 01:56:33,360 --> 01:56:36,179 simplifies a lot of these things for you 2748 01:56:36,179 --> 01:56:38,699 and makes it so easy 2749 01:56:38,699 --> 01:56:40,560 and I'll show you that a lot of the 2750 01:56:40,560 --> 01:56:43,860 boilerplate is just kind of gone 2751 01:56:43,860 --> 01:56:45,840 so here I'm going to be setting up our 2752 01:56:45,840 --> 01:56:48,060 entire state so I've already written out 2753 01:56:48,060 --> 01:56:50,159 the actions and reducers and all the 2754 01:56:50,159 --> 01:56:52,320 state logic over here so we're going to 2755 01:56:52,320 --> 01:56:53,940 keep all the information we're going to 2756 01:56:53,940 --> 01:56:56,159 start with this and I'll explain these 2757 01:56:56,159 --> 01:56:58,500 actions as we go 2758 01:56:58,500 --> 01:57:00,360 so we're going to have mode 2759 01:57:00,360 --> 01:57:01,800 of light 2760 01:57:01,800 --> 01:57:03,900 so this is going to represent dark mode 2761 01:57:03,900 --> 01:57:05,880 and light mode and we're going to 2762 01:57:05,880 --> 01:57:07,860 configure it globally 2763 01:57:07,860 --> 01:57:09,840 then we're going to have user we're 2764 01:57:09,840 --> 01:57:11,699 going to start with null 2765 01:57:11,699 --> 01:57:14,099 token that's going to be null so this is 2766 01:57:14,099 --> 01:57:15,659 all the auth information we're going to 2767 01:57:15,659 --> 01:57:18,179 store and then posts 2768 01:57:18,179 --> 01:57:19,739 it's going to include all the posts that 2769 01:57:19,739 --> 01:57:21,960 we need 2770 01:57:21,960 --> 01:57:23,280 and then we're going to have export 2771 01:57:23,280 --> 01:57:27,179 const auth slice equals create slice 2772 01:57:27,179 --> 01:57:30,599 like so and then in here we pass in the 2773 01:57:30,599 --> 01:57:33,420 name of auth to represent the auth 2774 01:57:33,420 --> 01:57:37,080 workflow and then initial state 2775 01:57:37,080 --> 01:57:38,880 essentially we're passing an initial 2776 01:57:38,880 --> 01:57:40,739 State into initial state 2777 01:57:40,739 --> 01:57:43,619 and then finally we do reducers so this 2778 01:57:43,619 --> 01:57:45,360 is our actions so essentially you can 2779 01:57:45,360 --> 01:57:48,360 think of this as functions 2780 01:57:48,360 --> 01:57:50,460 that's basically yeah these are 2781 01:57:50,460 --> 01:57:51,960 functions these are functions that 2782 01:57:51,960 --> 01:57:54,360 involve modifying the global State 2783 01:57:54,360 --> 01:57:56,520 that's the only difference in this in a 2784 01:57:56,520 --> 01:57:58,380 regular function I'm not sure why people 2785 01:57:58,380 --> 01:58:00,659 always use fancy terms to describe it 2786 01:58:00,659 --> 01:58:02,400 but these are just functions that do 2787 01:58:02,400 --> 01:58:04,500 what you need 2788 01:58:04,500 --> 01:58:06,119 and so the first thing we want to create 2789 01:58:06,119 --> 01:58:09,000 is going to be set mode and this will be 2790 01:58:09,000 --> 01:58:11,820 changing 2791 01:58:11,820 --> 01:58:14,699 from light mode to dark mode so we're 2792 01:58:14,699 --> 01:58:16,920 going to have state DOT mode 2793 01:58:16,920 --> 01:58:19,619 equal to State DOT mode 2794 01:58:19,619 --> 01:58:22,199 if that is equal to light 2795 01:58:22,199 --> 01:58:25,880 we're going to change it to dark 2796 01:58:26,280 --> 01:58:29,219 and if not we're going to change it to 2797 01:58:29,219 --> 01:58:31,080 light so essentially if it's dark we're 2798 01:58:31,080 --> 01:58:32,699 going to move it to light if it's light 2799 01:58:32,699 --> 01:58:34,199 it's going to move it to dark that's all 2800 01:58:34,199 --> 01:58:35,699 this is doing 2801 01:58:35,699 --> 01:58:38,880 and the Redux if you come from Redux 2802 01:58:38,880 --> 01:58:42,659 Redux has this idea of you can't change 2803 01:58:42,659 --> 01:58:45,239 this state directly you always want to 2804 01:58:45,239 --> 01:58:47,219 replace the object as opposed to 2805 01:58:47,219 --> 01:58:50,460 directly modifying the state 2806 01:58:50,460 --> 01:58:54,420 toolkit has this built-in Library called 2807 01:58:54,420 --> 01:58:56,580 imer this is the one thing I might not 2808 01:58:56,580 --> 01:58:59,219 agree with but basically you can act 2809 01:58:59,219 --> 01:59:02,040 like you modify the state directly even 2810 01:59:02,040 --> 01:59:04,560 though under the hood this is not what's 2811 01:59:04,560 --> 01:59:07,260 happening but essentially this is state 2812 01:59:07,260 --> 01:59:08,940 DOT mode represents the previous 2813 01:59:08,940 --> 01:59:12,000 condition and then what you set it to 2814 01:59:12,000 --> 01:59:14,760 will be the new state when you call this 2815 01:59:14,760 --> 01:59:16,860 function 2816 01:59:16,860 --> 01:59:19,320 all right and then set login 2817 01:59:19,320 --> 01:59:23,219 we'll have state and action so action is 2818 01:59:23,219 --> 01:59:25,199 going to be just like functions this is 2819 01:59:25,199 --> 01:59:26,699 where you set 2820 01:59:26,699 --> 01:59:28,679 they call it payload but it's basically 2821 01:59:28,679 --> 01:59:30,480 just the params or arguments for the 2822 01:59:30,480 --> 01:59:33,000 function that's what all that means 2823 01:59:33,000 --> 01:59:34,340 and then from here we're going to say 2824 01:59:34,340 --> 01:59:36,239 state.user is going to be equal to 2825 01:59:36,239 --> 01:59:37,980 action.payload 2826 01:59:37,980 --> 01:59:41,219 dot user so in our payload this is the 2827 01:59:41,219 --> 01:59:43,139 parameter we're sending a user parameter 2828 01:59:43,139 --> 01:59:44,760 from this function 2829 01:59:44,760 --> 01:59:46,679 and then we're going to say state.token 2830 01:59:46,679 --> 01:59:49,560 will be action.payload 2831 01:59:49,560 --> 01:59:52,619 .com so basically these this includes 2832 01:59:52,619 --> 01:59:54,619 all the arguments so action.user 2833 01:59:54,619 --> 01:59:57,080 action.token 2834 01:59:57,080 --> 01:59:58,380 action.payload.useraction.payload dot 2835 01:59:58,380 --> 02:00:00,960 token so those are just parameters we're 2836 02:00:00,960 --> 02:00:03,360 going to do this something similar for 2837 02:00:03,360 --> 02:00:06,060 set log out just a little bit different 2838 02:00:06,060 --> 02:00:08,040 and we're going to say state 2839 02:00:08,040 --> 02:00:11,659 and all we're going to do here 2840 02:00:12,020 --> 02:00:14,460 state.user equals null 2841 02:00:14,460 --> 02:00:17,699 state DOT token equals no so when you 2842 02:00:17,699 --> 02:00:19,500 log out when you hit the logout button 2843 02:00:19,500 --> 02:00:21,719 we're just going to reset this to have 2844 02:00:21,719 --> 02:00:23,400 nothing in there 2845 02:00:23,400 --> 02:00:27,119 and we're going to have set friends 2846 02:00:27,119 --> 02:00:30,599 so this will set the friends 2847 02:00:30,599 --> 02:00:33,119 into our local state because we need to 2848 02:00:33,119 --> 02:00:35,780 keep this information 2849 02:00:36,840 --> 02:00:39,300 and what I'm going to do is check if 2850 02:00:39,300 --> 02:00:41,699 state.user 2851 02:00:41,699 --> 02:00:44,460 if the user already exists 2852 02:00:44,460 --> 02:00:47,219 we're going to set state.user dot 2853 02:00:47,219 --> 02:00:48,480 friends 2854 02:00:48,480 --> 02:00:50,639 and we're going to be setting the 2855 02:00:50,639 --> 02:00:52,820 friends 2856 02:00:53,280 --> 02:00:55,380 inside our state 2857 02:00:55,380 --> 02:00:58,320 as long as the user already exists 2858 02:00:58,320 --> 02:01:00,360 otherwise we're just going to say 2859 02:01:00,360 --> 02:01:01,920 console Dot 2860 02:01:01,920 --> 02:01:05,460 error user friends non 2861 02:01:05,460 --> 02:01:08,360 existent 2862 02:01:10,080 --> 02:01:11,760 and then from there we're going to say 2863 02:01:11,760 --> 02:01:13,800 set posts 2864 02:01:13,800 --> 02:01:17,300 State action 2865 02:01:17,639 --> 02:01:19,500 and inside here we're going to say state 2866 02:01:19,500 --> 02:01:23,400 DOT post equals action dot payload dot 2867 02:01:23,400 --> 02:01:25,139 post so as you can see these functions 2868 02:01:25,139 --> 02:01:27,060 are pretty straightforward like set log 2869 02:01:27,060 --> 02:01:29,340 out we're just emptying it out set post 2870 02:01:29,340 --> 02:01:31,260 we're just going to set the post 2871 02:01:31,260 --> 02:01:33,300 these are simple functions that modify 2872 02:01:33,300 --> 02:01:35,760 our state as we need 2873 02:01:35,760 --> 02:01:37,619 and I've already done this beforehand so 2874 02:01:37,619 --> 02:01:38,940 these are the functions that we kind of 2875 02:01:38,940 --> 02:01:40,679 need and I'll explain them when we 2876 02:01:40,679 --> 02:01:44,099 actually use them so state.action 2877 02:01:44,099 --> 02:01:48,599 so sorry state.posts or step post 2878 02:01:48,599 --> 02:01:51,300 this one is the most complicated one 2879 02:01:51,300 --> 02:01:54,719 we're going to say updated posts so what 2880 02:01:54,719 --> 02:01:58,159 we're going to do is we're going to grab 2881 02:01:58,199 --> 02:02:01,380 our list of posts 2882 02:02:01,380 --> 02:02:06,659 map through each one and if post dot I 2883 02:02:06,659 --> 02:02:11,280 underscore ID is equal to the 2884 02:02:11,280 --> 02:02:12,599 current 2885 02:02:12,599 --> 02:02:14,099 post 2886 02:02:14,099 --> 02:02:18,360 ID that we're sending into this function 2887 02:02:18,360 --> 02:02:19,320 we're just going to return 2888 02:02:19,320 --> 02:02:21,420 action.payload 2889 02:02:21,420 --> 02:02:23,040 DOT bus so we're going to return the 2890 02:02:23,040 --> 02:02:25,380 post that we want 2891 02:02:25,380 --> 02:02:27,719 so we're only going to return the 2892 02:02:27,719 --> 02:02:30,900 relevant post otherwise 2893 02:02:30,900 --> 02:02:32,820 we're going to return what we currently 2894 02:02:32,820 --> 02:02:36,480 have so we only update with 2895 02:02:36,480 --> 02:02:39,239 the post the updated post that we 2896 02:02:39,239 --> 02:02:41,099 changed 2897 02:02:41,099 --> 02:02:43,080 and it's coming from the back end we're 2898 02:02:43,080 --> 02:02:44,699 only going to be 2899 02:02:44,699 --> 02:02:46,679 setting that particular post everything 2900 02:02:46,679 --> 02:02:48,360 else we leave 2901 02:02:48,360 --> 02:02:50,820 as it currently is so I'll explain this 2902 02:02:50,820 --> 02:02:51,780 when we 2903 02:02:51,780 --> 02:02:54,060 actually do it it'll make more sense 2904 02:02:54,060 --> 02:02:55,619 this is kind of complicated so we're 2905 02:02:55,619 --> 02:02:57,420 just going to say updated post 2906 02:02:57,420 --> 02:03:01,679 state.puss will be the updated post 2907 02:03:01,679 --> 02:03:04,320 and then from here this is part of Redux 2908 02:03:04,320 --> 02:03:06,540 toolkit all we have to do 2909 02:03:06,540 --> 02:03:10,340 is we're just going to repeat 2910 02:03:10,980 --> 02:03:12,599 our um 2911 02:03:12,599 --> 02:03:15,420 our actions 2912 02:03:15,420 --> 02:03:17,580 and we just have to write every single 2913 02:03:17,580 --> 02:03:21,599 one of them except posts set post 2914 02:03:21,599 --> 02:03:25,380 equals auth slice dot actions 2915 02:03:25,380 --> 02:03:28,139 and we're going to export default auth 2916 02:03:28,139 --> 02:03:32,060 slice dot reducer 2917 02:03:32,159 --> 02:03:34,260 and this is basically our entire State 2918 02:03:34,260 --> 02:03:36,119 this will be all 2919 02:03:36,119 --> 02:03:38,280 the logic that we'll need for the entire 2920 02:03:38,280 --> 02:03:41,159 application for Redux 2921 02:03:41,159 --> 02:03:43,139 and then finally 2922 02:03:43,139 --> 02:03:45,860 we just have to configure a few things 2923 02:03:45,860 --> 02:03:48,659 specifically more so for 2924 02:03:48,659 --> 02:03:50,699 persist it but we're going to set the 2925 02:03:50,699 --> 02:03:55,460 reducer inside our index.js file 2926 02:03:55,739 --> 02:03:58,199 so over here I'm going to import auth 2927 02:03:58,199 --> 02:04:00,239 reducer 2928 02:04:00,239 --> 02:04:02,520 from 2929 02:04:02,520 --> 02:04:04,679 dot slash date 2930 02:04:04,679 --> 02:04:06,420 so we're going to export the reducer we 2931 02:04:06,420 --> 02:04:08,099 just created then we're going to import 2932 02:04:08,099 --> 02:04:10,800 configure store 2933 02:04:10,800 --> 02:04:13,739 from reduxjs toolkit we're going to 2934 02:04:13,739 --> 02:04:16,380 import provider 2935 02:04:16,380 --> 02:04:18,780 from react Redux 2936 02:04:18,780 --> 02:04:20,520 and we're going to import a number of 2937 02:04:20,520 --> 02:04:21,599 things 2938 02:04:21,599 --> 02:04:23,880 this is when you use Redux persist only 2939 02:04:23,880 --> 02:04:26,699 so if you're not using Redux persist you 2940 02:04:26,699 --> 02:04:28,800 don't have to really do this but this is 2941 02:04:28,800 --> 02:04:30,840 specifically for Redux 2942 02:04:30,840 --> 02:04:32,639 persist 2943 02:04:32,639 --> 02:04:35,400 persist reducer we're going to have 2944 02:04:35,400 --> 02:04:36,540 flush 2945 02:04:36,540 --> 02:04:39,500 rehydrate 2946 02:04:39,780 --> 02:04:41,099 pause 2947 02:04:41,099 --> 02:04:43,260 so this kind of it is kind of weird to 2948 02:04:43,260 --> 02:04:44,699 do this 2949 02:04:44,699 --> 02:04:46,619 Purge 2950 02:04:46,619 --> 02:04:49,020 register 2951 02:04:49,020 --> 02:04:52,020 and we're going to do that from Redux 2952 02:04:52,020 --> 02:04:55,219 Dash persist 2953 02:04:55,560 --> 02:04:57,719 and then we're going to import 2954 02:04:57,719 --> 02:04:59,820 storage 2955 02:04:59,820 --> 02:05:03,239 from Redux Dash persist live storage and 2956 02:05:03,239 --> 02:05:05,699 finally we're going to import persist 2957 02:05:05,699 --> 02:05:07,739 gate 2958 02:05:07,739 --> 02:05:10,500 now Redux persist I think I mentioned it 2959 02:05:10,500 --> 02:05:11,520 before 2960 02:05:11,520 --> 02:05:15,360 but this is so we can save 2961 02:05:15,360 --> 02:05:17,400 all the state so all of this information 2962 02:05:17,400 --> 02:05:21,780 will be stored in local state meaning 2963 02:05:21,780 --> 02:05:24,780 anytime the user like closes the tab or 2964 02:05:24,780 --> 02:05:27,540 closes the browser that information will 2965 02:05:27,540 --> 02:05:29,340 still be stored in there the user 2966 02:05:29,340 --> 02:05:31,440 information will still be there the only 2967 02:05:31,440 --> 02:05:33,360 way they can get rid of it is if they 2968 02:05:33,360 --> 02:05:35,760 clear their cache 2969 02:05:35,760 --> 02:05:38,040 and this is good for certain things if 2970 02:05:38,040 --> 02:05:40,020 you want to keep the information 2971 02:05:40,020 --> 02:05:44,280 storage is an alternative that will have 2972 02:05:44,280 --> 02:05:46,080 information saved for that particular 2973 02:05:46,080 --> 02:05:48,060 session but if you close the tab that 2974 02:05:48,060 --> 02:05:49,860 information will go away 2975 02:05:49,860 --> 02:05:52,440 but local storage is perfect for this 2976 02:05:52,440 --> 02:05:56,099 use case so now I have to resign in 2977 02:05:56,099 --> 02:05:57,780 so the way we set this up we're going to 2978 02:05:57,780 --> 02:06:01,920 set up persist config we're going to set 2979 02:06:01,920 --> 02:06:03,119 key 2980 02:06:03,119 --> 02:06:04,860 of root 2981 02:06:04,860 --> 02:06:09,840 comma storage comma version colon one 2982 02:06:09,840 --> 02:06:11,760 like so 2983 02:06:11,760 --> 02:06:14,040 and we're going to say const persisted 2984 02:06:14,040 --> 02:06:15,780 reducer 2985 02:06:15,780 --> 02:06:18,599 and we're going to say persist reducer 2986 02:06:18,599 --> 02:06:24,619 and persist config comma auth reducer 2987 02:06:24,719 --> 02:06:26,340 so we're going to have the reducer 2988 02:06:26,340 --> 02:06:28,080 persisted 2989 02:06:28,080 --> 02:06:29,760 and then from here I'm going to set the 2990 02:06:29,760 --> 02:06:32,940 store using configure store 2991 02:06:32,940 --> 02:06:36,000 and pass and reducer with persist 2992 02:06:36,000 --> 02:06:37,139 bid 2993 02:06:37,139 --> 02:06:38,699 reducer 2994 02:06:38,699 --> 02:06:42,199 and we're going to set the middleware 2995 02:06:42,360 --> 02:06:45,300 get default 2996 02:06:45,300 --> 02:06:47,219 middleware so if you're wondering where 2997 02:06:47,219 --> 02:06:49,199 I'm getting all this information I'm 2998 02:06:49,199 --> 02:06:51,239 getting a lot of this from both Redux JS 2999 02:06:51,239 --> 02:06:52,739 toolkit 3000 02:06:52,739 --> 02:06:55,800 in combination with Redux persist they 3001 02:06:55,800 --> 02:06:58,380 have documentation on what to exactly 3002 02:06:58,380 --> 02:07:00,179 write and that's what I'm doing it's not 3003 02:07:00,179 --> 02:07:02,699 like I know 3004 02:07:02,699 --> 02:07:04,920 toolkit that well in terms of like 3005 02:07:04,920 --> 02:07:07,260 setting these parameters up it's just 3006 02:07:07,260 --> 02:07:11,760 there is a set of code that I wrote down 3007 02:07:11,760 --> 02:07:13,679 and I'm just following it 3008 02:07:13,679 --> 02:07:15,840 and this is to ignore some kind of 3009 02:07:15,840 --> 02:07:18,000 warning that they have if you don't if 3010 02:07:18,000 --> 02:07:20,040 you're using persist 3011 02:07:20,040 --> 02:07:22,500 so we're gonna pass in everything that 3012 02:07:22,500 --> 02:07:24,179 we had over here 3013 02:07:24,179 --> 02:07:26,219 so I'm just going to copy this 3014 02:07:26,219 --> 02:07:28,380 paste it in here 3015 02:07:28,380 --> 02:07:29,699 and those will be 3016 02:07:29,699 --> 02:07:31,560 our ignored actions 3017 02:07:31,560 --> 02:07:35,580 and then finally we can just go 3018 02:07:35,580 --> 02:07:38,719 to our provider 3019 02:07:39,119 --> 02:07:41,580 and inside our provider store equals 3020 02:07:41,580 --> 02:07:42,780 store 3021 02:07:42,780 --> 02:07:45,659 we can pass in our app 3022 02:07:45,659 --> 02:07:48,840 and then for persist to work 3023 02:07:48,840 --> 02:07:52,099 persist gate 3024 02:07:55,500 --> 02:07:57,540 inside of here we're going to pass in 3025 02:07:57,540 --> 02:08:00,239 loading equals null 3026 02:08:00,239 --> 02:08:03,360 persister equals persist 3027 02:08:03,360 --> 02:08:05,580 store 3028 02:08:05,580 --> 02:08:07,380 like that 3029 02:08:07,380 --> 02:08:09,300 now I know what you're thinking there is 3030 02:08:09,300 --> 02:08:11,400 still at least amount of boilerplate you 3031 02:08:11,400 --> 02:08:13,139 still have to configure all this you 3032 02:08:13,139 --> 02:08:14,639 only have to do this once but once you 3033 02:08:14,639 --> 02:08:16,500 configure it you're good there is 3034 02:08:16,500 --> 02:08:18,179 another state management Library I 3035 02:08:18,179 --> 02:08:19,679 forgot the name but it's getting a lot 3036 02:08:19,679 --> 02:08:21,840 of popularity the only thing I'm 3037 02:08:21,840 --> 02:08:23,820 cautious about using one of those 3038 02:08:23,820 --> 02:08:25,739 libraries is that 3039 02:08:25,739 --> 02:08:28,320 right now when you have some basic 3040 02:08:28,320 --> 02:08:30,780 application maybe you have 3041 02:08:30,780 --> 02:08:33,000 you know you don't really need too much 3042 02:08:33,000 --> 02:08:35,340 functionality and you don't have a lot 3043 02:08:35,340 --> 02:08:37,020 of use cases 3044 02:08:37,020 --> 02:08:38,580 then those State managements are 3045 02:08:38,580 --> 02:08:41,099 perfectly fine you can get by and have 3046 02:08:41,099 --> 02:08:42,840 even less code than this and it's 3047 02:08:42,840 --> 02:08:45,060 perfect for those but be careful of 3048 02:08:45,060 --> 02:08:46,860 those people who are hyping some of 3049 02:08:46,860 --> 02:08:49,260 those packages they're not considering 3050 02:08:49,260 --> 02:08:50,820 they're not going in they're not 3051 02:08:50,820 --> 02:08:52,560 creating production level applications 3052 02:08:52,560 --> 02:08:54,659 where you have all these weird edge 3053 02:08:54,659 --> 02:08:56,460 cases this happens a lot you when you 3054 02:08:56,460 --> 02:08:58,560 have a big application you get into 3055 02:08:58,560 --> 02:09:00,300 these weird little 3056 02:09:00,300 --> 02:09:03,599 specific edge cases and it becomes a 3057 02:09:03,599 --> 02:09:06,060 headache to work around now Redux has 3058 02:09:06,060 --> 02:09:07,560 been around longer and this is why 3059 02:09:07,560 --> 02:09:11,040 having using older libraries sometimes 3060 02:09:11,040 --> 02:09:12,719 as long as it's good enough 3061 02:09:12,719 --> 02:09:16,440 they are usually the desired package to 3062 02:09:16,440 --> 02:09:18,420 use and I highly recommend Rio because 3063 02:09:18,420 --> 02:09:20,280 it's been there for a while a lot of the 3064 02:09:20,280 --> 02:09:22,080 use cases has been created for example 3065 02:09:22,080 --> 02:09:24,599 like persist storage using local storage 3066 02:09:24,599 --> 02:09:26,880 this has been refined make sure there's 3067 02:09:26,880 --> 02:09:29,460 no bugs and this is why you would use 3068 02:09:29,460 --> 02:09:31,560 something like Redux overdose other 3069 02:09:31,560 --> 02:09:33,599 State Management tools yes you can get 3070 02:09:33,599 --> 02:09:35,340 up and running faster with some of those 3071 02:09:35,340 --> 02:09:37,800 other tools but toolkit makes it easy 3072 02:09:37,800 --> 02:09:41,159 enough that it's worth using so that you 3073 02:09:41,159 --> 02:09:42,840 can always scale your application as 3074 02:09:42,840 --> 02:09:44,520 much as you want later on if you ever 3075 02:09:44,520 --> 02:09:47,159 have a need for it so this is why I 3076 02:09:47,159 --> 02:09:49,199 highly recommend stay away from those 3077 02:09:49,199 --> 02:09:51,659 highly opinionated people saying Redux 3078 02:09:51,659 --> 02:09:53,760 is gone things like that it's just 3079 02:09:53,760 --> 02:09:55,980 chances are they haven't tried it they 3080 02:09:55,980 --> 02:09:57,239 haven't tried a lot of these packages 3081 02:09:57,239 --> 02:09:59,219 they just kind of say what they feel 3082 02:09:59,219 --> 02:10:01,320 like at the moment and they want to 3083 02:10:01,320 --> 02:10:04,260 speak their opinions 3084 02:10:04,260 --> 02:10:06,119 with that setup we're going to create 3085 02:10:06,119 --> 02:10:08,099 our theme file in our source directory 3086 02:10:08,099 --> 02:10:09,840 so I'm going to create a new file call 3087 02:10:09,840 --> 02:10:13,080 It theme Js 3088 02:10:13,080 --> 02:10:16,500 so right here if you go to the link in 3089 02:10:16,500 --> 02:10:18,719 the description below I'm just going to 3090 02:10:18,719 --> 02:10:22,020 copy these color tokens that we have 3091 02:10:22,020 --> 02:10:24,659 from the file so you can get these I 3092 02:10:24,659 --> 02:10:26,159 don't want to spend the entire time just 3093 02:10:26,159 --> 02:10:28,139 writing and typing these I feel like you 3094 02:10:28,139 --> 02:10:30,119 guys might be bored so you can just go 3095 02:10:30,119 --> 02:10:33,360 to the file and copy these directly or 3096 02:10:33,360 --> 02:10:36,360 if you want you can pause the video and 3097 02:10:36,360 --> 02:10:38,639 just look at this right here 3098 02:10:38,639 --> 02:10:41,340 so we have primary these colors 3099 02:10:41,340 --> 02:10:44,340 note we start from 50. same over here we 3100 02:10:44,340 --> 02:10:48,440 have gray from 0 10 50 100. 3101 02:10:49,080 --> 02:10:50,820 and then from here I'm going to set the 3102 02:10:50,820 --> 02:10:54,239 mui theme settings feel free if you want 3103 02:10:54,239 --> 02:10:56,159 to skip this section you can 3104 02:10:56,159 --> 02:10:59,099 copy all of those but I will do this 3105 02:10:59,099 --> 02:11:00,900 part manually so I can explain a few 3106 02:11:00,900 --> 02:11:02,940 things as I go so I'm going to say theme 3107 02:11:02,940 --> 02:11:04,139 settings 3108 02:11:04,139 --> 02:11:07,080 I'm going to say mode 3109 02:11:07,080 --> 02:11:11,400 in parens and return 3110 02:11:11,400 --> 02:11:14,460 and in here I'm going to say palette 3111 02:11:14,460 --> 02:11:17,639 this so this is going to set up material 3112 02:11:17,639 --> 02:11:20,880 UI theme so by doing this we can set the 3113 02:11:20,880 --> 02:11:24,000 default colors for material UI themes so 3114 02:11:24,000 --> 02:11:26,099 it makes it easier for us to configure 3115 02:11:26,099 --> 02:11:28,320 what we need and so we're going to have 3116 02:11:28,320 --> 02:11:29,520 two settings 3117 02:11:29,520 --> 02:11:32,699 like I mentioned with mode 3118 02:11:32,699 --> 02:11:33,960 of 3119 02:11:33,960 --> 02:11:35,940 dark 3120 02:11:35,940 --> 02:11:38,520 and if it is dark so we're going to do a 3121 02:11:38,520 --> 02:11:41,159 ternary operator if it is dark we're 3122 02:11:41,159 --> 02:11:42,599 going to set 3123 02:11:42,599 --> 02:11:45,300 these particular settings 3124 02:11:45,300 --> 02:11:48,440 so I'm going to say palette 3125 02:11:48,599 --> 02:11:52,520 values for dark mode 3126 02:11:53,340 --> 02:11:56,159 and then we're going to do primary 3127 02:11:56,159 --> 02:11:58,020 I'm going to say dark is going to be 3128 02:11:58,020 --> 02:12:03,060 color tokens dot primary 200. 3129 02:12:03,960 --> 02:12:06,060 main is going to be color 3130 02:12:06,060 --> 02:12:08,219 tokens primary 3131 02:12:08,219 --> 02:12:09,960 500 3132 02:12:09,960 --> 02:12:11,760 I'm going to set light is going to be 3133 02:12:11,760 --> 02:12:15,139 color tokens primary 3134 02:12:15,139 --> 02:12:17,580 800. so now these are values that I've 3135 02:12:17,580 --> 02:12:20,820 set kind of you know I've tested it 3136 02:12:20,820 --> 02:12:23,219 chosen colors that I feel like looks 3137 02:12:23,219 --> 02:12:25,440 good and match well together so this is 3138 02:12:25,440 --> 02:12:26,580 what I'm doing 3139 02:12:26,580 --> 02:12:28,260 we're going to say color tokens so 3140 02:12:28,260 --> 02:12:30,840 instead of me constantly typing this I'm 3141 02:12:30,840 --> 02:12:34,320 just going to copy color tokens dot Gray 3142 02:12:34,320 --> 02:12:38,400 and I'm going to put bracket 100 like so 3143 02:12:38,400 --> 02:12:42,960 I'm going to do main paste it 200. 3144 02:12:42,960 --> 02:12:45,179 medium Main 3145 02:12:45,179 --> 02:12:47,760 we need a lot of Shades of Gray for this 3146 02:12:47,760 --> 02:12:49,500 idea 300 3147 02:12:49,500 --> 02:12:51,300 medium 3148 02:12:51,300 --> 02:12:54,360 color tokens Gray 400. 3149 02:12:54,360 --> 02:12:55,739 light 3150 02:12:55,739 --> 02:12:59,820 color tekken's gray 700. 3151 02:13:00,719 --> 02:13:02,579 here I'm going to set the background as 3152 02:13:02,579 --> 02:13:05,280 well I'm going to say default it's going 3153 02:13:05,280 --> 02:13:09,179 to be color token suck gray 900 3154 02:13:09,179 --> 02:13:15,119 comma alt color tokens Dot 3155 02:13:15,119 --> 02:13:18,780 Gray 800. 3156 02:13:18,780 --> 02:13:22,260 and with this I'm going to save it 3157 02:13:22,260 --> 02:13:23,940 actually it's not going to Auto format 3158 02:13:23,940 --> 02:13:26,579 because we still have 3159 02:13:26,579 --> 02:13:29,099 an error so what I'm going to do is I'm 3160 02:13:29,099 --> 02:13:33,000 going to finish up this ternary operator 3161 02:13:33,000 --> 02:13:34,619 and I'm going to copy all of these 3162 02:13:34,619 --> 02:13:37,079 values inside 3163 02:13:37,079 --> 02:13:38,820 and I'm going to 3164 02:13:38,820 --> 02:13:41,040 manually change this one so I'm going to 3165 02:13:41,040 --> 02:13:43,079 say for light mode 3166 02:13:43,079 --> 02:13:45,900 this is going to be 700 3167 02:13:45,900 --> 02:13:47,520 500 3168 02:13:47,520 --> 02:13:50,599 and then 50. 3169 02:13:50,699 --> 02:13:53,960 and this is going to be 700 3170 02:13:53,960 --> 02:13:55,560 500. 3171 02:13:55,560 --> 02:13:57,480 400 3172 02:13:57,480 --> 02:13:59,280 300. 3173 02:13:59,280 --> 02:14:01,280 50 3174 02:14:02,099 --> 02:14:04,920 this is going to be 10. 3175 02:14:04,920 --> 02:14:07,560 and zero so now if you notice if you're 3176 02:14:07,560 --> 02:14:09,719 curious what these color settings are 3177 02:14:09,719 --> 02:14:11,159 dude they're kind of like inverted a 3178 02:14:11,159 --> 02:14:13,380 little bit so you have 3179 02:14:13,380 --> 02:14:15,599 almost inverted colors I didn't manually 3180 02:14:15,599 --> 02:14:17,880 go through and test them see which one 3181 02:14:17,880 --> 02:14:19,739 looked the best together 3182 02:14:19,739 --> 02:14:21,840 and then I'm going to put typography now 3183 02:14:21,840 --> 02:14:23,280 we're going to set the type of cover key 3184 02:14:23,280 --> 02:14:25,320 settings over here so we're going to set 3185 02:14:25,320 --> 02:14:28,520 font family 3186 02:14:29,639 --> 02:14:32,760 and I'm going to do Rubik 3187 02:14:32,760 --> 02:14:34,679 Sans 3188 02:14:34,679 --> 02:14:37,560 Sans serif 3189 02:14:37,560 --> 02:14:39,480 I'm going to be joining these together 3190 02:14:39,480 --> 02:14:42,500 with the comma 3191 02:14:43,020 --> 02:14:46,980 I'm going to set the font size of 12 3192 02:14:46,980 --> 02:14:49,739 and I'm going to set the H1 settings 3193 02:14:49,739 --> 02:14:51,199 and I'm going to copy the font 3194 02:14:51,199 --> 02:14:53,820 family.join like so 3195 02:14:53,820 --> 02:15:01,040 and then host in font size of 40 comma 3196 02:15:01,199 --> 02:15:03,719 and from here I'm going to just 3197 02:15:03,719 --> 02:15:08,239 copy and paste this several times 3198 02:15:13,560 --> 02:15:15,480 and we're going to set each one for 3199 02:15:15,480 --> 02:15:19,440 different font sizes we're going to keep 3200 02:15:19,440 --> 02:15:22,079 the fonts the same but we're just going 3201 02:15:22,079 --> 02:15:23,760 to change the font size 3202 02:15:23,760 --> 02:15:25,860 this will be H3 I'm going to set this to 3203 02:15:25,860 --> 02:15:29,760 24. we're going to set this H4 this will 3204 02:15:29,760 --> 02:15:32,040 be 20. 3205 02:15:32,040 --> 02:15:36,440 H5 is going to be 16. 3206 02:15:36,480 --> 02:15:41,300 H6 is going to be 14. 3207 02:15:41,940 --> 02:15:44,940 and that is our material UI theme 3208 02:15:44,940 --> 02:15:46,920 settings so if you take a look you can 3209 02:15:46,920 --> 02:15:49,320 take a look and double check all the 3210 02:15:49,320 --> 02:15:52,920 values you have in the finalized repo I 3211 02:15:52,920 --> 02:15:55,679 have a link to this as well 3212 02:15:55,679 --> 02:15:57,960 and then from here we're going to do 3213 02:15:57,960 --> 02:16:01,619 we're going to go back to app.js and 3214 02:16:01,619 --> 02:16:03,239 we're going to configure some of our 3215 02:16:03,239 --> 02:16:06,540 settings for our theme so we created the 3216 02:16:06,540 --> 02:16:08,699 theme settings but we have not placed it 3217 02:16:08,699 --> 02:16:11,460 in the components yet 3218 02:16:11,460 --> 02:16:13,260 so that is going to be what we're going 3219 02:16:13,260 --> 02:16:14,820 to do so but we're going to import a few 3220 02:16:14,820 --> 02:16:16,260 things first 3221 02:16:16,260 --> 02:16:18,719 we're going to import use Memo from 3222 02:16:18,719 --> 02:16:21,360 react 3223 02:16:21,360 --> 02:16:25,199 import use selector 3224 02:16:25,199 --> 02:16:27,840 from react 3225 02:16:27,840 --> 02:16:30,300 Redux 3226 02:16:30,300 --> 02:16:37,138 import c s s Base Line theme provider 3227 02:16:37,138 --> 02:16:38,218 from 3228 02:16:38,218 --> 02:16:41,820 at mui slash material 3229 02:16:41,820 --> 02:16:45,120 import create theme 3230 02:16:45,120 --> 02:16:48,179 from at mui 3231 02:16:48,179 --> 02:16:51,240 slash material slash 3232 02:16:51,240 --> 02:16:52,859 styles 3233 02:16:52,859 --> 02:16:54,120 and then finally we're going to import 3234 02:16:54,120 --> 02:16:57,420 theme settings from the file we just 3235 02:16:57,420 --> 02:16:58,379 created 3236 02:16:58,379 --> 02:17:01,019 and that's going to be from dot slash 3237 02:17:01,019 --> 02:17:03,320 theme 3238 02:17:05,700 --> 02:17:07,859 and then from here above our return 3239 02:17:07,859 --> 02:17:10,379 we're going to do const mode and we're 3240 02:17:10,379 --> 02:17:13,200 going to be grabbing the mode that we 3241 02:17:13,200 --> 02:17:15,540 have from our state 3242 02:17:15,540 --> 02:17:17,218 so the way we do that is we're going to 3243 02:17:17,218 --> 02:17:18,920 do state 3244 02:17:18,920 --> 02:17:22,679 dot mode so this will help us grab 3245 02:17:22,679 --> 02:17:25,558 the value we created in our initial 3246 02:17:25,558 --> 02:17:28,039 state 3247 02:17:28,320 --> 02:17:30,000 so if we ever want to grab information 3248 02:17:30,000 --> 02:17:31,920 from the store we just have to use U 3249 02:17:31,920 --> 02:17:35,040 selector grab the state in the correct 3250 02:17:35,040 --> 02:17:36,540 reducer 3251 02:17:36,540 --> 02:17:38,519 and it's pretty much there it's very 3252 02:17:38,519 --> 02:17:41,398 easy to use so con Steam 3253 02:17:41,398 --> 02:17:44,659 will be used memo 3254 02:17:45,240 --> 02:17:49,138 and we need to pass in create theme 3255 02:17:49,138 --> 02:17:50,939 and this is one of those things we just 3256 02:17:50,939 --> 02:17:53,218 have to do once for each app so theme 3257 02:17:53,218 --> 02:17:57,259 settings we're going to pass in mode 3258 02:17:58,080 --> 02:18:00,478 comma and we're going to put mode in 3259 02:18:00,478 --> 02:18:01,500 Brackets 3260 02:18:01,500 --> 02:18:03,718 so this will set up our theme we have 3261 02:18:03,718 --> 02:18:05,700 yet to pass it into 3262 02:18:05,700 --> 02:18:07,620 material UI yet and that's what we're 3263 02:18:07,620 --> 02:18:09,420 about to do so we're going to pass in 3264 02:18:09,420 --> 02:18:12,718 theme provider 3265 02:18:12,718 --> 02:18:14,879 and we're passing in a property into 3266 02:18:14,879 --> 02:18:16,920 theme 3267 02:18:16,920 --> 02:18:19,320 we're going to wrap this around the 3268 02:18:19,320 --> 02:18:21,620 routes 3269 02:18:21,898 --> 02:18:24,120 and now we should have our theme 3270 02:18:24,120 --> 02:18:26,939 configured for material UI and then one 3271 02:18:26,939 --> 02:18:29,638 thing we want to add is CSS Baseline 3272 02:18:29,638 --> 02:18:31,558 this is not really relevant to the theme 3273 02:18:31,558 --> 02:18:34,398 but it's going to reset our CSS to basic 3274 02:18:34,398 --> 02:18:38,398 CSS so if you ever heard of CSS reset 3275 02:18:38,398 --> 02:18:40,080 this is essentially what it's doing from 3276 02:18:40,080 --> 02:18:41,879 Material UI they have their own version 3277 02:18:41,879 --> 02:18:43,620 so 3278 02:18:43,620 --> 02:18:46,558 this makes it very convenient to reset 3279 02:18:46,558 --> 02:18:48,780 our CSS 3280 02:18:48,780 --> 02:18:51,058 we have most of everything set up let's 3281 02:18:51,058 --> 02:18:52,978 actually open up our terminal 3282 02:18:52,978 --> 02:18:56,580 and we're going to run npm run start 3283 02:18:56,580 --> 02:18:58,620 and we want to confirm everything's 3284 02:18:58,620 --> 02:19:00,478 working so we don't have any errors when 3285 02:19:00,478 --> 02:19:01,920 we start it 3286 02:19:01,920 --> 02:19:03,840 so when you open it up you can go to 3287 02:19:03,840 --> 02:19:05,160 localhost 3288 02:19:05,160 --> 02:19:08,459 refresh it you can open up your 3289 02:19:08,459 --> 02:19:10,740 uh what was it the console in your 3290 02:19:10,740 --> 02:19:14,280 browser you can use command Alt 3291 02:19:14,280 --> 02:19:16,679 command alt I to open it with the 3292 02:19:16,679 --> 02:19:18,058 shortcut 3293 02:19:18,058 --> 02:19:21,179 or if you're on a PC you can use Control 3294 02:19:21,179 --> 02:19:22,439 Alt 3295 02:19:22,439 --> 02:19:25,200 I and that will open up see if you have 3296 02:19:25,200 --> 02:19:27,478 any errors this is good if you see 3297 02:19:27,478 --> 02:19:29,099 something like this so this is all we 3298 02:19:29,099 --> 02:19:30,780 need we just want to make sure this is 3299 02:19:30,780 --> 02:19:33,179 running up and running so we can go on 3300 02:19:33,179 --> 02:19:34,320 to the next step 3301 02:19:34,320 --> 02:19:35,939 so I'm going to go back to our code I'm 3302 02:19:35,939 --> 02:19:37,320 going to close the terminal so you guys 3303 02:19:37,320 --> 02:19:38,340 can see 3304 02:19:38,340 --> 02:19:40,138 I'm just going to close all these tabs 3305 02:19:40,138 --> 02:19:43,138 out just to be more clear and I'm going 3306 02:19:43,138 --> 02:19:44,820 to go to 3307 02:19:44,820 --> 02:19:47,280 our client folder go to Source 3308 02:19:47,280 --> 02:19:48,720 components 3309 02:19:48,720 --> 02:19:50,399 and I'm going to create a new file I'm 3310 02:19:50,399 --> 02:19:52,740 going to call this 3311 02:19:52,740 --> 02:19:54,899 Flex between 3312 02:19:54,899 --> 02:19:57,240 oops not a folder a new file 3313 02:19:57,240 --> 02:19:59,820 and call this Flex between 3314 02:19:59,820 --> 02:20:02,340 jsx 3315 02:20:02,340 --> 02:20:05,040 so here I'm going to import a component 3316 02:20:05,040 --> 02:20:07,140 from Material UI 3317 02:20:07,140 --> 02:20:12,840 so at mui material import styled 3318 02:20:12,840 --> 02:20:16,160 from mui system 3319 02:20:16,260 --> 02:20:18,540 and I'm going to create a component 3320 02:20:18,540 --> 02:20:24,140 called Flex between equals styled box 3321 02:20:24,660 --> 02:20:26,939 and close it so if you've ever never 3322 02:20:26,939 --> 02:20:29,760 seen the syntax I don't use this too 3323 02:20:29,760 --> 02:20:31,620 often 3324 02:20:31,620 --> 02:20:34,740 but this is very good if you're reusing 3325 02:20:34,740 --> 02:20:37,979 CSS as a component now 3326 02:20:37,979 --> 02:20:40,560 you can use style component this is 3327 02:20:40,560 --> 02:20:42,600 essentially called style components and 3328 02:20:42,600 --> 02:20:44,939 you can name this component as you want 3329 02:20:44,939 --> 02:20:47,520 as if it's another component and you can 3330 02:20:47,520 --> 02:20:50,880 just pass in CSS properties in here and 3331 02:20:50,880 --> 02:20:52,439 in this case we're going to display of 3332 02:20:52,439 --> 02:20:58,100 flex justify content of space between 3333 02:20:58,260 --> 02:21:02,880 align items of Center 3334 02:21:02,880 --> 02:21:06,359 by doing this this allows us to reuse 3335 02:21:06,359 --> 02:21:10,620 this set of CSS properties 3336 02:21:10,620 --> 02:21:13,380 through different areas and this one 3337 02:21:13,380 --> 02:21:15,420 we're going to be using this quite a bit 3338 02:21:15,420 --> 02:21:17,460 it's very useful to have something like 3339 02:21:17,460 --> 02:21:20,040 this so we can align things and flex 3340 02:21:20,040 --> 02:21:23,399 things into the proper locations 3341 02:21:23,399 --> 02:21:25,680 and with that now we can go and create 3342 02:21:25,680 --> 02:21:27,899 our nav bar so navbar will be the first 3343 02:21:27,899 --> 02:21:30,540 thing we create so here we're going to 3344 02:21:30,540 --> 02:21:33,120 go to the navbar component and I'm going 3345 02:21:33,120 --> 02:21:35,520 to import a number of items 3346 02:21:35,520 --> 02:21:39,060 we're going to import use state 3347 02:21:39,060 --> 02:21:41,899 from react 3348 02:21:42,359 --> 02:21:44,880 and I'm going to import 3349 02:21:44,880 --> 02:21:46,500 box 3350 02:21:46,500 --> 02:21:49,020 from mui material 3351 02:21:49,020 --> 02:21:51,000 and in here I'm going to import a lot of 3352 02:21:51,000 --> 02:21:52,620 different components so I'm just going 3353 02:21:52,620 --> 02:21:54,660 to type all of this out so I'm going to 3354 02:21:54,660 --> 02:21:55,859 do box 3355 02:21:55,859 --> 02:21:58,500 icon button 3356 02:21:58,500 --> 02:22:01,319 input base 3357 02:22:01,319 --> 02:22:04,280 typography 3358 02:22:05,040 --> 02:22:07,700 select 3359 02:22:08,340 --> 02:22:11,840 menu item 3360 02:22:12,000 --> 02:22:14,280 form control 3361 02:22:14,280 --> 02:22:16,560 use theme 3362 02:22:16,560 --> 02:22:20,580 and use media query 3363 02:22:20,580 --> 02:22:23,100 let me go down I'm going to import icons 3364 02:22:23,100 --> 02:22:25,200 now so 3365 02:22:25,200 --> 02:22:28,500 if you're curious material UI 3366 02:22:28,500 --> 02:22:31,220 icons 3367 02:22:31,260 --> 02:22:33,479 and go over here 3368 02:22:33,479 --> 02:22:35,460 you can see this is where you can find 3369 02:22:35,460 --> 02:22:38,939 the icons you can grab the icon if you 3370 02:22:38,939 --> 02:22:41,040 want right here and then search this is 3371 02:22:41,040 --> 02:22:42,180 very useful 3372 02:22:42,180 --> 02:22:44,100 otherwise you can just follow along 3373 02:22:44,100 --> 02:22:46,020 because I already have the icon set up 3374 02:22:46,020 --> 02:22:48,180 so I'm going to write search 3375 02:22:48,180 --> 02:22:52,620 comma message comma dark mode comma 3376 02:22:52,620 --> 02:22:53,819 light 3377 02:22:53,819 --> 02:22:57,420 mode notifications 3378 02:22:57,840 --> 02:23:00,120 help menu 3379 02:23:00,120 --> 02:23:02,220 and then close 3380 02:23:02,220 --> 02:23:04,439 and we're going to say from 3381 02:23:04,439 --> 02:23:09,060 at mui icons material 3382 02:23:09,060 --> 02:23:10,920 and finally we're going to import use 3383 02:23:10,920 --> 02:23:13,500 dispatch 3384 02:23:13,500 --> 02:23:16,620 and then use selector 3385 02:23:16,620 --> 02:23:18,660 from react Redux 3386 02:23:18,660 --> 02:23:21,260 import 3387 02:23:21,660 --> 02:23:25,859 set mode from State as well as set log 3388 02:23:25,859 --> 02:23:28,100 out 3389 02:23:28,560 --> 02:23:32,420 import use navigate 3390 02:23:32,520 --> 02:23:35,160 from react router Dom and finally we're 3391 02:23:35,160 --> 02:23:38,700 going to import Flex between 3392 02:23:38,700 --> 02:23:40,200 like so 3393 02:23:40,200 --> 02:23:41,700 a lot of things 3394 02:23:41,700 --> 02:23:43,979 we needed to import but we're going to 3395 02:23:43,979 --> 02:23:45,420 be using a lot of these things to create 3396 02:23:45,420 --> 02:23:46,560 this 3397 02:23:46,560 --> 02:23:49,859 complete navbar 3398 02:23:49,859 --> 02:23:51,720 so we're going to be creating a number 3399 02:23:51,720 --> 02:23:53,460 of states and a lot of things over here 3400 02:23:53,460 --> 02:23:56,580 so we're going to create is mobile menu 3401 02:23:56,580 --> 02:23:58,439 toggle 3402 02:23:58,439 --> 02:24:01,020 and set is menu 3403 02:24:01,020 --> 02:24:02,880 is mobile 3404 02:24:02,880 --> 02:24:04,200 actually let me spell that correctly 3405 02:24:04,200 --> 02:24:08,000 make sure you spell that correctly 3406 02:24:08,160 --> 02:24:11,060 and this 3407 02:24:11,399 --> 02:24:15,120 is going to be the value to determine if 3408 02:24:15,120 --> 02:24:17,880 we want to open up the mobile menu when 3409 02:24:17,880 --> 02:24:20,399 it's in small screens 3410 02:24:20,399 --> 02:24:24,479 and we can use this to toggle it on and 3411 02:24:24,479 --> 02:24:26,399 off 3412 02:24:26,399 --> 02:24:27,720 and then we're going to create this 3413 02:24:27,720 --> 02:24:30,300 batch equals use this batch so this is 3414 02:24:30,300 --> 02:24:32,100 something you need to use so you can 3415 02:24:32,100 --> 02:24:35,640 dispatch actions from the reducers then 3416 02:24:35,640 --> 02:24:38,700 we're going to say const navigate 3417 02:24:38,700 --> 02:24:41,880 equals use navigate 3418 02:24:41,880 --> 02:24:43,680 then we're going to do a const user 3419 02:24:43,680 --> 02:24:47,600 equals use selector 3420 02:24:48,859 --> 02:24:52,560 use select or if I spell that correctly 3421 02:24:52,560 --> 02:24:54,660 yeah and then we're gonna 3422 02:24:54,660 --> 02:24:56,000 grab 3423 02:24:56,000 --> 02:24:59,479 the user information 3424 02:25:00,420 --> 02:25:02,280 then we're going to grab 3425 02:25:02,280 --> 02:25:03,899 or we're not going to grab we're going 3426 02:25:03,899 --> 02:25:07,439 to set a variable called is non-mobile 3427 02:25:07,439 --> 02:25:09,000 screens 3428 02:25:09,000 --> 02:25:11,580 and we're going to be using use media 3429 02:25:11,580 --> 02:25:13,740 query so this is a hook built into 3430 02:25:13,740 --> 02:25:16,800 material UI that allows us to determine 3431 02:25:16,800 --> 02:25:19,560 if the current screen size of the user 3432 02:25:19,560 --> 02:25:21,840 is below this Min width or higher than 3433 02:25:21,840 --> 02:25:24,960 Min width so it's an easy way to use a 3434 02:25:24,960 --> 02:25:28,560 media query inside of react 3435 02:25:28,560 --> 02:25:31,800 and not have to use like media query 3436 02:25:31,800 --> 02:25:34,439 that you normally would in CSS 3437 02:25:34,439 --> 02:25:37,200 and so we go like this we have our Min 3438 02:25:37,200 --> 02:25:39,660 width everything's set and I'm going to 3439 02:25:39,660 --> 02:25:41,040 say 3440 02:25:41,040 --> 02:25:42,540 and the final thing we're going to set 3441 02:25:42,540 --> 02:25:44,460 is the theme 3442 02:25:44,460 --> 02:25:47,100 and we're going to be using the 3443 02:25:47,100 --> 02:25:50,460 so basically this theme will allow us to 3444 02:25:50,460 --> 02:25:54,120 if we go back to our theme JS file 3445 02:25:54,120 --> 02:25:57,060 we can use any of these colors that 3446 02:25:57,060 --> 02:25:58,200 we've set 3447 02:25:58,200 --> 02:26:00,540 and as long as we specify for example 3448 02:26:00,540 --> 02:26:02,460 theme dot palette 3449 02:26:02,460 --> 02:26:06,300 dot neutral dot main will give us this 3450 02:26:06,300 --> 02:26:09,180 color if it's in dark mode 3451 02:26:09,180 --> 02:26:11,280 otherwise it can give us this color if 3452 02:26:11,280 --> 02:26:12,720 it's in light mode so it's very 3453 02:26:12,720 --> 02:26:14,280 convenient to use this because it 3454 02:26:14,280 --> 02:26:17,280 already automatically determines 3455 02:26:17,280 --> 02:26:21,800 the color based on the particular mode 3456 02:26:21,840 --> 02:26:23,819 so this is why we use these type of 3457 02:26:23,819 --> 02:26:25,680 colors 3458 02:26:25,680 --> 02:26:27,420 and so the first thing I'm going to get 3459 02:26:27,420 --> 02:26:31,200 is neutral light 3460 02:26:31,200 --> 02:26:34,680 I'm going to say theme dot palette 3461 02:26:34,680 --> 02:26:37,380 dot neutral 3462 02:26:37,380 --> 02:26:39,000 dot light 3463 02:26:39,000 --> 02:26:40,680 so it is kind of annoying that you have 3464 02:26:40,680 --> 02:26:42,780 to write a lot of 3465 02:26:42,780 --> 02:26:45,600 this stuff but it makes it very nice and 3466 02:26:45,600 --> 02:26:48,120 clean if you configure these variables 3467 02:26:48,120 --> 02:26:51,240 before you write it inside the jsx 3468 02:26:51,240 --> 02:26:53,880 so I'm going to have a dark one 3469 02:26:53,880 --> 02:26:55,620 I'm going to copy this 3470 02:26:55,620 --> 02:26:57,420 theme dot palette 3471 02:26:57,420 --> 02:26:59,040 and I'm going to say we're going to get 3472 02:26:59,040 --> 02:27:01,520 the background 3473 02:27:01,520 --> 02:27:05,880 theme.palette dot background dot default 3474 02:27:05,880 --> 02:27:10,220 and then we're going to do primary light 3475 02:27:10,500 --> 02:27:12,300 so we're going to do that theme.palette 3476 02:27:12,300 --> 02:27:15,720 dot primary dot light 3477 02:27:15,720 --> 02:27:18,300 and then we're going to const Alt 3478 02:27:18,300 --> 02:27:20,700 is equal to theme.palot dot background 3479 02:27:20,700 --> 02:27:23,700 Dot 3480 02:27:23,700 --> 02:27:27,000 so these are colors that we'll be using 3481 02:27:27,000 --> 02:27:29,160 and then finally we're just going to set 3482 02:27:29,160 --> 02:27:30,780 the full name 3483 02:27:30,780 --> 02:27:33,300 this is a convenience variable and we're 3484 02:27:33,300 --> 02:27:36,660 going to set this as user DOT first 3485 02:27:36,660 --> 02:27:38,160 name 3486 02:27:38,160 --> 02:27:39,960 and then 3487 02:27:39,960 --> 02:27:43,140 user dot last name 3488 02:27:43,140 --> 02:27:44,760 so this gives us 3489 02:27:44,760 --> 02:27:49,100 the full name access right here 3490 02:27:50,520 --> 02:27:51,960 and then from here we're going to go to 3491 02:27:51,960 --> 02:27:54,660 our jsx and we're going to Define some 3492 02:27:54,660 --> 02:27:56,460 variables here so I'm going to do Flex 3493 02:27:56,460 --> 02:27:58,200 between 3494 02:27:58,200 --> 02:28:00,060 and inside the flex between I'm going to 3495 02:28:00,060 --> 02:28:03,899 set padding of one REM 3496 02:28:03,899 --> 02:28:05,939 and six percent 3497 02:28:05,939 --> 02:28:09,200 and a background color 3498 02:28:10,260 --> 02:28:12,720 of Alt 3499 02:28:12,720 --> 02:28:16,020 so again we're using this reusable 3500 02:28:16,020 --> 02:28:19,319 component this has all those properties 3501 02:28:19,319 --> 02:28:21,899 by default and we can configure 3502 02:28:21,899 --> 02:28:23,939 different 3503 02:28:23,939 --> 02:28:26,340 CSS properties like we normally do with 3504 02:28:26,340 --> 02:28:29,580 material UI and just FYI material UI has 3505 02:28:29,580 --> 02:28:32,340 these box components like this one 3506 02:28:32,340 --> 02:28:35,939 so that allows us to pass in any type of 3507 02:28:35,939 --> 02:28:38,340 CSS properties and then use them as a 3508 02:28:38,340 --> 02:28:40,319 component property 3509 02:28:40,319 --> 02:28:43,260 so instead of patting colon 3510 02:28:43,260 --> 02:28:45,840 this value we're doing padding equals 3511 02:28:45,840 --> 02:28:48,720 string and we're passing in values so 3512 02:28:48,720 --> 02:28:50,640 it's very nice to use 3513 02:28:50,640 --> 02:28:52,800 but this is only available to the Box 3514 02:28:52,800 --> 02:28:54,840 component if you use other components 3515 02:28:54,840 --> 02:28:56,700 like button component you cannot do the 3516 02:28:56,700 --> 02:28:58,859 same thing you have to pass it into a 3517 02:28:58,859 --> 02:29:01,560 property called SX and pass it in as a 3518 02:29:01,560 --> 02:29:04,020 property of an object within that and 3519 02:29:04,020 --> 02:29:06,840 I'll show you when we use that so it'll 3520 02:29:06,840 --> 02:29:09,060 makes a lot of sense and from here I'm 3521 02:29:09,060 --> 02:29:11,100 going to use flex between again because 3522 02:29:11,100 --> 02:29:14,060 we want to set 3523 02:29:14,340 --> 02:29:15,720 particular 3524 02:29:15,720 --> 02:29:18,479 navbar Gap as well 3525 02:29:18,479 --> 02:29:21,240 now if you go back and you look at our 3526 02:29:21,240 --> 02:29:24,000 built component I'm just going to sign 3527 02:29:24,000 --> 02:29:25,680 in real quick 3528 02:29:25,680 --> 02:29:28,700 just to show you 3529 02:29:29,220 --> 02:29:33,439 seems like I did not let's 3530 02:29:34,260 --> 02:29:36,420 I'm going to resign this in fake 3531 02:29:36,420 --> 02:29:41,100 location fake occupation 3532 02:29:41,220 --> 02:29:43,560 set a user 3533 02:29:43,560 --> 02:29:45,600 I'm going to say fake 3534 02:29:45,600 --> 02:29:49,200 person at gmail.com fake person 3535 02:29:49,200 --> 02:29:51,859 register 3536 02:29:52,140 --> 02:29:56,180 make sure everything works okay 3537 02:29:56,460 --> 02:29:59,760 I'm gonna say fake person at gmail fake 3538 02:29:59,760 --> 02:30:03,660 person that we're gonna log in and we're 3539 02:30:03,660 --> 02:30:05,700 good to be logged in 3540 02:30:05,700 --> 02:30:07,620 and I just wanted to show you the nav 3541 02:30:07,620 --> 02:30:11,280 bar like this so I have this if you see 3542 02:30:11,280 --> 02:30:13,620 my other videos I have this total 3543 02:30:13,620 --> 02:30:15,660 pesticide Chrome extension very useful 3544 02:30:15,660 --> 02:30:18,300 to see what's happening in terms of flex 3545 02:30:18,300 --> 02:30:21,120 and the displays so if you look at this 3546 02:30:21,120 --> 02:30:24,240 nav bar we have a div and these two are 3547 02:30:24,240 --> 02:30:27,060 separate so we're doing Flex between to 3548 02:30:27,060 --> 02:30:29,280 show that these items are separate and 3549 02:30:29,280 --> 02:30:31,620 among this we have another Flex box in 3550 02:30:31,620 --> 02:30:34,920 here so you can see that these are all 3551 02:30:34,920 --> 02:30:38,040 flexed within a flex already same with 3552 02:30:38,040 --> 02:30:39,420 over here 3553 02:30:39,420 --> 02:30:42,500 so we're going to do that 3554 02:30:42,780 --> 02:30:45,540 so this is going to be 3555 02:30:45,540 --> 02:30:47,520 the logo so this we're just going to 3556 02:30:47,520 --> 02:30:49,080 typography 3557 02:30:49,080 --> 02:30:51,240 passing in socio 3558 02:30:51,240 --> 02:30:53,460 pedia Within 3559 02:30:53,460 --> 02:30:57,660 and inside I'm going to set font weight 3560 02:30:57,660 --> 02:30:59,700 of bold 3561 02:30:59,700 --> 02:31:01,859 I'm going to set a font size 3562 02:31:01,859 --> 02:31:06,920 of clamp one REM 2 REM 3563 02:31:06,920 --> 02:31:10,580 2.25 REM so now if you're 3564 02:31:10,580 --> 02:31:13,140 unfamiliar clap is a function you can 3565 02:31:13,140 --> 02:31:17,460 use in CSS that determines a minimum 3566 02:31:17,460 --> 02:31:20,340 a minimum value for a font 3567 02:31:20,340 --> 02:31:22,620 a maximum value for the font and a 3568 02:31:22,620 --> 02:31:24,479 preferred value so it will always try to 3569 02:31:24,479 --> 02:31:27,120 be 2 REM but the screen size gets too 3570 02:31:27,120 --> 02:31:29,160 small we're going to go to one RM if it 3571 02:31:29,160 --> 02:31:32,700 gets too big it's going to set 2.25 REM 3572 02:31:32,700 --> 02:31:35,340 it's very useful for fonts 3573 02:31:35,340 --> 02:31:37,020 you can probably use it for width as 3574 02:31:37,020 --> 02:31:39,720 well it's just more useful for fonts 3575 02:31:39,720 --> 02:31:41,280 then we're going to set the color as 3576 02:31:41,280 --> 02:31:43,020 primary which is kind of a light blue 3577 02:31:43,020 --> 02:31:46,740 color and we're going to set on click 3578 02:31:46,740 --> 02:31:49,080 and when you click this logo technically 3579 02:31:49,080 --> 02:31:51,840 you generally want to navigate to the 3580 02:31:51,840 --> 02:31:54,120 home page and that's what we'll do with 3581 02:31:54,120 --> 02:31:56,040 react router 3582 02:31:56,040 --> 02:31:58,200 and then we're going to set at SX so 3583 02:31:58,200 --> 02:31:59,880 like I mentioned this is where you can 3584 02:31:59,880 --> 02:32:02,939 put CSS properties if you have a 3585 02:32:02,939 --> 02:32:04,740 situation where you're passing in pseudo 3586 02:32:04,740 --> 02:32:06,660 properties this is where you're going to 3587 02:32:06,660 --> 02:32:09,479 have to do it so in this case when you 3588 02:32:09,479 --> 02:32:11,460 hover we're going to add some Styles so 3589 02:32:11,460 --> 02:32:13,560 we're going to give it a color a primary 3590 02:32:13,560 --> 02:32:16,800 light and give it a cursor 3591 02:32:16,800 --> 02:32:19,920 of pointer 3592 02:32:19,920 --> 02:32:21,840 we're going to save that that gives us 3593 02:32:21,840 --> 02:32:23,460 our logo 3594 02:32:23,460 --> 02:32:26,040 and below this and we're going to say if 3595 02:32:26,040 --> 02:32:26,899 it's 3596 02:32:26,899 --> 02:32:30,720 non-mobile screens 3597 02:32:30,720 --> 02:32:33,420 we're going to give it the search bar so 3598 02:32:33,420 --> 02:32:36,359 if it is above mobile screens we're not 3599 02:32:36,359 --> 02:32:39,060 going to show this or if it's sorry if 3600 02:32:39,060 --> 02:32:40,620 it is a Mobile screen we're not going to 3601 02:32:40,620 --> 02:32:41,640 show this 3602 02:32:41,640 --> 02:32:44,220 so we're going to do Flex between 3603 02:32:44,220 --> 02:32:47,280 I'm going to close this 3604 02:32:47,280 --> 02:32:49,319 like so 3605 02:32:49,319 --> 02:32:52,260 make sure that's closing tag 3606 02:32:52,260 --> 02:32:55,260 and inside this Flex between 3607 02:32:55,260 --> 02:32:57,420 we're going to have a background 3608 02:32:57,420 --> 02:32:59,880 color of 3609 02:32:59,880 --> 02:33:02,040 neutral light 3610 02:33:02,040 --> 02:33:08,040 give it a border radius of 9 pixel 3611 02:33:08,040 --> 02:33:10,640 Gap 3612 02:33:10,680 --> 02:33:15,120 of three REM in between the values I'm 3613 02:33:15,120 --> 02:33:19,260 going to give it a padding of 0.1 REM 3614 02:33:19,260 --> 02:33:22,920 and 1.5 REM so this is a shorthand this 3615 02:33:22,920 --> 02:33:25,080 means the zero point REM 3616 02:33:25,080 --> 02:33:28,979 on top and bottom and 1.5 REM left and 3617 02:33:28,979 --> 02:33:30,899 right so if you have two values 3618 02:33:30,899 --> 02:33:33,000 it oops 3619 02:33:33,000 --> 02:33:34,979 it reflects 3620 02:33:34,979 --> 02:33:38,160 top and bottom and then left and right 3621 02:33:38,160 --> 02:33:41,160 so that's a shorthand 3622 02:33:41,160 --> 02:33:43,380 and inside this I'm going to put input 3623 02:33:43,380 --> 02:33:45,800 base 3624 02:33:46,319 --> 02:33:50,460 I'm going to put placeholder of search 3625 02:33:50,460 --> 02:33:53,520 so that will give us a search value 3626 02:33:53,520 --> 02:33:55,080 and we're going to close this we're 3627 02:33:55,080 --> 02:33:57,060 going to say icon button 3628 02:33:57,060 --> 02:33:59,100 and inside here I'm going to give it a 3629 02:33:59,100 --> 02:34:00,479 search 3630 02:34:00,479 --> 02:34:02,819 value which is basically the icon I'm 3631 02:34:02,819 --> 02:34:04,500 going to save this 3632 02:34:04,500 --> 02:34:06,899 and everything gets fermented 3633 02:34:06,899 --> 02:34:09,840 and below this Flex between 3634 02:34:09,840 --> 02:34:11,700 I'm going to create another comment I'm 3635 02:34:11,700 --> 02:34:12,620 going to say 3636 02:34:12,620 --> 02:34:16,399 desktop nav 3637 02:34:16,560 --> 02:34:18,600 and below this this will be navigation 3638 02:34:18,600 --> 02:34:22,140 dedicated towards non-mobile screens so 3639 02:34:22,140 --> 02:34:24,660 I'm going to say is non mobile screens 3640 02:34:24,660 --> 02:34:27,300 again and we're going to put a ternary 3641 02:34:27,300 --> 02:34:29,340 operator we're going to give this Flex 3642 02:34:29,340 --> 02:34:31,319 between 3643 02:34:31,319 --> 02:34:35,120 and make sure we close that 3644 02:34:35,340 --> 02:34:39,000 and I'll fill this in a little bit 3645 02:34:39,000 --> 02:34:42,600 and for now I'm just going to put icon 3646 02:34:42,600 --> 02:34:44,100 button 3647 02:34:44,100 --> 02:34:46,140 as a secondary 3648 02:34:46,140 --> 02:34:48,960 just so we can have this Auto formatted 3649 02:34:48,960 --> 02:34:51,780 and close this and then I'll fill this 3650 02:34:51,780 --> 02:34:53,399 in 3651 02:34:53,399 --> 02:34:56,280 in here we're going to give it a gap of 3652 02:34:56,280 --> 02:34:58,760 two REM 3653 02:34:59,520 --> 02:35:02,399 I'm going to say icon button 3654 02:35:02,399 --> 02:35:05,100 on click 3655 02:35:05,100 --> 02:35:09,180 and I'm going to dispatch set mode so 3656 02:35:09,180 --> 02:35:10,080 this 3657 02:35:10,080 --> 02:35:13,740 is going to be the button for our light 3658 02:35:13,740 --> 02:35:15,420 and dark mode 3659 02:35:15,420 --> 02:35:18,240 so this is the dispatch of the action 3660 02:35:18,240 --> 02:35:21,780 that will change the mode 3661 02:35:21,780 --> 02:35:24,960 in our Redux so if I go back here this 3662 02:35:24,960 --> 02:35:27,540 will change the light to dark and dark 3663 02:35:27,540 --> 02:35:29,160 to light 3664 02:35:29,160 --> 02:35:31,620 so if I go back here I'm creating an 3665 02:35:31,620 --> 02:35:34,560 icon button and so if the theme dot 3666 02:35:34,560 --> 02:35:36,720 palette 3667 02:35:36,720 --> 02:35:38,460 dot mode 3668 02:35:38,460 --> 02:35:42,180 is equal to dark 3669 02:35:42,180 --> 02:35:44,100 what we are going to do is going to have 3670 02:35:44,100 --> 02:35:45,720 a ternary operator we're going to set 3671 02:35:45,720 --> 02:35:47,700 the dark mode 3672 02:35:47,700 --> 02:35:49,979 icon 3673 02:35:49,979 --> 02:35:54,720 and do SX font size 3674 02:35:54,720 --> 02:35:57,060 so so font size just represents the size 3675 02:35:57,060 --> 02:35:58,620 of 3676 02:35:58,620 --> 02:36:02,520 the icon over here or icon yeah 3677 02:36:02,520 --> 02:36:05,700 and then inside the second option we're 3678 02:36:05,700 --> 02:36:08,580 going to pass in light mode 3679 02:36:08,580 --> 02:36:12,800 and I'm going to copy this SX over here 3680 02:36:13,380 --> 02:36:15,540 and in this case we're going to set this 3681 02:36:15,540 --> 02:36:16,740 as color 3682 02:36:16,740 --> 02:36:19,080 of dark 3683 02:36:19,080 --> 02:36:22,380 and then font size of 25 pixel 3684 02:36:22,380 --> 02:36:25,460 we're going to save that 3685 02:36:25,800 --> 02:36:29,520 so again we're using Redux to flip the 3686 02:36:29,520 --> 02:36:31,800 switch for the dark and light mode and 3687 02:36:31,800 --> 02:36:35,300 we can change the dark and light mode 3688 02:36:35,939 --> 02:36:37,319 and then from here I'm going to say 3689 02:36:37,319 --> 02:36:38,640 message 3690 02:36:38,640 --> 02:36:41,880 which is another icon and actually I'm 3691 02:36:41,880 --> 02:36:43,920 going to be copying this SX equals font 3692 02:36:43,920 --> 02:36:45,720 size because I'll be repeatedly using it 3693 02:36:45,720 --> 02:36:48,780 same with the closing tag so I'm copying 3694 02:36:48,780 --> 02:36:50,640 that 3695 02:36:50,640 --> 02:36:52,920 so I'm pasting that for messages we're 3696 02:36:52,920 --> 02:36:54,120 going to do the same thing for 3697 02:36:54,120 --> 02:36:57,080 notifications 3698 02:36:57,359 --> 02:37:00,720 close that same with help 3699 02:37:00,720 --> 02:37:03,359 close that and then we're going to 3700 02:37:03,359 --> 02:37:07,319 create a form control so this is going 3701 02:37:07,319 --> 02:37:11,399 to be for the drop down at the top right 3702 02:37:11,399 --> 02:37:14,580 where we can see the user that's logged 3703 02:37:14,580 --> 02:37:19,040 in as well as the logout button 3704 02:37:19,620 --> 02:37:21,420 and here I'm going to give it a value of 3705 02:37:21,420 --> 02:37:24,020 Ed row 3706 02:37:24,600 --> 02:37:28,760 actually this value should be full name 3707 02:37:33,060 --> 02:37:34,920 right and then here I'm going to say 3708 02:37:34,920 --> 02:37:37,819 select 3709 02:37:39,359 --> 02:37:41,520 and inside here I'm going to give it a 3710 02:37:41,520 --> 02:37:45,479 value of full name 3711 02:37:45,479 --> 02:37:49,800 and give it some CSS properties with SX 3712 02:37:49,800 --> 02:37:52,319 we're going to say background color 3713 02:37:52,319 --> 02:37:55,800 of neutral light 3714 02:37:55,800 --> 02:38:00,359 a width of 150 pixel 3715 02:38:00,359 --> 02:38:03,979 border radius 3716 02:38:04,020 --> 02:38:05,060 of 3717 02:38:05,060 --> 02:38:08,160 0.25 REM 3718 02:38:08,160 --> 02:38:12,300 padding of 0.25 REM 1 REM 3719 02:38:12,300 --> 02:38:16,319 so again a shorthand for 0.25 REM top 3720 02:38:16,319 --> 02:38:18,960 bottom one REM left and right 3721 02:38:18,960 --> 02:38:22,040 and we're going to do 3722 02:38:22,380 --> 02:38:23,100 um 3723 02:38:23,100 --> 02:38:26,100 we're going to select within so the way 3724 02:38:26,100 --> 02:38:29,460 we select within the CSS class we're 3725 02:38:29,460 --> 02:38:33,120 going to Target a specific class name 3726 02:38:33,120 --> 02:38:35,100 in material UI 3727 02:38:35,100 --> 02:38:37,260 and you can do that by going into a 3728 02:38:37,260 --> 02:38:40,260 specter you can search inside it to see 3729 02:38:40,260 --> 02:38:42,120 which class you want to Target and 3730 02:38:42,120 --> 02:38:43,439 occasionally you have to do this it's a 3731 02:38:43,439 --> 02:38:45,479 little annoying 3732 02:38:45,479 --> 02:38:48,060 but once you find this class name you 3733 02:38:48,060 --> 02:38:50,880 want to fix we can change it like this 3734 02:38:50,880 --> 02:38:54,780 give this a 3 REM like so and then from 3735 02:38:54,780 --> 02:38:57,899 here I'm going to set and Dot mui select 3736 02:38:57,899 --> 02:39:02,220 Dash select Focus 3737 02:39:02,220 --> 02:39:04,439 I'm going to say colon I'm going to say 3738 02:39:04,439 --> 02:39:10,100 background color of neutral light 3739 02:39:11,399 --> 02:39:13,859 okay and then last thing we want to do 3740 02:39:13,859 --> 02:39:15,899 is input 3741 02:39:15,899 --> 02:39:18,180 input going to be 3742 02:39:18,180 --> 02:39:22,040 slash input base 3743 02:39:22,200 --> 02:39:24,720 so we're going to pass in an input of an 3744 02:39:24,720 --> 02:39:27,479 input component of input base and inside 3745 02:39:27,479 --> 02:39:30,300 the select we're going to say menu item 3746 02:39:30,300 --> 02:39:34,140 value a full name 3747 02:39:34,140 --> 02:39:36,000 so this is not actually going to be like 3748 02:39:36,000 --> 02:39:38,220 a select component where we're actually 3749 02:39:38,220 --> 02:39:40,439 selecting from the drop down we just 3750 02:39:40,439 --> 02:39:42,540 have a button when essentially this is 3751 02:39:42,540 --> 02:39:45,060 just a button within a drop down because 3752 02:39:45,060 --> 02:39:47,340 the only thing you can select is the log 3753 02:39:47,340 --> 02:39:50,580 out which will take us to another page 3754 02:39:50,580 --> 02:39:52,800 but this is what we're using 3755 02:39:52,800 --> 02:39:54,060 we're going to say this is going to be 3756 02:39:54,060 --> 02:39:56,460 full name as a value 3757 02:39:56,460 --> 02:40:00,960 and I'm going to set menu item 3758 02:40:00,960 --> 02:40:04,680 and I'm going to say on click 3759 02:40:04,680 --> 02:40:07,260 we are going to dispatch 3760 02:40:07,260 --> 02:40:09,600 set log out 3761 02:40:09,600 --> 02:40:12,420 so when you click this menu item 3762 02:40:12,420 --> 02:40:17,520 of log out it'll take us 3763 02:40:17,520 --> 02:40:21,300 and log out from our page 3764 02:40:21,300 --> 02:40:24,240 so it seems like I do have some kind of 3765 02:40:24,240 --> 02:40:25,620 error 3766 02:40:25,620 --> 02:40:27,479 let's see 3767 02:40:27,479 --> 02:40:29,460 and it seems like it starts from here 3768 02:40:29,460 --> 02:40:31,140 okay 3769 02:40:31,140 --> 02:40:33,720 we can see colon like this so make sure 3770 02:40:33,720 --> 02:40:35,819 when you look at this you can see why 3771 02:40:35,819 --> 02:40:38,340 it's not saving most likely you have 3772 02:40:38,340 --> 02:40:40,080 some kind of syntax error and that's 3773 02:40:40,080 --> 02:40:41,399 where I found it 3774 02:40:41,399 --> 02:40:43,800 so I'm going to save it now we're 3775 02:40:43,800 --> 02:40:46,979 prettier is not yelling at us 3776 02:40:46,979 --> 02:40:49,380 and finally we have the icon button 3777 02:40:49,380 --> 02:40:51,300 and inside the icon button I'm going to 3778 02:40:51,300 --> 02:40:54,000 say on click 3779 02:40:54,000 --> 02:40:56,520 pass this in set is 3780 02:40:56,520 --> 02:40:59,580 mobile menu toggled 3781 02:40:59,580 --> 02:41:02,640 and we're going to say is menu 3782 02:41:02,640 --> 02:41:05,280 is mobile menu 3783 02:41:05,280 --> 02:41:09,439 toggle so we're just going to flip it 3784 02:41:09,600 --> 02:41:12,899 so this is going to pop up an icon of a 3785 02:41:12,899 --> 02:41:16,200 menu when you are in small screens 3786 02:41:16,200 --> 02:41:20,000 so that's what it's doing over here 3787 02:41:21,600 --> 02:41:23,760 and then below this we're going to 3788 02:41:23,760 --> 02:41:26,840 create the mobile nav 3789 02:41:29,399 --> 02:41:32,780 and in here I'm going to say if it is 3790 02:41:32,780 --> 02:41:36,060 non-mobile screens so basically if it is 3791 02:41:36,060 --> 02:41:37,260 a Mobile screen 3792 02:41:37,260 --> 02:41:40,439 and if is mobile menu 3793 02:41:40,439 --> 02:41:43,319 toggled so basically when you click the 3794 02:41:43,319 --> 02:41:45,060 menu 3795 02:41:45,060 --> 02:41:48,899 item it should open up a box that will 3796 02:41:48,899 --> 02:41:52,740 close it all right a box that will have 3797 02:41:52,740 --> 02:41:56,120 the icons in there 3798 02:41:56,280 --> 02:41:59,280 and so this since it's a gonna be a 3799 02:41:59,280 --> 02:42:00,840 mobile in front of everything we're 3800 02:42:00,840 --> 02:42:03,180 going to give it a position of fixed 3801 02:42:03,180 --> 02:42:05,100 and we want this to take up the entire 3802 02:42:05,100 --> 02:42:06,600 height 3803 02:42:06,600 --> 02:42:09,240 probably a width of like you know 300 3804 02:42:09,240 --> 02:42:11,880 pixel 500 pixel around there 3805 02:42:11,880 --> 02:42:13,380 so we're going to set this to the right 3806 02:42:13,380 --> 02:42:15,240 we're going to set it to the bottom as 3807 02:42:15,240 --> 02:42:17,640 well so it takes up the entire page as 3808 02:42:17,640 --> 02:42:20,939 well as give it a height of 100 percent 3809 02:42:20,939 --> 02:42:22,979 we're going to give it a z index of 10 3810 02:42:22,979 --> 02:42:25,920 so it's in front of everything give it a 3811 02:42:25,920 --> 02:42:28,200 Max width 3812 02:42:28,200 --> 02:42:30,359 of 500 pixel 3813 02:42:30,359 --> 02:42:32,040 Min with 3814 02:42:32,040 --> 02:42:34,680 of 300 pixels and we're going to give it 3815 02:42:34,680 --> 02:42:36,359 a background color 3816 02:42:36,359 --> 02:42:38,640 of the background color that we set 3817 02:42:38,640 --> 02:42:41,819 earlier at the top of the component and 3818 02:42:41,819 --> 02:42:43,920 then we're going to give a close icon 3819 02:42:43,920 --> 02:42:48,359 after it as the first thing in our model 3820 02:42:48,359 --> 02:42:51,180 and in here I'm going to say display 3821 02:42:51,180 --> 02:42:53,760 of flex so I'm not going to use 3822 02:42:53,760 --> 02:42:56,340 the flex between component because I 3823 02:42:56,340 --> 02:42:59,420 just want to justify content to be Flex 3824 02:42:59,420 --> 02:43:03,240 end so this is specific so we don't we 3825 02:43:03,240 --> 02:43:06,180 cannot use our reusable component 3826 02:43:06,180 --> 02:43:07,620 and we're going to give the padding of 3827 02:43:07,620 --> 02:43:10,100 one REM 3828 02:43:10,380 --> 02:43:13,080 and inside this 3829 02:43:13,080 --> 02:43:15,120 I'm going to go back up I'm going to 3830 02:43:15,120 --> 02:43:17,479 just copy this where you have the menu 3831 02:43:17,479 --> 02:43:20,100 toggle and we're going to just be 3832 02:43:20,100 --> 02:43:22,620 using that 3833 02:43:22,620 --> 02:43:25,319 in our icon button 3834 02:43:25,319 --> 02:43:28,380 so I'm just going to hit enter I can do 3835 02:43:28,380 --> 02:43:32,819 on click and pass in our close icon 3836 02:43:32,819 --> 02:43:35,479 like so 3837 02:43:35,780 --> 02:43:38,460 and below that I'm going to create menu 3838 02:43:38,460 --> 02:43:40,500 items 3839 02:43:40,500 --> 02:43:44,340 so this is going to reflect closely to 3840 02:43:44,340 --> 02:43:45,780 what we have 3841 02:43:45,780 --> 02:43:47,760 earlier it's just going to be slightly 3842 02:43:47,760 --> 02:43:50,399 different but 3843 02:43:50,399 --> 02:43:51,899 I'm not going to make it reusable 3844 02:43:51,899 --> 02:43:53,220 because there's some 3845 02:43:53,220 --> 02:43:55,859 minor differences so it's not worth 3846 02:43:55,859 --> 02:43:59,640 going through the pain of trying to 3847 02:43:59,640 --> 02:44:01,680 make it reusable so I'm going to copy 3848 02:44:01,680 --> 02:44:04,100 all this 3849 02:44:05,640 --> 02:44:07,859 let's see and we're going to go down to 3850 02:44:07,859 --> 02:44:10,640 menu items 3851 02:44:10,680 --> 02:44:13,500 and I'm going to paste it all over here 3852 02:44:13,500 --> 02:44:16,979 so I copied everything from where the 3853 02:44:16,979 --> 02:44:20,960 light mode stuff happens 3854 02:44:22,200 --> 02:44:24,600 so if I go over here 3855 02:44:24,600 --> 02:44:27,240 I essentially copied 3856 02:44:27,240 --> 02:44:30,000 everything actually let me redo this so 3857 02:44:30,000 --> 02:44:32,220 I copied everything at the beginning 3858 02:44:32,220 --> 02:44:36,000 from the flex between in the desktop nav 3859 02:44:36,000 --> 02:44:37,859 and I'm just going to pretend you didn't 3860 02:44:37,859 --> 02:44:39,960 see that so 3861 02:44:39,960 --> 02:44:42,720 Let's uh 3862 02:44:42,720 --> 02:44:45,120 delete this right here 3863 02:44:45,120 --> 02:44:47,100 and in this menu item I'm going to 3864 02:44:47,100 --> 02:44:50,160 repaste it with the flux between 3865 02:44:50,160 --> 02:44:52,200 and we're gonna just modify some things 3866 02:44:52,200 --> 02:44:54,060 here so we're going to give it a display 3867 02:44:54,060 --> 02:44:56,460 of flex 3868 02:44:56,460 --> 02:44:59,040 we're going to do Flex Direction 3869 02:44:59,040 --> 02:45:02,460 of column so what that means is that 3870 02:45:02,460 --> 02:45:03,420 we're gonna 3871 02:45:03,420 --> 02:45:05,939 have it flexed up and down as opposed to 3872 02:45:05,939 --> 02:45:08,399 left and right this time we're going to 3873 02:45:08,399 --> 02:45:11,399 do Justified content of Center 3874 02:45:11,399 --> 02:45:13,740 so that we Center it vertically and we 3875 02:45:13,740 --> 02:45:16,260 Center it horizontally as well with 3876 02:45:16,260 --> 02:45:19,080 align items 3877 02:45:19,080 --> 02:45:21,840 and we're going to give it a gap of 3 3878 02:45:21,840 --> 02:45:23,700 REM instead 3879 02:45:23,700 --> 02:45:26,960 we're going to save that 3880 02:45:28,439 --> 02:45:30,540 and everything should 3881 02:45:30,540 --> 02:45:32,280 be good 3882 02:45:32,280 --> 02:45:34,380 I'm also going to set this icon button 3883 02:45:34,380 --> 02:45:35,819 to 3884 02:45:35,819 --> 02:45:39,420 font size just so just in case we have 3885 02:45:39,420 --> 02:45:41,100 the correct size 3886 02:45:41,100 --> 02:45:44,100 everything else let me double check 3887 02:45:44,100 --> 02:45:45,960 should be 3888 02:45:45,960 --> 02:45:48,840 exactly the same 3889 02:45:48,840 --> 02:45:51,420 I think even this is going to be the 3890 02:45:51,420 --> 02:45:54,800 same with 3rm 3891 02:45:55,140 --> 02:45:56,640 yeah 3892 02:45:56,640 --> 02:46:00,060 and with that we have our nav bar I know 3893 02:46:00,060 --> 02:46:01,979 there's a lot of moving pieces 3894 02:46:01,979 --> 02:46:03,660 let me zoom out so you can see 3895 02:46:03,660 --> 02:46:05,880 everything you have the menu items you 3896 02:46:05,880 --> 02:46:08,340 have mobile menu you have a close icon 3897 02:46:08,340 --> 02:46:10,560 you have the mobile nav and then you 3898 02:46:10,560 --> 02:46:13,800 have the desktop nav you have 3899 02:46:13,800 --> 02:46:16,200 all the different theme colors 3900 02:46:16,200 --> 02:46:18,420 and the logo and the search a lot of 3901 02:46:18,420 --> 02:46:21,000 things going on but this is probably one 3902 02:46:21,000 --> 02:46:22,500 of the bigger components that we are 3903 02:46:22,500 --> 02:46:24,359 going to be creating 3904 02:46:24,359 --> 02:46:27,000 this I want to see the nav bar for the 3905 02:46:27,000 --> 02:46:30,660 time being I'm going to add it to home 3906 02:46:30,660 --> 02:46:34,200 right here so I'm going to do 3907 02:46:34,200 --> 02:46:35,819 I'm going to select this I'm going to 3908 02:46:35,819 --> 02:46:37,140 hit box 3909 02:46:37,140 --> 02:46:39,120 so we're going to import box from 3910 02:46:39,120 --> 02:46:40,680 Material UI 3911 02:46:40,680 --> 02:46:43,319 and right here inside the box I'm going 3912 02:46:43,319 --> 02:46:45,899 to import navbar 3913 02:46:45,899 --> 02:46:48,660 like so using intellisense 3914 02:46:48,660 --> 02:46:51,240 and I want to check if this is working 3915 02:46:51,240 --> 02:46:54,359 on our live site so this is our 3916 02:46:54,359 --> 02:46:57,000 completed site but let's look at our 3917 02:46:57,000 --> 02:46:59,340 live site so now we added this to the 3918 02:46:59,340 --> 02:47:01,200 home page so we have to go to the home 3919 02:47:01,200 --> 02:47:04,040 page to see it 3920 02:47:09,780 --> 02:47:12,120 and we are waiting it for it to compile 3921 02:47:12,120 --> 02:47:15,060 compiled successfully and now you can 3922 02:47:15,060 --> 02:47:16,020 see 3923 02:47:16,020 --> 02:47:17,819 we have light dark mode we have 3924 02:47:17,819 --> 02:47:20,399 everything with our nav bar complete we 3925 02:47:20,399 --> 02:47:22,920 have a drop down we can log out if we 3926 02:47:22,920 --> 02:47:25,380 want to so perfect everything is working 3927 02:47:25,380 --> 02:47:27,780 as expected 3928 02:47:27,780 --> 02:47:29,460 you want to show 3929 02:47:29,460 --> 02:47:31,439 what it looks like when you're on mobile 3930 02:47:31,439 --> 02:47:34,200 screens it'll remove the search bar 3931 02:47:34,200 --> 02:47:35,700 everything will be 3932 02:47:35,700 --> 02:47:39,000 come this and you can open this up close 3933 02:47:39,000 --> 02:47:41,520 it as well 3934 02:47:41,520 --> 02:47:43,680 so that is everything and it's working 3935 02:47:43,680 --> 02:47:45,479 as expected 3936 02:47:45,479 --> 02:47:48,660 and with that I am now going to be 3937 02:47:48,660 --> 02:47:50,819 creating the login page and the register 3938 02:47:50,819 --> 02:47:53,340 page so if we look at the completed 3939 02:47:53,340 --> 02:47:54,720 application 3940 02:47:54,720 --> 02:47:56,760 I'm going to log out I'm going to show 3941 02:47:56,760 --> 02:47:58,920 you this is our login page so we'll have 3942 02:47:58,920 --> 02:48:02,819 a form but using the same form if you 3943 02:48:02,819 --> 02:48:04,439 click don't have an account sign up here 3944 02:48:04,439 --> 02:48:07,680 you can see that we have this form 3945 02:48:07,680 --> 02:48:10,920 set up so we can register over here so 3946 02:48:10,920 --> 02:48:12,720 we can go back to login we can go back 3947 02:48:12,720 --> 02:48:14,760 to sign up over here and we're going to 3948 02:48:14,760 --> 02:48:16,680 be reusing some of the same components 3949 02:48:16,680 --> 02:48:19,680 so going back to the code I'm going to 3950 02:48:19,680 --> 02:48:21,600 close all this again 3951 02:48:21,600 --> 02:48:24,479 go to login page 3952 02:48:24,479 --> 02:48:26,700 and in here I'm going to import the 3953 02:48:26,700 --> 02:48:29,479 number of items 3954 02:48:30,060 --> 02:48:33,800 so I'm going to import box 3955 02:48:34,680 --> 02:48:36,359 I'm going to import 3956 02:48:36,359 --> 02:48:42,859 typography use theme use media query 3957 02:48:43,260 --> 02:48:45,000 and inside of this I'm going to use 3958 02:48:45,000 --> 02:48:48,540 const theme use theme so we can grab our 3959 02:48:48,540 --> 02:48:51,180 colors again and I'm going to do const 3960 02:48:51,180 --> 02:48:55,020 is non-mobile screens we're going to use 3961 02:48:55,020 --> 02:48:58,680 media query like so and passing Min 3962 02:48:58,680 --> 02:49:02,280 width of a thousand 3963 02:49:02,280 --> 02:49:05,840 pixel like we did before 3964 02:49:07,500 --> 02:49:10,920 and inside here I'm going to use box 3965 02:49:10,920 --> 02:49:12,240 and 3966 02:49:12,240 --> 02:49:14,580 I'm going to create a few things so 3967 02:49:14,580 --> 02:49:16,439 actually 3968 02:49:16,439 --> 02:49:19,080 I'm going to copy a few things from the 3969 02:49:19,080 --> 02:49:22,080 nav bar because we have the sociopedia 3970 02:49:22,080 --> 02:49:23,939 value over here so I'm going to just 3971 02:49:23,939 --> 02:49:25,500 copy this 3972 02:49:25,500 --> 02:49:27,600 typography and we're just going to 3973 02:49:27,600 --> 02:49:29,700 modify a few things 3974 02:49:29,700 --> 02:49:31,500 so 3975 02:49:31,500 --> 02:49:33,840 in here I don't really need it on click 3976 02:49:33,840 --> 02:49:35,340 because we don't need to navigate with 3977 02:49:35,340 --> 02:49:38,240 this typography 3978 02:49:39,120 --> 02:49:41,220 and then from here I'm going to remove 3979 02:49:41,220 --> 02:49:43,819 the color 3980 02:49:45,660 --> 02:49:47,399 the primary action we can keep that we 3981 02:49:47,399 --> 02:49:49,880 can say font weight of bold a font size 3982 02:49:49,880 --> 02:49:54,359 of 32 pixel we don't need a hover 3983 02:49:54,359 --> 02:49:56,640 because we don't need to click on it 3984 02:49:56,640 --> 02:49:59,640 and around this typography I'm going to 3985 02:49:59,640 --> 02:50:03,560 kit box like so 3986 02:50:03,600 --> 02:50:05,880 and I'm going to say width of a hundred 3987 02:50:05,880 --> 02:50:08,160 percent 3988 02:50:08,160 --> 02:50:10,920 give it a background 3989 02:50:10,920 --> 02:50:12,600 color 3990 02:50:12,600 --> 02:50:15,240 of theme dot palette 3991 02:50:15,240 --> 02:50:19,500 dot background dot Alt 3992 02:50:19,500 --> 02:50:22,140 I'm going to give it a padding of one 3993 02:50:22,140 --> 02:50:23,460 REM 3994 02:50:23,460 --> 02:50:25,380 six percent 3995 02:50:25,380 --> 02:50:28,620 so one REM top top and bottom six 3996 02:50:28,620 --> 02:50:30,420 percent left and right 3997 02:50:30,420 --> 02:50:32,939 text align 3998 02:50:32,939 --> 02:50:36,240 of Center so we Center the text 3999 02:50:36,240 --> 02:50:38,760 we can save it that should include the 4000 02:50:38,760 --> 02:50:40,800 text at the top 4001 02:50:40,800 --> 02:50:42,780 and then 4002 02:50:42,780 --> 02:50:44,399 after this I'm going to create another 4003 02:50:44,399 --> 02:50:45,840 box 4004 02:50:45,840 --> 02:50:47,399 and this will be the form box 4005 02:50:47,399 --> 02:50:49,680 essentially and inside this box I'm 4006 02:50:49,680 --> 02:50:51,600 going to set the width 4007 02:50:51,600 --> 02:50:53,540 if it is 4008 02:50:53,540 --> 02:50:57,000 non-mobile screens we are going to be 4009 02:50:57,000 --> 02:51:00,600 setting with a 50 otherwise we want to 4010 02:51:00,600 --> 02:51:03,720 set it to 93 again these are just values 4011 02:51:03,720 --> 02:51:07,080 that I tested around looks the best I'm 4012 02:51:07,080 --> 02:51:10,140 going to set a padding of two REM 4013 02:51:10,140 --> 02:51:13,800 a margin of 2 REM Auto and by the way 4014 02:51:13,800 --> 02:51:17,460 I'm using root em so REM 4015 02:51:17,460 --> 02:51:20,939 this is based on the root size of the 4016 02:51:20,939 --> 02:51:21,780 font 4017 02:51:21,780 --> 02:51:24,720 and by doing this this allows us to have 4018 02:51:24,720 --> 02:51:26,640 consistency across different browsers 4019 02:51:26,640 --> 02:51:29,340 and font sizes so that's why I'm using 4020 02:51:29,340 --> 02:51:31,439 REM instead of other 4021 02:51:31,439 --> 02:51:33,720 values and occasionally we still need to 4022 02:51:33,720 --> 02:51:36,420 use pixels here and there but if you can 4023 02:51:36,420 --> 02:51:39,840 use REM might as well use it 4024 02:51:39,840 --> 02:51:41,340 we're going to have a border radius of 4025 02:51:41,340 --> 02:51:43,380 1.5 REM I'm going to give it a 4026 02:51:43,380 --> 02:51:45,060 background color 4027 02:51:45,060 --> 02:51:47,420 of theme dot palette 4028 02:51:47,420 --> 02:51:51,540 background dot Alt 4029 02:51:51,540 --> 02:51:53,640 and inside this box I'm going to set 4030 02:51:53,640 --> 02:51:55,260 typography 4031 02:51:55,260 --> 02:51:56,939 like so 4032 02:51:56,939 --> 02:52:01,260 give it a font weight of 500 a variant 4033 02:52:01,260 --> 02:52:04,859 of H5 SX 4034 02:52:04,859 --> 02:52:09,680 of margin bottom 1.5 4035 02:52:10,080 --> 02:52:13,220 REM as text 4036 02:52:14,100 --> 02:52:16,560 and then here I'm going to write a text 4037 02:52:16,560 --> 02:52:18,899 this is for just the description welcome 4038 02:52:18,899 --> 02:52:21,120 to socio 4039 02:52:21,120 --> 02:52:24,000 media the social 4040 02:52:24,000 --> 02:52:26,700 media for 4041 02:52:26,700 --> 02:52:30,479 socio paths 4042 02:52:31,319 --> 02:52:35,040 and that will have our layout set up and 4043 02:52:35,040 --> 02:52:37,200 inside this box I'm going to create a 4044 02:52:37,200 --> 02:52:39,660 form component that I did not create yet 4045 02:52:39,660 --> 02:52:42,000 and what I'm going to do is I'm going to 4046 02:52:42,000 --> 02:52:43,260 import 4047 02:52:43,260 --> 02:52:46,380 form from dot slash 4048 02:52:46,380 --> 02:52:48,180 form 4049 02:52:48,180 --> 02:52:49,859 this is again a component I have not 4050 02:52:49,859 --> 02:52:51,840 created so I'm going to go into the 4051 02:52:51,840 --> 02:52:54,060 login page folder I'm going to create a 4052 02:52:54,060 --> 02:52:57,359 new file call it forum.jsx 4053 02:52:57,359 --> 02:52:59,700 my apologies I have not closed the 4054 02:52:59,700 --> 02:53:02,520 Explorer so I'm going to do that and in 4055 02:53:02,520 --> 02:53:03,600 this form 4056 02:53:03,600 --> 02:53:05,939 this is going to be where we do all the 4057 02:53:05,939 --> 02:53:08,640 register functionality 4058 02:53:08,640 --> 02:53:10,140 so this there's going to be quite a bit 4059 02:53:10,140 --> 02:53:13,920 of things to do in this component 4060 02:53:13,920 --> 02:53:16,100 but a lot of it is pretty 4061 02:53:16,100 --> 02:53:18,500 self-explanatory and self or 4062 02:53:18,500 --> 02:53:20,760 straightforward I would say 4063 02:53:20,760 --> 02:53:22,380 but I'll walk you through everything so 4064 02:53:22,380 --> 02:53:25,680 import use state from react 4065 02:53:25,680 --> 02:53:27,300 we're going to go down I'm going to 4066 02:53:27,300 --> 02:53:29,760 import a number of items from Material 4067 02:53:29,760 --> 02:53:32,160 UI so I'm going to import box button 4068 02:53:32,160 --> 02:53:34,380 text field 4069 02:53:34,380 --> 02:53:37,200 use media query 4070 02:53:37,200 --> 02:53:39,120 typography 4071 02:53:39,120 --> 02:53:43,040 and use theme 4072 02:53:43,140 --> 02:53:48,620 and then from at m-u-y slash material 4073 02:53:49,100 --> 02:53:52,819 and also I'm yeah I'm going to import 4074 02:53:52,819 --> 02:53:58,740 edit outlined icon from at mui icons 4075 02:53:58,740 --> 02:54:01,859 material edit outline just for that 4076 02:54:01,859 --> 02:54:03,779 particular icon 4077 02:54:03,779 --> 02:54:06,120 and then I'm going to import formic 4078 02:54:06,120 --> 02:54:07,740 which is going to be 4079 02:54:07,740 --> 02:54:11,580 what we use for our form Library 4080 02:54:11,580 --> 02:54:13,319 then import 4081 02:54:13,319 --> 02:54:17,700 everything as yep from 4082 02:54:17,700 --> 02:54:18,840 yep 4083 02:54:18,840 --> 02:54:21,420 which is our validation Library 4084 02:54:21,420 --> 02:54:23,220 we're going to import use navigate 4085 02:54:23,220 --> 02:54:26,640 because we need to be able to navigate 4086 02:54:26,640 --> 02:54:28,319 when they register 4087 02:54:28,319 --> 02:54:30,000 and login 4088 02:54:30,000 --> 02:54:34,220 we're going to import use dispatch 4089 02:54:34,319 --> 02:54:36,000 because we're going to use react Redux 4090 02:54:36,000 --> 02:54:39,600 to store our user information we're 4091 02:54:39,600 --> 02:54:42,300 going to import set login once the user 4092 02:54:42,300 --> 02:54:43,920 sets 4093 02:54:43,920 --> 02:54:45,720 their login page 4094 02:54:45,720 --> 02:54:48,779 then we're going to import drop zone so 4095 02:54:48,779 --> 02:54:52,140 we can drop a file or let the user put 4096 02:54:52,140 --> 02:54:54,960 in the image so that they can upload the 4097 02:54:54,960 --> 02:54:56,399 file as well 4098 02:54:56,399 --> 02:54:58,620 and then also we're going to import Flex 4099 02:54:58,620 --> 02:55:00,840 between because we're going to be using 4100 02:55:00,840 --> 02:55:04,220 that component quite often 4101 02:55:05,100 --> 02:55:08,279 and that should be our Imports 4102 02:55:08,279 --> 02:55:10,319 so in here I'm going to create the 4103 02:55:10,319 --> 02:55:12,960 schema so these are the yup validation 4104 02:55:12,960 --> 02:55:15,840 schema so this will determine the shape 4105 02:55:15,840 --> 02:55:19,200 of how the form library is going to be 4106 02:55:19,200 --> 02:55:21,300 saving this information so I'm going to 4107 02:55:21,300 --> 02:55:25,800 say register schema yup dot object dot 4108 02:55:25,800 --> 02:55:28,040 shape 4109 02:55:28,200 --> 02:55:29,819 shape 4110 02:55:29,819 --> 02:55:33,380 and I'm going to pass in all the values 4111 02:55:33,380 --> 02:55:36,479 for our schema and we're going to have 4112 02:55:36,479 --> 02:55:38,939 first name 4113 02:55:38,939 --> 02:55:41,220 last name 4114 02:55:41,220 --> 02:55:43,020 email 4115 02:55:43,020 --> 02:55:45,120 password 4116 02:55:45,120 --> 02:55:47,040 location 4117 02:55:47,040 --> 02:55:49,020 occupation 4118 02:55:49,020 --> 02:55:51,359 and picture 4119 02:55:51,359 --> 02:55:53,580 and for the values 4120 02:55:53,580 --> 02:55:56,160 I'm going to do yep 4121 02:55:56,160 --> 02:55:58,020 dot string 4122 02:55:58,020 --> 02:56:00,000 required 4123 02:56:00,000 --> 02:56:02,399 and required 4124 02:56:02,399 --> 02:56:04,380 and I'm going to have this for pretty 4125 02:56:04,380 --> 02:56:07,319 much every single one of these values 4126 02:56:07,319 --> 02:56:08,700 since 4127 02:56:08,700 --> 02:56:10,380 I'm not going to spend the time to 4128 02:56:10,380 --> 02:56:13,020 validate everything perfectly this will 4129 02:56:13,020 --> 02:56:15,060 make it just easier for us to deal with 4130 02:56:15,060 --> 02:56:16,380 at the time being 4131 02:56:16,380 --> 02:56:18,120 and the only one that's going to be 4132 02:56:18,120 --> 02:56:20,399 different is going to be email because 4133 02:56:20,399 --> 02:56:22,500 we already it's already configured for 4134 02:56:22,500 --> 02:56:23,640 us 4135 02:56:23,640 --> 02:56:26,760 by yup so we don't actually have to do 4136 02:56:26,760 --> 02:56:30,060 anything and that's why I 4137 02:56:30,060 --> 02:56:32,880 M setting up this particular one 4138 02:56:32,880 --> 02:56:35,399 acquired true so basically what this is 4139 02:56:35,399 --> 02:56:38,100 doing is that when we validate our 4140 02:56:38,100 --> 02:56:40,380 inputs to make sure for example they 4141 02:56:40,380 --> 02:56:41,939 don't put something 4142 02:56:41,939 --> 02:56:44,279 that isn't correct for a first name if 4143 02:56:44,279 --> 02:56:46,080 you put like a 4144 02:56:46,080 --> 02:56:47,700 weird symbol 4145 02:56:47,700 --> 02:56:49,680 or something else it's going to show an 4146 02:56:49,680 --> 02:56:52,920 error if and also if you don't have 4147 02:56:52,920 --> 02:56:55,080 anything in that value 4148 02:56:55,080 --> 02:56:57,120 you're going to have a required value 4149 02:56:57,120 --> 02:56:59,460 error that pops up so that's what this 4150 02:56:59,460 --> 02:57:00,540 is kind of doing 4151 02:57:00,540 --> 02:57:03,240 same with this if it's going to say if 4152 02:57:03,240 --> 02:57:05,819 you don't have a correct email address 4153 02:57:05,819 --> 02:57:08,399 it's going to say invalid email and if 4154 02:57:08,399 --> 02:57:10,020 it's empty it's going to show required 4155 02:57:10,020 --> 02:57:12,720 so depending on which error is prevalent 4156 02:57:12,720 --> 02:57:15,660 it's going to run that 4157 02:57:15,660 --> 02:57:17,279 and also we're going to have a login 4158 02:57:17,279 --> 02:57:20,279 schema and we're going to set yup 4159 02:57:20,279 --> 02:57:22,740 Dot object.shape 4160 02:57:22,740 --> 02:57:25,460 like so 4161 02:57:25,560 --> 02:57:28,439 and I'm going to pass in email 4162 02:57:28,439 --> 02:57:31,819 the same thing as well 4163 02:57:32,160 --> 02:57:34,500 and same thing with password 4164 02:57:34,500 --> 02:57:37,319 so login is going to be like a stripped 4165 02:57:37,319 --> 02:57:39,600 down version of the register schema so 4166 02:57:39,600 --> 02:57:41,580 we can reuse some of the values 4167 02:57:41,580 --> 02:57:43,439 and in here we're going to do const 4168 02:57:43,439 --> 02:57:45,180 initial 4169 02:57:45,180 --> 02:57:47,460 values register 4170 02:57:47,460 --> 02:57:50,000 so now 4171 02:57:50,399 --> 02:57:53,399 while the schema set up the validation 4172 02:57:53,399 --> 02:57:56,100 this setup this sets up the initial 4173 02:57:56,100 --> 02:57:58,080 values so I'm just going to do first 4174 02:57:58,080 --> 02:57:59,399 name 4175 02:57:59,399 --> 02:58:01,859 empty string like so 4176 02:58:01,859 --> 02:58:04,020 and so I'm just going to copy this so I 4177 02:58:04,020 --> 02:58:08,279 can just write last name paste email 4178 02:58:08,279 --> 02:58:11,520 based password 4179 02:58:11,520 --> 02:58:14,520 and then paste it location 4180 02:58:14,520 --> 02:58:17,160 occupation 4181 02:58:17,160 --> 02:58:19,640 picture 4182 02:58:21,300 --> 02:58:22,740 and then finally we're going to do the 4183 02:58:22,740 --> 02:58:24,180 same thing for 4184 02:58:24,180 --> 02:58:26,720 login 4185 02:58:28,380 --> 02:58:29,760 so we're going to have 4186 02:58:29,760 --> 02:58:34,140 email paste it password 4187 02:58:34,140 --> 02:58:36,600 paste it 4188 02:58:36,600 --> 02:58:38,880 and then after all that we can now 4189 02:58:38,880 --> 02:58:41,819 create our form component 4190 02:58:41,819 --> 02:58:44,220 so we're going to make sure we do export 4191 02:58:44,220 --> 02:58:46,859 default form make sure we don't forget 4192 02:58:46,859 --> 02:58:49,160 that 4193 02:58:49,560 --> 02:58:51,899 and in here I'm going to create a number 4194 02:58:51,899 --> 02:58:55,200 of states so I'm going to do page type 4195 02:58:55,200 --> 02:58:57,359 and I'm going to set page 4196 02:58:57,359 --> 02:59:02,160 type like so I'm going to say use state 4197 02:59:02,160 --> 02:59:04,920 oops and it's going to be login 4198 02:59:04,920 --> 02:59:06,600 so we're going to have a situation where 4199 02:59:06,600 --> 02:59:08,819 we set the page type to be login or 4200 02:59:08,819 --> 02:59:10,680 register so we're going to display a 4201 02:59:10,680 --> 02:59:14,520 different form depending on this state 4202 02:59:14,520 --> 02:59:16,920 and then here I'm going to grab the 4203 02:59:16,920 --> 02:59:20,840 palette from use theme 4204 02:59:21,420 --> 02:59:24,000 we're going to set up this batch like 4205 02:59:24,000 --> 02:59:26,600 we've done before 4206 02:59:26,939 --> 02:59:29,700 then we're going to import 4207 02:59:29,700 --> 02:59:32,580 not import but use navigate so we can 4208 02:59:32,580 --> 02:59:35,399 navigate to different pages 4209 02:59:35,399 --> 02:59:38,160 we're going to do is non-mobile 4210 02:59:38,160 --> 02:59:40,740 and we're going to use the same 4211 02:59:40,740 --> 02:59:43,140 media query we did before 4212 02:59:43,140 --> 02:59:45,359 so min 4213 02:59:45,359 --> 02:59:48,240 with and this one's going to be 600 4214 02:59:48,240 --> 02:59:50,100 pixel because we have a different 4215 02:59:50,100 --> 02:59:52,200 criteria for this one 4216 02:59:52,200 --> 02:59:54,779 so I'm just going to set it like that 4217 02:59:54,779 --> 02:59:57,540 and finally just to make it convenient 4218 02:59:57,540 --> 02:59:58,920 because we'll be using this number of 4219 02:59:58,920 --> 03:00:00,779 times we're going to say page type it's 4220 03:00:00,779 --> 03:00:03,800 going to be equal to 4221 03:00:03,840 --> 03:00:05,640 login actually that there should be 4222 03:00:05,640 --> 03:00:07,620 triple equal 4223 03:00:07,620 --> 03:00:09,420 and that's going to be a variable of is 4224 03:00:09,420 --> 03:00:11,700 login it's just to shorten it makes it 4225 03:00:11,700 --> 03:00:14,760 easier same thing with is register 4226 03:00:14,760 --> 03:00:16,560 just makes it very clear 4227 03:00:16,560 --> 03:00:19,819 and concise 4228 03:00:20,399 --> 03:00:22,380 and by the way 4229 03:00:22,380 --> 03:00:25,620 this is a more advanced topic but naming 4230 03:00:25,620 --> 03:00:27,180 is one of the hardest things in 4231 03:00:27,180 --> 03:00:29,279 programming 4232 03:00:29,279 --> 03:00:32,700 is login when you have a Boolean 4233 03:00:32,700 --> 03:00:35,760 it's almost so nice to keep it with a 4234 03:00:35,760 --> 03:00:38,160 prefix of is 4235 03:00:38,160 --> 03:00:41,160 so if you can try to prefix a Boolean 4236 03:00:41,160 --> 03:00:44,460 with is that will show you that this is 4237 03:00:44,460 --> 03:00:46,500 going to be a specific Boolean it helps 4238 03:00:46,500 --> 03:00:49,020 with naming keeps it very simple if 4239 03:00:49,020 --> 03:00:51,060 Boolean always starts with is I know 4240 03:00:51,060 --> 03:00:53,399 some people do like has something and 4241 03:00:53,399 --> 03:00:54,960 then they change there is 4242 03:00:54,960 --> 03:00:57,000 I personally like it if it always is 4243 03:00:57,000 --> 03:00:59,160 because you can clearly see when 4244 03:00:59,160 --> 03:01:00,779 something is a Boolean 4245 03:01:00,779 --> 03:01:04,040 and or not a Boolean 4246 03:01:04,560 --> 03:01:06,300 and with that I'm going to create a 4247 03:01:06,300 --> 03:01:07,319 function 4248 03:01:07,319 --> 03:01:10,920 before we write the Java uh the jsx 4249 03:01:10,920 --> 03:01:12,600 I'm going to create a skeleton for 4250 03:01:12,600 --> 03:01:15,300 handle form submit and this is going to 4251 03:01:15,300 --> 03:01:17,279 be asynchronous 4252 03:01:17,279 --> 03:01:19,380 I'm going to give it a value of values 4253 03:01:19,380 --> 03:01:23,100 on submit props now these arguments are 4254 03:01:23,100 --> 03:01:25,319 going to come from formic and I'll show 4255 03:01:25,319 --> 03:01:27,000 you where we are going to be using it 4256 03:01:27,000 --> 03:01:28,859 but for now we're just going to keep it 4257 03:01:28,859 --> 03:01:30,300 empty 4258 03:01:30,300 --> 03:01:32,340 and I'm going to return 4259 03:01:32,340 --> 03:01:34,979 the formic component 4260 03:01:34,979 --> 03:01:37,020 like so 4261 03:01:37,020 --> 03:01:39,600 and inside the format component 4262 03:01:39,600 --> 03:01:42,960 this is where I do on submit and pass in 4263 03:01:42,960 --> 03:01:45,479 the handle form submit 4264 03:01:45,479 --> 03:01:47,819 function that I just created 4265 03:01:47,819 --> 03:01:49,380 and also I'm going to set the initial 4266 03:01:49,380 --> 03:01:50,640 values 4267 03:01:50,640 --> 03:01:53,340 I'm going to set is login 4268 03:01:53,340 --> 03:01:55,200 initial 4269 03:01:55,200 --> 03:01:58,920 values login and initial values register 4270 03:01:58,920 --> 03:02:01,979 so if we're on the islogin page we're 4271 03:02:01,979 --> 03:02:03,779 going to initialize our values with the 4272 03:02:03,779 --> 03:02:06,240 login component or login object that we 4273 03:02:06,240 --> 03:02:10,460 created otherwise we do register 4274 03:02:10,560 --> 03:02:12,000 and we're going to kind of do the same 4275 03:02:12,000 --> 03:02:14,160 thing for the validation schema so if I 4276 03:02:14,160 --> 03:02:15,060 go down 4277 03:02:15,060 --> 03:02:18,660 I write validation schema we pass in is 4278 03:02:18,660 --> 03:02:20,040 log in 4279 03:02:20,040 --> 03:02:24,660 login schema redo register schema 4280 03:02:24,660 --> 03:02:26,640 like so 4281 03:02:26,640 --> 03:02:28,380 and this is very convenient I like how 4282 03:02:28,380 --> 03:02:30,840 this is set up for formic we have the 4283 03:02:30,840 --> 03:02:32,580 initial values validation schema it's 4284 03:02:32,580 --> 03:02:35,460 pretty simple to use now there's a weird 4285 03:02:35,460 --> 03:02:37,319 part of the syntax and it's going to be 4286 03:02:37,319 --> 03:02:40,800 right here so I'm going to create 4287 03:02:40,800 --> 03:02:43,979 uh curly braces I'm gonna put 4288 03:02:43,979 --> 03:02:45,420 parens 4289 03:02:45,420 --> 03:02:48,120 with another curly braces 4290 03:02:48,120 --> 03:02:50,460 and I'm going to pass in a number of 4291 03:02:50,460 --> 03:02:52,020 values 4292 03:02:52,020 --> 03:02:56,640 in here so values errors touched handle 4293 03:02:56,640 --> 03:02:57,540 blur 4294 03:02:57,540 --> 03:03:00,060 handle change 4295 03:03:00,060 --> 03:03:01,560 handle 4296 03:03:01,560 --> 03:03:02,880 submit 4297 03:03:02,880 --> 03:03:04,080 actually no 4298 03:03:04,080 --> 03:03:08,580 handle submit like so set field value 4299 03:03:08,580 --> 03:03:13,399 and reset form 4300 03:03:14,220 --> 03:03:16,800 it seems like it's giving me some kind 4301 03:03:16,800 --> 03:03:19,200 of error over here I'm not exactly sure 4302 03:03:19,200 --> 03:03:21,060 why 4303 03:03:21,060 --> 03:03:24,260 what is that saying 4304 03:03:26,520 --> 03:03:29,420 and in here 4305 03:03:31,800 --> 03:03:34,580 so we have 4306 03:03:35,160 --> 03:03:39,300 we have reset form so like this I want 4307 03:03:39,300 --> 03:03:41,279 to do Arrow function like that so make 4308 03:03:41,279 --> 03:03:43,920 sure you're getting this 4309 03:03:43,920 --> 03:03:46,500 you're correcting this syntax the the 4310 03:03:46,500 --> 03:03:49,500 syntax can be a little wild right here 4311 03:03:49,500 --> 03:03:52,740 but these values allow you to use them 4312 03:03:52,740 --> 03:03:54,540 inside 4313 03:03:54,540 --> 03:03:57,300 your components and your form so it 4314 03:03:57,300 --> 03:04:00,300 makes it very nice to use 4315 03:04:00,300 --> 03:04:03,779 and with this we want to add a form 4316 03:04:03,779 --> 03:04:05,880 HTML tag 4317 03:04:05,880 --> 03:04:08,340 I'm going to do on submit 4318 03:04:08,340 --> 03:04:11,819 equals handle submit so what formic is 4319 03:04:11,819 --> 03:04:15,000 essentially doing is grabbing the handle 4320 03:04:15,000 --> 03:04:18,000 forms submit and passing it in our 4321 03:04:18,000 --> 03:04:20,279 formic so you can pass it into our on 4322 03:04:20,279 --> 03:04:22,380 submit function 4323 03:04:22,380 --> 03:04:25,200 so once we have that now we can do all 4324 03:04:25,200 --> 03:04:28,260 the form stuff inside this like normal I 4325 03:04:28,260 --> 03:04:29,760 know this is a little bit of funky 4326 03:04:29,760 --> 03:04:32,580 syntax but 4327 03:04:32,580 --> 03:04:33,660 you know 4328 03:04:33,660 --> 03:04:36,420 sometimes you have to react hook form 4329 03:04:36,420 --> 03:04:38,460 has its benefits but also has some other 4330 03:04:38,460 --> 03:04:40,560 downsides but I won't get into it so we 4331 03:04:40,560 --> 03:04:41,939 have box 4332 03:04:41,939 --> 03:04:43,380 so 4333 03:04:43,380 --> 03:04:45,720 and inside the Box 4334 03:04:45,720 --> 03:04:48,660 we can do display of grid so we're going 4335 03:04:48,660 --> 03:04:51,439 to use a grid 4336 03:04:52,020 --> 03:04:54,120 for this section 4337 03:04:54,120 --> 03:04:56,399 and we're going to set a gap of 30 pixel 4338 03:04:56,399 --> 03:04:58,979 meaning you have a gap between items of 4339 03:04:58,979 --> 03:05:01,380 30 pixel and I'm going to set a grid 4340 03:05:01,380 --> 03:05:03,840 template columns 4341 03:05:03,840 --> 03:05:06,660 and we're going to do repeat 4342 03:05:06,660 --> 03:05:10,740 of 4 comma min max 4343 03:05:10,740 --> 03:05:12,359 of zero 4344 03:05:12,359 --> 03:05:15,540 one fractional unit 4345 03:05:15,540 --> 03:05:17,160 and this will be our grid template 4346 03:05:17,160 --> 03:05:18,359 columns 4347 03:05:18,359 --> 03:05:19,859 A Min 4348 03:05:19,859 --> 03:05:21,660 Max 4349 03:05:21,660 --> 03:05:23,580 so what this is saying is that we're 4350 03:05:23,580 --> 03:05:27,240 going to split our grid into four 4351 03:05:27,240 --> 03:05:29,880 sections and it's going to be a minimum 4352 03:05:29,880 --> 03:05:31,500 of zero so if it gets too small it's 4353 03:05:31,500 --> 03:05:33,359 going to shrink all the way to zero 4354 03:05:33,359 --> 03:05:35,520 otherwise we're going to split this into 4355 03:05:35,520 --> 03:05:38,640 equal fractions of four 4356 03:05:38,640 --> 03:05:40,439 so if you take a look on the final 4357 03:05:40,439 --> 03:05:43,439 application we're basically splitting 4358 03:05:43,439 --> 03:05:45,600 this into four sections 4359 03:05:45,600 --> 03:05:49,200 so one two three four one two three four 4360 03:05:49,200 --> 03:05:51,120 one two three four one two three four 4361 03:05:51,120 --> 03:05:53,340 same with over here 4362 03:05:53,340 --> 03:05:54,899 and you know what I could have split 4363 03:05:54,899 --> 03:05:56,939 this into two you could split this into 4364 03:05:56,939 --> 03:05:58,500 two if you wanted 4365 03:05:58,500 --> 03:06:00,600 but I'm keeping it as four so I'm going 4366 03:06:00,600 --> 03:06:02,700 to set this as SX 4367 03:06:02,700 --> 03:06:06,240 and passing in and 4368 03:06:06,240 --> 03:06:07,200 div 4369 03:06:07,200 --> 03:06:09,060 so what we're doing is we're trending 4370 03:06:09,060 --> 03:06:12,720 we're targeting any divs 4371 03:06:12,720 --> 03:06:16,140 of this as a child component so anything 4372 03:06:16,140 --> 03:06:19,740 or child class so anything right below 4373 03:06:19,740 --> 03:06:22,620 it as div we're going to add a property 4374 03:06:22,620 --> 03:06:26,060 of grid column 4375 03:06:26,340 --> 03:06:29,160 capitalized like that 4376 03:06:29,160 --> 03:06:33,180 and if it is non-mobile meaning wider 4377 03:06:33,180 --> 03:06:36,479 screens we're going to say undefined 4378 03:06:36,479 --> 03:06:38,700 but if it is mobile we're going to say a 4379 03:06:38,700 --> 03:06:41,880 span of four 4380 03:06:41,880 --> 03:06:45,840 so essentially when we specify our text 4381 03:06:45,840 --> 03:06:47,880 field we're going to give that these 4382 03:06:47,880 --> 03:06:50,340 guys a grid column span of maybe like 4383 03:06:50,340 --> 03:06:52,800 two for example right here these will be 4384 03:06:52,800 --> 03:06:53,880 two 4385 03:06:53,880 --> 03:06:56,340 on larger screens 4386 03:06:56,340 --> 03:06:59,340 but when you get smaller to a Mobile 4387 03:06:59,340 --> 03:07:02,399 screen these are going to become a span 4388 03:07:02,399 --> 03:07:04,680 of four so they'll take up their own 4389 03:07:04,680 --> 03:07:07,439 entire width so that's why I am doing 4390 03:07:07,439 --> 03:07:09,960 this particular section so you don't 4391 03:07:09,960 --> 03:07:12,000 have to use mobile uh media queries 4392 03:07:12,000 --> 03:07:14,340 aside from this one and it makes a very 4393 03:07:14,340 --> 03:07:19,380 clean code without much complications 4394 03:07:21,240 --> 03:07:23,420 foreign 4395 03:07:25,740 --> 03:07:28,800 of text field with is register so in 4396 03:07:28,800 --> 03:07:30,960 this case if it's on the register 4397 03:07:30,960 --> 03:07:32,939 if it's on the register page we're going 4398 03:07:32,939 --> 03:07:36,899 to have a number of components over here 4399 03:07:36,899 --> 03:07:38,700 and we're going to write our first input 4400 03:07:38,700 --> 03:07:40,979 which is going to be text field 4401 03:07:40,979 --> 03:07:43,439 so that's like the input component from 4402 03:07:43,439 --> 03:07:45,060 Material UI 4403 03:07:45,060 --> 03:07:46,500 I'm going to close it but I'm going to 4404 03:07:46,500 --> 03:07:49,319 pass in a number of parameters over here 4405 03:07:49,319 --> 03:07:53,880 so I'm going to say label a first name 4406 03:07:53,880 --> 03:07:56,460 I'm going to say on blur we're going to 4407 03:07:56,460 --> 03:07:59,580 pass in the handle blur so this right 4408 03:07:59,580 --> 03:08:02,040 here these values are going to handle 4409 03:08:02,040 --> 03:08:04,200 the situation when you click out of a 4410 03:08:04,200 --> 03:08:05,880 input 4411 03:08:05,880 --> 03:08:08,640 on change 4412 03:08:08,640 --> 03:08:10,560 will handle the situation when you're 4413 03:08:10,560 --> 03:08:13,439 typing in this we're going to give it a 4414 03:08:13,439 --> 03:08:16,920 value of values.firstname 4415 03:08:16,920 --> 03:08:18,779 and then I'm going to say name is going 4416 03:08:18,779 --> 03:08:21,540 to be first name so we sync it to the 4417 03:08:21,540 --> 03:08:23,640 correct value in the initial value so 4418 03:08:23,640 --> 03:08:26,399 this has to align with the name you are 4419 03:08:26,399 --> 03:08:28,140 setting down here 4420 03:08:28,140 --> 03:08:30,600 not the label this is just the display 4421 03:08:30,600 --> 03:08:33,120 of the text 4422 03:08:33,120 --> 03:08:35,100 and then we're going to set the error to 4423 03:08:35,100 --> 03:08:40,319 be a Boolean of touched that first name 4424 03:08:40,319 --> 03:08:43,260 so basically if the first name has been 4425 03:08:43,260 --> 03:08:45,479 touched or not and we're going to do the 4426 03:08:45,479 --> 03:08:48,540 same thing with Boolean errors DOT first 4427 03:08:48,540 --> 03:08:51,060 name 4428 03:08:51,060 --> 03:08:52,859 so we want to check if it has been 4429 03:08:52,859 --> 03:08:55,439 touched or if there is an error then 4430 03:08:55,439 --> 03:08:58,560 this will show that we have an error for 4431 03:08:58,560 --> 03:09:00,180 this particular 4432 03:09:00,180 --> 03:09:01,800 text field 4433 03:09:01,800 --> 03:09:04,080 and we're going to do the similar things 4434 03:09:04,080 --> 03:09:05,760 with helper text and we're going to do 4435 03:09:05,760 --> 03:09:08,340 touched.firstname 4436 03:09:08,340 --> 03:09:12,240 and errors that first name 4437 03:09:12,240 --> 03:09:14,939 so what this is going to do is if it has 4438 03:09:14,939 --> 03:09:16,439 been touched 4439 03:09:16,439 --> 03:09:19,200 but we have an error we're going to be 4440 03:09:19,200 --> 03:09:22,500 showing the error otherwise we will show 4441 03:09:22,500 --> 03:09:24,840 that it's been touched or if it hasn't 4442 03:09:24,840 --> 03:09:26,939 been touched as well so this will show 4443 03:09:26,939 --> 03:09:28,680 the helper text 4444 03:09:28,680 --> 03:09:30,240 when we need to 4445 03:09:30,240 --> 03:09:32,819 and then finally we can do SX grid 4446 03:09:32,819 --> 03:09:36,300 column and give it a span of two for 4447 03:09:36,300 --> 03:09:38,640 this as I mentioned 4448 03:09:38,640 --> 03:09:40,560 in larger screens it's going to have 4449 03:09:40,560 --> 03:09:42,420 span of two 4450 03:09:42,420 --> 03:09:44,279 in smaller screens this is going to 4451 03:09:44,279 --> 03:09:46,740 override this guy 4452 03:09:46,740 --> 03:09:50,000 with the span of four 4453 03:09:51,060 --> 03:09:52,620 and now I know there's a lot of 4454 03:09:52,620 --> 03:09:54,240 properties over here but it's very nice 4455 03:09:54,240 --> 03:09:55,920 because you can just copy and paste it 4456 03:09:55,920 --> 03:09:58,620 like this multiple times and all we have 4457 03:09:58,620 --> 03:10:00,479 to do is change the values so if I go 4458 03:10:00,479 --> 03:10:02,399 like this I want to change this to last 4459 03:10:02,399 --> 03:10:05,279 name and then from here I can do command 4460 03:10:05,279 --> 03:10:08,279 D select all of these guys change it to 4461 03:10:08,279 --> 03:10:09,540 last 4462 03:10:09,540 --> 03:10:12,240 and then that's our next input 4463 03:10:12,240 --> 03:10:14,640 so it's very convenient 4464 03:10:14,640 --> 03:10:16,740 I'm going to do the same thing 4465 03:10:16,740 --> 03:10:18,300 this is going to be 4466 03:10:18,300 --> 03:10:20,700 location and this one's going to be 4467 03:10:20,700 --> 03:10:22,439 occupation 4468 03:10:22,439 --> 03:10:24,720 so I'm going to set this 4469 03:10:24,720 --> 03:10:27,240 one as location 4470 03:10:27,240 --> 03:10:30,660 same with the name 4471 03:10:30,660 --> 03:10:32,100 actually I'm going to change the last 4472 03:10:32,100 --> 03:10:34,800 name command D change all of these to 4473 03:10:34,800 --> 03:10:36,720 location 4474 03:10:36,720 --> 03:10:38,160 and then finally I'm going to do this 4475 03:10:38,160 --> 03:10:39,479 for 4476 03:10:39,479 --> 03:10:42,060 label and occupation 4477 03:10:42,060 --> 03:10:44,220 Dot 4478 03:10:44,220 --> 03:10:46,380 change the last name as well 4479 03:10:46,380 --> 03:10:49,560 this should be occupation 4480 03:10:49,560 --> 03:10:52,080 and then from here I did forget that we 4481 03:10:52,080 --> 03:10:53,640 need to change this to span of four 4482 03:10:53,640 --> 03:10:56,220 because these take up their own line 4483 03:10:56,220 --> 03:10:59,100 and I'm going to save that 4484 03:10:59,100 --> 03:11:01,200 and then finally 4485 03:11:01,200 --> 03:11:03,479 we're going to have to deal with the box 4486 03:11:03,479 --> 03:11:04,620 of 4487 03:11:04,620 --> 03:11:07,979 you know inputting profile image so this 4488 03:11:07,979 --> 03:11:09,779 one is going to be a little more intense 4489 03:11:09,779 --> 03:11:11,939 so we're going to say 4490 03:11:11,939 --> 03:11:13,500 we're going to give this 4491 03:11:13,500 --> 03:11:16,620 a grid column 4492 03:11:16,620 --> 03:11:19,859 of span of four like we did before with 4493 03:11:19,859 --> 03:11:23,060 a border of one 4494 03:11:23,060 --> 03:11:25,740 pixel solid 4495 03:11:25,740 --> 03:11:29,479 natural palette 4496 03:11:30,060 --> 03:11:32,460 neutral dot medium 4497 03:11:32,460 --> 03:11:35,160 so again this is a shorthand 4498 03:11:35,160 --> 03:11:37,680 of border with one pixel and it's a 4499 03:11:37,680 --> 03:11:39,960 solid line with this color so that's a 4500 03:11:39,960 --> 03:11:41,880 shorthand for borders 4501 03:11:41,880 --> 03:11:43,740 we're gonna do border radius 4502 03:11:43,740 --> 03:11:46,680 of 5 pixel 4503 03:11:46,680 --> 03:11:50,880 a padding of one REM 4504 03:11:50,880 --> 03:11:53,580 and inside this box now we're going to 4505 03:11:53,580 --> 03:11:57,380 use a component from Drop Zone 4506 03:11:57,660 --> 03:12:00,540 this is where we can have an automatic 4507 03:12:00,540 --> 03:12:02,760 configuration so we can 4508 03:12:02,760 --> 03:12:05,399 pass in files and have validation as 4509 03:12:05,399 --> 03:12:08,220 well so we're going to say accepted 4510 03:12:08,220 --> 03:12:09,600 files 4511 03:12:09,600 --> 03:12:13,740 is going to be dot jpeg comma dot jpeg 4512 03:12:13,740 --> 03:12:18,240 dot PNG or comma.png 4513 03:12:18,240 --> 03:12:20,399 so it will only accept that particular 4514 03:12:20,399 --> 03:12:22,620 file aside I think it might not be 4515 03:12:22,620 --> 03:12:25,200 working I'm not entirely sure I've had 4516 03:12:25,200 --> 03:12:26,700 weird scenarios where it doesn't 4517 03:12:26,700 --> 03:12:30,180 properly accept those but here we're 4518 03:12:30,180 --> 03:12:32,100 going to set multiple to false so that 4519 03:12:32,100 --> 03:12:35,520 means you cannot set multiple files we 4520 03:12:35,520 --> 03:12:38,399 just want only one image at most 4521 03:12:38,399 --> 03:12:40,439 and then from here we're going to set on 4522 03:12:40,439 --> 03:12:42,420 drop so this is going to be the Callback 4523 03:12:42,420 --> 03:12:45,140 function of what we do with the files 4524 03:12:45,140 --> 03:12:48,240 once a user drops it in here so we're 4525 03:12:48,240 --> 03:12:51,359 going to pass in the septed files 4526 03:12:51,359 --> 03:12:57,000 and in here we want to set field value 4527 03:12:57,000 --> 03:12:58,819 and we're going to set this as picture 4528 03:12:58,819 --> 03:13:04,140 comma accepted files zero 4529 03:13:04,140 --> 03:13:06,420 so what this is doing is 4530 03:13:06,420 --> 03:13:07,680 since 4531 03:13:07,680 --> 03:13:10,800 these text field is different we want to 4532 03:13:10,800 --> 03:13:12,779 set the set field value 4533 03:13:12,779 --> 03:13:16,500 for a specific formic input being 4534 03:13:16,500 --> 03:13:18,240 picture 4535 03:13:18,240 --> 03:13:20,819 we can use the set field value to set 4536 03:13:20,819 --> 03:13:23,220 those values if we need to and in this 4537 03:13:23,220 --> 03:13:25,380 case since we're using Drop Zone we need 4538 03:13:25,380 --> 03:13:29,060 to set this value manually 4539 03:13:29,340 --> 03:13:33,240 and up here we have a callback function 4540 03:13:33,240 --> 03:13:34,740 and again this is going to have some 4541 03:13:34,740 --> 03:13:37,319 weird syntax and this time is from drop 4542 03:13:37,319 --> 03:13:39,960 zone so we're going to pass in get root 4543 03:13:39,960 --> 03:13:41,399 props 4544 03:13:41,399 --> 03:13:44,279 and then get input prompts 4545 03:13:44,279 --> 03:13:47,580 so we can use those props 4546 03:13:47,580 --> 03:13:51,020 and pass it within 4547 03:13:51,240 --> 03:13:53,640 the jsx inside of here so I'm going to 4548 03:13:53,640 --> 03:13:56,700 give it the box like that 4549 03:13:56,700 --> 03:13:58,740 and we're going to do some styling over 4550 03:13:58,740 --> 03:13:59,880 here 4551 03:13:59,880 --> 03:14:01,800 and what I'm what I need to do is I'm 4552 03:14:01,800 --> 03:14:03,960 going to pass and get root props now 4553 03:14:03,960 --> 03:14:05,399 this is something you have to do with 4554 03:14:05,399 --> 03:14:07,080 drop zone so you're basically just 4555 03:14:07,080 --> 03:14:08,520 passing the props that they give you 4556 03:14:08,520 --> 03:14:11,819 passing it into the immediate div that's 4557 03:14:11,819 --> 03:14:13,020 underneath 4558 03:14:13,020 --> 03:14:14,399 and then from here I'm going to put the 4559 03:14:14,399 --> 03:14:16,859 Border I'm going to give it 4560 03:14:16,859 --> 03:14:19,859 2 pixel dashed 4561 03:14:19,859 --> 03:14:22,560 with the palette 4562 03:14:22,560 --> 03:14:24,540 primary dot Main 4563 03:14:24,540 --> 03:14:27,420 so this is another border shorthand and 4564 03:14:27,420 --> 03:14:30,600 we're doing pad one REM 4565 03:14:30,600 --> 03:14:35,100 SX of and we want to Target the hover 4566 03:14:35,100 --> 03:14:37,380 so when we hover over it we want to 4567 03:14:37,380 --> 03:14:39,240 change the cursor 4568 03:14:39,240 --> 03:14:42,080 to pointer 4569 03:14:43,979 --> 03:14:45,500 like so 4570 03:14:45,500 --> 03:14:49,319 it's all a bit of funky syntax going on 4571 03:14:49,319 --> 03:14:51,120 but 4572 03:14:51,120 --> 03:14:53,040 it's just this one section where we pass 4573 03:14:53,040 --> 03:14:54,300 in files 4574 03:14:54,300 --> 03:14:57,240 so it is acceptable so input we're going 4575 03:14:57,240 --> 03:14:59,220 to pass and get input 4576 03:14:59,220 --> 03:15:00,660 props 4577 03:15:00,660 --> 03:15:02,880 we're going to invoke it and we're going 4578 03:15:02,880 --> 03:15:05,720 to close this input 4579 03:15:05,880 --> 03:15:07,620 and inside of here 4580 03:15:07,620 --> 03:15:11,399 I'm going to do values.picture 4581 03:15:12,000 --> 03:15:15,600 and then I do a paragraph tag saying add 4582 03:15:15,600 --> 03:15:17,819 picture here 4583 03:15:17,819 --> 03:15:21,300 so if essentially the values doesn't 4584 03:15:21,300 --> 03:15:23,399 exist for the picture we're going to 4585 03:15:23,399 --> 03:15:25,620 display this text 4586 03:15:25,620 --> 03:15:28,319 otherwise what we're going to do is 4587 03:15:28,319 --> 03:15:30,979 we're going to show 4588 03:15:31,920 --> 03:15:35,279 show the name of the image that's been 4589 03:15:35,279 --> 03:15:37,640 added 4590 03:15:39,540 --> 03:15:42,960 so values.picture.name 4591 03:15:43,140 --> 03:15:45,840 like so 4592 03:15:45,840 --> 03:15:47,460 and then we're going to pass and edit 4593 03:15:47,460 --> 03:15:51,140 outlined icon 4594 03:15:52,560 --> 03:15:55,380 and that is essentially our drop zone so 4595 03:15:55,380 --> 03:15:57,420 now let me go back and I'll show you 4596 03:15:57,420 --> 03:15:59,640 what we have created so this is how it 4597 03:15:59,640 --> 03:16:01,260 originally looks add picture here 4598 03:16:01,260 --> 03:16:03,359 because there's no value we're showing 4599 03:16:03,359 --> 03:16:04,260 this 4600 03:16:04,260 --> 03:16:07,620 but once we add some kind of image 4601 03:16:07,620 --> 03:16:10,740 it will show the image name and they'll 4602 03:16:10,740 --> 03:16:13,020 show an edit icon and we can change it 4603 03:16:13,020 --> 03:16:15,920 if we want to again 4604 03:16:18,180 --> 03:16:20,100 so that is our drop zone so that's all 4605 03:16:20,100 --> 03:16:22,439 we have to do for our Drop Zone 4606 03:16:22,439 --> 03:16:25,800 so now there's a lot of HTML tags so be 4607 03:16:25,800 --> 03:16:28,020 very careful of where you put this so 4608 03:16:28,020 --> 03:16:30,660 you have Drop Zone you have box you have 4609 03:16:30,660 --> 03:16:33,420 an empty tag you want to go 4610 03:16:33,420 --> 03:16:35,580 after this guy 4611 03:16:35,580 --> 03:16:39,560 but in between the Box 4612 03:16:40,380 --> 03:16:42,420 and I'm going to create a couple more 4613 03:16:42,420 --> 03:16:44,279 text Fields actually so I'm going to go 4614 03:16:44,279 --> 03:16:47,939 up I'm going to copy this occupation 4615 03:16:47,939 --> 03:16:50,700 so now this is in the section if you 4616 03:16:50,700 --> 03:16:53,460 look if you remember closely 4617 03:16:53,460 --> 03:16:56,100 this part is enclosed just for the 4618 03:16:56,100 --> 03:16:58,560 register section 4619 03:16:58,560 --> 03:17:01,620 so this is for register 4620 03:17:01,620 --> 03:17:03,899 but this section is going to be the 4621 03:17:03,899 --> 03:17:06,240 section for both login and register so 4622 03:17:06,240 --> 03:17:08,340 that's going to be email 4623 03:17:08,340 --> 03:17:12,180 so this one is going to be email 4624 03:17:12,180 --> 03:17:14,640 and this is going to 4625 03:17:14,640 --> 03:17:17,399 have to also change the email as well 4626 03:17:17,399 --> 03:17:19,500 like that 4627 03:17:19,500 --> 03:17:22,020 and then I'm going to copy this 4628 03:17:22,020 --> 03:17:24,420 and paste it one last time and this is 4629 03:17:24,420 --> 03:17:27,380 going to be password 4630 03:17:28,140 --> 03:17:30,479 and the one difference here with the 4631 03:17:30,479 --> 03:17:33,540 password we want to to be hidden so we 4632 03:17:33,540 --> 03:17:36,420 can do tap type password and it'll hide 4633 03:17:36,420 --> 03:17:38,640 the value 4634 03:17:38,640 --> 03:17:41,760 I'm going to change the email as well 4635 03:17:41,760 --> 03:17:46,040 all of these we're going to do password 4636 03:17:48,960 --> 03:17:51,600 and then finally 4637 03:17:51,600 --> 03:17:55,560 with this we have 4638 03:17:55,560 --> 03:17:58,500 our closing box so underneath the 4639 03:17:58,500 --> 03:17:59,880 closing box 4640 03:17:59,880 --> 03:18:01,140 right here 4641 03:18:01,140 --> 03:18:03,779 I want to create the buttons section so 4642 03:18:03,779 --> 03:18:06,180 this will be the register button and the 4643 03:18:06,180 --> 03:18:08,760 text below it to switch between register 4644 03:18:08,760 --> 03:18:11,040 and login so I'm going to create another 4645 03:18:11,040 --> 03:18:13,939 box over here 4646 03:18:14,520 --> 03:18:18,479 I'm going to say button 4647 03:18:18,600 --> 03:18:20,939 and inside this button I'm going to give 4648 03:18:20,939 --> 03:18:22,500 it some properties this is going to be 4649 03:18:22,500 --> 03:18:24,720 full width 4650 03:18:24,720 --> 03:18:27,479 a type of submit 4651 03:18:27,479 --> 03:18:30,479 SX of margin 4652 03:18:30,479 --> 03:18:32,939 to REM 0. 4653 03:18:32,939 --> 03:18:36,600 padding of one REM 4654 03:18:36,600 --> 03:18:38,700 background color 4655 03:18:38,700 --> 03:18:40,439 of palette 4656 03:18:40,439 --> 03:18:43,859 primary dot Main 4657 03:18:43,859 --> 03:18:46,439 give it a color of palette 4658 03:18:46,439 --> 03:18:50,779 dot background dot Alt 4659 03:18:51,120 --> 03:18:54,960 and we're going to say and hover 4660 03:18:54,960 --> 03:18:57,180 colon color 4661 03:18:57,180 --> 03:18:58,920 palette 4662 03:18:58,920 --> 03:19:00,180 primary 4663 03:19:00,180 --> 03:19:01,740 dot Main 4664 03:19:01,740 --> 03:19:03,420 so 4665 03:19:03,420 --> 03:19:06,120 and inside this button I'm going to do 4666 03:19:06,120 --> 03:19:09,020 is login 4667 03:19:09,060 --> 03:19:12,180 with login as the text if it's a login 4668 03:19:12,180 --> 03:19:16,100 and register if it's not 4669 03:19:17,399 --> 03:19:20,520 and I'm going to do another typography 4670 03:19:20,520 --> 03:19:22,859 so this is a link below to switch 4671 03:19:22,859 --> 03:19:25,560 between login and 4672 03:19:25,560 --> 03:19:27,779 register 4673 03:19:27,779 --> 03:19:30,779 and in here 4674 03:19:30,779 --> 03:19:34,580 I'm going to set on click 4675 03:19:36,479 --> 03:19:39,660 and we're going to set page type 4676 03:19:39,660 --> 03:19:42,300 from islogin 4677 03:19:42,300 --> 03:19:43,979 it is login then we're going to set 4678 03:19:43,979 --> 03:19:47,160 register otherwise we are 4679 03:19:47,160 --> 03:19:50,600 gonna have it log in 4680 03:19:50,819 --> 03:19:53,700 and then reset form so now when we 4681 03:19:53,700 --> 03:19:56,939 switch between register and login 4682 03:19:56,939 --> 03:19:58,500 it's good to clean up 4683 03:19:58,500 --> 03:20:00,540 the inputs that they already have or 4684 03:20:00,540 --> 03:20:02,819 else you'll have some bugs and then 4685 03:20:02,819 --> 03:20:04,740 inside this we're going to have SX of 4686 03:20:04,740 --> 03:20:07,140 text decoration and we're going to set 4687 03:20:07,140 --> 03:20:09,000 underlined 4688 03:20:09,000 --> 03:20:10,680 for this one we're going to give it a 4689 03:20:10,680 --> 03:20:12,660 color of 4690 03:20:12,660 --> 03:20:14,100 palette 4691 03:20:14,100 --> 03:20:16,620 primary dot Main 4692 03:20:16,620 --> 03:20:20,160 and we're going to say and colon hover 4693 03:20:20,160 --> 03:20:23,460 and we're going to give it a cursor 4694 03:20:23,460 --> 03:20:27,060 of pointer when we hover over it and 4695 03:20:27,060 --> 03:20:30,740 give it a color of palettes 4696 03:20:32,939 --> 03:20:34,500 dot primary 4697 03:20:34,500 --> 03:20:37,279 dot light 4698 03:20:39,840 --> 03:20:42,899 save that and inside the typography over 4699 03:20:42,899 --> 03:20:44,220 here 4700 03:20:44,220 --> 03:20:48,060 I'm going to do is login 4701 03:20:48,060 --> 03:20:49,740 then we're going to have a text of don't 4702 03:20:49,740 --> 03:20:54,540 have an account question mark signed up 4703 03:20:54,540 --> 03:20:56,460 here 4704 03:20:56,460 --> 03:20:58,500 and if 4705 03:20:58,500 --> 03:21:00,300 you're on the register page we're going 4706 03:21:00,300 --> 03:21:04,979 to have already have an account 4707 03:21:04,979 --> 03:21:08,030 login here 4708 03:21:08,030 --> 03:21:10,200 [Music] 4709 03:21:10,200 --> 03:21:11,880 and that should cover most of everything 4710 03:21:11,880 --> 03:21:14,160 that we have for this 4711 03:21:14,160 --> 03:21:15,840 now the only thing missing is going to 4712 03:21:15,840 --> 03:21:18,120 be the logic when you click on register 4713 03:21:18,120 --> 03:21:19,500 or login 4714 03:21:19,500 --> 03:21:22,080 so that is going to be handled because 4715 03:21:22,080 --> 03:21:25,560 of button type submit and anytime you 4716 03:21:25,560 --> 03:21:27,240 have a button type submit inside the 4717 03:21:27,240 --> 03:21:29,520 form it's going to 4718 03:21:29,520 --> 03:21:32,700 run the handle submit function of this 4719 03:21:32,700 --> 03:21:35,040 so on submit so we're going to run this 4720 03:21:35,040 --> 03:21:37,500 and the handle submit essentially is 4721 03:21:37,500 --> 03:21:40,080 this handle form submit function that we 4722 03:21:40,080 --> 03:21:41,340 created earlier 4723 03:21:41,340 --> 03:21:42,720 so what we're going to do is we're going 4724 03:21:42,720 --> 03:21:45,000 to go in and we're going to pass 4725 03:21:45,000 --> 03:21:49,140 the logic in that we want so if 4726 03:21:49,140 --> 03:21:52,140 we are on the is login page we want to 4727 03:21:52,140 --> 03:21:53,040 run 4728 03:21:53,040 --> 03:21:55,260 some functionality that will call our 4729 03:21:55,260 --> 03:21:57,720 back end that we have created for 4730 03:21:57,720 --> 03:22:00,180 logging in 4731 03:22:00,180 --> 03:22:02,340 and we haven't created this function yet 4732 03:22:02,340 --> 03:22:05,520 so it's a login function with on 4733 03:22:05,520 --> 03:22:08,640 submit props so we are going to pass 4734 03:22:08,640 --> 03:22:12,479 that in and if it is is register 4735 03:22:12,479 --> 03:22:14,040 we're going to do the same thing with 4736 03:22:14,040 --> 03:22:16,680 the register function values 4737 03:22:16,680 --> 03:22:21,359 now it keeps auto typing it for me but 4738 03:22:21,359 --> 03:22:22,920 we're going to create these functions so 4739 03:22:22,920 --> 03:22:24,899 on submit props 4740 03:22:24,899 --> 03:22:28,740 we're going to be passing it into these 4741 03:22:28,740 --> 03:22:30,660 so the first function we're going to 4742 03:22:30,660 --> 03:22:32,640 create is going to be the register so 4743 03:22:32,640 --> 03:22:35,840 I'm going to register const register 4744 03:22:35,840 --> 03:22:42,140 async values comma on submit prompts 4745 03:22:42,540 --> 03:22:44,640 and in this 4746 03:22:44,640 --> 03:22:46,500 we're going to create 4747 03:22:46,500 --> 03:22:49,319 something with form data 4748 03:22:49,319 --> 03:22:50,819 and we're going to use form data 4749 03:22:50,819 --> 03:22:52,620 normally you have the value so every 4750 03:22:52,620 --> 03:22:54,779 value that we've created inside the text 4751 03:22:54,779 --> 03:22:58,140 field these values will show up 4752 03:22:58,140 --> 03:23:00,300 essentially in this value and these 4753 03:23:00,300 --> 03:23:01,800 values get passed into the register 4754 03:23:01,800 --> 03:23:02,939 function 4755 03:23:02,939 --> 03:23:04,740 which we are using 4756 03:23:04,740 --> 03:23:06,960 so typically we normally could just use 4757 03:23:06,960 --> 03:23:09,600 that and pass it into our request body 4758 03:23:09,600 --> 03:23:10,920 itself 4759 03:23:10,920 --> 03:23:14,040 but because we have a picture image 4760 03:23:14,040 --> 03:23:15,840 we're going to have to use this thing 4761 03:23:15,840 --> 03:23:20,160 called form data 4762 03:23:21,420 --> 03:23:24,359 from the JavaScript API so this I'm just 4763 03:23:24,359 --> 03:23:26,520 going to write this allows 4764 03:23:26,520 --> 03:23:29,340 us to 4765 03:23:29,340 --> 03:23:34,460 send form info with image 4766 03:23:34,500 --> 03:23:36,600 and what we have to do is we're going to 4767 03:23:36,600 --> 03:23:38,580 create this is essentially like an 4768 03:23:38,580 --> 03:23:40,859 object but we have to 4769 03:23:40,859 --> 03:23:43,739 add it in a special way so let value in 4770 03:23:43,739 --> 03:23:44,819 values 4771 03:23:44,819 --> 03:23:46,439 so meaning we're gonna 4772 03:23:46,439 --> 03:23:49,979 go through Loop through every key value 4773 03:23:49,979 --> 03:23:52,140 in this object 4774 03:23:52,140 --> 03:23:54,239 and we're going to append it to the form 4775 03:23:54,239 --> 03:23:55,680 data 4776 03:23:55,680 --> 03:23:57,720 like so now I know this is 4777 03:23:57,720 --> 03:24:00,180 unconventional but when you have an 4778 03:24:00,180 --> 03:24:02,819 image this is one way to send the image 4779 03:24:02,819 --> 03:24:05,040 through the request body 4780 03:24:05,040 --> 03:24:06,840 and this will cycle through all the 4781 03:24:06,840 --> 03:24:09,060 values added to form data 4782 03:24:09,060 --> 03:24:11,160 and the one thing we need to append 4783 03:24:11,160 --> 03:24:12,600 actually 4784 03:24:12,600 --> 03:24:14,040 is going to be 4785 03:24:14,040 --> 03:24:16,560 the picture path 4786 03:24:16,560 --> 03:24:18,899 and the picture path is essentially 4787 03:24:18,899 --> 03:24:21,800 going to be the name 4788 03:24:23,939 --> 03:24:27,660 so that is identified by if you go back 4789 03:24:27,660 --> 03:24:28,979 to our server 4790 03:24:28,979 --> 03:24:33,300 and we create the assets so p1.jpg that 4791 03:24:33,300 --> 03:24:35,939 is the name of the file and that's going 4792 03:24:35,939 --> 03:24:38,899 to be our path 4793 03:24:39,060 --> 03:24:41,160 and we need to append this manually 4794 03:24:41,160 --> 03:24:43,620 because we add the images that's how 4795 03:24:43,620 --> 03:24:46,460 it's going to be working 4796 03:24:46,920 --> 03:24:49,680 and then finally with that we can do 4797 03:24:49,680 --> 03:24:53,239 saved user response 4798 03:24:56,220 --> 03:24:59,100 to save whatever is returned from the 4799 03:24:59,100 --> 03:25:01,260 back end we're going to do a fetch call 4800 03:25:01,260 --> 03:25:03,840 to call an API 4801 03:25:03,840 --> 03:25:06,840 and do HTTP local 4802 03:25:06,840 --> 03:25:08,399 host 4803 03:25:08,399 --> 03:25:11,220 colon 3001 because that's what we set 4804 03:25:11,220 --> 03:25:12,960 the port to and we're going to do 4805 03:25:12,960 --> 03:25:15,000 register 4806 03:25:15,000 --> 03:25:16,920 like so 4807 03:25:16,920 --> 03:25:18,840 and inside here I'm going to create an 4808 03:25:18,840 --> 03:25:23,279 object and it's a method colon post 4809 03:25:23,279 --> 03:25:25,380 and we're going to give it a body of 4810 03:25:25,380 --> 03:25:28,399 form data 4811 03:25:28,739 --> 03:25:32,819 so we are now sending this form data to 4812 03:25:32,819 --> 03:25:35,520 this particular API call 4813 03:25:35,520 --> 03:25:38,040 and I'm going to say const saved user 4814 03:25:38,040 --> 03:25:40,739 and I'm going to do a weight saved user 4815 03:25:40,739 --> 03:25:44,040 response dot Json I'm going to invoke it 4816 03:25:44,040 --> 03:25:47,279 so whatever we get we're going to save 4817 03:25:47,279 --> 03:25:49,380 it over here we're going to make it into 4818 03:25:49,380 --> 03:25:52,500 a parsable form with DOT Json 4819 03:25:52,500 --> 03:25:55,439 and with that information we want to 4820 03:25:55,439 --> 03:25:56,580 make sure 4821 03:25:56,580 --> 03:26:00,600 our form is reset and that's why we are 4822 03:26:00,600 --> 03:26:03,180 passing an on submit props this comes 4823 03:26:03,180 --> 03:26:03,960 from 4824 03:26:03,960 --> 03:26:06,000 formic and that's why we're continually 4825 03:26:06,000 --> 03:26:09,000 passing it in and we want to do a reset 4826 03:26:09,000 --> 03:26:10,260 form 4827 03:26:10,260 --> 03:26:12,060 this provides the number of functions 4828 03:26:12,060 --> 03:26:14,880 with formic 4829 03:26:14,880 --> 03:26:19,500 and if saved user so if we successfully 4830 03:26:19,500 --> 03:26:22,080 succeeded getting the user we're going 4831 03:26:22,080 --> 03:26:24,840 to say set page type to be login 4832 03:26:24,840 --> 03:26:29,460 otherwise we're not going to re-navigate 4833 03:26:29,819 --> 03:26:31,560 so this is going to be our register 4834 03:26:31,560 --> 03:26:33,540 function and then we're also going to 4835 03:26:33,540 --> 03:26:35,880 create the login as well 4836 03:26:35,880 --> 03:26:37,920 and I'll demonstrate all of this very 4837 03:26:37,920 --> 03:26:38,939 shortly 4838 03:26:38,939 --> 03:26:41,399 once I have this complete 4839 03:26:41,399 --> 03:26:43,020 and this is going to have the same 4840 03:26:43,020 --> 03:26:44,520 arguments 4841 03:26:44,520 --> 03:26:46,020 and I'm just going to copy this over 4842 03:26:46,020 --> 03:26:48,720 save the user response 4843 03:26:48,720 --> 03:26:50,819 and instead the saved user response 4844 03:26:50,819 --> 03:26:52,859 we're going to have logged 4845 03:26:52,859 --> 03:26:54,540 in 4846 03:26:54,540 --> 03:26:56,399 response 4847 03:26:56,399 --> 03:26:58,560 like so 4848 03:26:58,560 --> 03:27:00,779 and instead of this being registered 4849 03:27:00,779 --> 03:27:03,680 this is going to be login 4850 03:27:04,739 --> 03:27:08,580 and we're going to set of headers 4851 03:27:08,580 --> 03:27:11,160 of content 4852 03:27:11,160 --> 03:27:13,380 type since we're not doing the form data 4853 03:27:13,380 --> 03:27:16,920 Now application slash Json 4854 03:27:16,920 --> 03:27:20,340 and hit a comma and inside the body I 4855 03:27:20,340 --> 03:27:23,819 can just do Json Dot stringify 4856 03:27:23,819 --> 03:27:26,520 and pass the values in directly because 4857 03:27:26,520 --> 03:27:29,100 it's formatted automatic or formatted in 4858 03:27:29,100 --> 03:27:31,319 the correct way already 4859 03:27:31,319 --> 03:27:35,120 we're going to con logged in is equal to 4860 03:27:35,120 --> 03:27:40,700 logged in response dot Json 4861 03:27:40,979 --> 03:27:42,840 and we're also gonna 4862 03:27:42,840 --> 03:27:45,960 reset form as well when we log in 4863 03:27:45,960 --> 03:27:47,399 and if 4864 03:27:47,399 --> 03:27:51,060 that API call has succeeded and the user 4865 03:27:51,060 --> 03:27:53,520 successfully authenticated we're going 4866 03:27:53,520 --> 03:27:55,140 to dispatch 4867 03:27:55,140 --> 03:27:57,540 and we're going to set login 4868 03:27:57,540 --> 03:28:00,260 with user logged 4869 03:28:00,260 --> 03:28:05,700 in.user like this token logged in dot 4870 03:28:05,700 --> 03:28:06,840 token 4871 03:28:06,840 --> 03:28:10,200 now if you remember where this is coming 4872 03:28:10,200 --> 03:28:13,200 from this is coming from 4873 03:28:13,200 --> 03:28:16,439 our Redux state so if you go set log in 4874 03:28:16,439 --> 03:28:19,739 we are setting the user and the token 4875 03:28:19,739 --> 03:28:24,479 inside our state inside our store 4876 03:28:24,479 --> 03:28:27,180 now if you know this action.payload 4877 03:28:27,180 --> 03:28:31,260 if you want to pass it into the payload 4878 03:28:31,260 --> 03:28:33,840 um or sorry if I go back to the form you 4879 03:28:33,840 --> 03:28:36,000 have to pass it into an object with the 4880 03:28:36,000 --> 03:28:39,000 user like this just keep note of it this 4881 03:28:39,000 --> 03:28:41,279 is the one Quirk of Redux toolkit that 4882 03:28:41,279 --> 03:28:44,580 you can see but once you understand it 4883 03:28:44,580 --> 03:28:46,680 pretty convenient 4884 03:28:46,680 --> 03:28:48,479 and once you have that we're going to 4885 03:28:48,479 --> 03:28:49,560 navigate 4886 03:28:49,560 --> 03:28:51,899 to the home so you should be able to 4887 03:28:51,899 --> 03:28:55,739 successfully authenticate 4888 03:28:56,939 --> 03:28:59,520 and with this let's double check our 4889 03:28:59,520 --> 03:29:00,720 terminal make sure we don't have any 4890 03:29:00,720 --> 03:29:03,060 errors so we're good and we're going to 4891 03:29:03,060 --> 03:29:05,700 go to our site 4892 03:29:05,700 --> 03:29:08,760 and I am going to navigate to the home 4893 03:29:08,760 --> 03:29:10,080 page 4894 03:29:10,080 --> 03:29:11,939 or not the home page but the login page 4895 03:29:11,939 --> 03:29:14,880 so we don't have an account created here 4896 03:29:14,880 --> 03:29:16,319 so I'm going to write don't have an 4897 03:29:16,319 --> 03:29:20,340 account I'm going to say fake man and I 4898 03:29:20,340 --> 03:29:21,600 know there's a warning over here 4899 03:29:21,600 --> 03:29:23,460 controlled input that's because we're 4900 03:29:23,460 --> 03:29:26,600 kind of switching between but this is 4901 03:29:26,600 --> 03:29:30,060 non-relevant I hate to ignore a warning 4902 03:29:30,060 --> 03:29:32,160 and I don't do that often but this is 4903 03:29:32,160 --> 03:29:34,739 one of the situations where it doesn't 4904 03:29:34,739 --> 03:29:37,140 affect anything 4905 03:29:37,140 --> 03:29:39,239 and I'm going to say fake 4906 03:29:39,239 --> 03:29:41,880 location in California 4907 03:29:41,880 --> 03:29:43,500 fake 4908 03:29:43,500 --> 03:29:44,700 fake 4909 03:29:44,700 --> 03:29:47,580 con man 4910 03:29:47,580 --> 03:29:50,640 I'm gonna put a random image 4911 03:29:50,640 --> 03:29:52,560 let's just say 4912 03:29:52,560 --> 03:29:55,080 let's say I look like this person okay 4913 03:29:55,080 --> 03:29:57,380 and then I'm going to put fake man 4914 03:29:57,380 --> 03:30:00,779 gmail.com and then fake man that's the 4915 03:30:00,779 --> 03:30:01,680 password 4916 03:30:01,680 --> 03:30:05,160 the register and it seems like we do 4917 03:30:05,160 --> 03:30:09,420 have an error so let's double check and 4918 03:30:09,420 --> 03:30:11,100 actually I know why 4919 03:30:11,100 --> 03:30:14,399 the reason why is we are not running our 4920 03:30:14,399 --> 03:30:15,479 server 4921 03:30:15,479 --> 03:30:18,840 at some point I closed it so I'm going 4922 03:30:18,840 --> 03:30:20,939 to create another terminal so I'm going 4923 03:30:20,939 --> 03:30:23,279 to do CD dot dot so I go to the parent 4924 03:30:23,279 --> 03:30:25,920 and now I can go into the server file 4925 03:30:25,920 --> 03:30:30,319 I'm going to run npm run start 4926 03:30:30,420 --> 03:30:33,660 let's make sure this is running and then 4927 03:30:33,660 --> 03:30:35,939 we also have our information so we can 4928 03:30:35,939 --> 03:30:38,460 try registering again and then we have 4929 03:30:38,460 --> 03:30:40,680 something successful perfect we have the 4930 03:30:40,680 --> 03:30:43,140 user coming back in 4931 03:30:43,140 --> 03:30:44,880 you can ignore that because we already 4932 03:30:44,880 --> 03:30:46,500 fixed that so we're going to say fake 4933 03:30:46,500 --> 03:30:51,180 man gmail.com fake man as well just note 4934 03:30:51,180 --> 03:30:53,040 that we don't have any validation checks 4935 03:30:53,040 --> 03:30:55,439 so this is case sensitive for the email 4936 03:30:55,439 --> 03:30:57,359 but typically you want to change that 4937 03:30:57,359 --> 03:30:59,520 then we have login 4938 03:30:59,520 --> 03:31:03,120 and now we can now log in perfectly 4939 03:31:03,120 --> 03:31:05,279 one thing to note is if you have the 4940 03:31:05,279 --> 03:31:08,220 Chrome Redux Dev tools extension which 4941 03:31:08,220 --> 03:31:10,380 is available in Brave and chrome and I 4942 03:31:10,380 --> 03:31:12,300 know there's probably a Firefox version 4943 03:31:12,300 --> 03:31:15,840 as well you can go to the Redux Tab and 4944 03:31:15,840 --> 03:31:18,600 you can see the state you can see all 4945 03:31:18,600 --> 03:31:20,880 your current state as well I know it's a 4946 03:31:20,880 --> 03:31:22,680 little hard to see I'm not entirely sure 4947 03:31:22,680 --> 03:31:25,080 to how to create make this bigger but 4948 03:31:25,080 --> 03:31:26,700 you can see that we have the user 4949 03:31:26,700 --> 03:31:28,800 information that we saved in as well as 4950 03:31:28,800 --> 03:31:30,840 a token 4951 03:31:30,840 --> 03:31:33,600 and just to note we have this saved in 4952 03:31:33,600 --> 03:31:35,399 our local storage and if you're ever 4953 03:31:35,399 --> 03:31:37,500 curious what's stored in the local 4954 03:31:37,500 --> 03:31:40,260 storage you can go to the application 4955 03:31:40,260 --> 03:31:42,899 tab on their local storage you can click 4956 03:31:42,899 --> 03:31:45,479 your current browser and you can see 4957 03:31:45,479 --> 03:31:48,000 that we have all of these stored in our 4958 03:31:48,000 --> 03:31:51,660 local store because of Redux persist 4959 03:31:51,660 --> 03:31:53,160 there's one last thing I want to 4960 03:31:53,160 --> 03:31:55,859 configure for authentication now that we 4961 03:31:55,859 --> 03:31:57,960 have the user and the tokens we can go 4962 03:31:57,960 --> 03:32:00,080 to app.js 4963 03:32:00,080 --> 03:32:03,479 and in here I'm going to do const is 4964 03:32:03,479 --> 03:32:05,819 auth meaning whether they're 4965 03:32:05,819 --> 03:32:08,700 walked in or not which is determined via 4966 03:32:08,700 --> 03:32:10,560 use selector 4967 03:32:10,560 --> 03:32:14,100 and we're going to grab the state 4968 03:32:14,100 --> 03:32:17,640 we're going to grab the state DOT token 4969 03:32:17,640 --> 03:32:20,399 so if the token exists we are 4970 03:32:20,399 --> 03:32:24,540 authorized so we can add this to our 4971 03:32:24,540 --> 03:32:26,819 routes 4972 03:32:26,819 --> 03:32:27,960 so 4973 03:32:27,960 --> 03:32:30,479 in The Element Section I'm going to put 4974 03:32:30,479 --> 03:32:32,100 is auth 4975 03:32:32,100 --> 03:32:36,080 with home page and if it doesn't 4976 03:32:36,540 --> 03:32:38,819 or if you're not authenticated we're 4977 03:32:38,819 --> 03:32:40,560 going to do navigate 4978 03:32:40,560 --> 03:32:44,540 using that component from 4979 03:32:44,580 --> 03:32:46,739 react router and we're going to navigate 4980 03:32:46,739 --> 03:32:47,819 to 4981 03:32:47,819 --> 03:32:50,040 the login page 4982 03:32:50,040 --> 03:32:53,540 actually this should be closing Tech 4983 03:32:56,460 --> 03:32:57,600 and we're going to do the same thing 4984 03:32:57,600 --> 03:33:01,279 over here for the profile page 4985 03:33:05,460 --> 03:33:08,399 colon like so 4986 03:33:08,399 --> 03:33:11,040 and I did not close that 4987 03:33:11,040 --> 03:33:14,220 and I believe that's correct there's one 4988 03:33:14,220 --> 03:33:15,840 extra one okay 4989 03:33:15,840 --> 03:33:18,000 so basically now the home and the 4990 03:33:18,000 --> 03:33:21,060 profile user are protected you need to 4991 03:33:21,060 --> 03:33:23,640 set the token now someone could 4992 03:33:23,640 --> 03:33:26,279 obviously just set the local storage and 4993 03:33:26,279 --> 03:33:28,620 make sure they have some random token in 4994 03:33:28,620 --> 03:33:31,620 this case but even then those routes are 4995 03:33:31,620 --> 03:33:33,899 protected so it doesn't really matter if 4996 03:33:33,899 --> 03:33:36,120 they can do that so this is just a UI 4997 03:33:36,120 --> 03:33:38,399 more of a UI visual thing so that they 4998 03:33:38,399 --> 03:33:40,739 can't access these page and they'll just 4999 03:33:40,739 --> 03:33:42,720 navigate them back to the login page if 5000 03:33:42,720 --> 03:33:44,880 they go to it directly 5001 03:33:44,880 --> 03:33:47,279 and with that the authentication and 5002 03:33:47,279 --> 03:33:51,840 authorization authorization is complete 5003 03:33:51,840 --> 03:33:54,239 now the next thing on our list is going 5004 03:33:54,239 --> 03:33:56,880 to be the home page and the layout so 5005 03:33:56,880 --> 03:33:58,800 we're going to be working on each of 5006 03:33:58,800 --> 03:34:01,500 these widgets as I call them 5007 03:34:01,500 --> 03:34:03,000 one by one 5008 03:34:03,000 --> 03:34:04,560 but before we start creating our first 5009 03:34:04,560 --> 03:34:06,420 widget we are going to create a 5010 03:34:06,420 --> 03:34:10,020 component and this is going to be called 5011 03:34:10,020 --> 03:34:11,580 widget 5012 03:34:11,580 --> 03:34:13,620 wrapper 5013 03:34:13,620 --> 03:34:16,700 Dot jsx 5014 03:34:17,100 --> 03:34:19,859 so like before this widget wrapper is 5015 03:34:19,859 --> 03:34:21,899 going to be a style component so I'm 5016 03:34:21,899 --> 03:34:24,660 going to go to flex between 5017 03:34:24,660 --> 03:34:27,840 copy the Imports 5018 03:34:27,840 --> 03:34:29,760 paste it 5019 03:34:29,760 --> 03:34:33,840 I'm going to create widget wrapper 5020 03:34:33,840 --> 03:34:38,279 and it's going to equal styled box 5021 03:34:38,340 --> 03:34:42,080 and theme like so 5022 03:34:43,380 --> 03:34:46,140 and pass in an object and in here we're 5023 03:34:46,140 --> 03:34:49,520 going to give it a padding of 1.5 REM 5024 03:34:49,520 --> 03:34:52,939 1.5 REM 5025 03:34:52,939 --> 03:34:55,739 0.75 REM 5026 03:34:55,739 --> 03:34:58,260 1.5 Ram 5027 03:34:58,260 --> 03:35:00,540 so this is a shorthand if you didn't 5028 03:35:00,540 --> 03:35:01,500 know 5029 03:35:01,500 --> 03:35:03,479 this represents 5030 03:35:03,479 --> 03:35:04,979 top 5031 03:35:04,979 --> 03:35:07,200 right bottom 5032 03:35:07,200 --> 03:35:09,779 left so it goes clockwise so if you have 5033 03:35:09,779 --> 03:35:12,180 four values for padding 5034 03:35:12,180 --> 03:35:14,460 you can add four values to represent 5035 03:35:14,460 --> 03:35:16,380 each side it's quite handy so you don't 5036 03:35:16,380 --> 03:35:19,620 have to specify different padding for 5037 03:35:19,620 --> 03:35:21,060 each side 5038 03:35:21,060 --> 03:35:23,580 then from here I'm going to say theme 5039 03:35:23,580 --> 03:35:28,080 dot palette dot background dot alt so if 5040 03:35:28,080 --> 03:35:29,760 you're using style components you can 5041 03:35:29,760 --> 03:35:32,340 pass the theme over here and grab the 5042 03:35:32,340 --> 03:35:34,520 value 5043 03:35:35,460 --> 03:35:39,200 and also by the way I'm missing a 5044 03:35:41,220 --> 03:35:43,500 missing friends right there 5045 03:35:43,500 --> 03:35:44,819 and then from here I'm going to do 5046 03:35:44,819 --> 03:35:47,340 border radius 5047 03:35:47,340 --> 03:35:51,180 and it's going to be 0.75 REM 5048 03:35:51,180 --> 03:35:53,399 and finally I'm going to export default 5049 03:35:53,399 --> 03:35:54,660 widget 5050 03:35:54,660 --> 03:35:55,920 wrapper 5051 03:35:55,920 --> 03:35:59,040 so this will wrap our widget give us a 5052 03:35:59,040 --> 03:36:00,720 base 5053 03:36:00,720 --> 03:36:02,460 styling for every single widget 5054 03:36:02,460 --> 03:36:04,920 including like the Border radius and the 5055 03:36:04,920 --> 03:36:07,319 color so it'll help us 5056 03:36:07,319 --> 03:36:08,760 build some of these wedges a little 5057 03:36:08,760 --> 03:36:10,380 faster 5058 03:36:10,380 --> 03:36:12,779 okay and then the next thing we're going 5059 03:36:12,779 --> 03:36:15,140 to be building 5060 03:36:16,080 --> 03:36:18,720 is going to be a user image widget so 5061 03:36:18,720 --> 03:36:21,260 user 5062 03:36:22,859 --> 03:36:24,899 user image 5063 03:36:24,899 --> 03:36:28,520 jsx like so 5064 03:36:28,560 --> 03:36:32,640 and in here we're going to import box 5065 03:36:32,640 --> 03:36:35,239 from 5066 03:36:35,520 --> 03:36:38,160 at mui slash 5067 03:36:38,160 --> 03:36:40,939 material 5068 03:36:41,040 --> 03:36:44,040 I'm going to do const user image 5069 03:36:44,040 --> 03:36:45,840 is equal to 5070 03:36:45,840 --> 03:36:47,939 image size 5071 03:36:47,939 --> 03:36:52,340 equal to 60 pixel 5072 03:36:52,380 --> 03:36:55,020 and in here 5073 03:36:55,020 --> 03:36:57,859 I'm going to just return 5074 03:36:58,380 --> 03:37:01,020 a box 5075 03:37:01,020 --> 03:37:03,899 let me export default first before I 5076 03:37:03,899 --> 03:37:06,140 forget 5077 03:37:08,819 --> 03:37:11,460 and in here we're going to have a width 5078 03:37:11,460 --> 03:37:15,779 of size and a height of size 5079 03:37:15,779 --> 03:37:18,540 so we have default height and width if 5080 03:37:18,540 --> 03:37:20,700 we don't specify 5081 03:37:20,700 --> 03:37:22,920 and then we're going to add 5082 03:37:22,920 --> 03:37:25,859 an image tag 5083 03:37:25,859 --> 03:37:28,439 and in here we're going to have style is 5084 03:37:28,439 --> 03:37:31,319 equal to object fit 5085 03:37:31,319 --> 03:37:35,640 cover so it takes up the entire space 5086 03:37:35,640 --> 03:37:38,700 as necessary and it does 5087 03:37:38,700 --> 03:37:41,819 crop it as necessary so in a way if you 5088 03:37:41,819 --> 03:37:43,560 have your images that are centered like 5089 03:37:43,560 --> 03:37:45,180 all the important information is in the 5090 03:37:45,180 --> 03:37:47,700 center object fit cover is a perfect fit 5091 03:37:47,700 --> 03:37:49,739 because it does crop the side if it 5092 03:37:49,739 --> 03:37:53,100 needs to fit the dimensions 5093 03:37:53,100 --> 03:37:55,500 we're gonna have a board of radius of 50 5094 03:37:55,500 --> 03:37:58,260 so this is the circle so essentially 5095 03:37:58,260 --> 03:37:59,939 this user image is going to be the 5096 03:37:59,939 --> 03:38:02,760 profile image that you see for each user 5097 03:38:02,760 --> 03:38:06,000 which is just going to be that Circle 5098 03:38:06,000 --> 03:38:07,920 and we're setting the width of size 5099 03:38:07,920 --> 03:38:11,279 height of size 5100 03:38:11,279 --> 03:38:17,359 in alt of user and the source of HTTP 5101 03:38:17,359 --> 03:38:20,819 slash localhost 5102 03:38:20,819 --> 03:38:22,739 three thousand 5103 03:38:22,739 --> 03:38:25,080 and one assets 5104 03:38:25,080 --> 03:38:27,720 slash image 5105 03:38:27,720 --> 03:38:30,540 so this will grab the profile image as 5106 03:38:30,540 --> 03:38:33,899 needed for each of the profile users 5107 03:38:33,899 --> 03:38:36,300 and this is just a convenience component 5108 03:38:36,300 --> 03:38:37,859 that we can reuse 5109 03:38:37,859 --> 03:38:40,260 so we're going to save all those close 5110 03:38:40,260 --> 03:38:41,700 them 5111 03:38:41,700 --> 03:38:45,680 and now I'm going to go to 5112 03:38:46,859 --> 03:38:49,319 our directory and I'm going to go under 5113 03:38:49,319 --> 03:38:51,180 widgets 5114 03:38:51,180 --> 03:38:53,100 I'm going to create a new file called 5115 03:38:53,100 --> 03:38:54,560 user 5116 03:38:54,560 --> 03:38:58,439 widget.jsx so this user widget 5117 03:38:58,439 --> 03:39:01,260 is going to be this right here so we're 5118 03:39:01,260 --> 03:39:04,140 going to create this first and by the 5119 03:39:04,140 --> 03:39:06,479 way user image represents these guys 5120 03:39:06,479 --> 03:39:08,340 widget wrapper represents just the 5121 03:39:08,340 --> 03:39:10,859 styling of each widget 5122 03:39:10,859 --> 03:39:13,260 so that's what each one does 5123 03:39:13,260 --> 03:39:15,960 and so in our user widget 5124 03:39:15,960 --> 03:39:17,819 we're going to do some imports so we're 5125 03:39:17,819 --> 03:39:19,500 going to import 5126 03:39:19,500 --> 03:39:22,520 and let me close this 5127 03:39:22,620 --> 03:39:24,540 we're going to import a number of icons 5128 03:39:24,540 --> 03:39:27,540 so we're going to import manage accounts 5129 03:39:27,540 --> 03:39:29,580 outlined 5130 03:39:29,580 --> 03:39:32,660 edit outlined location 5131 03:39:32,660 --> 03:39:35,399 on outlined 5132 03:39:35,399 --> 03:39:37,680 work outline 5133 03:39:37,680 --> 03:39:40,640 outlined 5134 03:39:42,120 --> 03:39:49,380 and all from at mui slash icons material 5135 03:39:49,380 --> 03:39:52,520 from here I'm going to import 5136 03:39:53,040 --> 03:39:55,500 box from mui material 5137 03:39:55,500 --> 03:39:58,020 in addition to typography 5138 03:39:58,020 --> 03:39:59,520 divider 5139 03:39:59,520 --> 03:40:02,600 and use theme 5140 03:40:03,120 --> 03:40:05,520 then we're going to import user image 5141 03:40:05,520 --> 03:40:07,560 that we just created 5142 03:40:07,560 --> 03:40:12,120 as well as import Flex between 5143 03:40:12,120 --> 03:40:16,020 and we import widget wrapper 5144 03:40:16,020 --> 03:40:19,620 and as you can see again with the source 5145 03:40:19,620 --> 03:40:23,399 configuration in JS config we can grab 5146 03:40:23,399 --> 03:40:26,160 the route via components because we 5147 03:40:26,160 --> 03:40:28,260 start from the source we do components 5148 03:40:28,260 --> 03:40:30,479 user image so we can always start from 5149 03:40:30,479 --> 03:40:33,000 here as opposed to just doing relative 5150 03:40:33,000 --> 03:40:35,640 Imports like this and that will give us 5151 03:40:35,640 --> 03:40:37,560 what we need but this is much more 5152 03:40:37,560 --> 03:40:40,859 cleaner more effective 5153 03:40:40,859 --> 03:40:42,359 and then from here I'm going to import 5154 03:40:42,359 --> 03:40:45,979 use selector 5155 03:40:46,080 --> 03:40:47,819 from react Redux 5156 03:40:47,819 --> 03:40:51,500 I'm going to import use effect 5157 03:40:51,840 --> 03:40:54,420 from react as well as 5158 03:40:54,420 --> 03:40:56,760 use state 5159 03:40:56,760 --> 03:40:58,700 and I'm going to import use navigate 5160 03:40:58,700 --> 03:41:02,460 from react router Dom 5161 03:41:02,460 --> 03:41:04,859 and below this I'm going to do const 5162 03:41:04,859 --> 03:41:07,979 user widget is equal to 5163 03:41:07,979 --> 03:41:10,560 user ID picture 5164 03:41:10,560 --> 03:41:13,160 path 5165 03:41:17,580 --> 03:41:20,340 and in here I'm going to do I'm going to 5166 03:41:20,340 --> 03:41:23,160 add some state so I'm going to add user 5167 03:41:23,160 --> 03:41:25,020 set user 5168 03:41:25,020 --> 03:41:27,359 use state 5169 03:41:27,359 --> 03:41:29,960 null 5170 03:41:30,300 --> 03:41:32,880 so this is how we're going to grab the 5171 03:41:32,880 --> 03:41:34,920 user 5172 03:41:34,920 --> 03:41:36,840 from the back end 5173 03:41:36,840 --> 03:41:39,840 and save it for our use and then we're 5174 03:41:39,840 --> 03:41:42,479 going to do const palette 5175 03:41:42,479 --> 03:41:45,840 is equal to use theme 5176 03:41:45,840 --> 03:41:48,960 const navigate as you can click use 5177 03:41:48,960 --> 03:41:51,380 navigate 5178 03:41:51,479 --> 03:41:55,620 const token is going to be use selector 5179 03:41:55,620 --> 03:42:00,080 and we're going to grab from the store 5180 03:42:02,819 --> 03:42:05,220 and then we're going to grab oops I 5181 03:42:05,220 --> 03:42:07,859 don't know why that did that 5182 03:42:07,859 --> 03:42:09,420 and then from here I'm going to grab 5183 03:42:09,420 --> 03:42:12,000 colors from the theme so dark equals 5184 03:42:12,000 --> 03:42:14,220 palette 5185 03:42:14,220 --> 03:42:17,220 dot neutral 5186 03:42:17,220 --> 03:42:19,020 dot dark 5187 03:42:19,020 --> 03:42:21,060 I'm going to just copy this so I'll have 5188 03:42:21,060 --> 03:42:22,020 to write 5189 03:42:22,020 --> 03:42:25,800 too much so I'm going to const medium 5190 03:42:25,800 --> 03:42:29,220 equals palette dot neutral medium 5191 03:42:29,220 --> 03:42:31,859 and then const main is equal to palette 5192 03:42:31,859 --> 03:42:34,739 on neutral Main 5193 03:42:34,739 --> 03:42:36,239 and again this is all coming from the 5194 03:42:36,239 --> 03:42:38,100 themes file you can check all those 5195 03:42:38,100 --> 03:42:40,680 colors out 5196 03:42:40,680 --> 03:42:42,120 and 5197 03:42:42,120 --> 03:42:44,939 here in our user widget when we enter 5198 03:42:44,939 --> 03:42:48,720 this particular page we want to grab the 5199 03:42:48,720 --> 03:42:50,580 user information so we're going to call 5200 03:42:50,580 --> 03:42:53,100 the API to grab this user 5201 03:42:53,100 --> 03:42:55,859 so the way to do that you can do const 5202 03:42:55,859 --> 03:42:59,580 get user is equal to async 5203 03:42:59,580 --> 03:43:00,840 like so 5204 03:43:00,840 --> 03:43:03,000 and we're going to make an API call so 5205 03:43:03,000 --> 03:43:04,979 we're going to call this response a 5206 03:43:04,979 --> 03:43:06,660 weight fetch 5207 03:43:06,660 --> 03:43:09,960 and we're going to pass in http 5208 03:43:09,960 --> 03:43:13,979 colon slash localhost 5209 03:43:14,000 --> 03:43:17,040 3001 users slash 5210 03:43:17,040 --> 03:43:18,899 user 5211 03:43:18,899 --> 03:43:22,920 oops user ID 5212 03:43:22,920 --> 03:43:26,180 I'm going to put a comma 5213 03:43:27,120 --> 03:43:30,120 comma and then I'm going to do 5214 03:43:30,120 --> 03:43:33,720 an object method 5215 03:43:33,720 --> 03:43:36,319 get 5216 03:43:37,800 --> 03:43:40,859 and then headers 5217 03:43:40,859 --> 03:43:43,380 with authorization 5218 03:43:43,380 --> 03:43:45,060 colon 5219 03:43:45,060 --> 03:43:47,760 Bearer 5220 03:43:47,760 --> 03:43:49,020 token 5221 03:43:49,020 --> 03:43:52,260 so now if you remember why we are doing 5222 03:43:52,260 --> 03:43:54,120 this is if you go back 5223 03:43:54,120 --> 03:43:57,359 to our server we go to 5224 03:43:57,359 --> 03:44:01,319 middleware we go to auth you can see in 5225 03:44:01,319 --> 03:44:02,880 our authorization 5226 03:44:02,880 --> 03:44:05,700 we are writing Bearer in our 5227 03:44:05,700 --> 03:44:07,439 authorization header 5228 03:44:07,439 --> 03:44:09,899 and we are taking everything behind it 5229 03:44:09,899 --> 03:44:11,819 which is the token 5230 03:44:11,819 --> 03:44:14,279 that is how we grab the token and then 5231 03:44:14,279 --> 03:44:16,680 we verify the jot token 5232 03:44:16,680 --> 03:44:20,420 so this is what's happening over here 5233 03:44:21,720 --> 03:44:24,560 and with that 5234 03:44:25,620 --> 03:44:27,120 go into the next line we're going to say 5235 03:44:27,120 --> 03:44:29,640 const data is equal to a weight 5236 03:44:29,640 --> 03:44:32,220 response.json 5237 03:44:32,220 --> 03:44:36,739 and we're going to set user as data 5238 03:44:38,760 --> 03:44:40,739 it also occurred to me that instead of 5239 03:44:40,739 --> 03:44:43,560 sending the user you can set the user 5240 03:44:43,560 --> 03:44:45,720 and actually no no this is correct this 5241 03:44:45,720 --> 03:44:47,340 is correct don't worry about ignore what 5242 03:44:47,340 --> 03:44:48,239 I said 5243 03:44:48,239 --> 03:44:50,279 use effect 5244 03:44:50,279 --> 03:44:51,960 and what we're going to do in this use 5245 03:44:51,960 --> 03:44:55,140 effect is we're going to grab get user 5246 03:44:55,140 --> 03:44:57,180 we're going to invoke that 5247 03:44:57,180 --> 03:45:01,319 I'm going to hit with an empty array 5248 03:45:01,319 --> 03:45:03,840 I'm going to do es lint 5249 03:45:03,840 --> 03:45:06,239 disable line 5250 03:45:06,239 --> 03:45:09,960 react hooks exhaustive 5251 03:45:09,960 --> 03:45:11,460 depths 5252 03:45:11,460 --> 03:45:14,880 sometimes I really hate when eslint 5253 03:45:14,880 --> 03:45:16,920 tells you that you have exhausted depths 5254 03:45:16,920 --> 03:45:19,500 you're missing this but a lot of times I 5255 03:45:19,500 --> 03:45:21,420 don't use exhaustive 5256 03:45:21,420 --> 03:45:22,979 dependencies 5257 03:45:22,979 --> 03:45:25,200 but anyways what this means is that when 5258 03:45:25,200 --> 03:45:27,660 you enter this page 5259 03:45:27,660 --> 03:45:30,180 and because this is an empty array 5260 03:45:30,180 --> 03:45:33,060 get user will be called when you enter 5261 03:45:33,060 --> 03:45:35,760 or when you render this component the 5262 03:45:35,760 --> 03:45:38,760 first time so on this page get user will 5263 03:45:38,760 --> 03:45:40,739 be called because this component gets 5264 03:45:40,739 --> 03:45:42,899 rendered 5265 03:45:42,899 --> 03:45:47,060 and this is how you make that API call 5266 03:45:47,340 --> 03:45:50,760 and so we also need the if user does not 5267 03:45:50,760 --> 03:45:54,000 exist we need to return null so if we 5268 03:45:54,000 --> 03:45:56,399 don't have a user we don't return 5269 03:45:56,399 --> 03:45:59,160 anything for the user widget yet 5270 03:45:59,160 --> 03:46:01,260 because it will error out because what 5271 03:46:01,260 --> 03:46:02,880 we're going to do next is going to 5272 03:46:02,880 --> 03:46:04,319 destructure 5273 03:46:04,319 --> 03:46:08,520 items from the user it's like this and 5274 03:46:08,520 --> 03:46:10,500 we're going to grab properties from it 5275 03:46:10,500 --> 03:46:13,020 so first name last name 5276 03:46:13,020 --> 03:46:14,180 location 5277 03:46:14,180 --> 03:46:15,960 occupation 5278 03:46:15,960 --> 03:46:18,779 viewed 5279 03:46:18,779 --> 03:46:19,920 profile 5280 03:46:19,920 --> 03:46:22,080 impressions 5281 03:46:22,080 --> 03:46:23,939 and Friends 5282 03:46:23,939 --> 03:46:25,739 so if we didn't have this it's going to 5283 03:46:25,739 --> 03:46:27,899 error out if user doesn't exist and it 5284 03:46:27,899 --> 03:46:30,300 always doesn't exist until the user gets 5285 03:46:30,300 --> 03:46:31,859 back information so it's always going to 5286 03:46:31,859 --> 03:46:34,200 show an error 5287 03:46:34,200 --> 03:46:37,620 but with this this will be fine 5288 03:46:37,620 --> 03:46:39,660 typically you would have a loading 5289 03:46:39,660 --> 03:46:41,580 component by the way you would have a 5290 03:46:41,580 --> 03:46:43,020 loading component while the user is 5291 03:46:43,020 --> 03:46:43,920 waiting 5292 03:46:43,920 --> 03:46:46,080 but to make it simple we're not going to 5293 03:46:46,080 --> 03:46:49,859 handle all the loading States 5294 03:46:49,859 --> 03:46:52,140 all right and then with this we're going 5295 03:46:52,140 --> 03:46:54,060 to use our widget wrapper and this is 5296 03:46:54,060 --> 03:46:55,920 the purpose we're always just going to 5297 03:46:55,920 --> 03:46:58,260 wrap our widgets with this to make it 5298 03:46:58,260 --> 03:47:00,239 more convenient 5299 03:47:00,239 --> 03:47:03,300 it doesn't save too much code but 5300 03:47:03,300 --> 03:47:05,939 enough because we use it enough 5301 03:47:05,939 --> 03:47:07,260 and so we're going to write the first 5302 03:47:07,260 --> 03:47:08,399 row 5303 03:47:08,399 --> 03:47:10,319 so here 5304 03:47:10,319 --> 03:47:12,540 we're going to do Flex between so 5305 03:47:12,540 --> 03:47:14,040 actually before I go 5306 03:47:14,040 --> 03:47:16,080 doing that 5307 03:47:16,080 --> 03:47:19,100 Let's ignore this 5308 03:47:20,880 --> 03:47:22,380 before I do this 5309 03:47:22,380 --> 03:47:24,600 you can see this is going to be the 5310 03:47:24,600 --> 03:47:27,540 first row so I'm going to turn on this 5311 03:47:27,540 --> 03:47:29,819 this will be the first row this will be 5312 03:47:29,819 --> 03:47:31,859 the second third 5313 03:47:31,859 --> 03:47:35,340 fourth sections and as you can see we're 5314 03:47:35,340 --> 03:47:37,380 using Flex for each one of these this is 5315 03:47:37,380 --> 03:47:38,399 flex 5316 03:47:38,399 --> 03:47:42,000 this is split into two and then you can 5317 03:47:42,000 --> 03:47:45,180 place these together and then this will 5318 03:47:45,180 --> 03:47:48,239 be left aligned over here this is flex 5319 03:47:48,239 --> 03:47:51,479 between right here 5320 03:47:51,479 --> 03:47:54,840 these two this element right here 5321 03:47:54,840 --> 03:47:56,880 over see like you see where I'm circling 5322 03:47:56,880 --> 03:48:00,420 and this one is flexed between 5323 03:48:00,420 --> 03:48:02,479 and then these two are flexed between 5324 03:48:02,479 --> 03:48:05,040 in this particular div 5325 03:48:05,040 --> 03:48:07,920 so a lot of flex is going on 5326 03:48:07,920 --> 03:48:09,720 but 5327 03:48:09,720 --> 03:48:11,160 pretty 5328 03:48:11,160 --> 03:48:13,020 pretty self-explanatory once you get the 5329 03:48:13,020 --> 03:48:14,040 hang of it 5330 03:48:14,040 --> 03:48:17,460 so Flex between we want to do a gap of 5331 03:48:17,460 --> 03:48:21,239 0.5 REM so there's a space 5332 03:48:21,239 --> 03:48:25,680 a padding bottom of 1.1 REM 5333 03:48:25,680 --> 03:48:28,020 and on click 5334 03:48:28,020 --> 03:48:31,200 we want the user to be able to navigate 5335 03:48:31,200 --> 03:48:33,840 to the profile page if they click on it 5336 03:48:33,840 --> 03:48:36,120 we have not created the profile page but 5337 03:48:36,120 --> 03:48:38,160 I am just going to write this 5338 03:48:38,160 --> 03:48:39,899 just for now 5339 03:48:39,899 --> 03:48:43,620 and we'll handle the profile page 5340 03:48:43,620 --> 03:48:45,540 later on 5341 03:48:45,540 --> 03:48:50,040 and by the way I have a PB so in 5342 03:48:50,040 --> 03:48:52,560 material UI you have some shorthands 5343 03:48:52,560 --> 03:48:54,420 with padding and margin because you use 5344 03:48:54,420 --> 03:48:56,880 it so frequently so PB can represent 5345 03:48:56,880 --> 03:48:59,100 padding bottom so you don't have to type 5346 03:48:59,100 --> 03:49:01,020 the entire thing 5347 03:49:01,020 --> 03:49:02,340 and then from here we're going to do 5348 03:49:02,340 --> 03:49:04,800 Flex between Gap 5349 03:49:04,800 --> 03:49:06,180 of 5350 03:49:06,180 --> 03:49:08,960 one REM 5351 03:49:09,540 --> 03:49:11,880 and inside here I'm going to use user 5352 03:49:11,880 --> 03:49:13,260 image 5353 03:49:13,260 --> 03:49:15,660 and put an image of 5354 03:49:15,660 --> 03:49:18,840 picture path 5355 03:49:18,840 --> 03:49:20,100 like so 5356 03:49:20,100 --> 03:49:22,560 and then I'm going to play the Box 5357 03:49:22,560 --> 03:49:24,359 and inside this box I'm going to say 5358 03:49:24,359 --> 03:49:26,939 typography 5359 03:49:26,939 --> 03:49:29,340 with the variant 5360 03:49:29,340 --> 03:49:30,899 of 5361 03:49:30,899 --> 03:49:32,760 H4 5362 03:49:32,760 --> 03:49:35,640 color of dark 5363 03:49:35,640 --> 03:49:40,200 font weight of 500 5364 03:49:40,200 --> 03:49:42,300 SX 5365 03:49:42,300 --> 03:49:43,560 of 5366 03:49:43,560 --> 03:49:47,540 and colon hover 5367 03:49:48,060 --> 03:49:50,700 and we're going to do color colon 5368 03:49:50,700 --> 03:49:51,899 palette 5369 03:49:51,899 --> 03:49:55,580 primary dot light 5370 03:49:56,100 --> 03:49:57,899 I'm going to do cursor 5371 03:49:57,899 --> 03:50:01,160 of pointer 5372 03:50:01,979 --> 03:50:03,840 I'm going to close this typography and 5373 03:50:03,840 --> 03:50:05,399 inside here I'm going to write first 5374 03:50:05,399 --> 03:50:07,080 name 5375 03:50:07,080 --> 03:50:10,920 and last name so that will be first and 5376 03:50:10,920 --> 03:50:12,720 last 5377 03:50:12,720 --> 03:50:15,060 and then finally below this I'm going to 5378 03:50:15,060 --> 03:50:18,020 do typography 5379 03:50:18,660 --> 03:50:21,000 give it the friends 5380 03:50:21,000 --> 03:50:23,880 dot length so to show number of friends 5381 03:50:23,880 --> 03:50:25,260 that they have 5382 03:50:25,260 --> 03:50:27,479 friends and we're going to give this a 5383 03:50:27,479 --> 03:50:31,100 color of medium 5384 03:50:31,260 --> 03:50:33,540 and then finally I'm going to have an 5385 03:50:33,540 --> 03:50:36,239 icon that says manage accounts I 5386 03:50:36,239 --> 03:50:40,580 outlined and we're going to close that 5387 03:50:40,859 --> 03:50:43,319 and after that I want to add a divider 5388 03:50:43,319 --> 03:50:44,939 between 5389 03:50:44,939 --> 03:50:48,720 our first row and our second row 5390 03:50:48,720 --> 03:50:51,060 our second row 5391 03:50:51,060 --> 03:50:53,779 will be here 5392 03:50:54,359 --> 03:50:56,640 and this one is going to be a little bit 5393 03:50:56,640 --> 03:50:58,620 simpler so we're going to do box with a 5394 03:50:58,620 --> 03:51:02,160 padding of one REM for top and bottom 5395 03:51:02,160 --> 03:51:05,279 zero for left and right 5396 03:51:05,279 --> 03:51:07,380 then we're going to add a box with a 5397 03:51:07,380 --> 03:51:10,640 display of flex 5398 03:51:10,640 --> 03:51:13,260 align items 5399 03:51:13,260 --> 03:51:15,180 of Center 5400 03:51:15,180 --> 03:51:19,160 and the gap of one REM 5401 03:51:19,380 --> 03:51:22,979 margin bottom of 0.5 REM note that this 5402 03:51:22,979 --> 03:51:24,300 is a little different from Flex between 5403 03:51:24,300 --> 03:51:27,120 we don't have Justified content 5404 03:51:27,120 --> 03:51:29,160 with space between we don't want to use 5405 03:51:29,160 --> 03:51:30,000 that 5406 03:51:30,000 --> 03:51:34,160 so that's why I'm manually writing it 5407 03:51:34,460 --> 03:51:36,600 and from here we're going to do location 5408 03:51:36,600 --> 03:51:39,000 on outlined we're going to do a font 5409 03:51:39,000 --> 03:51:39,840 size 5410 03:51:39,840 --> 03:51:42,060 of large 5411 03:51:42,060 --> 03:51:45,420 and we're going to give it SX of color 5412 03:51:45,420 --> 03:51:49,200 and a main a color of Main 5413 03:51:49,200 --> 03:51:52,920 actually let me do a self-closing tack 5414 03:51:52,920 --> 03:51:54,120 and then right here I'm going to do 5415 03:51:54,120 --> 03:51:59,479 typography with the color of medium 5416 03:51:59,520 --> 03:52:01,200 I'm going to put location 5417 03:52:01,200 --> 03:52:03,000 over here 5418 03:52:03,000 --> 03:52:05,040 and close it 5419 03:52:05,040 --> 03:52:06,960 I'm going to copy this 5420 03:52:06,960 --> 03:52:09,960 and place the box over here 5421 03:52:09,960 --> 03:52:12,239 and we don't need the margin bottom this 5422 03:52:12,239 --> 03:52:13,260 time 5423 03:52:13,260 --> 03:52:16,500 change this to work 5424 03:52:16,500 --> 03:52:18,060 outline 5425 03:52:18,060 --> 03:52:19,620 outlined 5426 03:52:19,620 --> 03:52:21,660 and then change the location to 5427 03:52:21,660 --> 03:52:24,000 occupation 5428 03:52:24,000 --> 03:52:26,220 so that is our second row 5429 03:52:26,220 --> 03:52:29,100 then we have the Third 5430 03:52:29,100 --> 03:52:31,640 row 5431 03:52:33,359 --> 03:52:35,460 and in here we're going to have a box of 5432 03:52:35,460 --> 03:52:40,380 padding one REM zero once again 5433 03:52:40,380 --> 03:52:43,520 and I'm going to do Flex 5434 03:52:44,819 --> 03:52:47,160 between 5435 03:52:47,160 --> 03:52:51,540 margin bottom of 0.5 REM and see how 5436 03:52:51,540 --> 03:52:53,520 useful flux between is we've been using 5437 03:52:53,520 --> 03:52:56,279 this multiple times and it saved us a 5438 03:52:56,279 --> 03:52:57,720 lot of typing 5439 03:52:57,720 --> 03:52:59,700 so typography is going to be over here 5440 03:52:59,700 --> 03:53:02,520 we're going to say who's viewed your 5441 03:53:02,520 --> 03:53:04,680 profile 5442 03:53:04,680 --> 03:53:08,640 and I'm going to have a color of 5443 03:53:08,640 --> 03:53:11,819 medium actually this should be in curly 5444 03:53:11,819 --> 03:53:14,700 braces not in quotes 5445 03:53:14,700 --> 03:53:17,840 so I'm going to copy this 5446 03:53:22,020 --> 03:53:23,760 and I'm going to give it a font 5447 03:53:23,760 --> 03:53:28,100 weight of 500 5448 03:53:29,279 --> 03:53:33,120 I'm going to do viewed profile 5449 03:53:33,120 --> 03:53:36,000 and in here the color should be main 5450 03:53:36,000 --> 03:53:38,600 this time 5451 03:53:41,600 --> 03:53:44,160 and then from here I'm gonna 5452 03:53:44,160 --> 03:53:46,319 copy everything in between I'm going to 5453 03:53:46,319 --> 03:53:47,939 do Flex between 5454 03:53:47,939 --> 03:53:49,140 here 5455 03:53:49,140 --> 03:53:51,239 and inside I'm gonna 5456 03:53:51,239 --> 03:53:53,700 paste what I had 5457 03:53:53,700 --> 03:53:55,500 and we're just going to change the text 5458 03:53:55,500 --> 03:53:57,420 it's going to be impressions 5459 03:53:57,420 --> 03:54:00,720 of your post 5460 03:54:00,720 --> 03:54:02,460 and this should be 5461 03:54:02,460 --> 03:54:05,359 impressions 5462 03:54:06,420 --> 03:54:08,580 there's a lot of typing for this so 5463 03:54:08,580 --> 03:54:10,080 we're just going to Breeze through 5464 03:54:10,080 --> 03:54:12,180 everything so we're going to do fourth 5465 03:54:12,180 --> 03:54:14,899 row 5466 03:54:15,840 --> 03:54:18,060 so the final rope we're going to do a 5467 03:54:18,060 --> 03:54:21,840 box with a padding of one REM top and 5468 03:54:21,840 --> 03:54:24,660 bottom and zero left and right 5469 03:54:24,660 --> 03:54:26,640 and in here I'm going to do typography 5470 03:54:26,640 --> 03:54:32,580 with the font size of one REM color of 5471 03:54:32,580 --> 03:54:38,760 main font weight of 500 margin bottom of 5472 03:54:38,760 --> 03:54:41,180 one REM 5473 03:54:41,340 --> 03:54:45,199 I'm going to write social profiles 5474 03:54:45,899 --> 03:54:48,540 and I'm going to write Flex between 5475 03:54:48,540 --> 03:54:51,439 give it a gap 5476 03:54:51,600 --> 03:54:55,020 and we're going to do a gap of one 5477 03:54:55,020 --> 03:54:56,220 oops 5478 03:54:56,220 --> 03:54:57,960 one REM 5479 03:54:57,960 --> 03:55:01,620 margin bottom of zero point 5480 03:55:01,620 --> 03:55:04,340 five REM 5481 03:55:04,859 --> 03:55:07,979 then I'm going to do Flex between 5482 03:55:07,979 --> 03:55:12,180 with a gap of one REM once again 5483 03:55:12,180 --> 03:55:15,420 I'm going to put an image tag 5484 03:55:15,420 --> 03:55:17,880 with the source 5485 03:55:17,880 --> 03:55:19,920 and we're going to do dot dot assets 5486 03:55:19,920 --> 03:55:23,220 slash Twitter dot PNG 5487 03:55:23,220 --> 03:55:24,779 so we're going to Source the image that 5488 03:55:24,779 --> 03:55:25,620 we 5489 03:55:25,620 --> 03:55:29,699 manually placed into the front end 5490 03:55:29,699 --> 03:55:31,080 and then we're here we're going to do a 5491 03:55:31,080 --> 03:55:33,319 box 5492 03:55:33,479 --> 03:55:36,600 with the typography 5493 03:55:36,600 --> 03:55:41,640 in color of Maine and the font weight of 5494 03:55:41,640 --> 03:55:44,160 500. 5495 03:55:44,160 --> 03:55:45,600 and inside here I'm going to write 5496 03:55:45,600 --> 03:55:46,439 Twitter 5497 03:55:46,439 --> 03:55:49,979 and below this typography 5498 03:55:49,979 --> 03:55:52,620 I'm going to do color equals 5499 03:55:52,620 --> 03:55:54,660 medium 5500 03:55:54,660 --> 03:55:58,580 I'm going to do social network 5501 03:56:01,080 --> 03:56:02,760 and then below this I'm going to write 5502 03:56:02,760 --> 03:56:04,920 edit outlined 5503 03:56:04,920 --> 03:56:10,399 the SX of color colon Main 5504 03:56:11,520 --> 03:56:15,120 like so so that is our first social icon 5505 03:56:15,120 --> 03:56:16,800 so I'm just going to give it some space 5506 03:56:16,800 --> 03:56:18,960 so we can distinguish 5507 03:56:18,960 --> 03:56:21,439 section 5508 03:56:22,319 --> 03:56:24,960 and we're going to do this one I'm going 5509 03:56:24,960 --> 03:56:27,600 to just paste everything 5510 03:56:27,600 --> 03:56:30,000 I'm going to give it a gap of one REM no 5511 03:56:30,000 --> 03:56:31,800 more in the bottom 5512 03:56:31,800 --> 03:56:34,319 and in here this should be LinkedIn this 5513 03:56:34,319 --> 03:56:36,560 time 5514 03:56:37,080 --> 03:56:41,120 with an ALT of LinkedIn 5515 03:56:41,160 --> 03:56:44,040 here this should be LinkedIn 5516 03:56:44,040 --> 03:56:46,859 as well and this should be 5517 03:56:46,859 --> 03:56:49,620 Network 5518 03:56:49,620 --> 03:56:52,620 platform 5519 03:56:52,620 --> 03:56:55,199 like so 5520 03:56:55,199 --> 03:56:57,899 and with that our user widget is now 5521 03:56:57,899 --> 03:56:58,920 complete 5522 03:56:58,920 --> 03:57:01,920 so now we want to input this into the 5523 03:57:01,920 --> 03:57:03,540 right location so I'm going to go to 5524 03:57:03,540 --> 03:57:06,600 home page go to our index and this is 5525 03:57:06,600 --> 03:57:10,020 where we will write 5526 03:57:10,020 --> 03:57:12,660 an input our user widget 5527 03:57:12,660 --> 03:57:14,279 but before that 5528 03:57:14,279 --> 03:57:16,080 let's actually 5529 03:57:16,080 --> 03:57:19,160 add a few things 5530 03:57:19,260 --> 03:57:22,739 let's add a variable for is non-mobile 5531 03:57:22,739 --> 03:57:24,540 screens because this is going to be 5532 03:57:24,540 --> 03:57:25,800 responsive 5533 03:57:25,800 --> 03:57:28,739 and I'm going to say use media query 5534 03:57:28,739 --> 03:57:30,600 import that 5535 03:57:30,600 --> 03:57:32,460 and I'm going to set 5536 03:57:32,460 --> 03:57:35,239 A Min 5537 03:57:35,460 --> 03:57:39,000 Dash with oops Min Dash with 5538 03:57:39,000 --> 03:57:42,800 of a thousand pixels 5539 03:57:45,479 --> 03:57:49,760 and I'm going to grab user information 5540 03:57:50,819 --> 03:57:55,279 of ID and picture path 5541 03:57:55,739 --> 03:57:58,560 using use selector 5542 03:57:58,560 --> 03:58:00,359 make sure you import it and we're going 5543 03:58:00,359 --> 03:58:02,899 to do state 5544 03:58:02,899 --> 03:58:08,359 dot user to grab it from the reducer 5545 03:58:08,580 --> 03:58:11,040 and in here I'm going to set up some 5546 03:58:11,040 --> 03:58:14,960 layout stuff so I'm going to do box 5547 03:58:17,760 --> 03:58:19,260 and I'm going to add some properties 5548 03:58:19,260 --> 03:58:21,239 inside 5549 03:58:21,239 --> 03:58:25,260 I'm going to add width of 100 percent 5550 03:58:25,260 --> 03:58:26,520 padding 5551 03:58:26,520 --> 03:58:30,239 of two REM six percent 5552 03:58:30,239 --> 03:58:32,160 display 5553 03:58:32,160 --> 03:58:35,819 that if it's none 5554 03:58:35,819 --> 03:58:38,279 mobile screens 5555 03:58:38,279 --> 03:58:41,520 we're going to give it a flex 5556 03:58:41,520 --> 03:58:44,699 otherwise we're going to do block 5557 03:58:44,699 --> 03:58:48,300 so that means when we display for big 5558 03:58:48,300 --> 03:58:50,720 screens that's why you can have three 5559 03:58:50,720 --> 03:58:54,060 widgets in a row whereas 5560 03:58:54,060 --> 03:58:55,920 on smaller screens we're just going to 5561 03:58:55,920 --> 03:58:58,739 have them on top of each other 5562 03:58:58,739 --> 03:59:00,660 and then we're going to set a gap of 0.5 5563 03:59:00,660 --> 03:59:02,399 REM 5564 03:59:02,399 --> 03:59:05,760 and justify content 5565 03:59:05,760 --> 03:59:09,560 with space between 5566 03:59:11,580 --> 03:59:13,439 and below this I'm going to create a box 5567 03:59:13,439 --> 03:59:17,239 with flex basis 5568 03:59:18,600 --> 03:59:22,140 is non-mobile screens we're going to set 5569 03:59:22,140 --> 03:59:26,399 it to 26 percent 5570 03:59:26,399 --> 03:59:29,220 and undefined so these are values that I 5571 03:59:29,220 --> 03:59:32,220 arbitrarily decided looked pretty nice 5572 03:59:32,220 --> 03:59:35,279 and in this box I'm going to set 5573 03:59:35,279 --> 03:59:38,000 user 5574 03:59:39,479 --> 03:59:41,580 widget which 5575 03:59:41,580 --> 03:59:44,160 does not seem to be exporting let me 5576 03:59:44,160 --> 03:59:45,840 make sure 5577 03:59:45,840 --> 03:59:48,720 I did I on the export user widget go 5578 03:59:48,720 --> 03:59:50,040 back to that file we're going to write 5579 03:59:50,040 --> 03:59:51,600 export default 5580 03:59:51,600 --> 03:59:54,859 user widget 5581 03:59:55,319 --> 03:59:58,380 that's why right now I can finally 5582 03:59:58,380 --> 04:00:01,699 import it like this 5583 04:00:01,859 --> 04:00:04,640 there you go 5584 04:00:05,160 --> 04:00:07,620 and the user widget requires a few 5585 04:00:07,620 --> 04:00:11,120 properties so user ID 5586 04:00:11,160 --> 04:00:14,880 lowercase and underscore ID is what 5587 04:00:14,880 --> 04:00:18,180 we're passing down with the picture path 5588 04:00:18,180 --> 04:00:22,100 of the picture path that we grabbed 5589 04:00:22,439 --> 04:00:24,180 from the store 5590 04:00:24,180 --> 04:00:28,699 so that is how we set up our user widget 5591 04:00:28,859 --> 04:00:32,460 now before we go on to the next 5592 04:00:32,460 --> 04:00:34,439 widget building it let's actually finish 5593 04:00:34,439 --> 04:00:37,199 up the layout on this home page so here 5594 04:00:37,199 --> 04:00:39,720 I'm going to write box 5595 04:00:39,720 --> 04:00:41,520 and I'm going to do Flex 5596 04:00:41,520 --> 04:00:42,779 basis 5597 04:00:42,779 --> 04:00:44,399 and actually I'm going to just copy this 5598 04:00:44,399 --> 04:00:46,260 over 5599 04:00:46,260 --> 04:00:48,239 from there 5600 04:00:48,239 --> 04:00:51,180 and paste it and change this to 42 5601 04:00:51,180 --> 04:00:53,220 percent 5602 04:00:53,220 --> 04:00:55,620 again arbitrary value values that I 5603 04:00:55,620 --> 04:00:57,060 found looks nice 5604 04:00:57,060 --> 04:01:00,000 and we're going to set is non-mobile 5605 04:01:00,000 --> 04:01:02,779 screens 5606 04:01:03,000 --> 04:01:05,040 we're going to give it a margin top of 5607 04:01:05,040 --> 04:01:07,380 undefined meaning it does not have any 5608 04:01:07,380 --> 04:01:08,699 margin top 5609 04:01:08,699 --> 04:01:11,340 for desktop but if you're on smaller 5610 04:01:11,340 --> 04:01:13,920 screens we need to give it a margin top 5611 04:01:13,920 --> 04:01:16,260 of two REM because now they're stacked 5612 04:01:16,260 --> 04:01:18,359 on top of each other and you need some 5613 04:01:18,359 --> 04:01:20,040 margin 5614 04:01:20,040 --> 04:01:23,120 when you're dealing with it 5615 04:01:23,640 --> 04:01:26,100 all right so we're going to close this 5616 04:01:26,100 --> 04:01:28,319 and in here we're going to add some 5617 04:01:28,319 --> 04:01:31,140 widgets but just not yet 5618 04:01:31,140 --> 04:01:33,300 and we're going to add another layout 5619 04:01:33,300 --> 04:01:37,020 element and this will only pop up 5620 04:01:37,020 --> 04:01:39,600 for desktop screen so your friends list 5621 04:01:39,600 --> 04:01:41,699 will only show 5622 04:01:41,699 --> 04:01:43,920 on desktop 5623 04:01:43,920 --> 04:01:45,899 as well as the advertisement so we're 5624 04:01:45,899 --> 04:01:48,540 going to have a box of flex basis 5625 04:01:48,540 --> 04:01:52,160 of 26 percent 5626 04:01:53,279 --> 04:01:56,779 and we're going to be closing this box 5627 04:02:00,000 --> 04:02:01,800 so we're going to fill out what these 5628 04:02:01,800 --> 04:02:04,739 widgets are going to be 5629 04:02:04,739 --> 04:02:07,699 as we go through 5630 04:02:10,020 --> 04:02:12,239 if I actually take a look 5631 04:02:12,239 --> 04:02:16,080 I see that I have made a mistake with 5632 04:02:16,080 --> 04:02:18,840 this this is a line left to right so if 5633 04:02:18,840 --> 04:02:21,300 you go back 5634 04:02:21,300 --> 04:02:23,819 you want to move manage accounts 5635 04:02:23,819 --> 04:02:28,020 outlined on line 77 after the flex 5636 04:02:28,020 --> 04:02:31,080 between 178 5637 04:02:31,080 --> 04:02:34,439 so move it after that and then also 5638 04:02:34,439 --> 04:02:38,340 if we go all the way down to line 143 5639 04:02:38,340 --> 04:02:40,319 this Flex between 5640 04:02:40,319 --> 04:02:42,420 line 143 5641 04:02:42,420 --> 04:02:46,199 should be placed all the way up right 5642 04:02:46,199 --> 04:02:49,560 below manage accounts outlined 5643 04:02:49,560 --> 04:02:51,720 now if you look back now everything's 5644 04:02:51,720 --> 04:02:53,819 fixed we're missing some dividers 5645 04:02:53,819 --> 04:02:54,899 actually 5646 04:02:54,899 --> 04:02:58,199 so if I go back after divider 5647 04:02:58,199 --> 04:02:59,520 second 5648 04:02:59,520 --> 04:03:02,359 and then third 5649 04:03:02,760 --> 04:03:05,399 will now have dividers everything should 5650 04:03:05,399 --> 04:03:09,779 be aligned perfectly there we go 5651 04:03:09,779 --> 04:03:12,479 as you can see I make some mistakes I'm 5652 04:03:12,479 --> 04:03:14,100 only human 5653 04:03:14,100 --> 04:03:16,859 but always you can just double check 5654 04:03:16,859 --> 04:03:18,720 with the UI you always want to make sure 5655 04:03:18,720 --> 04:03:20,819 as you go along you're double checking 5656 04:03:20,819 --> 04:03:23,939 what you have 5657 04:03:23,939 --> 04:03:25,680 next thing we're going to create is 5658 04:03:25,680 --> 04:03:26,580 going to be 5659 04:03:26,580 --> 04:03:28,500 this component we're going to call this 5660 04:03:28,500 --> 04:03:31,319 the my post component and you you will 5661 04:03:31,319 --> 04:03:33,060 be able to write things you'll be able 5662 04:03:33,060 --> 04:03:34,920 to add an image just like we did before 5663 04:03:34,920 --> 04:03:37,500 with the component we can add it and 5664 04:03:37,500 --> 04:03:39,840 then we can hit post 5665 04:03:39,840 --> 04:03:41,939 and it should add a post at the very 5666 04:03:41,939 --> 04:03:43,979 bottom so as you can see we just add 5667 04:03:43,979 --> 04:03:46,279 this 5668 04:03:48,420 --> 04:03:49,979 so we're going to go back to our code 5669 04:03:49,979 --> 04:03:53,040 we're going to close this 5670 04:03:53,040 --> 04:03:55,620 and inside of box 5671 04:03:55,620 --> 04:03:57,300 I'm going to write 5672 04:03:57,300 --> 04:03:59,899 post 5673 04:04:02,520 --> 04:04:05,100 I'm going to write my post 5674 04:04:05,100 --> 04:04:07,500 widget with picture 5675 04:04:07,500 --> 04:04:09,840 path of picture 5676 04:04:09,840 --> 04:04:13,279 path like so 5677 04:04:13,620 --> 04:04:16,520 and I'm going to import 5678 04:04:17,340 --> 04:04:20,160 my post 5679 04:04:20,160 --> 04:04:21,899 widget 5680 04:04:21,899 --> 04:04:25,500 from scenes widgets 5681 04:04:25,500 --> 04:04:28,979 my post widget 5682 04:04:28,979 --> 04:04:31,260 we have not created it yet so let's do 5683 04:04:31,260 --> 04:04:33,000 that so we're going to create a new file 5684 04:04:33,000 --> 04:04:38,660 my post widget Dot jsx 5685 04:04:39,840 --> 04:04:41,939 inside this component 5686 04:04:41,939 --> 04:04:43,920 and close this first inside this 5687 04:04:43,920 --> 04:04:46,680 component I'm going to import a lot of 5688 04:04:46,680 --> 04:04:48,479 icons 5689 04:04:48,479 --> 04:04:51,359 edit outlined 5690 04:04:51,359 --> 04:04:53,760 delete outlined 5691 04:04:53,760 --> 04:04:57,840 attach should make sure you don't 5692 04:04:57,840 --> 04:04:59,880 have all these errors 5693 04:04:59,880 --> 04:05:03,120 attach file 5694 04:05:03,120 --> 04:05:07,800 outlined GIF box outlined 5695 04:05:07,800 --> 04:05:10,260 image 5696 04:05:10,260 --> 04:05:12,359 I need to spell this correctly 5697 04:05:12,359 --> 04:05:14,699 image outlined 5698 04:05:14,699 --> 04:05:16,680 mic 5699 04:05:16,680 --> 04:05:19,380 outlined more 5700 04:05:19,380 --> 04:05:22,080 her rise outlined 5701 04:05:22,080 --> 04:05:25,680 last one's kind of weird so from at m u 5702 04:05:25,680 --> 04:05:28,739 i icons material 5703 04:05:28,739 --> 04:05:30,359 so a lot of icons 5704 04:05:30,359 --> 04:05:32,460 and then from here I'm going to import a 5705 04:05:32,460 --> 04:05:34,920 lot of material components box being the 5706 04:05:34,920 --> 04:05:36,060 first one 5707 04:05:36,060 --> 04:05:37,500 and then import 5708 04:05:37,500 --> 04:05:40,199 divider 5709 04:05:40,199 --> 04:05:43,160 typography 5710 04:05:43,800 --> 04:05:46,500 input base 5711 04:05:46,500 --> 04:05:48,720 use theme 5712 04:05:48,720 --> 04:05:50,399 button 5713 04:05:50,399 --> 04:05:52,560 icon button 5714 04:05:52,560 --> 04:05:56,100 use media query 5715 04:05:56,100 --> 04:05:58,560 and save it and I'll align 5716 04:05:58,560 --> 04:06:01,680 I'm going to import Drop Zone from react 5717 04:06:01,680 --> 04:06:03,300 to drop zone 5718 04:06:03,300 --> 04:06:06,239 import Flex 5719 04:06:06,239 --> 04:06:08,460 between 5720 04:06:08,460 --> 04:06:09,660 okay well 5721 04:06:09,660 --> 04:06:12,779 intellisense fix my error for me and I'm 5722 04:06:12,779 --> 04:06:16,260 going to import user image 5723 04:06:16,260 --> 04:06:20,540 import widget wrapper 5724 04:06:20,640 --> 04:06:24,739 and then we're going to import use state 5725 04:06:27,420 --> 04:06:30,060 I'm going to import use 5726 04:06:30,060 --> 04:06:31,859 dispatch 5727 04:06:31,859 --> 04:06:36,020 as well as use selector 5728 04:06:36,660 --> 04:06:39,600 and then import set 5729 04:06:39,600 --> 04:06:44,000 posts from State 5730 04:06:46,680 --> 04:06:49,020 so a lot of things to import we have a 5731 04:06:49,020 --> 04:06:51,359 lot of things to do for this component 5732 04:06:51,359 --> 04:06:53,880 so I'm going to create const my post 5733 04:06:53,880 --> 04:06:55,620 widget 5734 04:06:55,620 --> 04:07:00,260 is equal to picture path 5735 04:07:00,660 --> 04:07:02,699 I'm going to create a bunch of state so 5736 04:07:02,699 --> 04:07:05,160 I'm going to do const dispatch use 5737 04:07:05,160 --> 04:07:07,620 dispatch 5738 04:07:07,620 --> 04:07:09,060 const 5739 04:07:09,060 --> 04:07:13,979 is image set is image so this is going 5740 04:07:13,979 --> 04:07:17,220 to represent the switch whether if 5741 04:07:17,220 --> 04:07:19,739 someone has clicked the image button to 5742 04:07:19,739 --> 04:07:22,620 open up a place to drop an image if they 5743 04:07:22,620 --> 04:07:25,199 want to for the posting so we're going 5744 04:07:25,199 --> 04:07:28,100 to start with false 5745 04:07:28,380 --> 04:07:30,060 and then from here I'm going to do 5746 04:07:30,060 --> 04:07:32,460 another state this will be the actual 5747 04:07:32,460 --> 04:07:34,319 image if they actually drop it so I'm 5748 04:07:34,319 --> 04:07:36,960 going to set image there 5749 04:07:36,960 --> 04:07:40,460 and then we're going to start with null 5750 04:07:40,920 --> 04:07:44,399 then I'm going to do const Post set post 5751 04:07:44,399 --> 04:07:48,479 with use state of empty string so this 5752 04:07:48,479 --> 04:07:51,500 will represent 5753 04:07:53,520 --> 04:07:55,800 this will represent the actual post 5754 04:07:55,800 --> 04:07:58,560 content of description 5755 04:07:58,560 --> 04:08:01,380 and then we're also going to do palette 5756 04:08:01,380 --> 04:08:03,779 so we're grabbing 5757 04:08:03,779 --> 04:08:06,600 our colors once again 5758 04:08:06,600 --> 04:08:08,220 then we're going to grab 5759 04:08:08,220 --> 04:08:11,160 underscore ID from our store 5760 04:08:11,160 --> 04:08:15,020 from the user so use selector 5761 04:08:16,020 --> 04:08:18,060 state 5762 04:08:18,060 --> 04:08:20,939 with state DOT user 5763 04:08:20,939 --> 04:08:22,979 so this will be something we can send to 5764 04:08:22,979 --> 04:08:26,100 the back end so we know who's posting 5765 04:08:26,100 --> 04:08:27,600 the content 5766 04:08:27,600 --> 04:08:29,880 and then curse token 5767 04:08:29,880 --> 04:08:33,080 view selector will be used 5768 04:08:33,080 --> 04:08:38,359 to authorize this user to call this API 5769 04:08:38,399 --> 04:08:42,120 state DOT token so 5770 04:08:42,120 --> 04:08:44,399 and we're going to give it 5771 04:08:44,399 --> 04:08:47,939 is non-mobile screens variable so we can 5772 04:08:47,939 --> 04:08:50,880 use a use media query 5773 04:08:50,880 --> 04:08:54,720 so I'm going to pass in Min Dash width 5774 04:08:54,720 --> 04:08:57,859 1000 pixel 5775 04:09:01,380 --> 04:09:05,520 const medium main equals palette 5776 04:09:05,520 --> 04:09:07,260 dot neutral 5777 04:09:07,260 --> 04:09:10,380 dot medium mean 5778 04:09:10,380 --> 04:09:15,120 const medium is going to be palette 5779 04:09:15,120 --> 04:09:19,260 neutral dot medium like so 5780 04:09:19,260 --> 04:09:21,420 so now we have all our state we have all 5781 04:09:21,420 --> 04:09:23,699 our colors it's a lot of things going on 5782 04:09:23,699 --> 04:09:24,960 over there 5783 04:09:24,960 --> 04:09:26,699 but we should be good 5784 04:09:26,699 --> 04:09:28,620 now before we do anything we're going to 5785 04:09:28,620 --> 04:09:30,660 create the function that handles our 5786 04:09:30,660 --> 04:09:33,120 post and makes the API call so I'm going 5787 04:09:33,120 --> 04:09:37,979 to do const handle post async 5788 04:09:38,460 --> 04:09:40,500 and here we're going to use form data 5789 04:09:40,500 --> 04:09:42,960 again because we are passing an image so 5790 04:09:42,960 --> 04:09:45,779 we have to use it one more time so form 5791 04:09:45,779 --> 04:09:48,660 data like so so we can pass the image 5792 04:09:48,660 --> 04:09:51,180 and we're going to append manually 5793 04:09:51,180 --> 04:09:54,239 some properties and values so I'm going 5794 04:09:54,239 --> 04:09:56,779 to append 5795 04:09:57,720 --> 04:10:01,439 let me spell form data correctly append 5796 04:10:01,439 --> 04:10:03,960 user ID 5797 04:10:03,960 --> 04:10:05,819 underscore 5798 04:10:05,819 --> 04:10:08,239 ID 5799 04:10:09,779 --> 04:10:12,239 and then I'm going to do form data dot 5800 04:10:12,239 --> 04:10:14,600 append 5801 04:10:15,120 --> 04:10:17,220 with description 5802 04:10:17,220 --> 04:10:21,319 I'm going to pass in post like so 5803 04:10:21,720 --> 04:10:23,819 I'm going to do if image 5804 04:10:23,819 --> 04:10:27,540 so if there is an image we are gonna 5805 04:10:27,540 --> 04:10:31,260 deform data dot append 5806 04:10:31,260 --> 04:10:34,319 to the picture 5807 04:10:34,319 --> 04:10:36,420 key 5808 04:10:36,420 --> 04:10:39,000 we're going to pass the image 5809 04:10:39,000 --> 04:10:41,040 so if you remember 5810 04:10:41,040 --> 04:10:43,859 just as a summary just as a reminder of 5811 04:10:43,859 --> 04:10:44,880 what 5812 04:10:44,880 --> 04:10:48,120 it's doing if you go down with the post 5813 04:10:48,120 --> 04:10:51,660 section we have upload.single picture so 5814 04:10:51,660 --> 04:10:54,060 it's grabbing the picture key that we're 5815 04:10:54,060 --> 04:10:55,739 adding in this 5816 04:10:55,739 --> 04:10:58,380 certain scenario and it's uploading this 5817 04:10:58,380 --> 04:11:01,319 specific image right here 5818 04:11:01,319 --> 04:11:03,540 so just as a reminder to see show you 5819 04:11:03,540 --> 04:11:06,540 what it's actually doing so form data 5820 04:11:06,540 --> 04:11:08,040 append 5821 04:11:08,040 --> 04:11:09,779 picture 5822 04:11:09,779 --> 04:11:12,420 path so in addition to the image we need 5823 04:11:12,420 --> 04:11:13,500 the image 5824 04:11:13,500 --> 04:11:16,800 name as well so that will determine the 5825 04:11:16,800 --> 04:11:19,380 path of the image 5826 04:11:19,380 --> 04:11:20,640 and then after that we're going to do 5827 04:11:20,640 --> 04:11:24,600 const response await Fetch and we're 5828 04:11:24,600 --> 04:11:25,979 going to pass in 5829 04:11:25,979 --> 04:11:28,080 http 5830 04:11:28,080 --> 04:11:31,520 colon slash localhost 5831 04:11:31,520 --> 04:11:34,859 3001 slash posts like so 5832 04:11:34,859 --> 04:11:36,840 I'm going to do comma I'm going to give 5833 04:11:36,840 --> 04:11:38,040 it a method 5834 04:11:38,040 --> 04:11:40,140 of post 5835 04:11:40,140 --> 04:11:41,760 with the headers 5836 04:11:41,760 --> 04:11:43,439 of 5837 04:11:43,439 --> 04:11:45,600 authorization 5838 04:11:45,600 --> 04:11:48,420 and a better 5839 04:11:48,420 --> 04:11:51,979 token like so 5840 04:11:52,080 --> 04:11:55,920 I'm going to do body of form data 5841 04:11:55,920 --> 04:11:57,960 so that will be particularly our 5842 04:11:57,960 --> 04:11:59,960 response and we're going to do cons post 5843 04:11:59,960 --> 04:12:05,100 equals awaitresponse dot Json 5844 04:12:05,100 --> 04:12:07,620 and from here I'm going to dispatch set 5845 04:12:07,620 --> 04:12:09,779 posts 5846 04:12:09,779 --> 04:12:11,640 and give it a post 5847 04:12:11,640 --> 04:12:14,100 value 5848 04:12:14,100 --> 04:12:18,979 I'm going to do set image of null 5849 04:12:20,819 --> 04:12:24,359 and set post of empty string so this 5850 04:12:24,359 --> 04:12:26,460 will basically reset 5851 04:12:26,460 --> 04:12:29,460 all the state that we have once we make 5852 04:12:29,460 --> 04:12:32,180 an API call 5853 04:12:32,699 --> 04:12:35,880 so this will keep our list of posts 5854 04:12:35,880 --> 04:12:39,060 this will send the post information to 5855 04:12:39,060 --> 04:12:40,439 the back end 5856 04:12:40,439 --> 04:12:43,260 and the back end will return our list of 5857 04:12:43,260 --> 04:12:46,380 updated posts if you remember that 5858 04:12:46,380 --> 04:12:49,620 and just FYI when you're 5859 04:12:49,620 --> 04:12:51,960 and this is why it's so important when 5860 04:12:51,960 --> 04:12:53,939 you look at this when you're building 5861 04:12:53,939 --> 04:12:57,000 this application you have a set of mocks 5862 04:12:57,000 --> 04:12:59,040 you have to know as a front-end 5863 04:12:59,040 --> 04:13:00,120 developer 5864 04:13:00,120 --> 04:13:01,979 and as a backend developer as well you 5865 04:13:01,979 --> 04:13:04,500 have to plan beforehand because I've 5866 04:13:04,500 --> 04:13:07,439 seen this happen a lot where you kind of 5867 04:13:07,439 --> 04:13:09,600 you waste a lot of time because you 5868 04:13:09,600 --> 04:13:12,060 consider things like when you go to this 5869 04:13:12,060 --> 04:13:15,420 page we want to get the list of posts 5870 04:13:15,420 --> 04:13:16,800 right here so you're going to make an 5871 04:13:16,800 --> 04:13:18,239 API call you're going to get a list of 5872 04:13:18,239 --> 04:13:20,399 friends you're going to get this as well 5873 04:13:20,399 --> 04:13:24,479 but it's hard to remember what you want 5874 04:13:24,479 --> 04:13:25,920 to do when 5875 04:13:25,920 --> 04:13:29,160 you update some information and What 5876 04:13:29,160 --> 04:13:30,420 needs to change 5877 04:13:30,420 --> 04:13:33,420 so for example if I remove this person 5878 04:13:33,420 --> 04:13:36,239 as a friend 5879 04:13:36,239 --> 04:13:38,399 it's hard to remember that you need to 5880 04:13:38,399 --> 04:13:41,520 change this as well so you need when you 5881 04:13:41,520 --> 04:13:44,399 add this you need the updated friends 5882 04:13:44,399 --> 04:13:46,979 list coming from the API so you can 5883 04:13:46,979 --> 04:13:49,319 update that 5884 04:13:49,319 --> 04:13:52,500 same with this if you 5885 04:13:52,500 --> 04:13:54,899 if you have this post or like if you add 5886 04:13:54,899 --> 04:13:56,220 this post right 5887 04:13:56,220 --> 04:13:59,819 when we added this post we need a return 5888 04:13:59,819 --> 04:14:01,140 of 5889 04:14:01,140 --> 04:14:03,479 either the newly updated post and we can 5890 04:14:03,479 --> 04:14:05,939 just add it to our current list or we 5891 04:14:05,939 --> 04:14:08,279 can get the entire list of the posts and 5892 04:14:08,279 --> 04:14:10,620 just replace this list of posts right 5893 04:14:10,620 --> 04:14:13,380 here so you always have to consider 5894 04:14:13,380 --> 04:14:15,899 before you build the application how 5895 04:14:15,899 --> 04:14:19,319 you're going to set up the data 5896 04:14:19,319 --> 04:14:20,939 before 5897 04:14:20,939 --> 04:14:23,220 you make the API call and then after the 5898 04:14:23,220 --> 04:14:24,720 API call you have to consider what's 5899 04:14:24,720 --> 04:14:27,840 going to happen on the front end 5900 04:14:27,840 --> 04:14:30,060 of what changes it might sound fairly 5901 04:14:30,060 --> 04:14:31,920 obvious but when you get in the thick of 5902 04:14:31,920 --> 04:14:34,380 things it's very easy to forget that you 5903 04:14:34,380 --> 04:14:36,540 might need an updated version of all 5904 04:14:36,540 --> 04:14:38,819 those and things like that can take a 5905 04:14:38,819 --> 04:14:40,859 lot of time if you don't plan ahead 5906 04:14:40,859 --> 04:14:43,620 and it's happened to me quite often 5907 04:14:43,620 --> 04:14:45,840 so that's why a lot of times a lot of 5908 04:14:45,840 --> 04:14:48,000 front-end work ends up being handling 5909 04:14:48,000 --> 04:14:50,340 API requests 5910 04:14:50,340 --> 04:14:52,319 it takes a long time dealing with 5911 04:14:52,319 --> 04:14:54,540 updates and changes and things like that 5912 04:14:54,540 --> 04:14:57,600 and trying to sync with the back end 5913 04:14:57,600 --> 04:14:59,939 there's a lot of complexity there and 5914 04:14:59,939 --> 04:15:02,160 you shouldn't underestimate 5915 04:15:02,160 --> 04:15:04,260 those problems 5916 04:15:04,260 --> 04:15:06,540 anyways a little bit of a rant 5917 04:15:06,540 --> 04:15:08,220 here we're going to return 5918 04:15:08,220 --> 04:15:11,819 I'm going to add a widget wrapper 5919 04:15:11,819 --> 04:15:15,239 and in here I'm going to add a flex 5920 04:15:15,239 --> 04:15:16,800 between 5921 04:15:16,800 --> 04:15:21,899 with a gap of 1.5 REM 5922 04:15:21,899 --> 04:15:23,939 and inside here I'm going to say user 5923 04:15:23,939 --> 04:15:27,180 image with the image of picture 5924 04:15:27,180 --> 04:15:28,920 path 5925 04:15:28,920 --> 04:15:29,760 and we're going to have this 5926 04:15:29,760 --> 04:15:32,580 self-closing so this is the circle with 5927 04:15:32,580 --> 04:15:35,460 the profile user and then we're going to 5928 04:15:35,460 --> 04:15:38,600 do input base 5929 04:15:39,540 --> 04:15:42,000 and inside actually this should be 5930 04:15:42,000 --> 04:15:43,739 self-closing 5931 04:15:43,739 --> 04:15:45,779 we're going to have a few properties in 5932 04:15:45,779 --> 04:15:46,800 here 5933 04:15:46,800 --> 04:15:49,800 so we're going to have a placeholder 5934 04:15:49,800 --> 04:15:52,859 with what's 5935 04:15:52,859 --> 04:15:57,540 on your mind dot dot 5936 04:15:57,540 --> 04:16:00,359 and then on change 5937 04:16:00,359 --> 04:16:02,880 we're going to give it a event and we're 5938 04:16:02,880 --> 04:16:06,239 going to say set posts should be e dot 5939 04:16:06,239 --> 04:16:10,080 Target dot value so this input should be 5940 04:16:10,080 --> 04:16:12,359 updating the set post state that we 5941 04:16:12,359 --> 04:16:15,660 created and the value should be post 5942 04:16:15,660 --> 04:16:18,060 so it's a controlled input and we're 5943 04:16:18,060 --> 04:16:19,620 going to do SX 5944 04:16:19,620 --> 04:16:23,120 give it some styling so width of 100 5945 04:16:23,120 --> 04:16:25,800 takes up the entire width of the parent 5946 04:16:25,800 --> 04:16:27,720 component 5947 04:16:27,720 --> 04:16:28,859 and then we're going to do background 5948 04:16:28,859 --> 04:16:29,939 color 5949 04:16:29,939 --> 04:16:32,279 with palette 5950 04:16:32,279 --> 04:16:33,840 dot neutral 5951 04:16:33,840 --> 04:16:37,380 dot light with a border radius 5952 04:16:37,380 --> 04:16:40,520 of 2 REM 5953 04:16:41,279 --> 04:16:43,739 and a padding 5954 04:16:43,739 --> 04:16:46,800 of one REM to REM 5955 04:16:46,800 --> 04:16:51,739 1 REM top bottom 2 REM left right 5956 04:16:53,040 --> 04:16:55,439 and then after this Flex between we're 5957 04:16:55,439 --> 04:16:58,560 going to have is image so basically if 5958 04:16:58,560 --> 04:17:00,779 they click the image they want to add an 5959 04:17:00,779 --> 04:17:02,279 image to the Post 5960 04:17:02,279 --> 04:17:05,220 this will open up this div so we're 5961 04:17:05,220 --> 04:17:07,199 going to give it a box 5962 04:17:07,199 --> 04:17:10,080 I'm going to close it give the Box some 5963 04:17:10,080 --> 04:17:11,699 properties so I'm going to do grid 5964 04:17:11,699 --> 04:17:13,739 column 5965 04:17:13,739 --> 04:17:18,060 of span 4. 5966 04:17:18,120 --> 04:17:20,460 actually no sorry we don't need a grid 5967 04:17:20,460 --> 04:17:21,540 column 5968 04:17:21,540 --> 04:17:24,660 we can just say border radius 5969 04:17:24,660 --> 04:17:27,000 a 5 pixel 5970 04:17:27,000 --> 04:17:30,020 give it a border 5971 04:17:30,300 --> 04:17:32,939 of one pixel 5972 04:17:32,939 --> 04:17:37,520 solid and give it a medium 5973 04:17:37,620 --> 04:17:39,779 color 5974 04:17:39,779 --> 04:17:43,260 with a margin top of one REM 5975 04:17:43,260 --> 04:17:47,720 padding all around of one REM 5976 04:17:48,420 --> 04:17:50,100 inside this box I'm going to give it a 5977 04:17:50,100 --> 04:17:53,279 drop zone so another 5978 04:17:53,279 --> 04:17:57,060 fun little file dropping area 5979 04:17:57,060 --> 04:18:00,300 and what I could do is I can go back to 5980 04:18:00,300 --> 04:18:03,300 our form component and we can just 5981 04:18:03,300 --> 04:18:06,979 actually just copy the Drop Zone 5982 04:18:07,319 --> 04:18:09,479 because a lot of it will kind of be the 5983 04:18:09,479 --> 04:18:11,279 same there will be needed some 5984 04:18:11,279 --> 04:18:13,080 modifications so I'm going to just paste 5985 04:18:13,080 --> 04:18:15,260 that 5986 04:18:16,500 --> 04:18:18,060 I'm going to save it so we have it 5987 04:18:18,060 --> 04:18:19,560 aligned 5988 04:18:19,560 --> 04:18:22,500 this is good 5989 04:18:22,500 --> 04:18:24,420 instead of set field value we're going 5990 04:18:24,420 --> 04:18:27,120 to change this to set image 5991 04:18:27,120 --> 04:18:29,040 oops 5992 04:18:29,040 --> 04:18:31,800 set image and I'm going to pass accepted 5993 04:18:31,800 --> 04:18:35,600 files 0 in there 5994 04:18:36,779 --> 04:18:39,479 and inside here I'm going to put flex 5995 04:18:39,479 --> 04:18:41,779 between 5996 04:18:44,160 --> 04:18:47,720 and wrap this box around 5997 04:18:48,600 --> 04:18:51,840 the Box get root props border 5998 04:18:51,840 --> 04:18:55,739 this is all good one REM curse pointer 5999 04:18:55,739 --> 04:18:58,080 we want to give this a width of 100 6000 04:18:58,080 --> 04:18:59,939 percent 6001 04:18:59,939 --> 04:19:03,739 the input is good 6002 04:19:04,380 --> 04:19:06,540 instead of edit outline icon it should 6003 04:19:06,540 --> 04:19:09,120 just be edit outlined 6004 04:19:09,120 --> 04:19:11,220 instead of values.picture we're going to 6005 04:19:11,220 --> 04:19:12,840 say image 6006 04:19:12,840 --> 04:19:15,420 dot name 6007 04:19:15,420 --> 04:19:17,699 instead of values.picture it's going to 6008 04:19:17,699 --> 04:19:18,840 be 6009 04:19:18,840 --> 04:19:21,479 exclamation image 6010 04:19:21,479 --> 04:19:23,160 and then instead of picture it's going 6011 04:19:23,160 --> 04:19:24,899 to be add image 6012 04:19:24,899 --> 04:19:26,880 so 6013 04:19:26,880 --> 04:19:29,640 everything is pretty clean 6014 04:19:29,640 --> 04:19:31,859 and then 6015 04:19:31,859 --> 04:19:34,739 let me check 6016 04:19:34,739 --> 04:19:38,279 So Below this box I'm going to add 6017 04:19:38,279 --> 04:19:40,560 an image 6018 04:19:40,560 --> 04:19:42,720 and I'm going to add an icon button here 6019 04:19:42,720 --> 04:19:44,520 because this time we're going to add a 6020 04:19:44,520 --> 04:19:48,800 trash icon if they want to remove 6021 04:19:49,199 --> 04:19:51,920 the image 6022 04:19:53,040 --> 04:19:56,420 so we're going to do on click 6023 04:19:56,880 --> 04:20:00,720 and we're going to do set image null 6024 04:20:00,720 --> 04:20:02,340 in SX 6025 04:20:02,340 --> 04:20:05,300 of width 6026 04:20:05,699 --> 04:20:08,699 15 percent 6027 04:20:08,699 --> 04:20:09,779 and we're going to have a delete 6028 04:20:09,779 --> 04:20:12,300 outlined 6029 04:20:12,300 --> 04:20:14,220 so this will give a trash icon if we put 6030 04:20:14,220 --> 04:20:16,819 an image there 6031 04:20:19,500 --> 04:20:21,540 and that is our drop zone so we're gonna 6032 04:20:21,540 --> 04:20:23,340 have a box we're going to close it 6033 04:20:23,340 --> 04:20:24,899 and then from here we're going to have a 6034 04:20:24,899 --> 04:20:27,840 little divider and say SX 6035 04:20:27,840 --> 04:20:29,340 margin 6036 04:20:29,340 --> 04:20:33,899 of 1 0.25 REM 0. 6037 04:20:33,899 --> 04:20:37,640 Excel and we're going to close this 6038 04:20:38,160 --> 04:20:39,779 and then finally we're going to create 6039 04:20:39,779 --> 04:20:43,580 all the icons below 6040 04:20:44,520 --> 04:20:48,260 so I'm going to say Flex between 6041 04:20:49,380 --> 04:20:51,120 and another Flex 6042 04:20:51,120 --> 04:20:54,180 between over here with a gap of zero 6043 04:20:54,180 --> 04:20:55,380 point 6044 04:20:55,380 --> 04:20:58,680 two five REM 6045 04:20:58,680 --> 04:21:01,640 on click 6046 04:21:02,340 --> 04:21:05,580 set is image 6047 04:21:05,580 --> 04:21:08,399 exclamation is image 6048 04:21:08,399 --> 04:21:10,439 so this will turn off 6049 04:21:10,439 --> 04:21:14,720 and open the image drop zone 6050 04:21:14,760 --> 04:21:17,279 I'm going to put image outlined 6051 04:21:17,279 --> 04:21:23,040 with the SX of color colon medium Main 6052 04:21:23,040 --> 04:21:25,199 I'm going to have that self-closing 6053 04:21:25,199 --> 04:21:28,859 here I'm going to put typography 6054 04:21:28,859 --> 04:21:32,279 close that and inside the typography I'm 6055 04:21:32,279 --> 04:21:36,359 going to put color of medium Main 6056 04:21:36,359 --> 04:21:39,420 SX of 6057 04:21:39,420 --> 04:21:42,420 and colon hover 6058 04:21:42,420 --> 04:21:44,939 colon with a cursor 6059 04:21:44,939 --> 04:21:47,279 of pointer 6060 04:21:47,279 --> 04:21:51,380 a color of medium 6061 04:21:53,640 --> 04:21:57,260 and in here I'm going to put image 6062 04:21:58,080 --> 04:22:01,080 all right after the first closing Flex 6063 04:22:01,080 --> 04:22:04,140 between and before the second one 6064 04:22:04,140 --> 04:22:06,540 I'm going to add a section where it's if 6065 04:22:06,540 --> 04:22:07,260 it's 6066 04:22:07,260 --> 04:22:10,020 non-mobile screens because when it gets 6067 04:22:10,020 --> 04:22:11,819 small all the icons get smashed together 6068 04:22:11,819 --> 04:22:14,640 so we want to be able to address that so 6069 04:22:14,640 --> 04:22:16,680 I'm going to put 6070 04:22:16,680 --> 04:22:20,479 this to address the situation 6071 04:22:22,739 --> 04:22:25,620 and I'm just going to add a 6072 04:22:25,620 --> 04:22:28,140 closing tag here so we don't have any 6073 04:22:28,140 --> 04:22:30,300 syntax issues for now 6074 04:22:30,300 --> 04:22:32,220 we're going to add a flex 6075 04:22:32,220 --> 04:22:37,500 between give it a gap of 0.5 6076 04:22:37,500 --> 04:22:40,699 0.25 REM 6077 04:22:40,800 --> 04:22:43,020 and inside here I'm going to create GIF 6078 04:22:43,020 --> 04:22:47,760 box outlined with an SX of color colon 6079 04:22:47,760 --> 04:22:50,580 medium Main 6080 04:22:50,580 --> 04:22:52,199 I'm going to close it 6081 04:22:52,199 --> 04:22:54,720 and then I'm going to say typography 6082 04:22:54,720 --> 04:22:57,500 with color 6083 04:22:57,540 --> 04:22:58,739 medium 6084 04:22:58,739 --> 04:23:00,779 Main 6085 04:23:00,779 --> 04:23:03,300 clip 6086 04:23:03,300 --> 04:23:05,899 as well 6087 04:23:07,920 --> 04:23:10,439 I'm going to copy 6088 04:23:10,439 --> 04:23:12,600 and paste 6089 04:23:12,600 --> 04:23:15,300 all four of these 6090 04:23:15,300 --> 04:23:17,520 so this instead of GIF box I'm going to 6091 04:23:17,520 --> 04:23:19,199 do attach file 6092 04:23:19,199 --> 04:23:20,699 outlined 6093 04:23:20,699 --> 04:23:25,380 I'm going to put attach mint 6094 04:23:26,279 --> 04:23:29,340 in here this one's going to be Mike 6095 04:23:29,340 --> 04:23:32,960 outlined and we're going to do 6096 04:23:33,239 --> 04:23:35,600 audio 6097 04:23:37,560 --> 04:23:39,620 I think that's actually it clip 6098 04:23:39,620 --> 04:23:43,380 attachment audio okay yeah I added one 6099 04:23:43,380 --> 04:23:44,699 too many 6100 04:23:44,699 --> 04:23:46,859 so these won't have any functionalities 6101 04:23:46,859 --> 04:23:50,060 for the sake of time 6102 04:23:50,819 --> 04:23:52,800 but we'll keep going so we're going to 6103 04:23:52,800 --> 04:23:57,000 have gap of 0.25 REM and inside here 6104 04:23:57,000 --> 04:23:58,560 because 6105 04:23:58,560 --> 04:24:00,600 there's not enough space on smaller 6106 04:24:00,600 --> 04:24:02,819 screens we're just going to add one icon 6107 04:24:02,819 --> 04:24:06,180 and this is going to be more 6108 04:24:06,180 --> 04:24:07,380 Horizon 6109 04:24:07,380 --> 04:24:10,319 outlined SX 6110 04:24:10,319 --> 04:24:12,840 of color 6111 04:24:12,840 --> 04:24:15,300 medium Main 6112 04:24:15,300 --> 04:24:17,939 and close that 6113 04:24:17,939 --> 04:24:21,979 so this will be three dots instead 6114 04:24:23,100 --> 04:24:25,380 and once we have that we have one last 6115 04:24:25,380 --> 04:24:27,300 thing we want to address is going to be 6116 04:24:27,300 --> 04:24:29,699 the button of posting 6117 04:24:29,699 --> 04:24:32,600 so the button 6118 04:24:33,420 --> 04:24:35,880 will have a value of post 6119 04:24:35,880 --> 04:24:38,660 inside it 6120 04:24:38,819 --> 04:24:40,859 and by the way this is within Flex 6121 04:24:40,859 --> 04:24:42,359 between 6122 04:24:42,359 --> 04:24:46,340 and this is going to start with disabled 6123 04:24:47,760 --> 04:24:49,260 exclamation post and we're going to say 6124 04:24:49,260 --> 04:24:53,399 on click equals handle post 6125 04:24:53,399 --> 04:24:55,620 so the handle post 6126 04:24:55,620 --> 04:24:57,720 function that we created earlier will 6127 04:24:57,720 --> 04:25:00,000 address this situation and then from 6128 04:25:00,000 --> 04:25:01,739 here we're going to do SX 6129 04:25:01,739 --> 04:25:05,779 pass in color with palettes 6130 04:25:05,819 --> 04:25:09,960 dot background dot Alt 6131 04:25:09,960 --> 04:25:12,840 with the background color 6132 04:25:12,840 --> 04:25:14,460 of palette 6133 04:25:14,460 --> 04:25:17,100 dot primary dot Main 6134 04:25:17,100 --> 04:25:19,020 order radius 6135 04:25:19,020 --> 04:25:22,340 of 3 REM 6136 04:25:25,739 --> 04:25:29,279 and with that we have essentially our 6137 04:25:29,279 --> 04:25:32,640 my post widget all completed and it's 6138 04:25:32,640 --> 04:25:36,060 already placed into the right location 6139 04:25:36,060 --> 04:25:38,100 so let's check it out so this is a 6140 04:25:38,100 --> 04:25:40,699 completed app 6141 04:25:40,739 --> 04:25:44,580 okay so we do have module has no exports 6142 04:25:44,580 --> 04:25:46,319 so it seems like 6143 04:25:46,319 --> 04:25:49,140 I did not export it again okay 6144 04:25:49,140 --> 04:25:52,560 I need to remember to always export 6145 04:25:52,560 --> 04:25:55,140 export default my post so I'm going to 6146 04:25:55,140 --> 04:25:57,120 refresh it now you can see what's 6147 04:25:57,120 --> 04:25:59,880 happening here so let's check 6148 04:25:59,880 --> 04:26:02,520 so test 6149 04:26:02,520 --> 04:26:05,720 let's add our image 6150 04:26:07,199 --> 04:26:10,220 we're going to post it 6151 04:26:11,399 --> 04:26:13,859 and everything works so now we don't 6152 04:26:13,859 --> 04:26:16,140 have the my posts widget so we have not 6153 04:26:16,140 --> 04:26:18,720 placed the posts but we are making an 6154 04:26:18,720 --> 04:26:21,300 API call and we're getting the list of 6155 04:26:21,300 --> 04:26:24,180 posts as well when we return it so it's 6156 04:26:24,180 --> 04:26:27,300 working as expected perfect 6157 04:26:27,300 --> 04:26:28,800 next thing we're going to create is 6158 04:26:28,800 --> 04:26:31,319 going to be the posts widget and the 6159 04:26:31,319 --> 04:26:33,359 singular post widget so we're going to 6160 04:26:33,359 --> 04:26:36,060 have the plural version of the widgets 6161 04:26:36,060 --> 04:26:37,979 so that's going to have all the posts 6162 04:26:37,979 --> 04:26:40,080 and the singular post widget for each 6163 04:26:40,080 --> 04:26:42,840 one of these so let's get started so I'm 6164 04:26:42,840 --> 04:26:44,699 gonna go into 6165 04:26:44,699 --> 04:26:47,100 the widgets folder and we're going to 6166 04:26:47,100 --> 04:26:50,180 create posts 6167 04:26:50,399 --> 04:26:52,859 file post okay if it would let me type 6168 04:26:52,859 --> 04:26:55,859 posts 6169 04:26:55,920 --> 04:26:59,340 widget Dot jsx 6170 04:26:59,340 --> 04:27:00,899 I'm going to create another file called 6171 04:27:00,899 --> 04:27:03,000 post 6172 04:27:03,000 --> 04:27:06,000 widget.jsx 6173 04:27:06,300 --> 04:27:09,060 so I'm going to have those two open 6174 04:27:09,060 --> 04:27:11,460 close all of these and we're going to 6175 04:27:11,460 --> 04:27:15,359 start with plural posts 6176 04:27:15,359 --> 04:27:17,279 and we're going to start importing so 6177 04:27:17,279 --> 04:27:19,859 we're going to import use effect 6178 04:27:19,859 --> 04:27:21,659 from react 6179 04:27:21,659 --> 04:27:25,199 import use dispatch 6180 04:27:25,199 --> 04:27:28,859 and use selector 6181 04:27:28,859 --> 04:27:31,800 then I'm going to import set posts from 6182 04:27:31,800 --> 04:27:34,100 State 6183 04:27:34,439 --> 04:27:37,800 and import post 6184 04:27:37,800 --> 04:27:39,659 widget 6185 04:27:39,659 --> 04:27:43,439 from dot slash post widget 6186 04:27:43,439 --> 04:27:45,120 which is something we'll create and 6187 04:27:45,120 --> 04:27:47,640 Export as well 6188 04:27:47,640 --> 04:27:49,380 so here I'm going to create our 6189 04:27:49,380 --> 04:27:52,460 component posts 6190 04:27:52,620 --> 04:27:53,760 widget 6191 04:27:53,760 --> 04:27:55,319 equals 6192 04:27:55,319 --> 04:27:57,120 user ID 6193 04:27:57,120 --> 04:27:59,880 is profile 6194 04:27:59,880 --> 04:28:03,199 equals false 6195 04:28:04,500 --> 04:28:06,420 so those are the arguments that we have 6196 04:28:06,420 --> 04:28:09,000 and just so I don't forget I'm going to 6197 04:28:09,000 --> 04:28:12,840 do export default post widget like so 6198 04:28:12,840 --> 04:28:15,899 make sure I don't forget that 6199 04:28:15,899 --> 04:28:18,439 in here I'm going to do const dispatch 6200 04:28:18,439 --> 04:28:22,620 use dispatch so we can use Redux 6201 04:28:22,620 --> 04:28:24,720 then we're going to do cons posts and 6202 04:28:24,720 --> 04:28:27,080 grab 6203 04:28:29,100 --> 04:28:30,899 store 6204 04:28:30,899 --> 04:28:34,760 the store list of posts 6205 04:28:37,080 --> 04:28:40,140 like so and then grab the token as well 6206 04:28:40,140 --> 04:28:43,340 so use selector 6207 04:28:45,779 --> 04:28:49,159 and grab the token 6208 04:28:50,760 --> 04:28:52,920 all right so we're going to make two 6209 04:28:52,920 --> 04:28:55,140 different API calls over here 6210 04:28:55,140 --> 04:28:56,880 the reason why we're doing that is 6211 04:28:56,880 --> 04:29:00,239 because of this tag is profile so the 6212 04:29:00,239 --> 04:29:01,500 post widget 6213 04:29:01,500 --> 04:29:03,779 is going to do two things 6214 04:29:03,779 --> 04:29:06,540 on the home page it's going to grab all 6215 04:29:06,540 --> 04:29:09,479 the user all the posts from anybody 6216 04:29:09,479 --> 04:29:11,279 and that's going to be the API call 6217 04:29:11,279 --> 04:29:13,500 regarding 6218 04:29:13,500 --> 04:29:16,080 if you go down to the routes and you go 6219 04:29:16,080 --> 04:29:18,779 to post that's going to be all of these 6220 04:29:18,779 --> 04:29:21,720 posts so get feed posts so that's what's 6221 04:29:21,720 --> 04:29:24,420 going to happen on the home page 6222 04:29:24,420 --> 04:29:27,239 however if you go to the profile page 6223 04:29:27,239 --> 04:29:30,239 meaning a specific users page 6224 04:29:30,239 --> 04:29:32,880 we're going to call get user posts so 6225 04:29:32,880 --> 04:29:34,739 we're going to address both of these 6226 04:29:34,739 --> 04:29:37,279 situations 6227 04:29:38,880 --> 04:29:40,859 so the first thing we're going to do 6228 04:29:40,859 --> 04:29:43,620 we're going to get posts 6229 04:29:43,620 --> 04:29:47,479 like so with async 6230 04:29:48,479 --> 04:29:50,520 and then we're going to make a API call 6231 04:29:50,520 --> 04:29:53,220 it's a const response 6232 04:29:53,220 --> 04:29:55,920 equals await fetch 6233 04:29:55,920 --> 04:30:00,120 we're going to do HTTP colon localhost 6234 04:30:00,120 --> 04:30:04,199 colon 3001 slash post 6235 04:30:04,199 --> 04:30:06,840 this will grab all the posts 6236 04:30:06,840 --> 04:30:10,020 give it a method of get 6237 04:30:10,020 --> 04:30:14,399 and headers with an authorization 6238 04:30:14,399 --> 04:30:15,600 colon 6239 04:30:15,600 --> 04:30:18,979 of Bearer 6240 04:30:19,080 --> 04:30:22,560 and token inside like we did before to 6241 04:30:22,560 --> 04:30:24,720 validate the API call 6242 04:30:24,720 --> 04:30:27,560 and then we're gonna 6243 04:30:28,260 --> 04:30:30,239 make it 6244 04:30:30,239 --> 04:30:34,140 usable with response.json 6245 04:30:34,620 --> 04:30:36,420 and once we get the response we're going 6246 04:30:36,420 --> 04:30:38,159 to get dispatch 6247 04:30:38,159 --> 04:30:40,680 we're going to set the posts 6248 04:30:40,680 --> 04:30:41,819 value 6249 04:30:41,819 --> 04:30:44,580 inside our store 6250 04:30:44,580 --> 04:30:46,800 with the data that we got back 6251 04:30:46,800 --> 04:30:49,979 so that is going to be our get post 6252 04:30:49,979 --> 04:30:51,540 now we're going to copy this entire 6253 04:30:51,540 --> 04:30:52,979 thing and we're going to do the same 6254 04:30:52,979 --> 04:30:56,040 thing for get user post 6255 04:30:56,040 --> 04:30:57,420 but the 6256 04:30:57,420 --> 04:30:59,760 URL is going to be slightly different so 6257 04:30:59,760 --> 04:31:03,359 after post we're going to do slash 6258 04:31:03,359 --> 04:31:06,260 user ID 6259 04:31:06,479 --> 04:31:07,859 slash 6260 04:31:07,859 --> 04:31:10,640 posts 6261 04:31:10,680 --> 04:31:12,540 and this should be a template string 6262 04:31:12,540 --> 04:31:14,899 this time 6263 04:31:15,300 --> 04:31:16,800 so I know it's a little bit of funky 6264 04:31:16,800 --> 04:31:20,880 syntax we have user ID slash posts let's 6265 04:31:20,880 --> 04:31:23,340 actually make sure that's correct 6266 04:31:23,340 --> 04:31:27,120 so yeah post slash user ID slash post 6267 04:31:27,120 --> 04:31:29,819 probably gonna get rid of that but we're 6268 04:31:29,819 --> 04:31:32,460 going to keep this for now 6269 04:31:32,460 --> 04:31:34,020 you could probably get rid of this like 6270 04:31:34,020 --> 04:31:38,479 extra slash post it's kind of redundant 6271 04:31:39,479 --> 04:31:42,060 but up to you 6272 04:31:42,060 --> 04:31:44,880 so from here we have set post we're 6273 04:31:44,880 --> 04:31:47,279 going to do exact same thing afterwards 6274 04:31:47,279 --> 04:31:51,140 so in here I'm going to do use effect 6275 04:31:52,439 --> 04:31:57,080 I'm going to do if is profile 6276 04:31:58,319 --> 04:32:00,180 we're going to make 6277 04:32:00,180 --> 04:32:05,580 the get user post API call otherwise 6278 04:32:05,580 --> 04:32:08,760 we do the get posts call 6279 04:32:08,760 --> 04:32:11,100 which is pretty straightforward 6280 04:32:11,100 --> 04:32:12,420 and I'm going to give this an empty 6281 04:32:12,420 --> 04:32:15,180 array so it only calls once 6282 04:32:15,180 --> 04:32:18,540 so we're going to do eslint disable cool 6283 04:32:18,540 --> 04:32:19,859 online 6284 04:32:19,859 --> 04:32:22,319 react hooks 6285 04:32:22,319 --> 04:32:25,080 exhaustive 6286 04:32:25,080 --> 04:32:26,340 depths 6287 04:32:26,340 --> 04:32:29,399 get rid of that annoying warning 6288 04:32:29,399 --> 04:32:33,080 and under here we're going to return 6289 04:32:34,739 --> 04:32:36,600 empty fragment 6290 04:32:36,600 --> 04:32:39,300 but all we're going to do is with the 6291 04:32:39,300 --> 04:32:41,460 posts that we get we're going to create 6292 04:32:41,460 --> 04:32:45,260 a component for each post 6293 04:32:46,140 --> 04:32:49,140 so inside of here I'm going to do 6294 04:32:49,140 --> 04:32:52,140 parens in the bracket and we're going to 6295 04:32:52,140 --> 04:32:54,600 destructure a number of items from each 6296 04:32:54,600 --> 04:32:59,340 post so ID user ID first name 6297 04:32:59,340 --> 04:33:01,560 last name 6298 04:33:01,560 --> 04:33:04,141 description 6299 04:33:04,141 --> 04:33:05,820 location 6300 04:33:05,820 --> 04:33:08,039 picture path 6301 04:33:08,039 --> 04:33:09,840 user picture 6302 04:33:09,840 --> 04:33:11,160 path 6303 04:33:11,160 --> 04:33:15,439 likes and then comments 6304 04:33:16,799 --> 04:33:19,199 and then from here 6305 04:33:19,199 --> 04:33:21,840 I'm going to return 6306 04:33:21,840 --> 04:33:25,100 our post widget 6307 04:33:25,919 --> 04:33:27,778 and we're going to pass in a lot of 6308 04:33:27,778 --> 04:33:29,160 different props 6309 04:33:29,160 --> 04:33:32,959 so I'm going to copy this entire thing 6310 04:33:36,778 --> 04:33:39,900 I'm going to select all the commas with 6311 04:33:39,900 --> 04:33:41,160 command d 6312 04:33:41,160 --> 04:33:43,379 hit equals 6313 04:33:43,379 --> 04:33:45,118 put curly braces and we're going to 6314 04:33:45,118 --> 04:33:47,938 write each one individually and also we 6315 04:33:47,938 --> 04:33:50,340 need a key as well 6316 04:33:50,340 --> 04:33:53,340 so react doesn't give you a warning so 6317 04:33:53,340 --> 04:33:56,039 you're just going to pass it as ID 6318 04:33:56,039 --> 04:33:58,020 and here I'm going to change this to 6319 04:33:58,020 --> 04:34:00,920 post ID 6320 04:34:03,599 --> 04:34:04,919 and then we're going to change this to 6321 04:34:04,919 --> 04:34:05,938 post 6322 04:34:05,938 --> 04:34:08,820 user ID 6323 04:34:08,820 --> 04:34:10,980 this should be underscore 6324 04:34:10,980 --> 04:34:14,719 this should be user ID 6325 04:34:14,820 --> 04:34:16,680 and actually instead of first name last 6326 04:34:16,680 --> 04:34:19,141 name we're going to put name 6327 04:34:19,141 --> 04:34:21,419 and we're going to pass in 6328 04:34:21,419 --> 04:34:25,080 first actually dollar sign curly braces 6329 04:34:25,080 --> 04:34:27,900 first name space 6330 04:34:27,900 --> 04:34:31,219 last name 6331 04:34:32,278 --> 04:34:34,980 we're going to have description 6332 04:34:34,980 --> 04:34:36,299 and then 6333 04:34:36,299 --> 04:34:38,759 location 6334 04:34:38,759 --> 04:34:42,319 picture path 6335 04:34:42,480 --> 04:34:45,900 user picture path 6336 04:34:45,900 --> 04:34:48,599 likes and then 6337 04:34:48,599 --> 04:34:51,319 comments 6338 04:34:51,480 --> 04:34:54,299 and that should be all the values that 6339 04:34:54,299 --> 04:34:57,061 we're going to use for our post widget 6340 04:34:57,061 --> 04:35:00,118 and I made sure the export 6341 04:35:00,118 --> 04:35:02,458 so from here I'm going to go to our post 6342 04:35:02,458 --> 04:35:05,641 widget now and fill this out so we have 6343 04:35:05,641 --> 04:35:08,039 a number of imports here 6344 04:35:08,039 --> 04:35:10,799 import chat bubble 6345 04:35:10,799 --> 04:35:14,539 outline outlined 6346 04:35:15,359 --> 04:35:16,799 and then from here I'm going to import 6347 04:35:16,799 --> 04:35:18,660 favorite 6348 04:35:18,660 --> 04:35:21,000 border outlined 6349 04:35:21,000 --> 04:35:22,799 favorite 6350 04:35:22,799 --> 04:35:26,340 outlined so these are icons for liking 6351 04:35:26,340 --> 04:35:30,180 and then share outlined 6352 04:35:31,680 --> 04:35:32,938 and then from here I'm going to import 6353 04:35:32,938 --> 04:35:34,980 number of component 6354 04:35:34,980 --> 04:35:37,680 from Material UI 6355 04:35:37,680 --> 04:35:40,199 so import box 6356 04:35:40,199 --> 04:35:41,938 divider 6357 04:35:41,938 --> 04:35:44,039 icon button 6358 04:35:44,039 --> 04:35:48,480 typography and then use theme 6359 04:35:48,480 --> 04:35:50,278 I'm going to save that then I'm going to 6360 04:35:50,278 --> 04:35:52,980 import Flex between 6361 04:35:52,980 --> 04:35:56,480 I'm going to import friend 6362 04:35:57,000 --> 04:36:01,680 from components slash friend now we have 6363 04:36:01,680 --> 04:36:04,320 not created this so actually let's do 6364 04:36:04,320 --> 04:36:05,219 that 6365 04:36:05,219 --> 04:36:07,199 real quick so I'm going to go to 6366 04:36:07,199 --> 04:36:09,958 components create a new file and call 6367 04:36:09,958 --> 04:36:13,680 this friend jsx so this will be used in 6368 04:36:13,680 --> 04:36:16,438 this component as well as 6369 04:36:16,438 --> 04:36:19,878 the friends list component 6370 04:36:22,020 --> 04:36:23,520 so 6371 04:36:23,520 --> 04:36:25,740 this is going to have a number of items 6372 04:36:25,740 --> 04:36:28,459 so we're going to import 6373 04:36:30,480 --> 04:36:33,599 let's say import what person 6374 04:36:33,599 --> 04:36:35,699 add 6375 04:36:35,699 --> 04:36:37,259 outlined 6376 04:36:37,259 --> 04:36:41,000 with person remove outlined and actually 6377 04:36:41,000 --> 04:36:44,400 just to prevent confusion for you 6378 04:36:44,400 --> 04:36:47,099 friend is going to represent these guys 6379 04:36:47,099 --> 04:36:49,799 right here so 6380 04:36:49,799 --> 04:36:52,740 see these three items right here 6381 04:36:52,740 --> 04:36:56,458 this is particularly a friend 6382 04:36:56,458 --> 04:36:59,160 component 6383 04:36:59,160 --> 04:37:02,099 or action not this but this 6384 04:37:02,099 --> 04:37:04,500 since we're reusing these we want this 6385 04:37:04,500 --> 04:37:07,199 to be a separate component 6386 04:37:07,199 --> 04:37:09,118 so we're going to go back 6387 04:37:09,118 --> 04:37:12,419 and fill out our friend component 6388 04:37:12,419 --> 04:37:16,980 so here we're going to have import box 6389 04:37:16,980 --> 04:37:20,061 from interior UI 6390 04:37:20,820 --> 04:37:25,259 icon button typography 6391 04:37:25,259 --> 04:37:28,519 and use theme 6392 04:37:28,799 --> 04:37:32,160 then we're going to import use dispatch 6393 04:37:32,160 --> 04:37:35,938 with use selector 6394 04:37:35,938 --> 04:37:39,599 we're going to import set friends 6395 04:37:39,599 --> 04:37:42,599 from State we're going to import Flex 6396 04:37:42,599 --> 04:37:44,458 between 6397 04:37:44,458 --> 04:37:48,958 and import user image 6398 04:37:48,958 --> 04:37:49,980 and we're going to have the friend 6399 04:37:49,980 --> 04:37:52,020 component and the friend component 6400 04:37:52,020 --> 04:37:55,020 that's going to take the friend ID with 6401 04:37:55,020 --> 04:37:58,080 name subtitle 6402 04:37:58,080 --> 04:38:00,599 and user 6403 04:38:00,599 --> 04:38:03,900 picture path 6404 04:38:03,900 --> 04:38:06,561 like so 6405 04:38:07,561 --> 04:38:09,118 and again I'm going to make sure I 6406 04:38:09,118 --> 04:38:12,618 export default friend 6407 04:38:13,259 --> 04:38:15,240 inside of here I'm going to do const 6408 04:38:15,240 --> 04:38:18,118 palette 6409 04:38:18,118 --> 04:38:21,118 use steam to grab the colors cons 6410 04:38:21,118 --> 04:38:23,879 dispatch equals use 6411 04:38:23,879 --> 04:38:26,039 dispatch I should probably like copy 6412 04:38:26,039 --> 04:38:27,778 this at some point because 6413 04:38:27,778 --> 04:38:30,660 I keep writing the same thing 6414 04:38:30,660 --> 04:38:32,458 so we're going to do navigate equals use 6415 04:38:32,458 --> 04:38:34,878 navigate 6416 04:38:35,039 --> 04:38:36,660 const 6417 04:38:36,660 --> 04:38:39,539 underscore ID 6418 04:38:39,539 --> 04:38:43,199 and either use selector 6419 04:38:43,199 --> 04:38:45,299 I'm going to pass in state 6420 04:38:45,299 --> 04:38:48,539 with state.user 6421 04:38:48,539 --> 04:38:51,539 cons token as well 6422 04:38:51,539 --> 04:38:54,619 use selector 6423 04:38:57,180 --> 04:39:00,799 I'm going to grab the state.tok token 6424 04:39:01,561 --> 04:39:04,259 we're going to grab friends 6425 04:39:04,259 --> 04:39:06,419 from use selector 6426 04:39:06,419 --> 04:39:08,219 so we have not 6427 04:39:08,219 --> 04:39:10,740 configured a API call that grabs our 6428 04:39:10,740 --> 04:39:14,480 friends yet but once we do 6429 04:39:15,118 --> 04:39:16,561 we would be able to grab it here 6430 04:39:16,561 --> 04:39:17,938 actually I grabbed it from the users 6431 04:39:17,938 --> 04:39:19,500 sorry you don't need an APL code for 6432 04:39:19,500 --> 04:39:20,400 that 6433 04:39:20,400 --> 04:39:23,099 the user will have friends array 6434 04:39:23,099 --> 04:39:24,719 attached 6435 04:39:24,719 --> 04:39:26,641 so we can deal with that then we're 6436 04:39:26,641 --> 04:39:28,259 going to have 6437 04:39:28,259 --> 04:39:29,820 from here 6438 04:39:29,820 --> 04:39:31,680 actually let's move this because this is 6439 04:39:31,680 --> 04:39:33,539 all the colors 6440 04:39:33,539 --> 04:39:35,938 we should make the colors together so it 6441 04:39:35,938 --> 04:39:37,199 makes a lot more sense we're going to 6442 04:39:37,199 --> 04:39:40,218 see primary light 6443 04:39:40,440 --> 04:39:43,640 equals palette 6444 04:39:43,798 --> 04:39:45,600 Dot 6445 04:39:45,600 --> 04:39:47,580 I'm just going to copy palette to make 6446 04:39:47,580 --> 04:39:49,980 it easier so we're going to do primary 6447 04:39:49,980 --> 04:39:51,900 dot light 6448 04:39:51,900 --> 04:39:53,640 const primary 6449 04:39:53,640 --> 04:39:58,378 dark equals palette dot primary dot dark 6450 04:39:58,378 --> 04:40:02,700 const main equals palette dot primary 6451 04:40:02,700 --> 04:40:05,700 our pilot.neutral DOT Main 6452 04:40:05,700 --> 04:40:07,140 same with 6453 04:40:07,140 --> 04:40:09,860 medium 6454 04:40:10,920 --> 04:40:12,780 medium 6455 04:40:12,780 --> 04:40:15,540 and finally we want to check if the user 6456 04:40:15,540 --> 04:40:17,160 is a friend 6457 04:40:17,160 --> 04:40:19,080 because if it's a friend 6458 04:40:19,080 --> 04:40:21,540 we want to show an icon that shows that 6459 04:40:21,540 --> 04:40:24,360 they're going to remove the friend 6460 04:40:24,360 --> 04:40:26,040 if they're not a friend we want to show 6461 04:40:26,040 --> 04:40:28,080 an icon that makes it look like they'll 6462 04:40:28,080 --> 04:40:30,660 be able to add the friend so this is why 6463 04:40:30,660 --> 04:40:32,820 we have this functionality so what's 6464 04:40:32,820 --> 04:40:34,620 what we're going to do is Friends dot 6465 04:40:34,620 --> 04:40:35,700 find 6466 04:40:35,700 --> 04:40:38,218 we're going to check if the friend 6467 04:40:38,218 --> 04:40:40,320 exists 6468 04:40:40,320 --> 04:40:43,620 and if the friend ID is equivalent to 6469 04:40:43,620 --> 04:40:46,200 the friend ID being passed in from the 6470 04:40:46,200 --> 04:40:47,700 parent component 6471 04:40:47,700 --> 04:40:50,580 then we can trigger 6472 04:40:50,580 --> 04:40:54,320 whether if they're friend or not 6473 04:40:54,360 --> 04:40:56,040 and so we're going to create a function 6474 04:40:56,040 --> 04:40:59,660 that will make an API call 6475 04:40:59,820 --> 04:41:01,500 whether they'll be able to add the 6476 04:41:01,500 --> 04:41:03,540 friend or not 6477 04:41:03,540 --> 04:41:06,120 so if you take a look 6478 04:41:06,120 --> 04:41:08,160 so let me go back to the code 6479 04:41:08,160 --> 04:41:10,500 or let me go back to the website if you 6480 04:41:10,500 --> 04:41:11,580 take a look 6481 04:41:11,580 --> 04:41:13,980 this friend component has 6482 04:41:13,980 --> 04:41:15,718 since this person is already my friend 6483 04:41:15,718 --> 04:41:18,660 we're showing a minus icon so if I click 6484 04:41:18,660 --> 04:41:20,820 it now it shows gonna 6485 04:41:20,820 --> 04:41:23,638 the show that we can add this person as 6486 04:41:23,638 --> 04:41:24,660 well 6487 04:41:24,660 --> 04:41:26,820 so depending on whether they are a 6488 04:41:26,820 --> 04:41:29,520 friend or not it'll show a different 6489 04:41:29,520 --> 04:41:31,920 icon 6490 04:41:31,920 --> 04:41:34,440 so that's why we have this is friend and 6491 04:41:34,440 --> 04:41:37,020 that's why we need to create an API call 6492 04:41:37,020 --> 04:41:39,718 to make sure we add the friend and 6493 04:41:39,718 --> 04:41:41,700 remove the friend 6494 04:41:41,700 --> 04:41:43,080 so we're going to give it a response 6495 04:41:43,080 --> 04:41:46,920 within the weight of fetch 6496 04:41:46,920 --> 04:41:53,820 HTTP colon slash localhost colon 3000 6497 04:41:53,820 --> 04:41:55,200 and one 6498 04:41:55,200 --> 04:41:57,900 users slash 6499 04:41:57,900 --> 04:42:00,840 underscore ID 6500 04:42:00,840 --> 04:42:04,680 with friend ID so for that remember for 6501 04:42:04,680 --> 04:42:07,138 add removing a friend we need to pass in 6502 04:42:07,138 --> 04:42:08,638 both the ID 6503 04:42:08,638 --> 04:42:11,040 with the current user and the friend ID 6504 04:42:11,040 --> 04:42:13,080 that we want to 6505 04:42:13,080 --> 04:42:15,420 add or remove 6506 04:42:15,420 --> 04:42:17,520 and here we're going to have a method of 6507 04:42:17,520 --> 04:42:18,780 patch 6508 04:42:18,780 --> 04:42:21,660 this time with the headers 6509 04:42:21,660 --> 04:42:24,860 of authorization 6510 04:42:25,020 --> 04:42:26,878 Bearer 6511 04:42:26,878 --> 04:42:29,820 of token like we did before 6512 04:42:29,820 --> 04:42:33,060 and content type 6513 04:42:33,060 --> 04:42:37,138 of application Json 6514 04:42:38,760 --> 04:42:41,180 with that API call we're going to do 6515 04:42:41,180 --> 04:42:45,240 constata await response.json 6516 04:42:45,240 --> 04:42:48,900 and we're going to dispatch set friends 6517 04:42:48,900 --> 04:42:50,580 With Friends 6518 04:42:50,580 --> 04:42:52,378 and data 6519 04:42:52,378 --> 04:42:54,680 so 6520 04:42:55,500 --> 04:42:58,878 inside here I'm going to return 6521 04:43:02,760 --> 04:43:06,958 I'm going to pass in Flex between 6522 04:43:06,958 --> 04:43:08,820 with the flex 6523 04:43:08,820 --> 04:43:13,638 between of Gap of one REM 6524 04:43:14,100 --> 04:43:17,280 and then with the user image 6525 04:43:17,280 --> 04:43:19,798 an image of 6526 04:43:19,798 --> 04:43:22,638 user picture 6527 04:43:22,980 --> 04:43:24,480 path 6528 04:43:24,480 --> 04:43:29,540 and the size of 55 pixel 6529 04:43:30,000 --> 04:43:31,680 and inside this we're going to have a 6530 04:43:31,680 --> 04:43:33,860 box 6531 04:43:34,740 --> 04:43:37,860 and give it some properties so say on 6532 04:43:37,860 --> 04:43:40,218 click 6533 04:43:41,940 --> 04:43:44,700 and we're going to navigate 6534 04:43:44,700 --> 04:43:46,740 to slash profile 6535 04:43:46,740 --> 04:43:47,820 slash 6536 04:43:47,820 --> 04:43:49,200 friend 6537 04:43:49,200 --> 04:43:51,060 ID 6538 04:43:51,060 --> 04:43:52,860 now there is a bug 6539 04:43:52,860 --> 04:43:55,560 is that when you go to the user and you 6540 04:43:55,560 --> 04:43:58,860 go to a certain person's profile page 6541 04:43:58,860 --> 04:44:00,660 and then you try to click on someone 6542 04:44:00,660 --> 04:44:02,638 else's profile page and try to go to 6543 04:44:02,638 --> 04:44:05,760 that user the URL does update with react 6544 04:44:05,760 --> 04:44:06,900 router 6545 04:44:06,900 --> 04:44:10,440 but the components do not re-render now 6546 04:44:10,440 --> 04:44:12,180 there is a workaround to it but it's 6547 04:44:12,180 --> 04:44:15,480 very complex but there isn't an easy 6548 04:44:15,480 --> 04:44:17,638 work around which I'm not too big of a 6549 04:44:17,638 --> 04:44:20,160 fan of but it does the job so basically 6550 04:44:20,160 --> 04:44:23,458 it would go to the next users page and 6551 04:44:23,458 --> 04:44:25,920 then we'll refresh the page 6552 04:44:25,920 --> 04:44:28,260 I'm not too big a fan of solution but 6553 04:44:28,260 --> 04:44:29,160 it's a 6554 04:44:29,160 --> 04:44:32,878 dirty workaround that we have right now 6555 04:44:32,878 --> 04:44:35,160 so I'm not entirely sure what the best 6556 04:44:35,160 --> 04:44:36,840 solution is I just didn't want to deal 6557 04:44:36,840 --> 04:44:39,900 with having to write a long workaround 6558 04:44:39,900 --> 04:44:42,840 to get all the components working 6559 04:44:42,840 --> 04:44:44,400 in that 6560 04:44:44,400 --> 04:44:46,740 in that particular Edge case so this is 6561 04:44:46,740 --> 04:44:50,638 kind of a little bit of a hacky way to 6562 04:44:50,638 --> 04:44:53,820 deal with that so 6563 04:44:53,820 --> 04:44:56,458 with that in mind 6564 04:44:56,458 --> 04:44:58,378 like in real production app you're gonna 6565 04:44:58,378 --> 04:45:00,900 have to fix that 6566 04:45:00,900 --> 04:45:03,298 um but for something 6567 04:45:03,298 --> 04:45:05,160 small project like this I don't want you 6568 04:45:05,160 --> 04:45:07,798 to get hung up on fixing little edge 6569 04:45:07,798 --> 04:45:10,980 cases like that because that's not too 6570 04:45:10,980 --> 04:45:12,480 important unless you're dealing with the 6571 04:45:12,480 --> 04:45:14,958 real project 6572 04:45:15,780 --> 04:45:17,160 all right so we're going to give this a 6573 04:45:17,160 --> 04:45:19,260 typography with the color of main with a 6574 04:45:19,260 --> 04:45:21,480 variant 6575 04:45:21,480 --> 04:45:23,520 of H5 6576 04:45:23,520 --> 04:45:27,000 with a font weight of 500 6577 04:45:27,000 --> 04:45:29,820 and the SX 6578 04:45:29,820 --> 04:45:32,280 of 6579 04:45:32,280 --> 04:45:35,280 and colon hover 6580 04:45:35,280 --> 04:45:38,878 colon color of palette 6581 04:45:38,878 --> 04:45:43,320 dot primary dot light with a cursor 6582 04:45:43,320 --> 04:45:46,940 colon pointer 6583 04:45:47,760 --> 04:45:51,540 inside here I'm going to pass in name 6584 04:45:51,540 --> 04:45:55,560 and also typography with the color of 6585 04:45:55,560 --> 04:45:58,218 medium 6586 04:46:00,780 --> 04:46:03,000 a font size 6587 04:46:03,000 --> 04:46:06,840 of 0.75 REM 6588 04:46:06,840 --> 04:46:10,100 and a subtitle 6589 04:46:11,638 --> 04:46:14,280 and below the first flex between closing 6590 04:46:14,280 --> 04:46:15,780 tag 6591 04:46:15,780 --> 04:46:17,820 we're now going to add the 6592 04:46:17,820 --> 04:46:20,160 icon button 6593 04:46:20,160 --> 04:46:23,638 of the remove and add of the user 6594 04:46:23,638 --> 04:46:25,080 so I'm going to do 6595 04:46:25,080 --> 04:46:28,100 on click 6596 04:46:28,620 --> 04:46:29,940 I can do 6597 04:46:29,940 --> 04:46:35,040 patch friend like so and do SX of 6598 04:46:35,040 --> 04:46:37,320 background color 6599 04:46:37,320 --> 04:46:41,420 of primary light padding of 6600 04:46:41,420 --> 04:46:44,958 0.6 REM 6601 04:46:45,060 --> 04:46:47,400 and we're going to say if 6602 04:46:47,400 --> 04:46:50,458 it is a friend 6603 04:46:50,458 --> 04:46:52,798 we're going to add an icon that says 6604 04:46:52,798 --> 04:46:54,660 person 6605 04:46:54,660 --> 04:46:59,000 remove outlined give it a SX of color 6606 04:46:59,000 --> 04:47:02,940 colon primary dark 6607 04:47:02,940 --> 04:47:04,798 make sure that's closing 6608 04:47:04,798 --> 04:47:06,480 I'm just gonna 6609 04:47:06,480 --> 04:47:09,360 copy this 6610 04:47:09,360 --> 04:47:11,520 so I can just paste it over here and 6611 04:47:11,520 --> 04:47:14,580 this should be add outline so depending 6612 04:47:14,580 --> 04:47:17,760 on their a friend or not we're going to 6613 04:47:17,760 --> 04:47:19,260 show a different icon 6614 04:47:19,260 --> 04:47:22,340 and then we're going to save it 6615 04:47:23,760 --> 04:47:26,638 and it seems like use navigate has not 6616 04:47:26,638 --> 04:47:29,878 been imported so I'm going to import 6617 04:47:29,878 --> 04:47:32,958 use navigate 6618 04:47:37,620 --> 04:47:40,560 use dispatch everything's good make sure 6619 04:47:40,560 --> 04:47:43,520 everything is typed in you have no typos 6620 04:47:43,520 --> 04:47:46,320 and we're going to save it 6621 04:47:46,320 --> 04:47:49,798 and with that we can go back to post 6622 04:47:49,798 --> 04:47:50,878 widget 6623 04:47:50,878 --> 04:47:53,940 then we can import our friend 6624 04:47:53,940 --> 04:47:56,040 that we were working on 6625 04:47:56,040 --> 04:47:58,080 and we can continue our Imports so we're 6626 04:47:58,080 --> 04:48:00,900 going to import widget wrapper 6627 04:48:00,900 --> 04:48:04,200 import use state by the way I know this 6628 04:48:04,200 --> 04:48:06,180 part is kind of tenuous we have the 6629 04:48:06,180 --> 04:48:07,200 posts 6630 04:48:07,200 --> 04:48:10,200 the post widget and the friend component 6631 04:48:10,200 --> 04:48:12,840 so the post by the way is probably the 6632 04:48:12,840 --> 04:48:15,298 hardest part of the front end there's a 6633 04:48:15,298 --> 04:48:17,340 lot of functionality to it a lot of 6634 04:48:17,340 --> 04:48:19,798 little things happening so just 6635 04:48:19,798 --> 04:48:21,480 understand if you're a little confused 6636 04:48:21,480 --> 04:48:23,400 on what's Happening don't worry about it 6637 04:48:23,400 --> 04:48:24,900 just trying to 6638 04:48:24,900 --> 04:48:27,360 piece it together slowly so we're going 6639 04:48:27,360 --> 04:48:29,280 to import use dispatch 6640 04:48:29,280 --> 04:48:33,360 and then import use selector 6641 04:48:33,360 --> 04:48:37,200 and then we're going to import set post 6642 04:48:37,200 --> 04:48:39,798 like so 6643 04:48:40,138 --> 04:48:41,520 from here I'm going to create a 6644 04:48:41,520 --> 04:48:42,600 component 6645 04:48:42,600 --> 04:48:44,700 post widget 6646 04:48:44,700 --> 04:48:47,218 and in here I'm going to pass in a lot 6647 04:48:47,218 --> 04:48:49,440 of the things that I pass in Prior 6648 04:48:49,440 --> 04:48:54,060 so if I go back to posts widget go down 6649 04:48:54,060 --> 04:48:58,040 I can essentially just copy this 6650 04:48:58,560 --> 04:49:00,900 so I have the same values 6651 04:49:00,900 --> 04:49:02,940 the only thing we don't need is going to 6652 04:49:02,940 --> 04:49:04,680 be the key 6653 04:49:04,680 --> 04:49:06,360 and what I'm going to do is I'm going to 6654 04:49:06,360 --> 04:49:07,620 select 6655 04:49:07,620 --> 04:49:10,020 I'm going to select all the equal sign 6656 04:49:10,020 --> 04:49:14,120 and the opening braces like this 6657 04:49:14,878 --> 04:49:16,020 I'm going to 6658 04:49:16,020 --> 04:49:19,980 hit command shift right and I'll select 6659 04:49:19,980 --> 04:49:22,560 everything from that point to the end 6660 04:49:22,560 --> 04:49:24,718 and just hit back 6661 04:49:24,718 --> 04:49:27,780 and I'm going to put comma 6662 04:49:27,780 --> 04:49:30,540 so that's a neat short way to get rid of 6663 04:49:30,540 --> 04:49:33,660 all of that and then I'm going to have 6664 04:49:33,660 --> 04:49:37,280 a return like so 6665 04:49:37,680 --> 04:49:38,940 and this is where we're going to write 6666 04:49:38,940 --> 04:49:40,440 our logic but before that I'm going to 6667 04:49:40,440 --> 04:49:42,298 do export default post 6668 04:49:42,298 --> 04:49:44,780 widget 6669 04:49:45,120 --> 04:49:46,860 and we're going to add a number of State 6670 04:49:46,860 --> 04:49:49,200 like we did before 6671 04:49:49,200 --> 04:49:50,760 so here 6672 04:49:50,760 --> 04:49:53,040 I'm just gonna let's see if this works 6673 04:49:53,040 --> 04:49:54,180 so I'm just going to copy everything 6674 04:49:54,180 --> 04:49:57,180 over here I'm just going to modify 6675 04:49:57,180 --> 04:49:59,520 if I need to 6676 04:49:59,520 --> 04:50:03,840 so palette use team use dispatch I don't 6677 04:50:03,840 --> 04:50:06,120 need use navigate 6678 04:50:06,120 --> 04:50:08,100 so 6679 04:50:08,100 --> 04:50:10,560 use selector I grabbed it from the token 6680 04:50:10,560 --> 04:50:13,560 I don't need the ID 6681 04:50:13,560 --> 04:50:18,020 I don't need a list of friends either 6682 04:50:18,120 --> 04:50:21,000 so save me writing some some of the code 6683 04:50:21,000 --> 04:50:22,620 so 6684 04:50:22,620 --> 04:50:24,780 I'm going to add a state called is 6685 04:50:24,780 --> 04:50:29,160 comments set is comments so this is just 6686 04:50:29,160 --> 04:50:31,560 going to determine if we open the 6687 04:50:31,560 --> 04:50:33,180 comments list 6688 04:50:33,180 --> 04:50:35,760 or not so we can keep it as you state 6689 04:50:35,760 --> 04:50:38,600 false like this 6690 04:50:39,060 --> 04:50:42,180 we have the token then we also need the 6691 04:50:42,180 --> 04:50:44,400 const logged 6692 04:50:44,400 --> 04:50:47,878 in user ID now I'm being more explicit 6693 04:50:47,878 --> 04:50:49,500 because it's very confusing because you 6694 04:50:49,500 --> 04:50:51,600 have friend IDs you have the current 6695 04:50:51,600 --> 04:50:54,600 user ID you have the poster ID you want 6696 04:50:54,600 --> 04:50:56,820 to be more explicit in this case of 6697 04:50:56,820 --> 04:50:59,280 which ID represents who so that's why 6698 04:50:59,280 --> 04:51:01,500 I'm writing logged in user ID as opposed 6699 04:51:01,500 --> 04:51:03,060 to regular user ID 6700 04:51:03,060 --> 04:51:05,160 so I'm going to state 6701 04:51:05,160 --> 04:51:07,740 and then state DOT user 6702 04:51:07,740 --> 04:51:11,420 dot underscore ID 6703 04:51:12,298 --> 04:51:14,700 and then from here I'm going to do const 6704 04:51:14,700 --> 04:51:17,400 is light so now this part is a little 6705 04:51:17,400 --> 04:51:20,878 confusing so I'm going to write Boolean 6706 04:51:20,878 --> 04:51:22,378 likes 6707 04:51:22,378 --> 04:51:24,298 of logged 6708 04:51:24,298 --> 04:51:26,940 and user ID 6709 04:51:26,940 --> 04:51:30,000 so if you remember correctly on the back 6710 04:51:30,000 --> 04:51:33,980 end we have set 6711 04:51:34,080 --> 04:51:37,020 if I go to the models and set to the 6712 04:51:37,020 --> 04:51:37,860 user 6713 04:51:37,860 --> 04:51:40,080 and I look at 6714 04:51:40,080 --> 04:51:42,298 actually sorry post that's what I want 6715 04:51:42,298 --> 04:51:44,820 to look at we set the likes to the type 6716 04:51:44,820 --> 04:51:47,878 of map and of Boolean 6717 04:51:47,878 --> 04:51:50,878 so what this represents is that 6718 04:51:50,878 --> 04:51:53,458 we're going to have a likes is going to 6719 04:51:53,458 --> 04:51:56,458 be an object that looks like 6720 04:51:56,458 --> 04:51:58,798 uh 6721 04:51:58,798 --> 04:52:02,218 user ID whatever some some value blah 6722 04:52:02,218 --> 04:52:03,958 blah blah user ID 6723 04:52:03,958 --> 04:52:05,580 is going to be true 6724 04:52:05,580 --> 04:52:08,280 and then user id2 6725 04:52:08,280 --> 04:52:10,020 actually let's just do 6726 04:52:10,020 --> 04:52:11,400 this 6727 04:52:11,400 --> 04:52:13,320 true so this is what it's going to look 6728 04:52:13,320 --> 04:52:14,760 like 6729 04:52:14,760 --> 04:52:17,760 so if the user ID already exists in this 6730 04:52:17,760 --> 04:52:19,620 object 6731 04:52:19,620 --> 04:52:21,900 then we can check if they exist to see 6732 04:52:21,900 --> 04:52:25,560 if this current user is has liked it or 6733 04:52:25,560 --> 04:52:26,820 not 6734 04:52:26,820 --> 04:52:29,340 if they haven't liked it 6735 04:52:29,340 --> 04:52:32,160 it's not going to show up in this object 6736 04:52:32,160 --> 04:52:34,440 so that's why when you do likes 6737 04:52:34,440 --> 04:52:36,420 you're passing in the logged in user ID 6738 04:52:36,420 --> 04:52:38,340 so the current user ID that's logged in 6739 04:52:38,340 --> 04:52:40,920 you're going to check if it exists in 6740 04:52:40,920 --> 04:52:42,780 here and that's going to give us a 6741 04:52:42,780 --> 04:52:45,298 Boolean from there 6742 04:52:45,298 --> 04:52:47,878 they don't exist it's going to be false 6743 04:52:47,878 --> 04:52:50,458 so that's how we check if the user 6744 04:52:50,458 --> 04:52:52,620 has liked it or not and the reason why 6745 04:52:52,620 --> 04:52:55,020 we need that is if you go back 6746 04:52:55,020 --> 04:52:58,860 and you can see if I have like this we 6747 04:52:58,860 --> 04:53:00,600 need to know and we need to keep track 6748 04:53:00,600 --> 04:53:03,120 of if the current user has liked it or 6749 04:53:03,120 --> 04:53:04,980 not because if you refresh and you come 6750 04:53:04,980 --> 04:53:08,280 back this needs to keep the state of 6751 04:53:08,280 --> 04:53:09,298 which 6752 04:53:09,298 --> 04:53:11,700 the user has liked it or not 6753 04:53:11,700 --> 04:53:14,520 that's why we can't just do 6754 04:53:14,520 --> 04:53:15,600 um 6755 04:53:15,600 --> 04:53:17,940 we can't just put this as a count like 6756 04:53:17,940 --> 04:53:20,218 there's a possibility of storing just 6757 04:53:20,218 --> 04:53:22,620 the number of likes in the back end and 6758 04:53:22,620 --> 04:53:24,718 you can have whenever the user clicks 6759 04:53:24,718 --> 04:53:27,060 this it'll increase the number of likes 6760 04:53:27,060 --> 04:53:29,458 but you won't be able to track whether 6761 04:53:29,458 --> 04:53:31,740 that particular person has liked it or 6762 04:53:31,740 --> 04:53:33,420 not so the user can just continually 6763 04:53:33,420 --> 04:53:36,660 like it increase the number 6764 04:53:36,660 --> 04:53:39,000 themselves if they continually refresh 6765 04:53:39,000 --> 04:53:41,400 the page so you have to handle this on 6766 04:53:41,400 --> 04:53:43,560 the back end by keeping track of who 6767 04:53:43,560 --> 04:53:45,000 liked it 6768 04:53:45,000 --> 04:53:47,878 so this is again another reason why you 6769 04:53:47,878 --> 04:53:50,400 need to do data modeling beforehand to 6770 04:53:50,400 --> 04:53:54,020 catch situation like this 6771 04:53:55,798 --> 04:53:58,080 and then also we're going to get the LA 6772 04:53:58,080 --> 04:54:01,378 like count so the number of likes that 6773 04:54:01,378 --> 04:54:04,020 this uses that this post has we're going 6774 04:54:04,020 --> 04:54:07,260 to grab via object.keys 6775 04:54:07,260 --> 04:54:08,820 likes 6776 04:54:08,820 --> 04:54:10,200 dot link 6777 04:54:10,200 --> 04:54:12,540 so this grabs the number of likes via 6778 04:54:12,540 --> 04:54:15,560 how many keys there are 6779 04:54:16,440 --> 04:54:20,760 and after that we only need medium 6780 04:54:20,760 --> 04:54:24,560 and we just need primary 6781 04:54:25,680 --> 04:54:29,660 so palette dot primary 6782 04:54:29,940 --> 04:54:32,958 and then dot Main 6783 04:54:36,958 --> 04:54:38,700 and then with this 6784 04:54:38,700 --> 04:54:41,760 now we can create a function that will 6785 04:54:41,760 --> 04:54:43,798 change the number of likes so we're 6786 04:54:43,798 --> 04:54:45,240 going to create a function called patch 6787 04:54:45,240 --> 04:54:46,680 like 6788 04:54:46,680 --> 04:54:49,940 we're going to do async 6789 04:54:50,218 --> 04:54:51,840 and we're going to make an API call so 6790 04:54:51,840 --> 04:54:54,180 we're going to do response equals await 6791 04:54:54,180 --> 04:54:56,298 fetch 6792 04:54:56,298 --> 04:55:01,520 HTTP colon slash Local Host colon 6793 04:55:01,520 --> 04:55:04,740 3001 posts slash 6794 04:55:04,740 --> 04:55:07,200 post ID 6795 04:55:07,200 --> 04:55:09,660 slash like 6796 04:55:09,660 --> 04:55:12,540 colon I'm going to do method 6797 04:55:12,540 --> 04:55:15,298 patch like so 6798 04:55:15,298 --> 04:55:17,520 we're going to set a headers 6799 04:55:17,520 --> 04:55:20,458 with an authorization 6800 04:55:20,458 --> 04:55:23,458 of Bearer like we did before 6801 04:55:23,458 --> 04:55:26,160 now since we're always doing the bear we 6802 04:55:26,160 --> 04:55:28,320 could have made an abstract wrapper 6803 04:55:28,320 --> 04:55:29,878 function so we don't have to constantly 6804 04:55:29,878 --> 04:55:30,920 write this 6805 04:55:30,920 --> 04:55:34,260 but it's not too much extra code so I'm 6806 04:55:34,260 --> 04:55:36,138 going to do a content type 6807 04:55:36,138 --> 04:55:40,218 application flash Json 6808 04:55:41,040 --> 04:55:43,920 and we're going to do body Json Dot 6809 04:55:43,920 --> 04:55:46,458 stringify 6810 04:55:46,798 --> 04:55:49,440 and we're passing in the user ID 6811 04:55:49,440 --> 04:55:52,260 so the back end could keep track 6812 04:55:52,260 --> 04:55:55,200 of whether the current user ID 6813 04:55:55,200 --> 04:55:58,400 has liked the post 6814 04:56:00,900 --> 04:56:03,060 and what this response is what we 6815 04:56:03,060 --> 04:56:06,958 configured it was to return the updated 6816 04:56:06,958 --> 04:56:09,120 post so we 6817 04:56:09,120 --> 04:56:13,340 are just returning the entire post 6818 04:56:13,440 --> 04:56:15,718 I spelled this wrong so it's 6819 04:56:15,718 --> 04:56:17,638 giving me some funky results so 6820 04:56:17,638 --> 04:56:19,860 response.json 6821 04:56:19,860 --> 04:56:22,440 will give us the updated post from the 6822 04:56:22,440 --> 04:56:23,400 back end 6823 04:56:23,400 --> 04:56:26,280 so then that means we can just update 6824 04:56:26,280 --> 04:56:28,138 the post 6825 04:56:28,138 --> 04:56:30,860 instead 6826 04:56:33,120 --> 04:56:37,580 so that's why if you go to state 6827 04:56:38,218 --> 04:56:39,958 if you remember correctly 6828 04:56:39,958 --> 04:56:42,298 I'm going to go through the list of the 6829 04:56:42,298 --> 04:56:45,360 post to try to find the post 6830 04:56:45,360 --> 04:56:47,580 that we just updated 6831 04:56:47,580 --> 04:56:50,760 and if so we're just going to replace it 6832 04:56:50,760 --> 04:56:53,340 and this is basically replacing 6833 04:56:53,340 --> 04:56:55,860 that single post otherwise we just 6834 04:56:55,860 --> 04:56:58,980 return the original post if we did not 6835 04:56:58,980 --> 04:57:01,400 find it 6836 04:57:02,458 --> 04:57:05,878 and so if I go back to post widget 6837 04:57:05,878 --> 04:57:09,240 we have our patch like function now we 6838 04:57:09,240 --> 04:57:12,798 can write our jsx 6839 04:57:13,260 --> 04:57:15,120 so in here I'm going to do widget 6840 04:57:15,120 --> 04:57:17,878 wrapper 6841 04:57:17,878 --> 04:57:20,520 with a margin of 2 REM 6842 04:57:20,520 --> 04:57:25,100 top and bottom and zero left and right 6843 04:57:25,740 --> 04:57:27,718 and in here I'm going to create the 6844 04:57:27,718 --> 04:57:29,700 friend component so this is why we 6845 04:57:29,700 --> 04:57:31,200 created it 6846 04:57:31,200 --> 04:57:32,760 so now we're actually creating the 6847 04:57:32,760 --> 04:57:35,400 component of post widget but we just 6848 04:57:35,400 --> 04:57:37,680 need to pass in the correct things 6849 04:57:37,680 --> 04:57:39,718 so friend ID is going to be the post 6850 04:57:39,718 --> 04:57:42,600 user ID so the ID of the user who posted 6851 04:57:42,600 --> 04:57:43,320 it 6852 04:57:43,320 --> 04:57:45,958 then we're going to do name 6853 04:57:45,958 --> 04:57:49,260 pass in their name with the subtitle 6854 04:57:49,260 --> 04:57:52,378 in this case being the location 6855 04:57:52,378 --> 04:57:56,780 and the user picture path being 6856 04:57:56,780 --> 04:58:00,480 the same user picture path 6857 04:58:00,480 --> 04:58:02,780 so 6858 04:58:03,718 --> 04:58:05,760 we're going to have a typography with a 6859 04:58:05,760 --> 04:58:06,480 color 6860 04:58:06,480 --> 04:58:08,218 of Main 6861 04:58:08,218 --> 04:58:10,940 SX 6862 04:58:11,638 --> 04:58:15,320 margin top of one REM 6863 04:58:15,958 --> 04:58:19,700 and pass in a description 6864 04:58:21,240 --> 04:58:23,878 from here I'm going to do picture 6865 04:58:23,878 --> 04:58:26,360 path 6866 04:58:27,298 --> 04:58:31,160 and pass in in image 6867 04:58:32,820 --> 04:58:34,980 and this image is going to have a width 6868 04:58:34,980 --> 04:58:37,440 of 100 percent 6869 04:58:37,440 --> 04:58:40,740 height of Auto 6870 04:58:40,740 --> 04:58:44,298 alt of post 6871 04:58:46,500 --> 04:58:48,240 Style 6872 04:58:48,240 --> 04:58:51,798 of Border radius 6873 04:58:52,160 --> 04:58:55,020 0.75 REM 6874 04:58:55,020 --> 04:58:58,458 margin top 6875 04:58:59,360 --> 04:59:03,360 0.75 REM 6876 04:59:05,458 --> 04:59:08,458 and we're going to give it a source of 6877 04:59:08,458 --> 04:59:14,298 HTTP colon slash localhost colon 6878 04:59:14,298 --> 04:59:19,260 3001 assets slash picture 6879 04:59:19,260 --> 04:59:20,878 path 6880 04:59:20,878 --> 04:59:24,180 so this will be the post path or post a 6881 04:59:24,180 --> 04:59:25,860 picture 6882 04:59:25,860 --> 04:59:29,120 that we're creating right here 6883 04:59:29,760 --> 04:59:31,080 and then from here we're going to create 6884 04:59:31,080 --> 04:59:33,298 Flex between 6885 04:59:33,298 --> 04:59:37,878 the margin top of 0.25 REM 6886 04:59:38,040 --> 04:59:40,620 sure to close that 6887 04:59:40,620 --> 04:59:43,080 and I don't know why 6888 04:59:43,080 --> 04:59:46,920 it didn't automatically close it for me 6889 04:59:46,920 --> 04:59:49,980 and then Flex between 6890 04:59:49,980 --> 04:59:53,580 give it a gap of one REM 6891 04:59:53,580 --> 04:59:55,860 close it 6892 04:59:55,860 --> 04:59:58,320 and then one more Flex between so 6893 04:59:58,320 --> 04:59:59,700 there's three 6894 04:59:59,700 --> 05:00:05,420 and this one has a gap of 0.3 REM 6895 05:00:07,260 --> 05:00:10,740 and we're going to pass in icon button 6896 05:00:10,740 --> 05:00:12,660 on click 6897 05:00:12,660 --> 05:00:15,920 patch like 6898 05:00:17,400 --> 05:00:20,520 and in here is going to be is liked 6899 05:00:20,520 --> 05:00:22,138 with 6900 05:00:22,138 --> 05:00:26,160 favorite outlined SX 6901 05:00:26,160 --> 05:00:27,540 of color 6902 05:00:27,540 --> 05:00:29,160 primary 6903 05:00:29,160 --> 05:00:30,718 and we're going to make sure it's a 6904 05:00:30,718 --> 05:00:33,440 closing tag 6905 05:00:33,840 --> 05:00:36,120 colon and I'm going to do 6906 05:00:36,120 --> 05:00:37,620 favorite 6907 05:00:37,620 --> 05:00:41,218 border outlined 6908 05:00:41,218 --> 05:00:43,860 so this is determining the icon button 6909 05:00:43,860 --> 05:00:47,280 whether someone has liked it or not 6910 05:00:47,280 --> 05:00:49,680 and below this icon button I'm going to 6911 05:00:49,680 --> 05:00:52,700 do a typography 6912 05:00:52,860 --> 05:00:56,820 of like count so that the displays how 6913 05:00:56,820 --> 05:01:00,020 many likes there are 6914 05:01:00,840 --> 05:01:03,240 okay so after 6915 05:01:03,240 --> 05:01:06,378 the following Flex between 6916 05:01:07,080 --> 05:01:08,760 so I just want to be careful I don't 6917 05:01:08,760 --> 05:01:11,638 mess this up so there's two Closing one 6918 05:01:11,638 --> 05:01:13,378 closing above 6919 05:01:13,378 --> 05:01:15,060 in here we're going to create another 6920 05:01:15,060 --> 05:01:16,980 Flex between 6921 05:01:16,980 --> 05:01:21,798 with a gap of 0.3 REM 6922 05:01:22,320 --> 05:01:26,420 and actually I can just probably 6923 05:01:27,298 --> 05:01:30,378 just copy this 6924 05:01:33,660 --> 05:01:35,280 and I'm just going to remove everything 6925 05:01:35,280 --> 05:01:37,920 inside 6926 05:01:37,920 --> 05:01:40,378 and on click we're going to remove the 6927 05:01:40,378 --> 05:01:44,340 patch like to be set is comments 6928 05:01:44,340 --> 05:01:47,218 and we're going to revert is comments so 6929 05:01:47,218 --> 05:01:51,080 it'll open the comment section 6930 05:01:51,240 --> 05:01:54,080 and remove it 6931 05:01:55,798 --> 05:01:59,660 and we're going to have chat bubble 6932 05:01:59,878 --> 05:02:04,378 outline outlined like so 6933 05:02:04,378 --> 05:02:07,320 inside here we're going to do typography 6934 05:02:07,320 --> 05:02:11,120 with comments dot length 6935 05:02:11,120 --> 05:02:14,580 so that determines the number of 6936 05:02:14,580 --> 05:02:17,100 comments as well 6937 05:02:17,100 --> 05:02:18,900 all right so 6938 05:02:18,900 --> 05:02:21,000 we have to be very careful to figure out 6939 05:02:21,000 --> 05:02:22,798 where to place it 6940 05:02:22,798 --> 05:02:25,500 so this 6941 05:02:25,500 --> 05:02:28,680 this is the liked 6942 05:02:28,680 --> 05:02:32,840 then this is the comment section 6943 05:02:35,100 --> 05:02:38,458 and then from here below 6944 05:02:38,458 --> 05:02:41,340 this Flex between so there's two closing 6945 05:02:41,340 --> 05:02:43,138 Flex betweens 6946 05:02:43,138 --> 05:02:45,900 we're going to have 6947 05:02:45,900 --> 05:02:49,080 an icon button 6948 05:02:49,080 --> 05:02:52,260 with share outlined 6949 05:02:52,260 --> 05:02:54,920 like so 6950 05:02:58,080 --> 05:03:01,320 and then this one should be closed 6951 05:03:01,320 --> 05:03:04,760 let me double check 6952 05:03:06,660 --> 05:03:09,060 and then we should have below this Flex 6953 05:03:09,060 --> 05:03:12,718 between we're going to do is comments 6954 05:03:12,718 --> 05:03:14,700 so just make sure we aligned a lot of 6955 05:03:14,700 --> 05:03:17,160 these Flex betweens it's nice but you 6956 05:03:17,160 --> 05:03:19,620 see there's just it's hard to figure out 6957 05:03:19,620 --> 05:03:22,020 where the lines 6958 05:03:22,020 --> 05:03:24,240 so this is where we're going to display 6959 05:03:24,240 --> 05:03:26,760 the actual comments 6960 05:03:26,760 --> 05:03:29,520 so we're gonna have a box 6961 05:03:29,520 --> 05:03:33,600 with a margin top of 0.5 REM 6962 05:03:33,600 --> 05:03:36,120 and I'm going to iterate through our 6963 05:03:36,120 --> 05:03:40,340 comment section there is a comments.map 6964 05:03:40,440 --> 05:03:42,420 pass it in a comment 6965 05:03:42,420 --> 05:03:45,120 with an index 6966 05:03:45,120 --> 05:03:48,620 and in here I'm going to return 6967 05:03:52,378 --> 05:03:55,458 I'm going to return a box 6968 05:03:57,060 --> 05:03:59,458 and close the box like that 6969 05:03:59,458 --> 05:04:02,420 and give it a key 6970 05:04:03,060 --> 05:04:04,138 with 6971 05:04:04,138 --> 05:04:06,180 a name 6972 05:04:06,180 --> 05:04:07,798 Dash 6973 05:04:07,798 --> 05:04:09,000 I 6974 05:04:09,000 --> 05:04:11,400 so that will give it a unique 6975 05:04:11,400 --> 05:04:14,580 index the reason why I have 6976 05:04:14,580 --> 05:04:18,000 the I which is one two three we pass in 6977 05:04:18,000 --> 05:04:19,740 the name as well the reason why we do 6978 05:04:19,740 --> 05:04:21,360 that is to make this unique this is 6979 05:04:21,360 --> 05:04:25,440 index 0 1 2 might not be actually unique 6980 05:04:25,440 --> 05:04:28,138 so you need to keep that 6981 05:04:28,138 --> 05:04:30,120 you need to add something to make it 6982 05:04:30,120 --> 05:04:32,840 truly unique 6983 05:04:32,940 --> 05:04:35,218 okay so we have a divider we're going to 6984 05:04:35,218 --> 05:04:37,200 do typography 6985 05:04:37,200 --> 05:04:39,000 SX 6986 05:04:39,000 --> 05:04:42,060 pass in color colon Main 6987 05:04:42,060 --> 05:04:43,798 margin 6988 05:04:43,798 --> 05:04:48,718 of 0.5 REM 0 6989 05:04:48,840 --> 05:04:52,440 padding left of one REM 6990 05:04:52,440 --> 05:04:54,420 ake sure we close it 6991 05:04:54,420 --> 05:04:56,280 and inside here I'm going to pass in 6992 05:04:56,280 --> 05:04:59,000 comment 6993 05:05:00,958 --> 05:05:02,820 and it seems like we have everything 6994 05:05:02,820 --> 05:05:05,040 aligned properly and then there's 6995 05:05:05,040 --> 05:05:06,180 actually 6996 05:05:06,180 --> 05:05:10,920 one more divider right below it as well 6997 05:05:10,920 --> 05:05:12,718 we are exporting 6998 05:05:12,718 --> 05:05:16,820 we have the post widget over here 6999 05:05:18,180 --> 05:05:20,878 we have the friend widget 7000 05:05:20,878 --> 05:05:23,700 and now we can check go back to home 7001 05:05:23,700 --> 05:05:26,520 page and we want to add 7002 05:05:26,520 --> 05:05:28,440 the widgets over here 7003 05:05:28,440 --> 05:05:32,298 so my post widget 7004 05:05:33,600 --> 05:05:37,378 we should have the posts widget 7005 05:05:37,378 --> 05:05:38,820 underneath 7006 05:05:38,820 --> 05:05:42,138 passing in the user ID 7007 05:05:42,480 --> 05:05:44,638 underscore ID 7008 05:05:44,638 --> 05:05:47,180 so 7009 05:05:49,440 --> 05:05:54,320 cool and let's let's double check Maybe 7010 05:05:54,540 --> 05:05:57,298 favorite border outlined is not defined 7011 05:05:57,298 --> 05:05:59,520 so if I go back to post 7012 05:05:59,520 --> 05:06:01,620 widget 7013 05:06:01,620 --> 05:06:04,500 forward outlined 7014 05:06:04,500 --> 05:06:07,138 that should be actually let me double 7015 05:06:07,138 --> 05:06:09,440 check 7016 05:06:11,160 --> 05:06:13,798 there we go 7017 05:06:13,798 --> 05:06:17,638 favorite border outlined okay 7018 05:06:17,638 --> 05:06:19,378 everything's imported 7019 05:06:19,378 --> 05:06:21,718 ah perfect let me double check 7020 05:06:21,718 --> 05:06:24,540 everything so we have a like 7021 05:06:24,540 --> 05:06:27,600 okay it does not seem to update the 7022 05:06:27,600 --> 05:06:30,060 likes so let's fix that comments is 7023 05:06:30,060 --> 05:06:34,160 working let's see if we can add a friend 7024 05:06:34,440 --> 05:06:36,860 and 7025 05:06:38,940 --> 05:06:42,060 it does seem to add it perfect we don't 7026 05:06:42,060 --> 05:06:43,980 have the friends list yet we'll get to 7027 05:06:43,980 --> 05:06:44,760 that 7028 05:06:44,760 --> 05:06:46,920 the only thing that's not working is the 7029 05:06:46,920 --> 05:06:49,260 like button so let's go and take care of 7030 05:06:49,260 --> 05:06:50,160 that 7031 05:06:50,160 --> 05:06:52,260 after looking through I figured out what 7032 05:06:52,260 --> 05:06:54,240 the problem with the like is if you go 7033 05:06:54,240 --> 05:06:56,760 back I had a little bit of a typo if you 7034 05:06:56,760 --> 05:06:59,940 go to the index State Post underscore ID 7035 05:06:59,940 --> 05:07:02,700 so you want to put a dot over here 7036 05:07:02,700 --> 05:07:04,980 make sure you have that dot 7037 05:07:04,980 --> 05:07:07,500 let's save it and now 7038 05:07:07,500 --> 05:07:09,298 I'm going to refresh it 7039 05:07:09,298 --> 05:07:11,940 let's go back 7040 05:07:11,940 --> 05:07:15,718 everything should work as expected 7041 05:07:15,718 --> 05:07:18,660 great we have the comments we have add 7042 05:07:18,660 --> 05:07:20,820 friends remove friends 7043 05:07:20,820 --> 05:07:22,920 our post sections is now complete post 7044 05:07:22,920 --> 05:07:24,840 section was probably the the hardest 7045 05:07:24,840 --> 05:07:28,138 part because there's adding removing and 7046 05:07:28,138 --> 05:07:32,458 adding likes grooming removing likes 7047 05:07:32,458 --> 05:07:35,580 it's quite tough it might not look as if 7048 05:07:35,580 --> 05:07:38,400 it's a hard issue but it can be quite 7049 05:07:38,400 --> 05:07:40,138 challenging 7050 05:07:40,138 --> 05:07:42,360 all right and the last two widgets that 7051 05:07:42,360 --> 05:07:43,920 we need to take care of is going to be 7052 05:07:43,920 --> 05:07:45,718 this advertisement widget and the 7053 05:07:45,718 --> 05:07:48,000 friends list widget these two should not 7054 05:07:48,000 --> 05:07:51,120 be as involved as the other two so we're 7055 05:07:51,120 --> 05:07:52,620 just going to handle those so I'm going 7056 05:07:52,620 --> 05:07:54,540 to close everything 7057 05:07:54,540 --> 05:07:56,940 I'm going to just close a lot of these 7058 05:07:56,940 --> 05:07:58,320 folders so 7059 05:07:58,320 --> 05:08:00,900 we can focus on the right things so 7060 05:08:00,900 --> 05:08:02,638 under widgets I'm going to create a new 7061 05:08:02,638 --> 05:08:07,378 file called advert widget.jsx 7062 05:08:09,298 --> 05:08:11,160 close this I'm going to import 7063 05:08:11,160 --> 05:08:14,160 typography 7064 05:08:14,280 --> 05:08:16,560 use theme as well 7065 05:08:16,560 --> 05:08:20,100 and I'm going to import Flex between 7066 05:08:20,100 --> 05:08:24,240 and then import widget wrapper 7067 05:08:24,240 --> 05:08:26,520 now I'm going to create the advert 7068 05:08:26,520 --> 05:08:28,320 widget 7069 05:08:28,320 --> 05:08:30,120 so 7070 05:08:30,120 --> 05:08:33,420 make sure I export 7071 05:08:33,420 --> 05:08:38,520 default advert widget 7072 05:08:39,780 --> 05:08:42,420 and from here I'm going to do const 7073 05:08:42,420 --> 05:08:43,980 palette 7074 05:08:43,980 --> 05:08:46,378 equals use theme 7075 05:08:46,378 --> 05:08:48,180 and we're just going to grab some colors 7076 05:08:48,180 --> 05:08:50,340 so we're going to grab the dark so 7077 05:08:50,340 --> 05:08:51,480 palette 7078 05:08:51,480 --> 05:08:55,500 dot neutral dot dark I'm going to copy 7079 05:08:55,500 --> 05:08:59,100 palette dot neutral like so const main 7080 05:08:59,100 --> 05:09:01,440 equals that 7081 05:09:01,440 --> 05:09:03,000 main as well 7082 05:09:03,000 --> 05:09:06,420 const medium with palette dot neutral 7083 05:09:06,420 --> 05:09:09,080 medium 7084 05:09:11,160 --> 05:09:13,740 and we're going to return 7085 05:09:13,740 --> 05:09:16,680 widget wrapper 7086 05:09:16,680 --> 05:09:19,100 and I'm just going to do Flex between 7087 05:09:19,100 --> 05:09:22,200 with typography 7088 05:09:22,200 --> 05:09:23,280 color 7089 05:09:23,280 --> 05:09:25,138 of dark 7090 05:09:25,138 --> 05:09:26,638 variant 7091 05:09:26,638 --> 05:09:28,980 of H5 7092 05:09:28,980 --> 05:09:31,138 font weight 7093 05:09:31,138 --> 05:09:33,540 of 500. 7094 05:09:33,540 --> 05:09:36,920 I'm going to write sponsored 7095 05:09:37,320 --> 05:09:38,638 and below this I'm going to do 7096 05:09:38,638 --> 05:09:44,000 typography with the color of medium 7097 05:09:45,298 --> 05:09:48,660 and we're going to write create add 7098 05:09:48,660 --> 05:09:50,340 and below this Flex between I'm going to 7099 05:09:50,340 --> 05:09:52,940 do image 7100 05:09:55,138 --> 05:09:56,340 with 7101 05:09:56,340 --> 05:09:58,920 of a hundred percent 7102 05:09:58,920 --> 05:10:01,980 height of Auto 7103 05:10:01,980 --> 05:10:05,218 alt of advert 7104 05:10:05,218 --> 05:10:11,100 source of HTTP colon slash localhost 7105 05:10:11,100 --> 05:10:14,700 colon 3001 assets 7106 05:10:14,700 --> 05:10:16,760 I'm going to just do info 7107 05:10:16,760 --> 05:10:19,680 4.jpg so this is just a hard-coded 7108 05:10:19,680 --> 05:10:21,298 image we're not going to actually 7109 05:10:21,298 --> 05:10:24,420 Implement an advertisement here 7110 05:10:24,420 --> 05:10:25,440 so 7111 05:10:25,440 --> 05:10:27,000 we're just going to have border radius 7112 05:10:27,000 --> 05:10:29,218 of zero point 7113 05:10:29,218 --> 05:10:32,400 seven five REM 7114 05:10:32,400 --> 05:10:34,200 margin 7115 05:10:34,200 --> 05:10:39,320 of 0.75 REM top bottom 7116 05:10:39,320 --> 05:10:42,298 zero left and right 7117 05:10:42,298 --> 05:10:44,638 then we're going to do Flex between 7118 05:10:44,638 --> 05:10:47,700 and we're going to do typography 7119 05:10:47,700 --> 05:10:49,500 with a color 7120 05:10:49,500 --> 05:10:51,780 of Main 7121 05:10:51,780 --> 05:10:55,920 we're going to say Mika cosmetics 7122 05:10:56,340 --> 05:10:59,218 and don't go looking for it because 7123 05:10:59,218 --> 05:11:00,900 I just made that up I don't know if it's 7124 05:11:00,900 --> 05:11:03,180 a real thing 7125 05:11:03,180 --> 05:11:05,878 it is real then maybe you can go check 7126 05:11:05,878 --> 05:11:06,958 out 7127 05:11:06,958 --> 05:11:09,780 check out their products not not a 7128 05:11:09,780 --> 05:11:11,638 sponsorship so Mika 7129 05:11:11,638 --> 05:11:13,740 cosmetics 7130 05:11:13,740 --> 05:11:16,280 .com 7131 05:11:16,440 --> 05:11:18,480 and below this Flex between we're going 7132 05:11:18,480 --> 05:11:20,700 to do typography 7133 05:11:20,700 --> 05:11:22,378 with a color 7134 05:11:22,378 --> 05:11:24,180 of medium 7135 05:11:24,180 --> 05:11:28,020 margin of 0.5 REM top and bottom with 7136 05:11:28,020 --> 05:11:30,540 the zero left and right and I'm just 7137 05:11:30,540 --> 05:11:32,958 going to write 7138 05:11:33,060 --> 05:11:36,180 random text so your pathway to stunning 7139 05:11:36,180 --> 05:11:38,580 and immaculate 7140 05:11:38,580 --> 05:11:40,440 Beauty 7141 05:11:40,440 --> 05:11:44,218 and made sure your skin 7142 05:11:44,218 --> 05:11:47,040 is exfoliating 7143 05:11:47,040 --> 05:11:49,860 skin and Shining 7144 05:11:49,860 --> 05:11:52,878 like light 7145 05:11:54,480 --> 05:11:56,340 and that's pretty much our average 7146 05:11:56,340 --> 05:11:58,680 widget so we're just going to go to our 7147 05:11:58,680 --> 05:11:59,760 home page 7148 05:11:59,760 --> 05:12:02,160 go to our index file 7149 05:12:02,160 --> 05:12:03,958 we're going to go under 7150 05:12:03,958 --> 05:12:06,060 this Flex basis and I'm just going to 7151 05:12:06,060 --> 05:12:07,500 add 7152 05:12:07,500 --> 05:12:10,378 the advert 7153 05:12:10,378 --> 05:12:12,298 widget 7154 05:12:12,298 --> 05:12:15,360 so nice and simple it does not take 7155 05:12:15,360 --> 05:12:17,638 anything inside so that's all we need to 7156 05:12:17,638 --> 05:12:19,820 do 7157 05:12:20,458 --> 05:12:21,718 and also I'm going to create a little 7158 05:12:21,718 --> 05:12:25,980 box with a margin of two REM top and 7159 05:12:25,980 --> 05:12:28,138 bottom and zero left and right so this 7160 05:12:28,138 --> 05:12:30,718 is just going to get some space in there 7161 05:12:30,718 --> 05:12:31,860 and we're going to create the friends 7162 05:12:31,860 --> 05:12:33,718 list widget now 7163 05:12:33,718 --> 05:12:37,200 so friend list widget 7164 05:12:37,200 --> 05:12:39,540 Dot jsx 7165 05:12:39,540 --> 05:12:43,200 I'm going to close this close the advert 7166 05:12:43,200 --> 05:12:45,958 and in here I'm going to do some imports 7167 05:12:45,958 --> 05:12:49,700 so import box 7168 05:12:49,740 --> 05:12:51,360 to your UI 7169 05:12:51,360 --> 05:12:55,020 typography use theme 7170 05:12:55,020 --> 05:12:57,360 we're going to import a friend 7171 05:12:57,360 --> 05:13:00,600 from component front import widget 7172 05:13:00,600 --> 05:13:02,700 wrapper 7173 05:13:02,700 --> 05:13:06,860 import use effect 7174 05:13:08,160 --> 05:13:12,260 import use dispatch 7175 05:13:12,480 --> 05:13:15,240 and use selector 7176 05:13:15,240 --> 05:13:19,700 I'm going to import set friends 7177 05:13:20,040 --> 05:13:21,298 from here I'm going to create a 7178 05:13:21,298 --> 05:13:24,180 component called friend list widget 7179 05:13:24,180 --> 05:13:28,100 with user ID 7180 05:13:30,900 --> 05:13:34,620 and I'm going to make sure I export this 7181 05:13:34,620 --> 05:13:36,120 friend 7182 05:13:36,120 --> 05:13:39,138 list widget 7183 05:13:41,878 --> 05:13:45,958 and in here I'm going to go over to 7184 05:13:45,958 --> 05:13:48,480 let's see what's the most 7185 05:13:48,480 --> 05:13:49,860 similar 7186 05:13:49,860 --> 05:13:51,180 yeah I'm going to go to the friend 7187 05:13:51,180 --> 05:13:53,760 component I'm just going to copy this 7188 05:13:53,760 --> 05:13:55,980 see if this works out 7189 05:13:55,980 --> 05:13:59,100 we're going to have dispatch 7190 05:13:59,100 --> 05:14:01,138 and instead of navigate we're going to 7191 05:14:01,138 --> 05:14:03,298 do theme 7192 05:14:03,298 --> 05:14:05,520 use theme 7193 05:14:05,520 --> 05:14:08,040 we don't need the ID but we can keep the 7194 05:14:08,040 --> 05:14:10,378 other two 7195 05:14:10,378 --> 05:14:12,600 just trying to find ways to shorten 7196 05:14:12,600 --> 05:14:13,860 writing 7197 05:14:13,860 --> 05:14:15,958 some of this 7198 05:14:15,958 --> 05:14:17,400 so we're using the same thing over and 7199 05:14:17,400 --> 05:14:18,718 over 7200 05:14:18,718 --> 05:14:20,340 and from here I'm going to create a 7201 05:14:20,340 --> 05:14:22,740 function called get friends so we can 7202 05:14:22,740 --> 05:14:26,480 get a list of the users friends 7203 05:14:27,298 --> 05:14:29,638 we're going to do response 7204 05:14:29,638 --> 05:14:32,160 a weight fetch 7205 05:14:32,160 --> 05:14:33,958 and the reason why we can't just grab it 7206 05:14:33,958 --> 05:14:35,820 from the user list of friends we're 7207 05:14:35,820 --> 05:14:36,900 going to be using this friends list 7208 05:14:36,900 --> 05:14:39,240 widget if you click on someone else's 7209 05:14:39,240 --> 05:14:42,060 profile so this will grab the list of 7210 05:14:42,060 --> 05:14:43,080 users 7211 05:14:43,080 --> 05:14:46,860 before that specific user ID 7212 05:14:46,860 --> 05:14:49,320 so we need to make sure we're handling 7213 05:14:49,320 --> 05:14:52,200 not just the current user but also other 7214 05:14:52,200 --> 05:14:56,298 users as well so HTTP colon slash 7215 05:14:56,298 --> 05:15:01,200 localhost colon 3001 users slash 7216 05:15:01,200 --> 05:15:05,100 user ID friends 7217 05:15:06,180 --> 05:15:08,878 and in here I'm going to do method colon 7218 05:15:08,878 --> 05:15:11,100 get 7219 05:15:11,100 --> 05:15:12,600 with headers 7220 05:15:12,600 --> 05:15:14,040 of 7221 05:15:14,040 --> 05:15:16,560 authorization colon 7222 05:15:16,560 --> 05:15:18,180 Bearer 7223 05:15:18,180 --> 05:15:20,780 token 7224 05:15:21,958 --> 05:15:25,440 the const data of a weight response dot 7225 05:15:25,440 --> 05:15:26,458 Json 7226 05:15:26,458 --> 05:15:30,360 and we're going to dispatch set friends 7227 05:15:30,360 --> 05:15:33,060 With Friends of data 7228 05:15:33,060 --> 05:15:35,580 so we're setting our data or setting our 7229 05:15:35,580 --> 05:15:37,320 friends list 7230 05:15:37,320 --> 05:15:39,600 in our state 7231 05:15:39,600 --> 05:15:40,980 and we're going to make sure we got to 7232 05:15:40,980 --> 05:15:43,500 call this so we're going to do use 7233 05:15:43,500 --> 05:15:45,420 effect 7234 05:15:45,420 --> 05:15:48,600 so get friends 7235 05:15:48,600 --> 05:15:51,360 and in here this should be empty array 7236 05:15:51,360 --> 05:15:53,958 and we're going to do es lint 7237 05:15:53,958 --> 05:15:55,920 disable 7238 05:15:55,920 --> 05:16:03,240 oops disable line react hooks exhaustive 7239 05:16:05,520 --> 05:16:08,840 and in here we're going to return 7240 05:16:10,500 --> 05:16:12,600 a widget 7241 05:16:12,600 --> 05:16:15,200 wrapper 7242 05:16:15,780 --> 05:16:18,920 the typography 7243 05:16:20,458 --> 05:16:22,860 with a friend list 7244 05:16:22,860 --> 05:16:24,780 and inside the typography we're going to 7245 05:16:24,780 --> 05:16:25,920 give it some 7246 05:16:25,920 --> 05:16:27,420 properties so we're going to color 7247 05:16:27,420 --> 05:16:28,980 palette 7248 05:16:28,980 --> 05:16:31,020 the neutral 7249 05:16:31,020 --> 05:16:32,520 dot dark 7250 05:16:32,520 --> 05:16:37,020 with a variant of H5 font weight 7251 05:16:37,020 --> 05:16:40,378 of 500 SX 7252 05:16:40,378 --> 05:16:45,260 of margin bottom 1.5 REM 7253 05:16:45,840 --> 05:16:49,200 and inside here we're going to do box 7254 05:16:49,200 --> 05:16:51,240 give this a display 7255 05:16:51,240 --> 05:16:55,878 of flex but the flux Direction 7256 05:16:56,280 --> 05:17:00,240 will be column so go up and down instead 7257 05:17:00,240 --> 05:17:02,340 and we're going to give it a gap of 1.5 7258 05:17:02,340 --> 05:17:05,000 REM 7259 05:17:06,540 --> 05:17:08,218 and what I want to do is I'm going to 7260 05:17:08,218 --> 05:17:10,920 map out friends 7261 05:17:10,920 --> 05:17:14,120 and for each friend 7262 05:17:14,700 --> 05:17:17,760 I'm going to use the friend component 7263 05:17:17,760 --> 05:17:19,980 actually let me 7264 05:17:19,980 --> 05:17:23,100 fix the syntax over here 7265 05:17:23,100 --> 05:17:26,060 I'm going to do friend 7266 05:17:27,360 --> 05:17:30,718 and I'm going to pass in 7267 05:17:30,718 --> 05:17:35,040 key a friend dot underscore ID 7268 05:17:35,040 --> 05:17:37,020 friend ID 7269 05:17:37,020 --> 05:17:42,798 friend dot underscore ID with a name 7270 05:17:43,260 --> 05:17:47,520 of friend DOT first name 7271 05:17:47,520 --> 05:17:51,180 friend dot last name 7272 05:17:51,180 --> 05:17:53,700 give it a sub title 7273 05:17:53,700 --> 05:17:55,920 a friend.aku 7274 05:17:55,920 --> 05:17:57,420 patient 7275 05:17:57,420 --> 05:18:00,600 user picture path 7276 05:18:00,600 --> 05:18:01,820 with 7277 05:18:01,820 --> 05:18:05,160 friend.picture path 7278 05:18:05,160 --> 05:18:06,600 and that 7279 05:18:06,600 --> 05:18:10,680 should conclude our friends list widget 7280 05:18:10,680 --> 05:18:13,620 we can go back to index.jsx and we're 7281 05:18:13,620 --> 05:18:15,240 going to pass in the friend 7282 05:18:15,240 --> 05:18:16,500 list 7283 05:18:16,500 --> 05:18:18,060 widget 7284 05:18:18,060 --> 05:18:20,520 close it but we're also going to add 7285 05:18:20,520 --> 05:18:24,080 the user ID property 7286 05:18:25,320 --> 05:18:27,480 underscore ID 7287 05:18:27,480 --> 05:18:29,160 and with that 7288 05:18:29,160 --> 05:18:31,200 hopefully 7289 05:18:31,200 --> 05:18:33,840 you can see our friends list perfect 7290 05:18:33,840 --> 05:18:37,080 we can remove it we can add them 7291 05:18:37,080 --> 05:18:40,920 go down add a random person we have our 7292 05:18:40,920 --> 05:18:43,340 friend list we have our ad all working 7293 05:18:43,340 --> 05:18:46,020 light and dark mode 7294 05:18:46,020 --> 05:18:49,020 everything is working as expected 7295 05:18:49,020 --> 05:18:51,480 now the only thing left is going to be 7296 05:18:51,480 --> 05:18:54,120 the profile page 7297 05:18:54,120 --> 05:18:56,340 now in our completed application if we 7298 05:18:56,340 --> 05:18:58,980 take a look we go to Steve Ralph's page 7299 05:18:58,980 --> 05:19:02,040 we can see most of everything is going 7300 05:19:02,040 --> 05:19:04,200 to be all widgets that we've already 7301 05:19:04,200 --> 05:19:06,120 created and that's the whole purpose of 7302 05:19:06,120 --> 05:19:08,820 react you can use reusable components 7303 05:19:08,820 --> 05:19:10,860 and we can reuse them for different 7304 05:19:10,860 --> 05:19:15,060 purposes so here I have this user widget 7305 05:19:15,060 --> 05:19:17,400 I have the friend list widget the my 7306 05:19:17,400 --> 05:19:18,900 post widget 7307 05:19:18,900 --> 05:19:22,260 and the post widget right here 7308 05:19:22,260 --> 05:19:24,420 so we can use pretty much everything we 7309 05:19:24,420 --> 05:19:26,340 can go to another person we can have 7310 05:19:26,340 --> 05:19:28,620 their posts we can see everyone else's 7311 05:19:28,620 --> 05:19:30,840 post as well we can like 7312 05:19:30,840 --> 05:19:33,180 we can see the comments 7313 05:19:33,180 --> 05:19:34,798 things like that 7314 05:19:34,798 --> 05:19:37,560 so everything is all set up we just need 7315 05:19:37,560 --> 05:19:40,620 to set the layout but we can reuse a lot 7316 05:19:40,620 --> 05:19:42,420 of the same components so let's actually 7317 05:19:42,420 --> 05:19:44,458 get to it 7318 05:19:44,458 --> 05:19:47,218 so if we go to scenes we're going to go 7319 05:19:47,218 --> 05:19:49,138 to profile page we've already create 7320 05:19:49,138 --> 05:19:51,660 created the layout all we have to do is 7321 05:19:51,660 --> 05:19:53,280 set this up so we're going to import a 7322 05:19:53,280 --> 05:19:54,958 number of items so we're going to import 7323 05:19:54,958 --> 05:19:57,798 box 7324 05:19:58,378 --> 05:20:00,180 use media 7325 05:20:00,180 --> 05:20:02,280 query 7326 05:20:02,280 --> 05:20:05,580 and close this close this close this 7327 05:20:05,580 --> 05:20:09,378 I'm going to import use effect 7328 05:20:09,420 --> 05:20:12,958 with use state 7329 05:20:12,958 --> 05:20:17,180 and then import use selector 7330 05:20:18,360 --> 05:20:20,458 react Redux 7331 05:20:20,458 --> 05:20:24,378 import use params 7332 05:20:24,600 --> 05:20:27,540 we're going to import navbar 7333 05:20:27,540 --> 05:20:30,120 because we need the nav bar again import 7334 05:20:30,120 --> 05:20:33,240 friend list widget 7335 05:20:33,240 --> 05:20:36,958 import my post widget 7336 05:20:36,958 --> 05:20:39,120 import 7337 05:20:39,120 --> 05:20:40,680 s 7338 05:20:40,680 --> 05:20:43,200 plural widget 7339 05:20:43,200 --> 05:20:47,660 import user widget 7340 05:20:48,180 --> 05:20:50,580 and then from here I'm going to do const 7341 05:20:50,580 --> 05:20:52,920 user 7342 05:20:52,920 --> 05:20:55,860 set user so in this case we need to set 7343 05:20:55,860 --> 05:20:59,580 the user specific to this page so we're 7344 05:20:59,580 --> 05:21:01,560 going to keep it as local state 7345 05:21:01,560 --> 05:21:04,920 and we're going to grab the user ID 7346 05:21:04,920 --> 05:21:07,260 from the URL 7347 05:21:07,260 --> 05:21:09,360 so if you have noticed so I'm going to 7348 05:21:09,360 --> 05:21:10,920 go back 7349 05:21:10,920 --> 05:21:14,760 I've noticed the user ID if I click on 7350 05:21:14,760 --> 05:21:15,540 this 7351 05:21:15,540 --> 05:21:18,958 I get a profile ID 7352 05:21:18,958 --> 05:21:21,540 right here and we've set that before 7353 05:21:21,540 --> 05:21:24,298 when we navigate to someone else's page 7354 05:21:24,298 --> 05:21:28,020 we are able to get this information and 7355 05:21:28,020 --> 05:21:31,340 use that as our user ID 7356 05:21:31,798 --> 05:21:34,320 so with that we also are going to get 7357 05:21:34,320 --> 05:21:35,820 the token as well because we're going to 7358 05:21:35,820 --> 05:21:38,718 make an API call 7359 05:21:40,020 --> 05:21:42,718 State and we're going to do state DOT 7360 05:21:42,718 --> 05:21:45,000 token 7361 05:21:45,000 --> 05:21:46,940 and we're going to do is non-mobile 7362 05:21:46,940 --> 05:21:50,940 screens we're going to grab use media 7363 05:21:50,940 --> 05:21:53,240 query 7364 05:21:53,520 --> 05:21:57,000 and we're going to pass in Min width of 7365 05:21:57,000 --> 05:22:00,500 a thousand pixel 7366 05:22:01,138 --> 05:22:02,760 and I'm going to call a function called 7367 05:22:02,760 --> 05:22:04,378 get user 7368 05:22:04,378 --> 05:22:06,000 so we're just going to get the user 7369 05:22:06,000 --> 05:22:08,100 information 7370 05:22:08,100 --> 05:22:10,260 for this page so we're going to do a 7371 05:22:10,260 --> 05:22:15,560 const response equals await fetch 7372 05:22:16,218 --> 05:22:20,360 HTTP colon slash localhost 7373 05:22:20,360 --> 05:22:24,180 3001 users slash 7374 05:22:24,180 --> 05:22:27,000 user ID we've already made this type of 7375 05:22:27,000 --> 05:22:28,680 API call V4 7376 05:22:28,680 --> 05:22:31,320 so we're just going to repeat that again 7377 05:22:31,320 --> 05:22:33,420 the method of get we're going to do 7378 05:22:33,420 --> 05:22:35,458 headers again 7379 05:22:35,458 --> 05:22:36,840 with 7380 05:22:36,840 --> 05:22:39,000 authorization 7381 05:22:39,000 --> 05:22:41,340 of Bearer 7382 05:22:41,340 --> 05:22:43,620 token 7383 05:22:43,620 --> 05:22:45,900 Dot 7384 05:22:45,900 --> 05:22:48,680 and then we're gonna 7385 05:22:48,900 --> 05:22:52,138 format the response that we get with 7386 05:22:52,138 --> 05:22:54,900 response dot Json 7387 05:22:54,900 --> 05:22:56,820 and we're going to set the user as the 7388 05:22:56,820 --> 05:22:59,218 data 7389 05:22:59,218 --> 05:23:01,200 and finally we're going to make the API 7390 05:23:01,200 --> 05:23:04,218 call using use effect 7391 05:23:04,260 --> 05:23:06,780 get user 7392 05:23:06,780 --> 05:23:10,280 passing an empty array 7393 05:23:10,560 --> 05:23:13,820 and disabling 7394 05:23:14,280 --> 05:23:16,138 the linting 7395 05:23:16,138 --> 05:23:17,820 react hooks 7396 05:23:17,820 --> 05:23:20,780 exhaustive 7397 05:23:21,900 --> 05:23:25,878 and also again if the user 7398 05:23:25,980 --> 05:23:27,620 does not exist we're going to return 7399 05:23:27,620 --> 05:23:32,480 null so we don't get any errors 7400 05:23:33,718 --> 05:23:36,480 inside of our GSX I'm going to add box 7401 05:23:36,480 --> 05:23:37,620 component 7402 05:23:37,620 --> 05:23:41,040 I'm going to add a nav bar 7403 05:23:41,040 --> 05:23:43,200 and actually what we can do is go back 7404 05:23:43,200 --> 05:23:45,860 to the home page 7405 05:23:46,440 --> 05:23:49,740 let me just copy some of this and we're 7406 05:23:49,740 --> 05:23:51,958 just going to modify it it's not exactly 7407 05:23:51,958 --> 05:23:54,600 going to be that similar but 7408 05:23:54,600 --> 05:23:56,218 some of it will be similar so we're 7409 05:23:56,218 --> 05:23:58,500 going to have two REM six percent Flex 7410 05:23:58,500 --> 05:24:00,360 blocks 7411 05:24:00,360 --> 05:24:02,218 this time we're going to have a gap of 2 7412 05:24:02,218 --> 05:24:03,600 REM 7413 05:24:03,600 --> 05:24:07,260 justify content of Center because now we 7414 05:24:07,260 --> 05:24:09,900 want it to be Center 7415 05:24:09,900 --> 05:24:11,218 uh 7416 05:24:11,218 --> 05:24:14,060 Center location 7417 05:24:14,218 --> 05:24:17,040 so this is going to be 26 percent we're 7418 05:24:17,040 --> 05:24:19,378 going to have 42 percent we're not going 7419 05:24:19,378 --> 05:24:21,718 to have a separate 7420 05:24:21,718 --> 05:24:24,920 third column 7421 05:24:26,040 --> 05:24:27,840 in here 7422 05:24:27,840 --> 05:24:29,878 Flex bases we're going to have a user 7423 05:24:29,878 --> 05:24:32,700 widget we're also going to have a box 7424 05:24:32,700 --> 05:24:37,740 a margin of 2 REM 0 let's write I'm also 7425 05:24:37,740 --> 05:24:39,660 going to have a friend 7426 05:24:39,660 --> 05:24:43,680 friendless widget of user ID equals user 7427 05:24:43,680 --> 05:24:44,520 ID 7428 05:24:44,520 --> 05:24:47,240 like so 7429 05:24:48,060 --> 05:24:50,940 this should be pretty good and similar 7430 05:24:50,940 --> 05:24:53,340 my post widget should be there except 7431 05:24:53,340 --> 05:24:56,520 this should be user dot picture path 7432 05:24:56,520 --> 05:24:58,620 then we're going to have 7433 05:24:58,620 --> 05:25:01,020 posts widget which should be pretty 7434 05:25:01,020 --> 05:25:02,520 identical 7435 05:25:02,520 --> 05:25:05,760 we're just going to set this as user ID 7436 05:25:05,760 --> 05:25:07,860 and we're just going to say this time is 7437 05:25:07,860 --> 05:25:10,560 is profile so we're just grabbing this 7438 05:25:10,560 --> 05:25:11,940 person's user 7439 05:25:11,940 --> 05:25:13,920 and then from there I'm going to create 7440 05:25:13,920 --> 05:25:15,900 copy this box so we just have a little 7441 05:25:15,900 --> 05:25:17,878 margin right there 7442 05:25:17,878 --> 05:25:21,180 and with that 7443 05:25:21,180 --> 05:25:23,820 we should be able to get the same output 7444 05:25:23,820 --> 05:25:26,878 as here on our completed app 7445 05:25:26,878 --> 05:25:29,940 but not without some errors that we have 7446 05:25:29,940 --> 05:25:33,420 to handle so ID is underscore ID is not 7447 05:25:33,420 --> 05:25:35,040 defined 7448 05:25:35,040 --> 05:25:38,458 okay so if I look over here this 7449 05:25:38,458 --> 05:25:41,340 is not correct because it's not defined 7450 05:25:41,340 --> 05:25:43,320 but also what's the next error picture 7451 05:25:43,320 --> 05:25:45,900 path is not defined so if I go over here 7452 05:25:45,900 --> 05:25:48,718 this would be user dot picture path 7453 05:25:48,718 --> 05:25:51,480 and I think 7454 05:25:51,480 --> 05:25:53,760 that should cover all of it 7455 05:25:53,760 --> 05:25:56,940 so if I go here click on Steve Ralph 7456 05:25:56,940 --> 05:25:59,580 and I can see this is working as 7457 05:25:59,580 --> 05:26:02,100 expected we have friends we have all our 7458 05:26:02,100 --> 05:26:04,320 friends we can go back and go to the 7459 05:26:04,320 --> 05:26:06,360 main page we can go to someone else's 7460 05:26:06,360 --> 05:26:09,240 profile same with this 7461 05:26:09,240 --> 05:26:11,520 everything is working as expected 7462 05:26:11,520 --> 05:26:12,900 perfect 7463 05:26:12,900 --> 05:26:16,560 and with that that is everything in our 7464 05:26:16,560 --> 05:26:19,980 application this was quite the complete 7465 05:26:19,980 --> 05:26:22,138 package we have done everything from 7466 05:26:22,138 --> 05:26:26,820 back in to front end using mirn setting 7467 05:26:26,820 --> 05:26:29,040 up our databases setting up 7468 05:26:29,040 --> 05:26:32,760 authentication with JWT tokens we have 7469 05:26:32,760 --> 05:26:35,160 set up the front end with responsive 7470 05:26:35,160 --> 05:26:36,718 layouts 7471 05:26:36,718 --> 05:26:39,480 we have responsive layouts 7472 05:26:39,480 --> 05:26:42,420 on smaller screens full screens things 7473 05:26:42,420 --> 05:26:45,000 like that we also have light and dark 7474 05:26:45,000 --> 05:26:48,060 mode we can add friends remove friends 7475 05:26:48,060 --> 05:26:52,080 we can like a user's post dislike them 7476 05:26:52,080 --> 05:26:55,500 we have also the comments list we have 7477 05:26:55,500 --> 05:26:58,680 information all coming from the back end 7478 05:26:58,680 --> 05:27:01,080 so we're not using actual fake data that 7479 05:27:01,080 --> 05:27:03,060 we're actually using real data that we 7480 05:27:03,060 --> 05:27:06,060 are putting into the database we 7481 05:27:06,060 --> 05:27:08,700 even have a page where you can go for 7482 05:27:08,700 --> 05:27:12,660 persons users or a person's profile page 7483 05:27:12,660 --> 05:27:14,458 and grab all the information that they 7484 05:27:14,458 --> 05:27:17,878 have and see what they have there we can 7485 05:27:17,878 --> 05:27:21,480 even create our own posts as well and we 7486 05:27:21,480 --> 05:27:24,958 can register a new user logging in with 7487 05:27:24,958 --> 05:27:28,020 validation we have done everything from 7488 05:27:28,020 --> 05:27:30,958 complete scratch I'm very glad that you 7489 05:27:30,958 --> 05:27:32,580 are able to get through this entire 7490 05:27:32,580 --> 05:27:35,638 application it's not easy to do all of 7491 05:27:35,638 --> 05:27:38,040 this work this is a lot of information 7492 05:27:38,040 --> 05:27:41,340 and hard it's a hard project because it 7493 05:27:41,340 --> 05:27:43,440 is doing everything this is complete 7494 05:27:43,440 --> 05:27:46,080 from back end to front end see how they 7495 05:27:46,080 --> 05:27:48,420 connect see how they work together so 7496 05:27:48,420 --> 05:27:51,240 you have done a great job getting up to 7497 05:27:51,240 --> 05:27:53,280 this point now if you have any questions 7498 05:27:53,280 --> 05:27:55,740 about this project you can write a 7499 05:27:55,740 --> 05:27:57,780 comment below see if there's anything 7500 05:27:57,780 --> 05:27:59,760 you like and tell me if there's anything 7501 05:27:59,760 --> 05:28:03,000 you want me to build for next time but 7502 05:28:03,000 --> 05:28:05,700 also please if you do make sure to like 7503 05:28:05,700 --> 05:28:08,218 comment and subscribe if you like this 7504 05:28:08,218 --> 05:28:10,980 content so I can see you next time with 7505 05:28:10,980 --> 05:28:15,620 the project that you want to see next 485506

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.