All language subtitles for [English (auto-generated)] Build and Deploy a Full Stack MERN Application With CRUD, Auth, and Charts Using Refine [DownSub.com]
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,319 --> 00:00:04,799
full stack myrn application the Pinnacle
2
00:00:04,799 --> 00:00:07,680
of web development yep you heard that
3
00:00:07,680 --> 00:00:10,320
right today you'll learn how to build
4
00:00:10,320 --> 00:00:14,580
and deploy a full stack man application
5
00:00:14,580 --> 00:00:17,820
with modern material design a fully
6
00:00:17,820 --> 00:00:19,920
functional dashboard a property
7
00:00:19,920 --> 00:00:23,100
management page and a user's page both
8
00:00:23,100 --> 00:00:25,260
connected to our database and the
9
00:00:25,260 --> 00:00:27,539
profile page that connects the two this
10
00:00:27,539 --> 00:00:30,420
video is the updated full stack mern
11
00:00:30,420 --> 00:00:33,180
course you've all been waiting for this
12
00:00:33,180 --> 00:00:35,399
video is perfect for you if you want to
13
00:00:35,399 --> 00:00:38,040
learn how to convert a figma design into
14
00:00:38,040 --> 00:00:40,739
a fully functional website dive into the
15
00:00:40,739 --> 00:00:43,140
world of full stack development using
16
00:00:43,140 --> 00:00:45,420
the most popular stack out there and
17
00:00:45,420 --> 00:00:47,820
master crowd principles that allow you
18
00:00:47,820 --> 00:00:50,760
to create read update and delete
19
00:00:50,760 --> 00:00:53,940
documents our application will have a
20
00:00:53,940 --> 00:00:55,860
properties page where you can read our
21
00:00:55,860 --> 00:00:57,780
properties and you will also be able to
22
00:00:57,780 --> 00:01:00,180
create a property and finally on our Pro
23
00:01:00,180 --> 00:01:02,399
property detail page you'll be able to
24
00:01:02,399 --> 00:01:05,099
update and delete it that means if you
25
00:01:05,099 --> 00:01:06,780
learn how to build this application
26
00:01:06,780 --> 00:01:09,360
you'll be able to make the most complex
27
00:01:09,360 --> 00:01:12,060
and modern applications out there if you
28
00:01:12,060 --> 00:01:14,700
think about it every app is a crud app
29
00:01:14,700 --> 00:01:18,979
in a way create read update and delete
30
00:01:18,979 --> 00:01:24,960
posts images articles files messages and
31
00:01:24,960 --> 00:01:27,540
more you get the point after you develop
32
00:01:27,540 --> 00:01:29,460
this app I'll even teach you how to
33
00:01:29,460 --> 00:01:31,320
deploy to the Internet so you can share
34
00:01:31,320 --> 00:01:33,299
it with your friends potential employers
35
00:01:33,299 --> 00:01:35,880
and put it on your portfolio to get a
36
00:01:35,880 --> 00:01:38,820
job you might be wondering what are the
37
00:01:38,820 --> 00:01:40,860
prerequisites for building such a
38
00:01:40,860 --> 00:01:43,860
fantastic web application you only need
39
00:01:43,860 --> 00:01:46,920
a solid understanding of react a basic
40
00:01:46,920 --> 00:01:49,680
understanding of node and mongodb can be
41
00:01:49,680 --> 00:01:51,899
helpful but they're not a requirement
42
00:01:51,899 --> 00:01:54,299
we're going to start simple and then
43
00:01:54,299 --> 00:01:56,579
move to more complex topics as we go
44
00:01:56,579 --> 00:01:58,920
I'll explain every step of the way
45
00:01:58,920 --> 00:02:01,500
alongside building this application you
46
00:02:01,500 --> 00:02:03,780
learn how to use the most in-demand
47
00:02:03,780 --> 00:02:06,920
Technologies today node.js Express
48
00:02:06,920 --> 00:02:10,258
mongodb and the reactions that together
49
00:02:10,258 --> 00:02:13,200
form the powerful Marine stack material
50
00:02:13,200 --> 00:02:16,319
UI the most popular UI component kit
51
00:02:16,319 --> 00:02:19,319
nowadays typescript yep you heard that
52
00:02:19,319 --> 00:02:21,420
right we'll be using typescript on this
53
00:02:21,420 --> 00:02:23,580
project and no previous typescript
54
00:02:23,580 --> 00:02:25,620
knowledge is required you'll learn how
55
00:02:25,620 --> 00:02:28,260
to transform a figma design into a fully
56
00:02:28,260 --> 00:02:30,480
functioning website using cloudinery
57
00:02:30,480 --> 00:02:33,120
you'll also learn how to optimize images
58
00:02:33,120 --> 00:02:36,360
and store them on the cloud and using
59
00:02:36,360 --> 00:02:38,760
Google auth you'll provide your users
60
00:02:38,760 --> 00:02:41,340
with a quick and easy way for them to
61
00:02:41,340 --> 00:02:44,700
log in and register and most importantly
62
00:02:44,700 --> 00:02:48,300
you'll learn how to build react based
63
00:02:48,300 --> 00:02:50,640
crud applications incredibly easily
64
00:02:50,640 --> 00:02:54,300
using refine have you ever wondered if
65
00:02:54,300 --> 00:02:55,920
there is a tool that will set up
66
00:02:55,920 --> 00:02:57,720
everything you need for a website like
67
00:02:57,720 --> 00:03:00,060
authentication State Management and
68
00:03:00,060 --> 00:03:02,280
routing while still giving you the
69
00:03:02,280 --> 00:03:04,620
freedom to customize it that's exactly
70
00:03:04,620 --> 00:03:07,760
what refine is refine is a headless
71
00:03:07,760 --> 00:03:10,500
react-based framework for Rapid web
72
00:03:10,500 --> 00:03:12,959
application development now what does it
73
00:03:12,959 --> 00:03:15,180
mean for a tool to be headless headless
74
00:03:15,180 --> 00:03:17,459
is the most popular development approach
75
00:03:17,459 --> 00:03:20,040
nowadays so far it has been limited to
76
00:03:20,040 --> 00:03:22,080
the back end with great examples like
77
00:03:22,080 --> 00:03:25,319
strappy refine found a way of building a
78
00:03:25,319 --> 00:03:27,360
headless structure Logic on the
79
00:03:27,360 --> 00:03:29,400
front-end side it offers both the
80
00:03:29,400 --> 00:03:32,459
freedom to start from scratch or use any
81
00:03:32,459 --> 00:03:34,440
UI framework of your choice with
82
00:03:34,440 --> 00:03:37,019
built-in support for material UI and
83
00:03:37,019 --> 00:03:40,620
design chakra UI and maintain refine
84
00:03:40,620 --> 00:03:42,840
provides plenty of features that make
85
00:03:42,840 --> 00:03:44,940
your app ready to ship within minutes
86
00:03:44,940 --> 00:03:47,819
one of the biggest features is zero
87
00:03:47,819 --> 00:03:50,879
config one minute setup with a single
88
00:03:50,879 --> 00:03:53,640
CLI command and it's not just the UI
89
00:03:53,640 --> 00:03:55,680
reframe provides connections to more
90
00:03:55,680 --> 00:03:58,319
than 15 pack-end Services making it easy
91
00:03:58,319 --> 00:04:01,739
to set up and use other than that refine
92
00:04:01,739 --> 00:04:05,040
also offers SSR support with nextgs or
93
00:04:05,040 --> 00:04:08,159
remix and auto-generated crud uis from
94
00:04:08,159 --> 00:04:10,439
your API data structure and of course
95
00:04:10,439 --> 00:04:12,180
there are many additional features as
96
00:04:12,180 --> 00:04:14,400
you can see here one of the best things
97
00:04:14,400 --> 00:04:16,858
about refine is its excellent Discord
98
00:04:16,858 --> 00:04:19,320
Community they are always ready to help
99
00:04:19,320 --> 00:04:21,600
so you can get support and resolve your
100
00:04:21,600 --> 00:04:24,360
bugs quickly refine also has a strong
101
00:04:24,360 --> 00:04:27,360
presence in GitHub with over 7000 Stars
102
00:04:27,360 --> 00:04:30,000
their development team is very active
103
00:04:30,000 --> 00:04:32,400
and quickly resolves issues reported in
104
00:04:32,400 --> 00:04:34,919
the platform and the download stats for
105
00:04:34,919 --> 00:04:37,740
refine are also increasing day by day
106
00:04:37,740 --> 00:04:40,139
which is a testament to its popularity
107
00:04:40,139 --> 00:04:43,320
and Effectiveness among developers with
108
00:04:43,320 --> 00:04:44,900
its headless design by approach
109
00:04:44,900 --> 00:04:47,460
excellent community support and strong
110
00:04:47,460 --> 00:04:49,979
presence on GitHub refine is a great
111
00:04:49,979 --> 00:04:51,720
choice for anyone looking to develop
112
00:04:51,720 --> 00:04:54,419
apps quickly and easily and that's
113
00:04:54,419 --> 00:04:57,240
exactly what I'll teach you today in
114
00:04:57,240 --> 00:04:59,940
this full stack course alongside this
115
00:04:59,940 --> 00:05:03,240
video I've also prepared a complete myrn
116
00:05:03,240 --> 00:05:05,580
roadmap and a cheat sheet that covers
117
00:05:05,580 --> 00:05:07,500
everything you need to become a
118
00:05:07,500 --> 00:05:10,259
fantastic Marine developer the guide has
119
00:05:10,259 --> 00:05:12,600
an entire step-by-step burn Mastery
120
00:05:12,600 --> 00:05:14,940
roadmap prerequisites helpful
121
00:05:14,940 --> 00:05:17,280
illustrations and even learn project
122
00:05:17,280 --> 00:05:19,740
ideas that you can build after watching
123
00:05:19,740 --> 00:05:22,139
this video you can download the ultimate
124
00:05:22,139 --> 00:05:24,240
guide and use it as a reference on your
125
00:05:24,240 --> 00:05:26,160
web development Journey whenever you're
126
00:05:26,160 --> 00:05:28,860
unsure what to learn next the link to
127
00:05:28,860 --> 00:05:30,720
the comprehensive guide will be in the
128
00:05:30,720 --> 00:05:33,419
description if this video reaches 30 000
129
00:05:33,419 --> 00:05:35,940
likes I'm recording more learn videos
130
00:05:35,940 --> 00:05:38,940
with that said let's dive right into the
131
00:05:38,940 --> 00:05:41,759
code as we always do on JavaScript
132
00:05:41,759 --> 00:05:44,100
Mastery we're going to start from bare
133
00:05:44,100 --> 00:05:46,919
Beginnings by opening an empty Visual
134
00:05:46,919 --> 00:05:49,680
Studio code window and creating a new
135
00:05:49,680 --> 00:05:52,740
folder on our desktop in this case we
136
00:05:52,740 --> 00:05:57,000
can call it refine underscore dashboard
137
00:05:57,000 --> 00:05:59,940
finally drag and drop that empty folder
138
00:05:59,940 --> 00:06:01,820
into your empty Visual Studio code
139
00:06:01,820 --> 00:06:04,740
inside of our Visual Studio code you can
140
00:06:04,740 --> 00:06:07,320
go to view and then terminal this is
141
00:06:07,320 --> 00:06:09,539
going to open up an empty integrated
142
00:06:09,539 --> 00:06:12,060
Visual Studio code terminal inside of
143
00:06:12,060 --> 00:06:15,780
here we can run one single command npm
144
00:06:15,780 --> 00:06:17,180
create
145
00:06:17,180 --> 00:06:21,780
refine Dash app at latest and then
146
00:06:21,780 --> 00:06:24,000
client like this
147
00:06:24,000 --> 00:06:26,280
now we're asked a question whether we
148
00:06:26,280 --> 00:06:28,919
want to install that package and yes we
149
00:06:28,919 --> 00:06:30,419
do
150
00:06:30,419 --> 00:06:32,880
once it is installed it's going to open
151
00:06:32,880 --> 00:06:35,759
up a CLI that's going to ask us all the
152
00:06:35,759 --> 00:06:38,580
questions it needs to know to initialize
153
00:06:38,580 --> 00:06:41,759
our application and there we go first we
154
00:06:41,759 --> 00:06:44,280
need to choose a project template in
155
00:06:44,280 --> 00:06:47,539
this case let's go with create react app
156
00:06:47,539 --> 00:06:49,919
then what would you like to name your
157
00:06:49,919 --> 00:06:51,840
project in this case we can name it
158
00:06:51,840 --> 00:06:53,819
client since we'll be using it on the
159
00:06:53,819 --> 00:06:55,080
client side
160
00:06:55,080 --> 00:06:57,780
then we need to choose our backend
161
00:06:57,780 --> 00:07:00,180
service in this case we'll be using a
162
00:07:00,180 --> 00:07:02,819
rest API as you will create your own
163
00:07:02,819 --> 00:07:06,960
backend API then it's asking us which UI
164
00:07:06,960 --> 00:07:09,120
framework we want to use and in this
165
00:07:09,120 --> 00:07:10,500
case we're going to proceed with
166
00:07:10,500 --> 00:07:13,860
material UI now it's asking us if we
167
00:07:13,860 --> 00:07:15,960
want to add some example Pages we're
168
00:07:15,960 --> 00:07:17,940
going to click yes do we want to
169
00:07:17,940 --> 00:07:20,400
customize the material UI theme we're
170
00:07:20,400 --> 00:07:22,800
going to also say yes do you want to
171
00:07:22,800 --> 00:07:24,900
customize the material UI layout we're
172
00:07:24,900 --> 00:07:26,940
going to also say yes
173
00:07:26,940 --> 00:07:29,099
do you want to add dark mode support
174
00:07:29,099 --> 00:07:31,319
we're going to say yes to that as well
175
00:07:31,319 --> 00:07:34,380
do you need any authentication logic yes
176
00:07:34,380 --> 00:07:37,800
we'll be using Google do you need i18n
177
00:07:37,800 --> 00:07:40,440
support in this case we won't be using
178
00:07:40,440 --> 00:07:43,440
that but it's good to know it exists do
179
00:07:43,440 --> 00:07:45,900
you want to add k-bar command interface
180
00:07:45,900 --> 00:07:47,759
support in this case we won't be needing
181
00:07:47,759 --> 00:07:49,919
it now we need to choose a package
182
00:07:49,919 --> 00:07:52,560
manager you can use npm or yarn in this
183
00:07:52,560 --> 00:07:55,139
case I'm going to proceed with mpm and
184
00:07:55,139 --> 00:07:58,020
we can share our choices anonymously and
185
00:07:58,020 --> 00:08:00,599
with that done refine is going to take
186
00:08:00,599 --> 00:08:03,660
all the answers we put in here and it's
187
00:08:03,660 --> 00:08:06,000
going to initialize the perfect starter
188
00:08:06,000 --> 00:08:08,819
repository let's give it a second and
189
00:08:08,819 --> 00:08:10,500
I'll be right back
190
00:08:10,500 --> 00:08:13,740
and there we go success created client
191
00:08:13,740 --> 00:08:17,220
ad client we can see our entire file and
192
00:08:17,220 --> 00:08:19,560
folder structure right here but most
193
00:08:19,560 --> 00:08:21,120
importantly we can go to our
194
00:08:21,120 --> 00:08:23,039
package.json to check the install
195
00:08:23,039 --> 00:08:26,280
dependencies as you can see we have a
196
00:08:26,280 --> 00:08:28,319
lot of refined packages which are going
197
00:08:28,319 --> 00:08:30,840
to make all of this possible but we're
198
00:08:30,840 --> 00:08:32,760
going to also add a couple of packages
199
00:08:32,760 --> 00:08:36,419
on our own so down below we can now CD
200
00:08:36,419 --> 00:08:39,779
into client like this and then we can
201
00:08:39,779 --> 00:08:42,899
type npm install and then we can add
202
00:08:42,899 --> 00:08:46,020
Apex charts we're going to use these for
203
00:08:46,020 --> 00:08:47,820
those beautiful charts on the dashboard
204
00:08:47,820 --> 00:08:52,920
we also need react Dash Apex charts
205
00:08:52,920 --> 00:08:56,880
and believe it or not that is it refine
206
00:08:56,880 --> 00:08:58,620
provided us with everything else we're
207
00:08:58,620 --> 00:09:00,839
gonna need to create a full stack marine
208
00:09:00,839 --> 00:09:02,940
application so for now simply press
209
00:09:02,940 --> 00:09:05,459
enter let's wait for our charts to be
210
00:09:05,459 --> 00:09:08,160
installed and then we can explore our
211
00:09:08,160 --> 00:09:09,540
Repository
212
00:09:09,540 --> 00:09:11,580
so what we can do is close the packet
213
00:09:11,580 --> 00:09:13,800
Json inside of the packet Json let's
214
00:09:13,800 --> 00:09:15,600
check out the command to run our
215
00:09:15,600 --> 00:09:18,600
application that's going to be mpm run
216
00:09:18,600 --> 00:09:21,779
Dev so inside of our client let's run
217
00:09:21,779 --> 00:09:24,600
npm run Dev and let's check it out in
218
00:09:24,600 --> 00:09:25,440
action
219
00:09:25,440 --> 00:09:28,800
and as soon as the website opens up you
220
00:09:28,800 --> 00:09:31,140
will be greeted with a series of errors
221
00:09:31,140 --> 00:09:33,720
but no worries these are really simple
222
00:09:33,720 --> 00:09:36,720
to fix we just need to import the title
223
00:09:36,720 --> 00:09:40,320
cider in the layout in our components so
224
00:09:40,320 --> 00:09:42,180
just go to source
225
00:09:42,180 --> 00:09:43,920
components
226
00:09:43,920 --> 00:09:48,000
layout and then index.ts inside of here
227
00:09:48,000 --> 00:09:49,620
we're currently exporting just the
228
00:09:49,620 --> 00:09:52,019
header but we need to export everything
229
00:09:52,019 --> 00:09:53,700
from
230
00:09:53,700 --> 00:09:57,000
dot slash layout as well and then we're
231
00:09:57,000 --> 00:09:58,500
going to duplicate this two more times
232
00:09:58,500 --> 00:10:00,959
and we're going to do the cider
233
00:10:00,959 --> 00:10:03,300
and we're gonna do the title
234
00:10:03,300 --> 00:10:05,519
with that done if we now go back to the
235
00:10:05,519 --> 00:10:08,399
website you can see we have a fully
236
00:10:08,399 --> 00:10:11,040
fledged and fully functional dashboard
237
00:10:11,040 --> 00:10:14,580
available right here isn't that great we
238
00:10:14,580 --> 00:10:17,339
can also log out and this all has been
239
00:10:17,339 --> 00:10:19,560
created for us but don't worry we're
240
00:10:19,560 --> 00:10:21,420
going to start with everything from
241
00:10:21,420 --> 00:10:24,540
scratch so now we can log out and you're
242
00:10:24,540 --> 00:10:26,700
gonna see a page that looks like this
243
00:10:26,700 --> 00:10:28,800
of course we want to modify it to fit
244
00:10:28,800 --> 00:10:31,920
your application so the login is going
245
00:10:31,920 --> 00:10:33,360
to be the first thing we're going to
246
00:10:33,360 --> 00:10:35,880
focus on to start with the login we can
247
00:10:35,880 --> 00:10:39,000
close our index we can go to our pages
248
00:10:39,000 --> 00:10:41,339
and the login is going to be the only
249
00:10:41,339 --> 00:10:44,339
page that is there right now inside of
250
00:10:44,339 --> 00:10:45,839
there we're importing things like use
251
00:10:45,839 --> 00:10:48,420
effect use ref and there's also a
252
00:10:48,420 --> 00:10:50,700
special hook called use login which
253
00:10:50,700 --> 00:10:53,279
we're going to utilize later on we also
254
00:10:53,279 --> 00:10:56,579
have some imports from Material UI great
255
00:10:56,579 --> 00:10:58,920
with that said we can start modifying
256
00:10:58,920 --> 00:11:01,560
our login component for that we're going
257
00:11:01,560 --> 00:11:03,899
to have to import our application logo
258
00:11:03,899 --> 00:11:07,440
which we don't yet have so now might be
259
00:11:07,440 --> 00:11:09,779
the best time for me to provide you with
260
00:11:09,779 --> 00:11:12,420
all the files and assets that you'll be
261
00:11:12,420 --> 00:11:14,220
able to use throughout the entire
262
00:11:14,220 --> 00:11:15,860
process of building this application
263
00:11:15,860 --> 00:11:19,079
down in the description you can find a
264
00:11:19,079 --> 00:11:22,620
link to a zipped assets folder simply
265
00:11:22,620 --> 00:11:25,140
unzip it and then paste it right here
266
00:11:25,140 --> 00:11:27,180
inside of your source
267
00:11:27,180 --> 00:11:28,860
that's going to look something like this
268
00:11:28,860 --> 00:11:31,500
inside of there you'll see an index.js
269
00:11:31,500 --> 00:11:34,019
exporting those two logos and then two
270
00:11:34,019 --> 00:11:36,300
different versions of those logos in the
271
00:11:36,300 --> 00:11:38,519
SVG format another thing that you can
272
00:11:38,519 --> 00:11:40,560
get from the description and that's
273
00:11:40,560 --> 00:11:42,420
going to be in the GitHub gist down
274
00:11:42,420 --> 00:11:45,720
below are the links to a specific font
275
00:11:45,720 --> 00:11:48,300
we'll be using across our application so
276
00:11:48,300 --> 00:11:50,420
let's go to our public
277
00:11:50,420 --> 00:11:53,700
index.html and then inside of here just
278
00:11:53,700 --> 00:11:56,160
below the theme color you can add those
279
00:11:56,160 --> 00:11:58,079
three links that you can find in the
280
00:11:58,079 --> 00:12:00,899
GitHub just down below below that in
281
00:12:00,899 --> 00:12:03,300
that same GitHub just below you can also
282
00:12:03,300 --> 00:12:07,200
find the index.css file so right in the
283
00:12:07,200 --> 00:12:10,320
source you can create a new index.css
284
00:12:10,320 --> 00:12:12,600
file and then you can simply copy and
285
00:12:12,600 --> 00:12:15,540
paste the styles from the GitHub gist
286
00:12:15,540 --> 00:12:17,700
as you can see these are simply some
287
00:12:17,700 --> 00:12:20,399
media queries positionings of cards and
288
00:12:20,399 --> 00:12:22,560
setting up the font family another thing
289
00:12:22,560 --> 00:12:25,140
we'll be using in our application is the
290
00:12:25,140 --> 00:12:26,700
constants folder so let's create
291
00:12:26,700 --> 00:12:28,260
constants
292
00:12:28,260 --> 00:12:31,940
and then inside of it let's create a new
293
00:12:31,940 --> 00:12:35,220
index.ts file the constants are also
294
00:12:35,220 --> 00:12:36,839
going to be in the GitHub just down
295
00:12:36,839 --> 00:12:38,820
below and as you can see this is just
296
00:12:38,820 --> 00:12:41,880
about 30 lines of simple property
297
00:12:41,880 --> 00:12:44,459
referrals info things like title
298
00:12:44,459 --> 00:12:47,220
percentage and color for one of the
299
00:12:47,220 --> 00:12:49,620
charts we'll be using I didn't want all
300
00:12:49,620 --> 00:12:51,540
of you to type this by hand because we
301
00:12:51,540 --> 00:12:53,279
have more important things to focus on
302
00:12:53,279 --> 00:12:55,019
another thing you'll have to get from
303
00:12:55,019 --> 00:12:57,120
that same GitHub gist is going to be the
304
00:12:57,120 --> 00:13:00,120
code for one of the utility functions so
305
00:13:00,120 --> 00:13:02,519
inside of utils you can create a new
306
00:13:02,519 --> 00:13:04,860
file called validate
307
00:13:04,860 --> 00:13:09,120
form dot TS you can simply copy and
308
00:13:09,120 --> 00:13:11,940
paste it right here this is a file
309
00:13:11,940 --> 00:13:13,800
that's going to check if we have
310
00:13:13,800 --> 00:13:15,839
properly entered all of the properties
311
00:13:15,839 --> 00:13:18,300
again this isn't so complicated
312
00:13:18,300 --> 00:13:20,700
logically but it takes a lot of time to
313
00:13:20,700 --> 00:13:22,800
write out so I simply provided it here
314
00:13:22,800 --> 00:13:25,019
for you so we can focus on the Marine
315
00:13:25,019 --> 00:13:27,480
stack Logic on top of that below the
316
00:13:27,480 --> 00:13:29,880
assets there's also going to be an
317
00:13:29,880 --> 00:13:32,760
interfaces zipped folder we need the
318
00:13:32,760 --> 00:13:34,440
interfaces because we're using
319
00:13:34,440 --> 00:13:37,399
typescript this is going to help our IDE
320
00:13:37,399 --> 00:13:40,260
know which specific properties our
321
00:13:40,260 --> 00:13:42,839
objects have so you can delete the
322
00:13:42,839 --> 00:13:44,880
current interfaces folder
323
00:13:44,880 --> 00:13:47,700
unzip the one link below and then simply
324
00:13:47,700 --> 00:13:50,160
paste it right here there you'll be able
325
00:13:50,160 --> 00:13:52,920
to see that we have our Google so we can
326
00:13:52,920 --> 00:13:54,660
see what do we have once the user logs
327
00:13:54,660 --> 00:13:57,600
in but we also have additional props for
328
00:13:57,600 --> 00:14:00,839
some charts for our properties for our
329
00:14:00,839 --> 00:14:03,839
agents and so on later on we're going to
330
00:14:03,839 --> 00:14:06,180
dive deeper into this to explain how
331
00:14:06,180 --> 00:14:08,880
these properties correlate to our actual
332
00:14:08,880 --> 00:14:11,220
objects and the last thing you'll have
333
00:14:11,220 --> 00:14:12,959
to get from that GitHub just down below
334
00:14:12,959 --> 00:14:15,660
and I promise this is the last one is
335
00:14:15,660 --> 00:14:18,660
the config file for our charts so inside
336
00:14:18,660 --> 00:14:21,000
of the components folder we can create a
337
00:14:21,000 --> 00:14:23,459
new folder called charts
338
00:14:23,459 --> 00:14:27,019
inside of there we can create a new
339
00:14:27,019 --> 00:14:31,380
chart.config DOT TS file and inside of
340
00:14:31,380 --> 00:14:33,240
there you can paste that config file
341
00:14:33,240 --> 00:14:35,160
this is just going to simplify the
342
00:14:35,160 --> 00:14:37,800
process of creating our charts and with
343
00:14:37,800 --> 00:14:40,079
that said we are ready to dive into
344
00:14:40,079 --> 00:14:43,680
creating our login page which we started
345
00:14:43,680 --> 00:14:46,980
in the first place great now we have the
346
00:14:46,980 --> 00:14:49,100
access to our logo so we can import
347
00:14:49,100 --> 00:14:51,839
that's going to be a Riga which is the
348
00:14:51,839 --> 00:14:54,959
name of our application from dot slash
349
00:14:54,959 --> 00:14:58,139
assets there we go now as you can see
350
00:14:58,139 --> 00:14:59,820
the Google button has already been
351
00:14:59,820 --> 00:15:01,740
created for us so we don't have to do
352
00:15:01,740 --> 00:15:04,440
anything there but right here we need to
353
00:15:04,440 --> 00:15:07,160
enter our client ID coming from Google
354
00:15:07,160 --> 00:15:10,320
so now I'm going to show you how to get
355
00:15:10,320 --> 00:15:14,959
your client ID first go to
356
00:15:14,959 --> 00:15:17,160
console.cloud.google.com the link is
357
00:15:17,160 --> 00:15:19,560
going to be down in the description then
358
00:15:19,560 --> 00:15:21,899
on top you'll have to create a new
359
00:15:21,899 --> 00:15:24,839
project so just click right here and
360
00:15:24,839 --> 00:15:27,540
then click create new project let's name
361
00:15:27,540 --> 00:15:30,000
our project yariga or you can do real
362
00:15:30,000 --> 00:15:32,699
estate or refine whatever you prefer and
363
00:15:32,699 --> 00:15:35,040
let's click create our project is being
364
00:15:35,040 --> 00:15:37,380
created as we speak this process usually
365
00:15:37,380 --> 00:15:39,240
takes just a couple of seconds
366
00:15:39,240 --> 00:15:41,820
and as soon as it has been created you
367
00:15:41,820 --> 00:15:43,560
can click select project
368
00:15:43,560 --> 00:15:47,279
go to the navigation menu and click apis
369
00:15:47,279 --> 00:15:48,720
and services
370
00:15:48,720 --> 00:15:51,480
great now that we're here the first
371
00:15:51,480 --> 00:15:53,880
thing we'll have to do is to go to oauth
372
00:15:53,880 --> 00:15:56,519
consent screen there you can choose
373
00:15:56,519 --> 00:15:59,399
external you can enter your app name I'm
374
00:15:59,399 --> 00:16:01,860
gonna do your Riga you can do refine or
375
00:16:01,860 --> 00:16:03,660
whatever and then you can choose your
376
00:16:03,660 --> 00:16:04,620
email
377
00:16:04,620 --> 00:16:06,959
after that you can scroll all the way
378
00:16:06,959 --> 00:16:10,260
down enter your email one more time in
379
00:16:10,260 --> 00:16:12,120
this case that's going to be a developer
380
00:16:12,120 --> 00:16:14,880
email but that's the same for us and
381
00:16:14,880 --> 00:16:18,440
then you can save and continue
382
00:16:18,839 --> 00:16:21,420
the second step is to add the Scopes we
383
00:16:21,420 --> 00:16:24,180
can save and continue we can save and
384
00:16:24,180 --> 00:16:26,940
continue for users and we have our
385
00:16:26,940 --> 00:16:29,300
summary
386
00:16:29,639 --> 00:16:32,940
now from here we can go to credentials
387
00:16:32,940 --> 00:16:35,459
and then we can create credential
388
00:16:35,459 --> 00:16:39,060
let's create a new oauth client ID we
389
00:16:39,060 --> 00:16:41,220
can choose our application type that's
390
00:16:41,220 --> 00:16:43,320
going to be a web application
391
00:16:43,320 --> 00:16:46,620
app name is going to be a Riga
392
00:16:46,620 --> 00:16:48,660
and then we can add authorized
393
00:16:48,660 --> 00:16:51,839
JavaScript Origins so let's add a URI
394
00:16:51,839 --> 00:16:54,720
I'm going to do HTTP colon forward slash
395
00:16:54,720 --> 00:16:58,800
forward slash localhost 3000 let's copy
396
00:16:58,800 --> 00:17:01,920
it let's also add localhost
397
00:17:01,920 --> 00:17:06,720
without the column 3000 to be safe
398
00:17:06,720 --> 00:17:08,640
and then we're going to add authorize
399
00:17:08,640 --> 00:17:11,280
the redirect Uris which are going to be
400
00:17:11,280 --> 00:17:15,660
the same localhost 3000 and localhost
401
00:17:15,660 --> 00:17:18,299
and with that we can click create
402
00:17:18,299 --> 00:17:20,099
now it says right here that it might
403
00:17:20,099 --> 00:17:22,079
take five minutes for these to take
404
00:17:22,079 --> 00:17:24,419
effect but we can immediately see our
405
00:17:24,419 --> 00:17:27,119
client ID right here I'm going to copy
406
00:17:27,119 --> 00:17:27,839
it
407
00:17:27,839 --> 00:17:30,240
and we can go back to our application we
408
00:17:30,240 --> 00:17:32,640
can of course just add it right here but
409
00:17:32,640 --> 00:17:34,799
that is not the best practice and here
410
00:17:34,799 --> 00:17:36,240
in JavaScript Master read the best
411
00:17:36,240 --> 00:17:38,340
practices are the only things we teach
412
00:17:38,340 --> 00:17:41,760
so what you can do is go to your file
413
00:17:41,760 --> 00:17:44,760
explorer collapse everything and then
414
00:17:44,760 --> 00:17:47,100
inside of the client you can create a
415
00:17:47,100 --> 00:17:50,460
new file called dot EnV this is going to
416
00:17:50,460 --> 00:17:53,100
store our environment variables inside
417
00:17:53,100 --> 00:17:55,080
of there you can create a new variable
418
00:17:55,080 --> 00:17:58,140
called react underscore app underscore
419
00:17:58,140 --> 00:18:01,260
Google underscore client underscore ID
420
00:18:01,260 --> 00:18:03,900
and then you can make that equal to this
421
00:18:03,900 --> 00:18:05,940
key that we just copied
422
00:18:05,940 --> 00:18:07,799
that's going to look something like this
423
00:18:07,799 --> 00:18:11,580
and now inside of her login.tsx instead
424
00:18:11,580 --> 00:18:13,080
of just typing it manually right here
425
00:18:13,080 --> 00:18:15,919
for everybody to see you can say
426
00:18:15,919 --> 00:18:19,380
process.env dot react underscore app
427
00:18:19,380 --> 00:18:21,600
underscore Google others for client
428
00:18:21,600 --> 00:18:25,200
underscore ID and we can save it now for
429
00:18:25,200 --> 00:18:26,820
the changes to take effect we have to
430
00:18:26,820 --> 00:18:30,179
reload our terminal so press Ctrl c y
431
00:18:30,179 --> 00:18:33,360
and then simply rerun it by running npm
432
00:18:33,360 --> 00:18:36,539
run Dev and with that we should be back
433
00:18:36,539 --> 00:18:39,660
on our localhost 3000. now we can
434
00:18:39,660 --> 00:18:42,000
continue setting up our login function
435
00:18:42,000 --> 00:18:44,580
and finally now that we have our own
436
00:18:44,580 --> 00:18:47,100
Google client ID we can scroll down and
437
00:18:47,100 --> 00:18:49,260
we can change the look and feel of our
438
00:18:49,260 --> 00:18:50,280
login
439
00:18:50,280 --> 00:18:52,980
immediately starting with the Box we
440
00:18:52,980 --> 00:18:55,500
won't be using this background which has
441
00:18:55,500 --> 00:18:57,299
a gradient we're going to do something
442
00:18:57,299 --> 00:19:00,720
simpler so inside of the SX probe you
443
00:19:00,720 --> 00:19:03,600
can add the background color equal to
444
00:19:03,600 --> 00:19:06,260
that's going to be hash
445
00:19:06,260 --> 00:19:08,820
fcfc FC
446
00:19:08,820 --> 00:19:11,400
and we can save that and immediately on
447
00:19:11,400 --> 00:19:13,380
localhost you're gonna see we have this
448
00:19:13,380 --> 00:19:16,200
really white gray color now we're gonna
449
00:19:16,200 --> 00:19:18,539
have this container we're gonna have a
450
00:19:18,539 --> 00:19:20,880
box and then we have to change the logo
451
00:19:20,880 --> 00:19:23,340
in this case we're going to use a logo
452
00:19:23,340 --> 00:19:25,320
with a source
453
00:19:25,320 --> 00:19:29,100
of yariga which is the name of our app
454
00:19:29,100 --> 00:19:31,980
and we can rename it to your Riga logo
455
00:19:31,980 --> 00:19:35,100
now if we save this go back and reload
456
00:19:35,100 --> 00:19:37,620
you can see we have our new completely
457
00:19:37,620 --> 00:19:40,260
custom login now if you click sign in
458
00:19:40,260 --> 00:19:42,900
with Google it's going to open up a new
459
00:19:42,900 --> 00:19:45,240
window that looks like this and you can
460
00:19:45,240 --> 00:19:47,700
log in you'll have to first confirm that
461
00:19:47,700 --> 00:19:49,820
you want to sign in so we can do that
462
00:19:49,820 --> 00:19:54,120
and we are in that was it that was
463
00:19:54,120 --> 00:19:56,580
everything we needed to do to make the
464
00:19:56,580 --> 00:19:59,840
Google oauth login work isn't that crazy
465
00:19:59,840 --> 00:20:02,880
now we can start focusing on our sidebar
466
00:20:02,880 --> 00:20:05,400
or cider how refine likes to call it
467
00:20:05,400 --> 00:20:07,980
we're going to add all of the additional
468
00:20:07,980 --> 00:20:11,100
Pages routes change the logo and the
469
00:20:11,100 --> 00:20:13,200
look and feel to do that we can close
470
00:20:13,200 --> 00:20:17,179
our login go to our source components
471
00:20:17,179 --> 00:20:22,679
layout cider and index.ts this is where
472
00:20:22,679 --> 00:20:25,380
the rest of the magic will happen as you
473
00:20:25,380 --> 00:20:28,679
can see refine provided us with a lot of
474
00:20:28,679 --> 00:20:31,559
predefined features things like collapse
475
00:20:31,559 --> 00:20:34,440
open open even links and translations
476
00:20:34,440 --> 00:20:37,440
and so much more so we only have to make
477
00:20:37,440 --> 00:20:40,140
a few cosmetic adjustments before we
478
00:20:40,140 --> 00:20:42,059
start making our changes let's open up
479
00:20:42,059 --> 00:20:44,760
the browser side by side with our editor
480
00:20:44,760 --> 00:20:46,200
like this
481
00:20:46,200 --> 00:20:49,380
and let's get started let's go down all
482
00:20:49,380 --> 00:20:54,000
the way to line 137 right here and we
483
00:20:54,000 --> 00:20:56,039
can modify the font size to about 16
484
00:20:56,039 --> 00:20:58,919
pixel I found this value to be just a
485
00:20:58,919 --> 00:21:00,120
bit better
486
00:21:00,120 --> 00:21:03,720
we can go down a bit more to line 180
487
00:21:03,720 --> 00:21:06,240
and right here we're going to change the
488
00:21:06,240 --> 00:21:09,539
background color of our item so list
489
00:21:09,539 --> 00:21:13,500
item button line 181 we want to check if
490
00:21:13,500 --> 00:21:16,500
we have currently selected the item
491
00:21:16,500 --> 00:21:18,840
if that is the case we can change the
492
00:21:18,840 --> 00:21:20,580
color to B
493
00:21:20,580 --> 00:21:27,120
Ash 1 e 3 6 e 8 like this and also when
494
00:21:27,120 --> 00:21:29,340
not hovering we also want to change this
495
00:21:29,340 --> 00:21:33,120
so let's say if is selected then we can
496
00:21:33,120 --> 00:21:35,580
have a color of 4 7
497
00:21:35,580 --> 00:21:39,720
5 b e 8 like this and then we can have
498
00:21:39,720 --> 00:21:42,840
transparent if we now save this you can
499
00:21:42,840 --> 00:21:44,400
see these are going to get a bit bigger
500
00:21:44,400 --> 00:21:46,320
and we have a different color which
501
00:21:46,320 --> 00:21:48,780
right now doesn't suit the design at all
502
00:21:48,780 --> 00:21:50,760
but soon enough you're gonna see how
503
00:21:50,760 --> 00:21:52,679
great this is going to look like as a
504
00:21:52,679 --> 00:21:55,020
matter of fact let me show you exactly
505
00:21:55,020 --> 00:21:57,600
what we're going for this right here is
506
00:21:57,600 --> 00:21:59,760
the finalized design we want to have the
507
00:21:59,760 --> 00:22:02,039
logo on the top and this is how we want
508
00:22:02,039 --> 00:22:04,679
our list items to look like so let's try
509
00:22:04,679 --> 00:22:07,620
to turn this into this
510
00:22:07,620 --> 00:22:09,960
with that said we can scroll a bit more
511
00:22:09,960 --> 00:22:12,539
down below this justify Center
512
00:22:12,539 --> 00:22:16,020
we can add a margin of 10 pixels and
513
00:22:16,020 --> 00:22:18,840
then Auto we can also add a border
514
00:22:18,840 --> 00:22:22,380
radius of 12 pixels and we can add a Min
515
00:22:22,380 --> 00:22:26,760
height equal to 56 pixels finally we can
516
00:22:26,760 --> 00:22:29,700
add a width of 90 percent
517
00:22:29,700 --> 00:22:31,799
now if we save this this is going to
518
00:22:31,799 --> 00:22:34,260
look just a bit different and they
519
00:22:34,260 --> 00:22:36,179
already have this spill-like structure
520
00:22:36,179 --> 00:22:38,760
which is closer to the design we can
521
00:22:38,760 --> 00:22:40,919
keep scrolling down a bit to see this
522
00:22:40,919 --> 00:22:43,200
color right here and we're going to
523
00:22:43,200 --> 00:22:46,080
change it we can check if it is selected
524
00:22:46,080 --> 00:22:49,559
then we want to have hash FFF meaning
525
00:22:49,559 --> 00:22:50,700
pure white
526
00:22:50,700 --> 00:22:52,919
otherwise we can have
527
00:22:52,919 --> 00:22:55,460
hash
528
00:22:55,460 --> 00:22:58,140
808191 and of course this is a ternary
529
00:22:58,140 --> 00:22:59,580
operator
530
00:22:59,580 --> 00:23:01,740
below that we're going to have primary
531
00:23:01,740 --> 00:23:04,559
typography props there we want to change
532
00:23:04,559 --> 00:23:07,620
the font size to 16 pixels again and
533
00:23:07,620 --> 00:23:09,600
below the font weight we can change the
534
00:23:09,600 --> 00:23:12,840
color again if is selected we're going
535
00:23:12,840 --> 00:23:15,380
to do a classic just white color
536
00:23:15,380 --> 00:23:18,120
otherwise we can have
537
00:23:18,120 --> 00:23:21,860
the same one we had before hash
538
00:23:21,860 --> 00:23:25,559
808191 and we can also add a margin left
539
00:23:25,559 --> 00:23:28,500
to divide it a bit from the border of 10
540
00:23:28,500 --> 00:23:29,580
pixels
541
00:23:29,580 --> 00:23:30,960
great
542
00:23:30,960 --> 00:23:33,419
as you can see this is now even closer
543
00:23:33,419 --> 00:23:34,860
to this
544
00:23:34,860 --> 00:23:38,220
but if we scroll just a bit more down to
545
00:23:38,220 --> 00:23:39,780
line 258
546
00:23:39,780 --> 00:23:43,020
we can change the font size to 16 pixels
547
00:23:43,020 --> 00:23:45,900
here as well and then we can change our
548
00:23:45,900 --> 00:23:48,299
logout button so here you can see the
549
00:23:48,299 --> 00:23:52,260
log out and on line 277 we can expand it
550
00:23:52,260 --> 00:23:55,380
and below the justify content we can add
551
00:23:55,380 --> 00:23:58,980
a margin of 10 pixels Auto we can also
552
00:23:58,980 --> 00:24:03,120
add a border radius of 12 pixels A Min
553
00:24:03,120 --> 00:24:06,900
height of 56 pixels and a width of 90.
554
00:24:06,900 --> 00:24:08,640
this is going to make the logo button
555
00:24:08,640 --> 00:24:11,940
appear the same as our regular resource
556
00:24:11,940 --> 00:24:14,820
button finally in the list item we can
557
00:24:14,820 --> 00:24:19,159
change the color to be hash
558
00:24:19,400 --> 00:24:22,620
808191 and we can also increase the font
559
00:24:22,620 --> 00:24:26,700
size right here on 298 to 16 pixels
560
00:24:26,700 --> 00:24:29,940
finally a bit below we're going to see
561
00:24:29,940 --> 00:24:33,000
our drawer that drawer we can change the
562
00:24:33,000 --> 00:24:36,600
color to again the same thing eight zero
563
00:24:36,600 --> 00:24:39,419
eight one nine one and we of course have
564
00:24:39,419 --> 00:24:42,419
to have the hash sign for the cooler
565
00:24:42,419 --> 00:24:44,760
great but now we're gonna see the
566
00:24:44,760 --> 00:24:47,280
biggest change there is if you scroll a
567
00:24:47,280 --> 00:24:49,980
bit more down we want to see our drawer
568
00:24:49,980 --> 00:24:51,559
which is right here
569
00:24:51,559 --> 00:24:55,080
386 we have our background color BG
570
00:24:55,080 --> 00:24:57,600
cooler and we want to change that to
571
00:24:57,600 --> 00:25:00,020
hash
572
00:25:00,020 --> 00:25:03,539
fcfcfc and now if you save that you can
573
00:25:03,539 --> 00:25:05,400
see that this is going to take that
574
00:25:05,400 --> 00:25:06,780
light color
575
00:25:06,780 --> 00:25:09,179
also we can change the elevation to zero
576
00:25:09,179 --> 00:25:12,240
to remove that shadow if you scroll a
577
00:25:12,240 --> 00:25:14,840
bit more down we're gonna see the button
578
00:25:14,840 --> 00:25:18,120
for left and right for expanding and
579
00:25:18,120 --> 00:25:20,940
collapsing our sidebar there we can give
580
00:25:20,940 --> 00:25:23,960
it a background of hash
581
00:25:23,960 --> 00:25:26,940
475b E8
582
00:25:26,940 --> 00:25:28,620
there we go that's going to make it
583
00:25:28,620 --> 00:25:31,860
match our design just a bit better
584
00:25:31,860 --> 00:25:34,380
and also we want to give it an on Hover
585
00:25:34,380 --> 00:25:36,840
effect so that's going to be and
586
00:25:36,840 --> 00:25:38,400
call and hover
587
00:25:38,400 --> 00:25:40,380
Colin and then we want to change the
588
00:25:40,380 --> 00:25:42,059
background
589
00:25:42,059 --> 00:25:47,940
to be equal to Hash 1 e 3 6 e 8.
590
00:25:47,940 --> 00:25:49,860
there we go so if you look into that
591
00:25:49,860 --> 00:25:52,500
right now it's just a bit better finally
592
00:25:52,500 --> 00:25:55,919
going a bit more down to our box we're
593
00:25:55,919 --> 00:25:58,140
going to have a BG color which we want
594
00:25:58,140 --> 00:26:02,000
to change to hash
595
00:26:02,000 --> 00:26:04,440
475b E8
596
00:26:04,440 --> 00:26:07,559
there we go this is when it is collapsed
597
00:26:07,559 --> 00:26:09,840
so now everything matches
598
00:26:09,840 --> 00:26:12,779
and if we expand it and compare it it is
599
00:26:12,779 --> 00:26:15,299
looking a bit closer to what we have now
600
00:26:15,299 --> 00:26:16,919
it seems that we're close to being done
601
00:26:16,919 --> 00:26:19,080
but if we make our browser just a bit
602
00:26:19,080 --> 00:26:21,000
smaller you can notice we still have
603
00:26:21,000 --> 00:26:23,460
this color right here and we want to
604
00:26:23,460 --> 00:26:27,120
change that so let's go to line 360 and
605
00:26:27,120 --> 00:26:29,760
right here you can see 363 we have to
606
00:26:29,760 --> 00:26:31,760
change the color to Hash
607
00:26:31,760 --> 00:26:35,700
fcfc FC there we go so now we have our
608
00:26:35,700 --> 00:26:38,100
white sidebar which is close to this one
609
00:26:38,100 --> 00:26:40,620
but of course the text of this resource
610
00:26:40,620 --> 00:26:43,980
should also be gray so let's see if we
611
00:26:43,980 --> 00:26:45,960
missed just one style right here when
612
00:26:45,960 --> 00:26:47,580
changing the color
613
00:26:47,580 --> 00:26:50,100
and it looks like we didn't miss it but
614
00:26:50,100 --> 00:26:53,159
we just missed placing this sign right
615
00:26:53,159 --> 00:26:55,559
here at least I did so make sure to add
616
00:26:55,559 --> 00:26:58,380
a hash on 183 and then we should have
617
00:26:58,380 --> 00:27:00,360
something that looks like this which is
618
00:27:00,360 --> 00:27:02,159
much much closer to the sidebar we're
619
00:27:02,159 --> 00:27:04,380
going for but now we can focus on
620
00:27:04,380 --> 00:27:07,440
changing the logo on top as well so
621
00:27:07,440 --> 00:27:10,080
let's go to our file explorer and let's
622
00:27:10,080 --> 00:27:12,299
open up our header component
623
00:27:12,299 --> 00:27:15,779
inside our header we're going to go to
624
00:27:15,779 --> 00:27:18,000
our app bar and we're going to change
625
00:27:18,000 --> 00:27:20,520
the elevation to zero and we're going to
626
00:27:20,520 --> 00:27:23,039
add an SX prop which is used for styling
627
00:27:23,039 --> 00:27:26,940
in material UI and change the background
628
00:27:26,940 --> 00:27:32,220
to be equal to Hash FC FC FC
629
00:27:32,220 --> 00:27:34,260
there we go so this is going to change
630
00:27:34,260 --> 00:27:37,380
it finally we won't be needing this icon
631
00:27:37,380 --> 00:27:40,260
button to change the color from dark to
632
00:27:40,260 --> 00:27:41,940
light mode
633
00:27:41,940 --> 00:27:44,100
and that's going to be it for the header
634
00:27:44,100 --> 00:27:46,679
but now we can go to the title component
635
00:27:46,679 --> 00:27:48,900
which is right here
636
00:27:48,900 --> 00:27:51,720
inside the title we have to import our
637
00:27:51,720 --> 00:27:55,440
logos so we're gonna import the logo as
638
00:27:55,440 --> 00:27:58,980
well as yariga coming from just assets
639
00:27:58,980 --> 00:28:02,340
there we go and now instead of linking
640
00:28:02,340 --> 00:28:05,039
to refine logos we can simply when
641
00:28:05,039 --> 00:28:08,159
collapsed link 2 that's going to be
642
00:28:08,159 --> 00:28:11,820
Source equal to logo
643
00:28:11,820 --> 00:28:15,299
and we can put the alt off here we go
644
00:28:15,299 --> 00:28:18,539
and then when it is expanded
645
00:28:18,539 --> 00:28:21,659
we can show another logo which is going
646
00:28:21,659 --> 00:28:24,720
to be the ariga there we go so now if we
647
00:28:24,720 --> 00:28:26,760
save this we're going to get a colored
648
00:28:26,760 --> 00:28:28,919
logo which should make everything look a
649
00:28:28,919 --> 00:28:31,620
bit different there we go so before we
650
00:28:31,620 --> 00:28:33,419
had white and white which didn't look
651
00:28:33,419 --> 00:28:35,220
good but now we have something that
652
00:28:35,220 --> 00:28:38,460
looks much closer to our design and that
653
00:28:38,460 --> 00:28:41,159
is wonderful we can also collapse it and
654
00:28:41,159 --> 00:28:42,960
you can see it immediately collapses to
655
00:28:42,960 --> 00:28:44,760
this smaller version of the logo which
656
00:28:44,760 --> 00:28:46,980
you think looks just great and we also
657
00:28:46,980 --> 00:28:49,260
have our icons which are collapsed right
658
00:28:49,260 --> 00:28:50,279
here
659
00:28:50,279 --> 00:28:52,740
great now that we have made design
660
00:28:52,740 --> 00:28:55,140
changes you might be wondering how can
661
00:28:55,140 --> 00:28:58,260
you add additional items to this sidebar
662
00:28:58,260 --> 00:29:01,980
list well let me show you refine made it
663
00:29:01,980 --> 00:29:04,200
so easy by providing a structure for you
664
00:29:04,200 --> 00:29:07,620
to keep adding new lines and pages so
665
00:29:07,620 --> 00:29:11,400
let's go to app.tsx and let's scroll all
666
00:29:11,400 --> 00:29:14,760
the way down to the main component which
667
00:29:14,760 --> 00:29:17,640
you're rendering which is the refine
668
00:29:17,640 --> 00:29:20,100
component inside of here we can provide
669
00:29:20,100 --> 00:29:22,559
a lot of different props to it and
670
00:29:22,559 --> 00:29:24,600
they're going to immediately change how
671
00:29:24,600 --> 00:29:26,880
our app behaves and what features does
672
00:29:26,880 --> 00:29:27,960
it have
673
00:29:27,960 --> 00:29:30,299
and we do that by adding additional
674
00:29:30,299 --> 00:29:32,760
resources remember we're creating our
675
00:29:32,760 --> 00:29:35,700
application as a crud app create read
676
00:29:35,700 --> 00:29:38,820
update and delete resources in this case
677
00:29:38,820 --> 00:29:41,520
we immediately have posts which is great
678
00:29:41,520 --> 00:29:44,399
but we want to change that just a bit
679
00:29:44,399 --> 00:29:47,700
we're going to rename posts to property
680
00:29:47,700 --> 00:29:50,760
right here and right now they have all
681
00:29:50,760 --> 00:29:53,159
of these mui components which simulate
682
00:29:53,159 --> 00:29:55,919
our layout right now but we will want to
683
00:29:55,919 --> 00:29:58,020
create our own look and style and
684
00:29:58,020 --> 00:30:00,659
components for all of these pages so
685
00:30:00,659 --> 00:30:03,419
what we can do is we can remove all of
686
00:30:03,419 --> 00:30:04,500
that
687
00:30:04,500 --> 00:30:07,500
and save it immediately you can see that
688
00:30:07,500 --> 00:30:10,140
we have a 404 built in as well which is
689
00:30:10,140 --> 00:30:13,020
great and it got removed from the list
690
00:30:13,020 --> 00:30:16,020
because there's nothing yet to show but
691
00:30:16,020 --> 00:30:17,880
don't worry we're gonna fix that really
692
00:30:17,880 --> 00:30:21,299
soon for now just to be able to see our
693
00:30:21,299 --> 00:30:24,779
post we can add a list and we can add
694
00:30:24,779 --> 00:30:27,600
the mui inferencer which was there
695
00:30:27,600 --> 00:30:29,940
before this is just going to allow us to
696
00:30:29,940 --> 00:30:32,279
see how it would look like once we add
697
00:30:32,279 --> 00:30:35,100
additional properties there we go as you
698
00:30:35,100 --> 00:30:37,559
can see the errors are built into refine
699
00:30:37,559 --> 00:30:39,480
as well so you don't have to worry about
700
00:30:39,480 --> 00:30:41,399
things like these you just have to focus
701
00:30:41,399 --> 00:30:44,220
on the data now let's add additional
702
00:30:44,220 --> 00:30:46,500
resources I'm going to duplicate this
703
00:30:46,500 --> 00:30:49,080
below and from property I'm going to
704
00:30:49,080 --> 00:30:51,600
rename that to agent
705
00:30:51,600 --> 00:30:53,640
we're going to also add a couple more
706
00:30:53,640 --> 00:30:57,000
below agent we're going to have review
707
00:30:57,000 --> 00:30:59,820
below review we're gonna have our
708
00:30:59,820 --> 00:31:00,840
message
709
00:31:00,840 --> 00:31:03,480
and then finally below message we're
710
00:31:03,480 --> 00:31:07,860
going to have our my profile now if we
711
00:31:07,860 --> 00:31:09,539
save that
712
00:31:09,539 --> 00:31:11,940
you can see that it's going to add all
713
00:31:11,940 --> 00:31:15,120
of these list items to our dashboard but
714
00:31:15,120 --> 00:31:16,320
there are a couple of things we want to
715
00:31:16,320 --> 00:31:18,480
change first of all you can see that an
716
00:31:18,480 --> 00:31:20,580
S for plural has been added to all of
717
00:31:20,580 --> 00:31:22,919
those lists but we don't have my
718
00:31:22,919 --> 00:31:26,340
profiles but rather my profile so we can
719
00:31:26,340 --> 00:31:29,820
provide an additional options object and
720
00:31:29,820 --> 00:31:33,000
set the label to be equal to my profile
721
00:31:33,000 --> 00:31:35,580
this is going to make it look just a bit
722
00:31:35,580 --> 00:31:37,919
better we have to add a comma right
723
00:31:37,919 --> 00:31:38,820
there
724
00:31:38,820 --> 00:31:41,700
there we go my profile and you can also
725
00:31:41,700 --> 00:31:44,220
notice that we have to modify the icons
726
00:31:44,220 --> 00:31:47,039
for all of these properties so scrolling
727
00:31:47,039 --> 00:31:49,500
all the way up we can import those icons
728
00:31:49,500 --> 00:31:52,919
right here below the refine mui Imports
729
00:31:52,919 --> 00:31:54,600
we can say import
730
00:31:54,600 --> 00:31:57,960
account Circle outlined
731
00:31:57,960 --> 00:32:03,000
we can also import chat bubble outline
732
00:32:03,000 --> 00:32:05,899
we can import the people
733
00:32:05,899 --> 00:32:08,220
alt outlined
734
00:32:08,220 --> 00:32:12,779
we can import the star outline rounded
735
00:32:12,779 --> 00:32:16,980
and finally Villa outlined there we go
736
00:32:16,980 --> 00:32:19,260
now all of that is going to come from
737
00:32:19,260 --> 00:32:24,120
ADM UI forward slash icons Dash material
738
00:32:24,120 --> 00:32:26,220
we can now scroll down to where we
739
00:32:26,220 --> 00:32:27,960
Define those lists
740
00:32:27,960 --> 00:32:31,380
and under property we can add an icon
741
00:32:31,380 --> 00:32:34,679
property and that icon in this case is
742
00:32:34,679 --> 00:32:37,500
going to be Villa outlined we can keep
743
00:32:37,500 --> 00:32:40,140
adding additional icons the second one
744
00:32:40,140 --> 00:32:43,860
is going to be people alt outlined that
745
00:32:43,860 --> 00:32:46,860
changed as well then for the review we
746
00:32:46,860 --> 00:32:50,760
can add an icon of star outline rounded
747
00:32:50,760 --> 00:32:54,240
then for the message we can add an icon
748
00:32:54,240 --> 00:32:57,360
of chat bubble outline of course and
749
00:32:57,360 --> 00:32:59,940
then for my profile we can add an icon
750
00:32:59,940 --> 00:33:03,899
of account Circle outline as well and
751
00:33:03,899 --> 00:33:07,260
now this is looking much much better as
752
00:33:07,260 --> 00:33:09,299
you can see it is looking like it does
753
00:33:09,299 --> 00:33:11,899
on the design it is exactly the same
754
00:33:11,899 --> 00:33:14,460
wonderful we can collapse it and as you
755
00:33:14,460 --> 00:33:16,320
can see we have the tooltips and
756
00:33:16,320 --> 00:33:18,960
everything works perfectly right off the
757
00:33:18,960 --> 00:33:22,260
bat wonderful on top of all of these
758
00:33:22,260 --> 00:33:24,600
resources we're gonna also have a
759
00:33:24,600 --> 00:33:27,659
dashboard page so we can add a special
760
00:33:27,659 --> 00:33:31,140
property called dashboard page which is
761
00:33:31,140 --> 00:33:34,019
going to be equal to our home and that
762
00:33:34,019 --> 00:33:35,940
home page is something we haven't yet
763
00:33:35,940 --> 00:33:39,120
created so right at the top we can
764
00:33:39,120 --> 00:33:40,140
import
765
00:33:40,140 --> 00:33:42,240
all of the pages that we'll be using
766
00:33:42,240 --> 00:33:45,120
throughout this video that can be done a
767
00:33:45,120 --> 00:33:47,159
bit below where we have local Imports
768
00:33:47,159 --> 00:33:49,440
and right now we're importing just the
769
00:33:49,440 --> 00:33:51,960
login so let's expand that
770
00:33:51,960 --> 00:33:53,760
let's maybe divide it from all other
771
00:33:53,760 --> 00:33:55,679
Imports so we can see it more clearly
772
00:33:55,679 --> 00:33:58,500
and let's import that's going to be
773
00:33:58,500 --> 00:34:00,899
login we're going to also have a home
774
00:34:00,899 --> 00:34:03,960
page an agents page we're going to have
775
00:34:03,960 --> 00:34:06,659
a my profile page
776
00:34:06,659 --> 00:34:09,839
we're going to have a property Details
777
00:34:09,839 --> 00:34:12,000
page we're going to have an old
778
00:34:12,000 --> 00:34:14,159
properties page
779
00:34:14,159 --> 00:34:16,940
like this we're going to have a create
780
00:34:16,940 --> 00:34:19,139
property page
781
00:34:19,139 --> 00:34:21,540
we're going to have an agent profile
782
00:34:21,540 --> 00:34:26,399
page and an edit property page there we
783
00:34:26,399 --> 00:34:28,800
go so a lot of different pages and of
784
00:34:28,800 --> 00:34:30,119
course we're going to get an error now
785
00:34:30,119 --> 00:34:32,699
because we haven't yet created them so
786
00:34:32,699 --> 00:34:34,679
now might be the best time to go into
787
00:34:34,679 --> 00:34:37,619
pages and start creating these pages one
788
00:34:37,619 --> 00:34:38,639
by one
789
00:34:38,639 --> 00:34:41,639
so let's start with the home that's
790
00:34:41,639 --> 00:34:45,719
going to be home dot TSX
791
00:34:45,719 --> 00:34:48,060
and immediately inside of there we can
792
00:34:48,060 --> 00:34:51,239
run rafce this is going to immediately
793
00:34:51,239 --> 00:34:54,599
create a simple home page now if this
794
00:34:54,599 --> 00:34:56,099
didn't work for you you can go to
795
00:34:56,099 --> 00:34:59,460
extensions and then you can install es7
796
00:34:59,460 --> 00:35:03,420
plus react react native Redux Snippets
797
00:35:03,420 --> 00:35:06,300
as soon as you install this the rafce
798
00:35:06,300 --> 00:35:10,140
command should work so install it run
799
00:35:10,140 --> 00:35:12,960
ref CE and then let's proceed with all
800
00:35:12,960 --> 00:35:15,780
other components we'll be using
801
00:35:15,780 --> 00:35:18,300
the second component right here is the
802
00:35:18,300 --> 00:35:22,859
agent dash profile dot TSX there we can
803
00:35:22,859 --> 00:35:26,760
also run rafce but we can change this to
804
00:35:26,760 --> 00:35:29,760
agent profile like so
805
00:35:29,760 --> 00:35:32,460
then we're also going to have an agent
806
00:35:32,460 --> 00:35:34,760
property or a page
807
00:35:34,760 --> 00:35:40,260
agent.tsx where we can also run rafce
808
00:35:40,320 --> 00:35:42,780
then we're going to have a new file
809
00:35:42,780 --> 00:35:47,460
called all Dash properties dot TSX and
810
00:35:47,460 --> 00:35:50,820
there we can also run rafce and we can
811
00:35:50,820 --> 00:35:53,880
fix this right here from all properties
812
00:35:53,880 --> 00:35:57,180
to all properties in camel case
813
00:35:57,180 --> 00:36:00,599
great now we can create a new create
814
00:36:00,599 --> 00:36:02,640
property so that's going to be create
815
00:36:02,640 --> 00:36:07,079
Dash property dot TSX we can run rafce
816
00:36:07,079 --> 00:36:11,339
and once again fix the create property
817
00:36:11,339 --> 00:36:12,839
to camel case
818
00:36:12,839 --> 00:36:15,119
after that we're going to have the edit
819
00:36:15,119 --> 00:36:16,740
Dash property
820
00:36:16,740 --> 00:36:18,780
dot TSX
821
00:36:18,780 --> 00:36:21,900
we can run rafce and one more time we
822
00:36:21,900 --> 00:36:25,400
can edit this to camel case
823
00:36:26,099 --> 00:36:28,760
finally we're going to have my profile
824
00:36:28,760 --> 00:36:33,540
my Dash profile dot TSX we can run rafce
825
00:36:33,540 --> 00:36:36,119
and then we can edit this to my profile
826
00:36:36,119 --> 00:36:37,920
in camel case
827
00:36:37,920 --> 00:36:43,140
and the last one on our list is property
828
00:36:43,140 --> 00:36:47,099
Dash details dot TSX and there we can
829
00:36:47,099 --> 00:36:49,320
again run rafce
830
00:36:49,320 --> 00:36:52,500
and change this to camel case
831
00:36:52,500 --> 00:36:55,020
there we go so now we have all of these
832
00:36:55,020 --> 00:36:57,839
components but we are yet to export them
833
00:36:57,839 --> 00:37:00,260
so let's create a new
834
00:37:00,260 --> 00:37:03,980
index.ts file inside of the pages folder
835
00:37:03,980 --> 00:37:06,540
there we need to import all of these
836
00:37:06,540 --> 00:37:08,640
components and then export them from one
837
00:37:08,640 --> 00:37:11,400
file this file is going to be down in
838
00:37:11,400 --> 00:37:12,900
the description so you'll be able to
839
00:37:12,900 --> 00:37:15,119
Simply copy and paste it it's going to
840
00:37:15,119 --> 00:37:17,400
contain just some simple imports and
841
00:37:17,400 --> 00:37:19,140
exports so you don't have to type them
842
00:37:19,140 --> 00:37:22,920
by hand great with that said we can now
843
00:37:22,920 --> 00:37:26,160
go back all the way by closing all of
844
00:37:26,160 --> 00:37:29,520
these files and going back to our
845
00:37:29,520 --> 00:37:31,560
app.tsx
846
00:37:31,560 --> 00:37:33,900
there you can see that we're exporting
847
00:37:33,900 --> 00:37:37,500
home was not found in Pages login that's
848
00:37:37,500 --> 00:37:39,599
because we have to remove the login here
849
00:37:39,599 --> 00:37:42,240
because now we're importing all of the
850
00:37:42,240 --> 00:37:43,200
pages
851
00:37:43,200 --> 00:37:46,320
and if we do that we are back here and
852
00:37:46,320 --> 00:37:47,940
you can see that this special dashboard
853
00:37:47,940 --> 00:37:51,119
appeared as you can see our dashboard is
854
00:37:51,119 --> 00:37:53,760
different from our list items list items
855
00:37:53,760 --> 00:37:56,400
represent resources and dashboard is a
856
00:37:56,400 --> 00:37:58,440
standalone home page so let's just
857
00:37:58,440 --> 00:38:00,300
change the icon color for that as well
858
00:38:00,300 --> 00:38:03,440
by going back to the cider
859
00:38:03,440 --> 00:38:06,839
index.tsx of The Cider component and
860
00:38:06,839 --> 00:38:10,140
then going to our dashboard that's on
861
00:38:10,140 --> 00:38:13,560
line 218 there if you scroll down a bit
862
00:38:13,560 --> 00:38:16,200
you can see this list item icon and then
863
00:38:16,200 --> 00:38:21,140
the color here we want to use the hash
864
00:38:21,140 --> 00:38:24,660
808191 and if you save that you can see
865
00:38:24,660 --> 00:38:26,760
the color of the dashboard changed as
866
00:38:26,760 --> 00:38:27,480
well
867
00:38:27,480 --> 00:38:30,000
now to make our dashboard look the same
868
00:38:30,000 --> 00:38:32,040
as our resource properties we can also
869
00:38:32,040 --> 00:38:36,960
give it a margin left of about 20 pixels
870
00:38:36,960 --> 00:38:39,480
and we can also give it a margin right
871
00:38:39,480 --> 00:38:43,920
of about let's do 14 pixels right here
872
00:38:43,920 --> 00:38:46,020
so this should move it a bit to the
873
00:38:46,020 --> 00:38:46,680
right
874
00:38:46,680 --> 00:38:48,839
and we might went overboard right here
875
00:38:48,839 --> 00:38:51,359
so let's try to do 10.
876
00:38:51,359 --> 00:38:55,260
or maybe something like 6 will do
877
00:38:55,260 --> 00:38:57,420
there we go so this is now looking much
878
00:38:57,420 --> 00:39:00,119
better we can properly move between all
879
00:39:00,119 --> 00:39:02,400
of these Pages as you can see the URL
880
00:39:02,400 --> 00:39:05,099
changes and also the highlights actually
881
00:39:05,099 --> 00:39:07,079
change on the left side so we can be on
882
00:39:07,079 --> 00:39:08,579
the dashboard where we have our home
883
00:39:08,579 --> 00:39:10,920
component or we can move to all of our
884
00:39:10,920 --> 00:39:13,680
different pages great with that said
885
00:39:13,680 --> 00:39:16,380
we're now done with the sidebar
886
00:39:16,380 --> 00:39:18,300
and of course the next thing we can
887
00:39:18,300 --> 00:39:20,880
focus on is going to be the home page
888
00:39:20,880 --> 00:39:23,339
so to start with the home page let's go
889
00:39:23,339 --> 00:39:27,599
to our app.tsx there we specified that
890
00:39:27,599 --> 00:39:29,820
our home page will be the dashboard page
891
00:39:29,820 --> 00:39:32,880
so we can control click into it and here
892
00:39:32,880 --> 00:39:35,339
we are this is where we're going to
893
00:39:35,339 --> 00:39:38,040
develop that great looking dashboard let
894
00:39:38,040 --> 00:39:39,560
me show you how that's going to look
895
00:39:39,560 --> 00:39:42,420
there we go we're going to have the
896
00:39:42,420 --> 00:39:44,820
dashboard title right here then for
897
00:39:44,820 --> 00:39:48,480
cards two different charts and then a
898
00:39:48,480 --> 00:39:52,140
property list great with that said let's
899
00:39:52,140 --> 00:39:54,900
get started with creating our dashboard
900
00:39:54,900 --> 00:39:57,599
to start creating our dashboard we can
901
00:39:57,599 --> 00:39:59,339
first import a couple of things we're
902
00:39:59,339 --> 00:40:01,440
going to need the first thing is going
903
00:40:01,440 --> 00:40:05,700
to be the import use list hook and that
904
00:40:05,700 --> 00:40:09,180
hook is coming from pan code right here
905
00:40:09,180 --> 00:40:13,320
forward slash refine Dash core this is
906
00:40:13,320 --> 00:40:16,260
one of the most important refines Hooks
907
00:40:16,260 --> 00:40:18,480
and it allows us to get access to a
908
00:40:18,480 --> 00:40:20,940
specific resource such as a property
909
00:40:20,940 --> 00:40:23,640
then we'll have to import all of the
910
00:40:23,640 --> 00:40:25,440
different components we'll be using on
911
00:40:25,440 --> 00:40:27,540
our dashboard and if you think about it
912
00:40:27,540 --> 00:40:29,940
we have created all the pages but we
913
00:40:29,940 --> 00:40:32,460
haven't yet created the components so
914
00:40:32,460 --> 00:40:35,220
inside of the components folder we have
915
00:40:35,220 --> 00:40:38,280
to create them let's start with creating
916
00:40:38,280 --> 00:40:41,760
the agent folder right here inside of
917
00:40:41,760 --> 00:40:44,099
the components folder and that agent
918
00:40:44,099 --> 00:40:46,760
folder is going to have an agent card
919
00:40:46,760 --> 00:40:51,260
dot TSX and there we can also run rafce
920
00:40:51,260 --> 00:40:54,300
then we're going to have a folder for
921
00:40:54,300 --> 00:40:56,820
all of the charts we already have it so
922
00:40:56,820 --> 00:40:59,940
inside of there we can create a pi chart
923
00:40:59,940 --> 00:41:04,079
dot TSX and we can run rafce inside of
924
00:41:04,079 --> 00:41:06,540
there as well alongside our pie chart
925
00:41:06,540 --> 00:41:09,420
we're going to also have property
926
00:41:09,420 --> 00:41:11,339
referrals
927
00:41:11,339 --> 00:41:14,820
dot TSX and that's also going to be a
928
00:41:14,820 --> 00:41:17,460
regular Arrow function component finally
929
00:41:17,460 --> 00:41:19,560
we're going to have a chart for total
930
00:41:19,560 --> 00:41:22,940
revenue so we can write a component
931
00:41:22,940 --> 00:41:25,859
totalrevenue.tsx and create a react
932
00:41:25,859 --> 00:41:29,220
Arrow function component great below the
933
00:41:29,220 --> 00:41:31,619
chart we're also going to have a home
934
00:41:31,619 --> 00:41:34,140
folder this is where all of the
935
00:41:34,140 --> 00:41:35,579
components that we'll be using in our
936
00:41:35,579 --> 00:41:37,920
homepage will be and we only need one
937
00:41:37,920 --> 00:41:41,520
it's going to be called top agent dot
938
00:41:41,520 --> 00:41:42,720
TSX
939
00:41:42,720 --> 00:41:45,599
and we can again run rvfce inside of
940
00:41:45,599 --> 00:41:48,119
there there is just one component of the
941
00:41:48,119 --> 00:41:50,220
home and that's because we have another
942
00:41:50,220 --> 00:41:52,740
folder called common inside of there
943
00:41:52,740 --> 00:41:54,660
we'll have components that will reuse
944
00:41:54,660 --> 00:41:57,599
across all the different pages so let's
945
00:41:57,599 --> 00:41:59,460
create the first one that's going to be
946
00:41:59,460 --> 00:42:03,780
custom button dot TSX and inside of
947
00:42:03,780 --> 00:42:06,119
there we can run rafce
948
00:42:06,119 --> 00:42:09,140
another one is going to be a form
949
00:42:09,140 --> 00:42:12,960
component.tsx and we can also run refce
950
00:42:12,960 --> 00:42:15,900
next we're going to have a profile dot
951
00:42:15,900 --> 00:42:19,980
TSX where we can also run rafce and the
952
00:42:19,980 --> 00:42:24,180
last one is going to be a property
953
00:42:24,180 --> 00:42:27,660
card dot TSX maybe the most important
954
00:42:27,660 --> 00:42:30,560
one so far and we're also gonna run
955
00:42:30,560 --> 00:42:33,119
rafce inside of it
956
00:42:33,119 --> 00:42:37,380
great now we have to create an index.ts
957
00:42:37,380 --> 00:42:40,140
file inside of the components folder
958
00:42:40,140 --> 00:42:42,240
again in the GitHub just down below
959
00:42:42,240 --> 00:42:44,579
you'll find a file where we are
960
00:42:44,579 --> 00:42:46,680
exporting all of those components we
961
00:42:46,680 --> 00:42:48,420
have just created so we can simply
962
00:42:48,420 --> 00:42:51,180
import them in one line inside of every
963
00:42:51,180 --> 00:42:54,000
single other page in our project
964
00:42:54,000 --> 00:42:56,640
once you paste that we can close all of
965
00:42:56,640 --> 00:42:59,160
the currently open files go back to home
966
00:42:59,160 --> 00:43:03,060
which makes us ready to import them
967
00:43:03,060 --> 00:43:06,420
let's start by creating import and we're
968
00:43:06,420 --> 00:43:09,060
going to import the pie chart let's also
969
00:43:09,060 --> 00:43:12,780
do property referrals
970
00:43:12,780 --> 00:43:16,579
let's do total revenue
971
00:43:16,680 --> 00:43:18,660
we're going to also need the property
972
00:43:18,660 --> 00:43:19,920
card
973
00:43:19,920 --> 00:43:23,700
and finally top agent and all of these
974
00:43:23,700 --> 00:43:26,579
are coming from components
975
00:43:26,579 --> 00:43:29,099
great and now we can use them in our
976
00:43:29,099 --> 00:43:31,440
home that's going to be it for our
977
00:43:31,440 --> 00:43:33,359
Imports and we are ready to start
978
00:43:33,359 --> 00:43:35,540
creating the structure of our home page
979
00:43:35,540 --> 00:43:38,520
to get started with creating our home
980
00:43:38,520 --> 00:43:41,400
page we can first turn this div into a
981
00:43:41,400 --> 00:43:44,640
box since we're using material UI a box
982
00:43:44,640 --> 00:43:46,380
essentially is a div with some
983
00:43:46,380 --> 00:43:48,660
additional properties and of course all
984
00:43:48,660 --> 00:43:50,220
of these properties that we want to use
985
00:43:50,220 --> 00:43:53,520
we need to import at the top so right
986
00:43:53,520 --> 00:43:56,700
here let's import typography
987
00:43:56,700 --> 00:43:58,740
which is essentially a fancy way of
988
00:43:58,740 --> 00:44:00,780
saying a text element
989
00:44:00,780 --> 00:44:05,819
a box and a stack coming from add pan
990
00:44:05,819 --> 00:44:08,819
code and that's going to be refine Dash
991
00:44:08,819 --> 00:44:12,240
mui and if we save this we should be
992
00:44:12,240 --> 00:44:14,040
able to see what we had at the start
993
00:44:14,040 --> 00:44:17,460
which is an empty slate now right here
994
00:44:17,460 --> 00:44:20,760
we can add a typography so let's add a
995
00:44:20,760 --> 00:44:24,180
typography that is not a self-closing
996
00:44:24,180 --> 00:44:25,200
element
997
00:44:25,200 --> 00:44:28,319
but it's going to say dashboard
998
00:44:28,319 --> 00:44:30,480
let's give it a couple of props such as
999
00:44:30,480 --> 00:44:36,000
font size of 25 font weight of 700 and
1000
00:44:36,000 --> 00:44:38,280
let's also give it a color
1001
00:44:38,280 --> 00:44:43,200
equal to Hash one one one four two d
1002
00:44:43,200 --> 00:44:45,900
now if we save this we can see our
1003
00:44:45,900 --> 00:44:47,520
dashboard title
1004
00:44:47,520 --> 00:44:50,180
below that we're gonna have one more box
1005
00:44:50,180 --> 00:44:53,339
and this box is going to wrap our four
1006
00:44:53,339 --> 00:44:57,540
charts these ones right here so that box
1007
00:44:57,540 --> 00:45:00,300
is going to have an empty of 20 pixels
1008
00:45:00,300 --> 00:45:03,119
for margin top it's going to have a
1009
00:45:03,119 --> 00:45:06,300
display equal to flex and it's going to
1010
00:45:06,300 --> 00:45:10,200
have a flex wrap equal to wrap finally a
1011
00:45:10,200 --> 00:45:13,319
gap of four inside of there we can
1012
00:45:13,319 --> 00:45:17,339
render our PI chart component that looks
1013
00:45:17,339 --> 00:45:19,020
like this
1014
00:45:19,020 --> 00:45:21,180
that is just the component that right
1015
00:45:21,180 --> 00:45:24,599
now says by chart that's about it but
1016
00:45:24,599 --> 00:45:26,520
soon enough we're going to develop it so
1017
00:45:26,520 --> 00:45:29,220
that it represents some data so let's
1018
00:45:29,220 --> 00:45:31,980
pass some props to it let's pass a title
1019
00:45:31,980 --> 00:45:35,400
equal to properties
1020
00:45:35,400 --> 00:45:37,380
for sale
1021
00:45:37,380 --> 00:45:41,640
let's add a value let's say there is 684
1022
00:45:41,640 --> 00:45:43,800
for now we're going to leave this static
1023
00:45:43,800 --> 00:45:46,859
we're going to add a series of an array
1024
00:45:46,859 --> 00:45:50,400
of 75 and 25 you're gonna soon see what
1025
00:45:50,400 --> 00:45:52,740
this is and then we can provide colors
1026
00:45:52,740 --> 00:45:56,099
for those Series so those colors can be
1027
00:45:56,099 --> 00:45:57,420
an array
1028
00:45:57,420 --> 00:46:00,780
off first one is going to be four seven
1029
00:46:00,780 --> 00:46:04,079
five b e eight and then the second one
1030
00:46:04,079 --> 00:46:10,079
can be hash E4 E8 e f great and now
1031
00:46:10,079 --> 00:46:12,119
immediately you can see that typescript
1032
00:46:12,119 --> 00:46:15,300
lets us know that this pie chart is not
1033
00:46:15,300 --> 00:46:17,640
accepting a title property so that is
1034
00:46:17,640 --> 00:46:19,859
something that we have too so it
1035
00:46:19,859 --> 00:46:21,839
essentially lets us know hey you're not
1036
00:46:21,839 --> 00:46:23,579
expecting any properties here which is
1037
00:46:23,579 --> 00:46:24,839
pretty cool
1038
00:46:24,839 --> 00:46:28,260
great now that we have this property we
1039
00:46:28,260 --> 00:46:30,420
can also duplicate it four more times
1040
00:46:30,420 --> 00:46:32,760
because we need four of these and we can
1041
00:46:32,760 --> 00:46:34,619
just change some values for the second
1042
00:46:34,619 --> 00:46:37,380
one let's say properties for rent change
1043
00:46:37,380 --> 00:46:41,040
this to about 550 maybe a series of 60
1044
00:46:41,040 --> 00:46:44,160
and 40 these are percentages
1045
00:46:44,160 --> 00:46:46,800
we can also randomize the colors just a
1046
00:46:46,800 --> 00:46:49,140
bit so I'm going to change some letters
1047
00:46:49,140 --> 00:46:50,280
right here
1048
00:46:50,280 --> 00:46:52,500
the third one is going to be total
1049
00:46:52,500 --> 00:46:55,040
customers
1050
00:46:55,500 --> 00:46:58,579
let's say that is equal to
1051
00:46:58,579 --> 00:47:03,240
5684. let's leave that to 75.25 let's
1052
00:47:03,240 --> 00:47:06,119
change the colors just a bit again just
1053
00:47:06,119 --> 00:47:08,220
entering some random numbers and the
1054
00:47:08,220 --> 00:47:10,680
last one is going to be total cities so
1055
00:47:10,680 --> 00:47:12,240
this is the amount of cities that we
1056
00:47:12,240 --> 00:47:15,060
have in which we have properties in and
1057
00:47:15,060 --> 00:47:16,880
that can be about
1058
00:47:16,880 --> 00:47:19,680
555. great
1059
00:47:19,680 --> 00:47:23,520
now we can save that we can go into the
1060
00:47:23,520 --> 00:47:26,099
pie chart component and we can properly
1061
00:47:26,099 --> 00:47:29,220
accept these properties so we are
1062
00:47:29,220 --> 00:47:32,880
accepting a title we need a value a
1063
00:47:32,880 --> 00:47:35,520
series and colors
1064
00:47:35,520 --> 00:47:38,819
great and we can start creating this
1065
00:47:38,819 --> 00:47:42,960
card right here properties for sale so
1066
00:47:42,960 --> 00:47:44,760
to do that we're going to convert this
1067
00:47:44,760 --> 00:47:47,040
into a box
1068
00:47:47,040 --> 00:47:49,200
and still I think we're getting that
1069
00:47:49,200 --> 00:47:51,300
error and that's because the box is not
1070
00:47:51,300 --> 00:47:53,819
defined so in pie chart we have to
1071
00:47:53,819 --> 00:47:54,839
import
1072
00:47:54,839 --> 00:47:56,240
box
1073
00:47:56,240 --> 00:48:01,200
typography and the stack coming from at
1074
00:48:01,200 --> 00:48:06,060
that's going to be pan card refine mui
1075
00:48:06,060 --> 00:48:08,460
and we also need to import the interface
1076
00:48:08,460 --> 00:48:10,980
for typescript so that's going to be Pi
1077
00:48:10,980 --> 00:48:13,619
chart props
1078
00:48:13,619 --> 00:48:16,140
from interfaces
1079
00:48:16,140 --> 00:48:19,560
home like this get right
1080
00:48:19,560 --> 00:48:22,680
now we have to specify that these props
1081
00:48:22,680 --> 00:48:25,980
are going to be of a type pie chart
1082
00:48:25,980 --> 00:48:29,160
prompts and now typescript immediately
1083
00:48:29,160 --> 00:48:31,619
helps us as you can see right here we're
1084
00:48:31,619 --> 00:48:34,800
accepting callers but in the home we
1085
00:48:34,800 --> 00:48:37,380
provided color which is phenomenal
1086
00:48:37,380 --> 00:48:39,060
because we know that we simply need to
1087
00:48:39,060 --> 00:48:41,280
change this to colors and then the value
1088
00:48:41,280 --> 00:48:43,740
is properly going to work if we didn't
1089
00:48:43,740 --> 00:48:45,599
have typescript in this case we could
1090
00:48:45,599 --> 00:48:48,180
have spent hours trying to find that one
1091
00:48:48,180 --> 00:48:52,079
little typo great with that said let's
1092
00:48:52,079 --> 00:48:56,099
create our look and feel of our card
1093
00:48:56,099 --> 00:49:00,780
first let's add a stack within this box
1094
00:49:00,780 --> 00:49:03,060
that stack is essentially just a div
1095
00:49:03,060 --> 00:49:05,160
that's going to have a direction of
1096
00:49:05,160 --> 00:49:07,980
column and inside of there we want to
1097
00:49:07,980 --> 00:49:10,740
have two different typographies four two
1098
00:49:10,740 --> 00:49:12,480
different pieces of text
1099
00:49:12,480 --> 00:49:15,240
so let's create a first typography
1100
00:49:15,240 --> 00:49:18,420
that one is going to render the title
1101
00:49:18,420 --> 00:49:20,460
and if you save it we should be able to
1102
00:49:20,460 --> 00:49:22,380
see it right here properties for sale
1103
00:49:22,380 --> 00:49:25,079
rent total customers and properties for
1104
00:49:25,079 --> 00:49:28,020
cities now let's modify it a bit by
1105
00:49:28,020 --> 00:49:31,319
giving it a font size of 14.
1106
00:49:31,319 --> 00:49:35,300
and let's give it a cooler equal to
1107
00:49:35,300 --> 00:49:38,280
808191 and of course we need a hash at
1108
00:49:38,280 --> 00:49:40,740
the start finally below that we're gonna
1109
00:49:40,740 --> 00:49:43,319
have one more typography much larger
1110
00:49:43,319 --> 00:49:46,140
this time 24. the color is going to be
1111
00:49:46,140 --> 00:49:50,220
one one one four two D and then it's
1112
00:49:50,220 --> 00:49:53,099
also going to have a font weight
1113
00:49:53,099 --> 00:49:57,359
equal to 700 meaning bolded and a margin
1114
00:49:57,359 --> 00:50:00,540
top of one or Mt and it's going to
1115
00:50:00,540 --> 00:50:02,400
render the value
1116
00:50:02,400 --> 00:50:04,920
so now we have our title and we also
1117
00:50:04,920 --> 00:50:07,079
have the value great
1118
00:50:07,079 --> 00:50:10,020
finally we can render our react Apex
1119
00:50:10,020 --> 00:50:13,380
chart by importing it at the top we can
1120
00:50:13,380 --> 00:50:17,579
say import react Apex chart
1121
00:50:17,579 --> 00:50:21,780
from react Dash Apex charts and then we
1122
00:50:21,780 --> 00:50:23,460
can render it as a self-closing
1123
00:50:23,460 --> 00:50:26,520
component just below the stack
1124
00:50:26,520 --> 00:50:30,359
react Apex
1125
00:50:30,359 --> 00:50:33,720
chart and self-close it
1126
00:50:33,720 --> 00:50:36,599
we need to provided options first
1127
00:50:36,599 --> 00:50:39,480
so that's going to be an object where
1128
00:50:39,480 --> 00:50:40,560
the chart
1129
00:50:40,560 --> 00:50:42,900
it's going to have another object and
1130
00:50:42,900 --> 00:50:45,420
it's going to have a type of donut in
1131
00:50:45,420 --> 00:50:48,059
this case so this is a donut chart it's
1132
00:50:48,059 --> 00:50:49,920
going to have colors which is going to
1133
00:50:49,920 --> 00:50:52,740
be equal to colors like this meaning we
1134
00:50:52,740 --> 00:50:55,079
can just omit the latter
1135
00:50:55,079 --> 00:50:57,420
then it's going to have a legend which
1136
00:50:57,420 --> 00:50:59,940
in this case show is going to be false
1137
00:50:59,940 --> 00:51:02,400
because we don't need it and it's going
1138
00:51:02,400 --> 00:51:06,059
to have data labels again an object of
1139
00:51:06,059 --> 00:51:09,359
enabled is equal to false because we
1140
00:51:09,359 --> 00:51:12,780
don't need any data labels in this case
1141
00:51:12,780 --> 00:51:15,599
so that's it for the options if we just
1142
00:51:15,599 --> 00:51:18,180
add a final comma right here and we save
1143
00:51:18,180 --> 00:51:21,119
it let's see if we see something
1144
00:51:21,119 --> 00:51:24,839
nope nothing yet and that's because data
1145
00:51:24,839 --> 00:51:26,819
labels
1146
00:51:26,819 --> 00:51:28,680
looks like I misspelled it right here
1147
00:51:28,680 --> 00:51:31,079
but good thing we're using typescript so
1148
00:51:31,079 --> 00:51:33,780
it notice that and we are good to go we
1149
00:51:33,780 --> 00:51:36,599
cannot yet quite see the chart but
1150
00:51:36,599 --> 00:51:40,020
that's because below the options we
1151
00:51:40,020 --> 00:51:42,359
didn't yet provided a series we didn't
1152
00:51:42,359 --> 00:51:45,300
provide the type equal to Donut and most
1153
00:51:45,300 --> 00:51:47,280
importantly we need to give it a width
1154
00:51:47,280 --> 00:51:51,720
of 120 pixels now if we save that you
1155
00:51:51,720 --> 00:51:53,760
can see those beautiful charts appear
1156
00:51:53,760 --> 00:51:56,579
right here and not only that if you
1157
00:51:56,579 --> 00:51:58,680
reload they're going to be nicely
1158
00:51:58,680 --> 00:52:00,059
animated
1159
00:52:00,059 --> 00:52:03,480
wonderful finally let's style the cards
1160
00:52:03,480 --> 00:52:05,099
themselves
1161
00:52:05,099 --> 00:52:07,680
we can do that by styling the Box
1162
00:52:07,680 --> 00:52:10,079
so let's make some space and let's give
1163
00:52:10,079 --> 00:52:13,079
it an ID equal to chart let's give it a
1164
00:52:13,079 --> 00:52:15,660
flex property of one
1165
00:52:15,660 --> 00:52:18,240
let's give it a display equal to flex as
1166
00:52:18,240 --> 00:52:22,400
well we can give it a BG color of hash
1167
00:52:22,400 --> 00:52:27,599
fcfc FC also a flex Direction
1168
00:52:27,599 --> 00:52:29,640
of row
1169
00:52:29,640 --> 00:52:32,960
justify content
1170
00:52:33,359 --> 00:52:37,440
of space Dash between align items of
1171
00:52:37,440 --> 00:52:38,339
Center
1172
00:52:38,339 --> 00:52:41,300
PL for padding left of 3.5
1173
00:52:41,300 --> 00:52:44,780
py meaning padding vertical axis of 2
1174
00:52:44,780 --> 00:52:47,280
Gap two
1175
00:52:47,280 --> 00:52:52,140
and finally border radius of 15 pixels
1176
00:52:52,140 --> 00:52:55,380
minimum height or Min height equal to
1177
00:52:55,380 --> 00:52:58,800
110 pixels and then the width equal to
1178
00:52:58,800 --> 00:53:01,920
fit Dash content now if we save this
1179
00:53:01,920 --> 00:53:04,140
we're going to see the look and feel of
1180
00:53:04,140 --> 00:53:06,660
our newly created charts of course only
1181
00:53:06,660 --> 00:53:08,520
if we fix the error that we have right
1182
00:53:08,520 --> 00:53:11,040
here it looks like we misspelled height
1183
00:53:11,040 --> 00:53:15,300
so if we fix Min height there we go this
1184
00:53:15,300 --> 00:53:18,839
is looking wonderful we have all of our
1185
00:53:18,839 --> 00:53:21,000
charts right here we can even hover to
1186
00:53:21,000 --> 00:53:23,520
see what it is about also some of the
1187
00:53:23,520 --> 00:53:25,260
charts have colors that are a bit hard
1188
00:53:25,260 --> 00:53:27,540
to see on the white background so what
1189
00:53:27,540 --> 00:53:29,640
we can do is take maybe the third chart
1190
00:53:29,640 --> 00:53:32,700
and then copy the colors for it to all
1191
00:53:32,700 --> 00:53:35,579
other colors as well of course feel free
1192
00:53:35,579 --> 00:53:37,559
to play with this and put the ones that
1193
00:53:37,559 --> 00:53:41,880
you prefer the most if we save this now
1194
00:53:41,880 --> 00:53:45,300
there we go this is looking great we
1195
00:53:45,300 --> 00:53:46,800
have four different cards and if we
1196
00:53:46,800 --> 00:53:49,440
expand this you can see they have a flex
1197
00:53:49,440 --> 00:53:51,240
property so they're always going to
1198
00:53:51,240 --> 00:53:53,760
appear nicely on the screen wonderful
1199
00:53:53,760 --> 00:53:56,160
now with that said if we look at the
1200
00:53:56,160 --> 00:53:58,079
design we're done with the first part
1201
00:53:58,079 --> 00:54:00,300
and we are ready to begin with this
1202
00:54:00,300 --> 00:54:03,660
second huge chart right here so on the
1203
00:54:03,660 --> 00:54:06,720
home page we can go below our initial
1204
00:54:06,720 --> 00:54:09,960
box and then there we can create a new
1205
00:54:09,960 --> 00:54:11,099
stack
1206
00:54:11,099 --> 00:54:14,640
this stack is going to have a property
1207
00:54:14,640 --> 00:54:17,700
of empty margin top of 25 pixels to
1208
00:54:17,700 --> 00:54:20,640
divide it from the top cards a width of
1209
00:54:20,640 --> 00:54:22,260
100 percent
1210
00:54:22,260 --> 00:54:26,700
a direction equal to an object of on
1211
00:54:26,700 --> 00:54:29,099
small devices column
1212
00:54:29,099 --> 00:54:33,660
and on large devices meaning LG row so
1213
00:54:33,660 --> 00:54:35,579
this means that we're going to have it
1214
00:54:35,579 --> 00:54:38,460
next to each other on big devices but on
1215
00:54:38,460 --> 00:54:40,319
smaller devices they're going to appear
1216
00:54:40,319 --> 00:54:44,460
one below another great with that said
1217
00:54:44,460 --> 00:54:46,440
inside of there we can render two
1218
00:54:46,440 --> 00:54:49,079
different components total revenue which
1219
00:54:49,079 --> 00:54:51,480
is our huge chart a self-closing
1220
00:54:51,480 --> 00:54:54,180
component as well as property referrals
1221
00:54:54,180 --> 00:54:57,300
which is this smaller chart with that
1222
00:54:57,300 --> 00:54:59,520
said if we save it and go back
1223
00:54:59,520 --> 00:55:01,619
we should be able to see just the texts
1224
00:55:01,619 --> 00:55:04,200
but if we dive into this component by
1225
00:55:04,200 --> 00:55:06,359
control clicking it we can now start
1226
00:55:06,359 --> 00:55:09,480
developing the total revenue chart
1227
00:55:09,480 --> 00:55:12,660
great to start creating our total
1228
00:55:12,660 --> 00:55:15,900
revenue chart we can go back to home and
1229
00:55:15,900 --> 00:55:18,300
to the pie chart to quickly grab some of
1230
00:55:18,300 --> 00:55:19,920
the Imports right here we're going to
1231
00:55:19,920 --> 00:55:22,500
get the imports from the Apex charts and
1232
00:55:22,500 --> 00:55:25,559
the one from refine mui so we can go
1233
00:55:25,559 --> 00:55:27,359
back and we can paste them right here
1234
00:55:27,359 --> 00:55:30,059
we're going to also need one icon that's
1235
00:55:30,059 --> 00:55:31,980
going to be import
1236
00:55:31,980 --> 00:55:33,839
Arrow
1237
00:55:33,839 --> 00:55:34,920
Circle
1238
00:55:34,920 --> 00:55:39,480
up rounded and that is coming from add
1239
00:55:39,480 --> 00:55:42,839
mui forward slash icons Dash material
1240
00:55:42,839 --> 00:55:44,880
we're going to also need the chart
1241
00:55:44,880 --> 00:55:47,640
config so we can say import
1242
00:55:47,640 --> 00:55:50,220
total revenue
1243
00:55:50,220 --> 00:55:54,359
options from dot slash chart dot config
1244
00:55:54,359 --> 00:55:56,819
and there's one more config that's going
1245
00:55:56,819 --> 00:56:00,599
to be total revenue series also coming
1246
00:56:00,599 --> 00:56:03,300
from chart config if we quickly explore
1247
00:56:03,300 --> 00:56:04,980
those you're gonna see that these are
1248
00:56:04,980 --> 00:56:06,480
the ones that we provided at the start
1249
00:56:06,480 --> 00:56:09,300
of the video that's simply some data for
1250
00:56:09,300 --> 00:56:12,180
us to show in the chart later on you can
1251
00:56:12,180 --> 00:56:14,160
make this Dynamic but for now we're
1252
00:56:14,160 --> 00:56:16,500
going to use this chart config with that
1253
00:56:16,500 --> 00:56:18,480
said let's start by wrapping everything
1254
00:56:18,480 --> 00:56:21,480
in a box as we always do in mui
1255
00:56:21,480 --> 00:56:22,740
applications
1256
00:56:22,740 --> 00:56:25,920
this box is going to have some padding
1257
00:56:25,920 --> 00:56:29,819
so we can say p is equal to four then we
1258
00:56:29,819 --> 00:56:32,280
can give it a flex of one
1259
00:56:32,280 --> 00:56:35,180
we can set the BG color to be equal to
1260
00:56:35,180 --> 00:56:37,280
Hash
1261
00:56:37,280 --> 00:56:40,800
fcfcfc we can also give it an ID equal
1262
00:56:40,800 --> 00:56:44,160
to chart we can give it a display
1263
00:56:44,160 --> 00:56:46,680
equal to flex
1264
00:56:46,680 --> 00:56:50,640
a flex Direction equal to column and a
1265
00:56:50,640 --> 00:56:54,359
border radius equal to 15 pixels
1266
00:56:54,359 --> 00:56:57,660
there we go this is just our card
1267
00:56:57,660 --> 00:56:59,940
now what do we have to have in this card
1268
00:56:59,940 --> 00:57:03,660
let's look at the design so we have the
1269
00:57:03,660 --> 00:57:05,760
total revenue and then we have last
1270
00:57:05,760 --> 00:57:07,500
month running month this is going to
1271
00:57:07,500 --> 00:57:09,720
come with our chart and then we have the
1272
00:57:09,720 --> 00:57:12,359
revenue and the chart itself so with
1273
00:57:12,359 --> 00:57:14,760
that in mind let's create a new
1274
00:57:14,760 --> 00:57:16,319
typography
1275
00:57:16,319 --> 00:57:19,980
this typography is going to say total
1276
00:57:19,980 --> 00:57:21,780
revenue
1277
00:57:21,780 --> 00:57:24,480
and now we can style it a bit by giving
1278
00:57:24,480 --> 00:57:28,680
it a font size equal to 18 pixels
1279
00:57:28,680 --> 00:57:31,200
of course that's going to be like this
1280
00:57:31,200 --> 00:57:35,460
18 we can give it a font weight of 600
1281
00:57:35,460 --> 00:57:39,680
and a color of Hash
1282
00:57:39,680 --> 00:57:43,619
11142 D if we save this our Revenue just
1283
00:57:43,619 --> 00:57:47,280
grew a bit larger great now below that
1284
00:57:47,280 --> 00:57:49,800
we can create a stack
1285
00:57:49,800 --> 00:57:52,980
that stack is going to contain another
1286
00:57:52,980 --> 00:57:54,300
typography
1287
00:57:54,300 --> 00:57:57,300
which we can create right now and it's
1288
00:57:57,300 --> 00:57:58,619
going to say
1289
00:57:58,619 --> 00:58:00,380
dollar
1290
00:58:00,380 --> 00:58:05,579
236 comma 535 so we're showing this
1291
00:58:05,579 --> 00:58:08,400
dollar amount again right now static but
1292
00:58:08,400 --> 00:58:10,800
you can make it Dynamic if you want to
1293
00:58:10,800 --> 00:58:13,920
now let's style that stack by giving it
1294
00:58:13,920 --> 00:58:17,760
an m y of 20 pixels that's margin
1295
00:58:17,760 --> 00:58:23,040
vertical a direction equal to rho a gap
1296
00:58:23,040 --> 00:58:26,460
equal to four and a flex wrap equal to
1297
00:58:26,460 --> 00:58:30,059
wrap great and we can also style the
1298
00:58:30,059 --> 00:58:34,200
typography by giving it a font size of a
1299
00:58:34,200 --> 00:58:38,819
huge 28 pixels a font weight equal to
1300
00:58:38,819 --> 00:58:40,500
700
1301
00:58:40,500 --> 00:58:44,839
and a color equal to Hash one one one
1302
00:58:44,839 --> 00:58:48,720
four two D and if we save that that's
1303
00:58:48,720 --> 00:58:51,599
going to look just a bit better but now
1304
00:58:51,599 --> 00:58:54,180
below this typography we can create
1305
00:58:54,180 --> 00:58:57,420
another stack this stack is going to
1306
00:58:57,420 --> 00:59:01,380
have an arrow Circle rounded up
1307
00:59:01,380 --> 00:59:04,440
and it's going to have an SX prop
1308
00:59:04,440 --> 00:59:06,720
equal to an object we here we're going
1309
00:59:06,720 --> 00:59:11,460
to have the font size equal to 25 and
1310
00:59:11,460 --> 00:59:13,440
we're going to have a color equal to
1311
00:59:13,440 --> 00:59:15,440
Hash
1312
00:59:15,440 --> 00:59:18,240
475b E8
1313
00:59:18,240 --> 00:59:19,859
let's check it out
1314
00:59:19,859 --> 00:59:22,680
there we go so this is that icon and
1315
00:59:22,680 --> 00:59:25,079
then below that icon we're gonna have
1316
00:59:25,079 --> 00:59:29,099
another stack a stack within a stack and
1317
00:59:29,099 --> 00:59:32,640
that stack is going to have a typography
1318
00:59:32,640 --> 00:59:35,180
that's simply going to say
1319
00:59:35,180 --> 00:59:38,880
0.8 percent and we can give it a font
1320
00:59:38,880 --> 00:59:42,359
size equal to 15.
1321
00:59:42,359 --> 00:59:45,660
and we can give it a color equal to Hash
1322
00:59:45,660 --> 00:59:49,500
four seven five b e eight
1323
00:59:49,500 --> 00:59:51,480
if we save that you can see the
1324
00:59:51,480 --> 00:59:53,400
percentage and we're just trying to
1325
00:59:53,400 --> 00:59:56,160
achieve this look right here so finally
1326
00:59:56,160 --> 00:59:58,740
we can duplicate this typography
1327
00:59:58,740 --> 01:00:03,240
say instead of 1.8 we can say then last
1328
01:00:03,240 --> 01:00:04,799
month
1329
01:00:04,799 --> 01:00:07,319
and there we can change the color to
1330
01:00:07,319 --> 01:00:10,980
eight zero eight one nine one
1331
01:00:10,980 --> 01:00:13,440
and if we go back this is looking a bit
1332
01:00:13,440 --> 01:00:15,960
closer than what we had before we can
1333
01:00:15,960 --> 01:00:18,180
also change the font size to 12 to make
1334
01:00:18,180 --> 01:00:20,520
this a bit smaller
1335
01:00:20,520 --> 01:00:23,700
finally the stack above has to have a
1336
01:00:23,700 --> 01:00:24,780
Direction
1337
01:00:24,780 --> 01:00:27,720
equal to rho now make sure that you're
1338
01:00:27,720 --> 01:00:30,299
editing this stack right here and not
1339
01:00:30,299 --> 01:00:32,040
this tag that's wrapping these two
1340
01:00:32,040 --> 01:00:34,799
elements so stack and then we have arrow
1341
01:00:34,799 --> 01:00:37,140
that stack has to have a direction of
1342
01:00:37,140 --> 01:00:42,420
row also align items equal to Center
1343
01:00:42,420 --> 01:00:46,140
and finally a gap equal to one if we
1344
01:00:46,140 --> 01:00:48,660
save this that's going to look just a
1345
01:00:48,660 --> 01:00:51,480
bit better there we go so the last thing
1346
01:00:51,480 --> 01:00:54,059
we need is going to be the chart itself
1347
01:00:54,059 --> 01:00:58,200
and we can do that below this last stack
1348
01:00:58,200 --> 01:01:01,619
right here we can render a react
1349
01:01:01,619 --> 01:01:05,640
Apex chart a self-closing chart that's
1350
01:01:05,640 --> 01:01:08,700
going to render series equal to total
1351
01:01:08,700 --> 01:01:10,740
revenue series
1352
01:01:10,740 --> 01:01:12,480
like this
1353
01:01:12,480 --> 01:01:15,299
we imported that at the top and then we
1354
01:01:15,299 --> 01:01:17,099
can render the type in this case it's
1355
01:01:17,099 --> 01:01:19,440
going to be a bar chart we can set the
1356
01:01:19,440 --> 01:01:23,059
height to 310 and we can provide options
1357
01:01:23,059 --> 01:01:27,480
equal to total revenue options
1358
01:01:27,480 --> 01:01:30,240
now if we save this
1359
01:01:30,240 --> 01:01:33,180
the chart appears now as you can see
1360
01:01:33,180 --> 01:01:35,579
this is still not looking exactly like
1361
01:01:35,579 --> 01:01:37,500
it does on the design it looks a bit
1362
01:01:37,500 --> 01:01:39,420
stretched out it has a bit too much
1363
01:01:39,420 --> 01:01:42,299
height so let's see where the issue
1364
01:01:42,299 --> 01:01:45,240
could be it's most likely going to be in
1365
01:01:45,240 --> 01:01:49,020
a stack that wraps our chart as well as
1366
01:01:49,020 --> 01:01:51,839
our typography so there instead of doing
1367
01:01:51,839 --> 01:01:55,079
my 20 which is 20 times the special
1368
01:01:55,079 --> 01:01:57,839
material AI unit we just want to do 20
1369
01:01:57,839 --> 01:02:00,359
pixels that's going to make all the
1370
01:02:00,359 --> 01:02:01,799
difference
1371
01:02:01,799 --> 01:02:05,040
there we go so now if we expand this we
1372
01:02:05,040 --> 01:02:08,400
have a beautiful Revenue which also is
1373
01:02:08,400 --> 01:02:10,440
fully responsive as you can see right
1374
01:02:10,440 --> 01:02:13,040
here so it's going to adapt to any size
1375
01:02:13,040 --> 01:02:16,380
and also just to show you if we reload
1376
01:02:16,380 --> 01:02:18,000
we're going to have a wonderful
1377
01:02:18,000 --> 01:02:20,280
animation and we can also hover over it
1378
01:02:20,280 --> 01:02:23,099
to get more details we can also click
1379
01:02:23,099 --> 01:02:25,799
right here to collab specific pieces and
1380
01:02:25,799 --> 01:02:27,900
it's going to nicely animate
1381
01:02:27,900 --> 01:02:31,079
Apex charts really is phenomenal so I
1382
01:02:31,079 --> 01:02:33,480
highly recommend you checking it out but
1383
01:02:33,480 --> 01:02:36,359
in this case I prefer this one with that
1384
01:02:36,359 --> 01:02:38,280
said we can move to the second piece
1385
01:02:38,280 --> 01:02:40,619
which is property referrals we can close
1386
01:02:40,619 --> 01:02:43,020
the total revenue and then go to home
1387
01:02:43,020 --> 01:02:45,780
and control click property referrals
1388
01:02:45,780 --> 01:02:49,619
great to get started with our property
1389
01:02:49,619 --> 01:02:52,500
referrals we can once again import the
1390
01:02:52,500 --> 01:02:56,760
Box the stack and the typography coming
1391
01:02:56,760 --> 01:03:02,280
from pan card refine mui great now on
1392
01:03:02,280 --> 01:03:04,980
top of that we're gonna also import a
1393
01:03:04,980 --> 01:03:08,760
property referrals info which is coming
1394
01:03:08,760 --> 01:03:12,720
from Constance forward slash index
1395
01:03:12,720 --> 01:03:15,660
great let's just spell it properly so we
1396
01:03:15,660 --> 01:03:18,540
don't have any mistakes later on and we
1397
01:03:18,540 --> 01:03:21,540
should be good to go now to get started
1398
01:03:21,540 --> 01:03:23,460
with property referrals we can again
1399
01:03:23,460 --> 01:03:26,579
turn this into a box and it's going to
1400
01:03:26,579 --> 01:03:28,980
have almost the same exact properties as
1401
01:03:28,980 --> 01:03:31,260
the previous box so let's go to total
1402
01:03:31,260 --> 01:03:33,599
revenue and let's simply copy all of
1403
01:03:33,599 --> 01:03:36,839
these properties go back and then add
1404
01:03:36,839 --> 01:03:39,480
them right here
1405
01:03:39,480 --> 01:03:42,180
now let's see padding is going to remain
1406
01:03:42,180 --> 01:03:45,380
for Flex in this case we don't need Flex
1407
01:03:45,380 --> 01:03:48,599
BG color is going to remain the same ID
1408
01:03:48,599 --> 01:03:51,839
is fine in this case we'll have to add a
1409
01:03:51,839 --> 01:03:56,760
Min width of 490 display Flex for the
1410
01:03:56,760 --> 01:03:59,819
radius 15 and flex Direction column
1411
01:03:59,819 --> 01:04:02,819
great inside of there we can also have a
1412
01:04:02,819 --> 01:04:04,740
typography which is going to be the same
1413
01:04:04,740 --> 01:04:07,079
as in the total revenue so we can simply
1414
01:04:07,079 --> 01:04:10,980
copy it go back and paste it right here
1415
01:04:10,980 --> 01:04:13,799
that's a typography with a font size of
1416
01:04:13,799 --> 01:04:17,960
18 font weight of 600 and the color of
1417
01:04:17,960 --> 01:04:21,480
1142d and it's going to say not total
1418
01:04:21,480 --> 01:04:25,619
revenue but rather property referrals
1419
01:04:25,619 --> 01:04:28,559
there we go now if we save this we
1420
01:04:28,559 --> 01:04:30,240
should be able to see that box appear
1421
01:04:30,240 --> 01:04:32,339
right here below
1422
01:04:32,339 --> 01:04:35,520
and there below this typography we want
1423
01:04:35,520 --> 01:04:38,520
to add a stack that stack is going to
1424
01:04:38,520 --> 01:04:42,660
have an my of 20 pixels a direction of
1425
01:04:42,660 --> 01:04:46,440
column and a gap of four
1426
01:04:46,440 --> 01:04:49,040
and inside of there we want to map over
1427
01:04:49,040 --> 01:04:52,920
all of these bars so if you look at this
1428
01:04:52,920 --> 01:04:54,180
we're going to have a couple of
1429
01:04:54,180 --> 01:04:56,400
different bars each bar is going to have
1430
01:04:56,400 --> 01:04:59,220
a name or a title a percentage and then
1431
01:04:59,220 --> 01:05:00,960
the this bar that's going to represent
1432
01:05:00,960 --> 01:05:03,780
the percent filled so to make our life a
1433
01:05:03,780 --> 01:05:06,299
bit easier we're going to create a new
1434
01:05:06,299 --> 01:05:08,640
component called progress bar
1435
01:05:08,640 --> 01:05:13,140
can't progress bar is equal to an arrow
1436
01:05:13,140 --> 01:05:14,460
function or rather a functional
1437
01:05:14,460 --> 01:05:16,799
component with an instant return meaning
1438
01:05:16,799 --> 01:05:18,960
just put parentheses right here
1439
01:05:18,960 --> 01:05:20,579
and we're going to pass a couple of
1440
01:05:20,579 --> 01:05:22,980
props to it we're going to pass a title
1441
01:05:22,980 --> 01:05:26,520
a percentage and a color
1442
01:05:26,520 --> 01:05:28,559
and since we're in typescript we have to
1443
01:05:28,559 --> 01:05:31,200
Define this as an interface so right
1444
01:05:31,200 --> 01:05:33,480
here we can say interface
1445
01:05:33,480 --> 01:05:37,920
progress bar props and that's going to
1446
01:05:37,920 --> 01:05:41,160
be a title of string it's also going to
1447
01:05:41,160 --> 01:05:44,099
have a percentage of number and it's
1448
01:05:44,099 --> 01:05:46,500
going to have a color of string and now
1449
01:05:46,500 --> 01:05:49,079
we can Define our progress bar props as
1450
01:05:49,079 --> 01:05:53,520
progress bar props great now how is our
1451
01:05:53,520 --> 01:05:55,619
progress bar going to look like well
1452
01:05:55,619 --> 01:05:57,720
first we have to have a stack with a
1453
01:05:57,720 --> 01:06:00,660
title any percentage on top so let's
1454
01:06:00,660 --> 01:06:03,859
create a box element
1455
01:06:04,619 --> 01:06:07,859
that box is going to have a width of 100
1456
01:06:07,859 --> 01:06:09,540
percent
1457
01:06:09,540 --> 01:06:11,640
inside of there we're going to have a
1458
01:06:11,640 --> 01:06:14,640
stack and that stack is going to have a
1459
01:06:14,640 --> 01:06:17,579
direction equal to row because here
1460
01:06:17,579 --> 01:06:19,559
social media is in the left side and
1461
01:06:19,559 --> 01:06:21,240
then we have on the right side of
1462
01:06:21,240 --> 01:06:22,559
percentage
1463
01:06:22,559 --> 01:06:25,079
it's also going to be align items equal
1464
01:06:25,079 --> 01:06:28,859
to Center and justify content
1465
01:06:28,859 --> 01:06:31,980
is going to be space Dash between as you
1466
01:06:31,980 --> 01:06:33,480
can see right here social media on the
1467
01:06:33,480 --> 01:06:35,099
left side and percentage on the right
1468
01:06:35,099 --> 01:06:36,000
side
1469
01:06:36,000 --> 01:06:38,039
inside of there we want to have two
1470
01:06:38,039 --> 01:06:41,099
different typographies so typography one
1471
01:06:41,099 --> 01:06:44,400
is going to Simply render the title and
1472
01:06:44,400 --> 01:06:46,079
we can give it some styles
1473
01:06:46,079 --> 01:06:49,140
font size of 16
1474
01:06:49,140 --> 01:06:53,299
font weight of 500 and finally a color
1475
01:06:53,299 --> 01:06:57,299
of hash1142d
1476
01:06:59,099 --> 01:07:00,780
and finally we can duplicate this
1477
01:07:00,780 --> 01:07:02,339
topography below
1478
01:07:02,339 --> 01:07:05,220
render the percentage and add a
1479
01:07:05,220 --> 01:07:07,319
percentage sign after that
1480
01:07:07,319 --> 01:07:10,740
now if we save this and go back nothing
1481
01:07:10,740 --> 01:07:12,900
is going to show because we're not using
1482
01:07:12,900 --> 01:07:15,299
this progress bar yet so right here
1483
01:07:15,299 --> 01:07:18,420
below let's Loop over all of our
1484
01:07:18,420 --> 01:07:22,559
property referrals info call a DOT map
1485
01:07:22,559 --> 01:07:25,980
on it get each individual bar and for
1486
01:07:25,980 --> 01:07:29,280
each bar return a progress bar
1487
01:07:29,280 --> 01:07:32,099
self-closing component to which we can
1488
01:07:32,099 --> 01:07:35,940
pass a key equal to bar.title and we can
1489
01:07:35,940 --> 01:07:38,579
spread out all of the rest of bar
1490
01:07:38,579 --> 01:07:40,980
properties now this property referrals
1491
01:07:40,980 --> 01:07:43,260
info is simply an array of a lot of
1492
01:07:43,260 --> 01:07:46,200
different titles percentages and colors
1493
01:07:46,200 --> 01:07:49,619
copied from this design right here so if
1494
01:07:49,619 --> 01:07:52,319
we go back and now we should be able to
1495
01:07:52,319 --> 01:07:55,680
see social media 64 Marketplace 40 and
1496
01:07:55,680 --> 01:07:57,780
so on great
1497
01:07:57,780 --> 01:08:00,059
but now we have to implement the bar
1498
01:08:00,059 --> 01:08:03,660
itself this part so that's going to be
1499
01:08:03,660 --> 01:08:06,960
right below the stack right below the
1500
01:08:06,960 --> 01:08:09,780
stack we can create another box that box
1501
01:08:09,780 --> 01:08:12,780
is going to have a margin 2 to divide it
1502
01:08:12,780 --> 01:08:15,539
a bit from the top a position equal to
1503
01:08:15,539 --> 01:08:16,920
relative
1504
01:08:16,920 --> 01:08:19,859
a width of 100 percent
1505
01:08:19,859 --> 01:08:24,359
and a height of only 8 pixels finally a
1506
01:08:24,359 --> 01:08:29,399
border radius of 1. and a BG cooler
1507
01:08:29,399 --> 01:08:32,960
equal to Hash E4
1508
01:08:32,960 --> 01:08:35,640
E8 e f
1509
01:08:35,640 --> 01:08:37,799
and finally inside of there we can
1510
01:08:37,799 --> 01:08:39,359
render a box
1511
01:08:39,359 --> 01:08:41,819
that box is going to be a self-closing
1512
01:08:41,819 --> 01:08:42,839
component
1513
01:08:42,839 --> 01:08:46,500
it's going to have a width equal to a
1514
01:08:46,500 --> 01:08:49,560
template string of percentage and then
1515
01:08:49,560 --> 01:08:52,140
we can add a percentage sign at the end
1516
01:08:52,140 --> 01:08:54,299
and most importantly it's going to have
1517
01:08:54,299 --> 01:08:57,779
a BG color equal to color now if we save
1518
01:08:57,779 --> 01:08:59,580
this and go back
1519
01:08:59,580 --> 01:09:02,819
we can already see empty bar lines
1520
01:09:02,819 --> 01:09:05,160
now the only thing we have to do is give
1521
01:09:05,160 --> 01:09:08,160
it a position equal to Absolute and this
1522
01:09:08,160 --> 01:09:10,080
is going to make the colors appear on
1523
01:09:10,080 --> 01:09:12,179
top of these elements of course after
1524
01:09:12,179 --> 01:09:15,238
giving it a height of 100 percent
1525
01:09:15,238 --> 01:09:18,719
and a border radius of one
1526
01:09:18,719 --> 01:09:20,880
there we go so now we can see those
1527
01:09:20,880 --> 01:09:23,219
items appear right there and you can see
1528
01:09:23,219 --> 01:09:25,198
we are not in the full width right now
1529
01:09:25,198 --> 01:09:27,060
of the browser but still everything
1530
01:09:27,060 --> 01:09:30,000
looks and feels so nice and if you
1531
01:09:30,000 --> 01:09:31,439
expand it further
1532
01:09:31,439 --> 01:09:33,839
you can see how nicely it appears on the
1533
01:09:33,839 --> 01:09:36,120
right side right here the one thing that
1534
01:09:36,120 --> 01:09:38,759
we're missing is the spacing between the
1535
01:09:38,759 --> 01:09:41,460
total revenue and property referrals
1536
01:09:41,460 --> 01:09:44,339
so if we collapse this
1537
01:09:44,339 --> 01:09:46,140
we can now close the appropriate
1538
01:09:46,140 --> 01:09:48,359
referral since we're done with that on
1539
01:09:48,359 --> 01:09:50,460
this stack wrapping the revenue and
1540
01:09:50,460 --> 01:09:53,040
property referrals we can add a gap
1541
01:09:53,040 --> 01:09:55,500
property of four and that's going to
1542
01:09:55,500 --> 01:09:58,199
give us a gap between those two elements
1543
01:09:58,199 --> 01:10:01,380
there we go it just appeared so if we
1544
01:10:01,380 --> 01:10:03,660
expand it you can see how beautiful this
1545
01:10:03,660 --> 01:10:06,780
is we have our fully animated charts
1546
01:10:06,780 --> 01:10:09,239
right here we also have our charts on
1547
01:10:09,239 --> 01:10:11,340
the top and we have property referrals
1548
01:10:11,340 --> 01:10:13,920
on the right side this is all a process
1549
01:10:13,920 --> 01:10:16,440
of creating a dashboard but now we're
1550
01:10:16,440 --> 01:10:18,480
going to dive into creating properties
1551
01:10:18,480 --> 01:10:21,000
and that's where we dive into the full
1552
01:10:21,000 --> 01:10:23,580
stack part of this application if I open
1553
01:10:23,580 --> 01:10:26,880
up our figma design you can see that now
1554
01:10:26,880 --> 01:10:28,260
we're going to start working with
1555
01:10:28,260 --> 01:10:30,960
property lists meaning we have to be
1556
01:10:30,960 --> 01:10:33,420
able to create those properties read
1557
01:10:33,420 --> 01:10:36,600
them update them and delete them so
1558
01:10:36,600 --> 01:10:38,400
we're diving into an interesting part of
1559
01:10:38,400 --> 01:10:42,000
this video right away for now we can be
1560
01:10:42,000 --> 01:10:43,980
happy with the dashboard we can close
1561
01:10:43,980 --> 01:10:45,900
our our home
1562
01:10:45,900 --> 01:10:48,780
and go to our app and we can start
1563
01:10:48,780 --> 01:10:52,260
implementing our first ever resource or
1564
01:10:52,260 --> 01:10:54,780
property so instead of rendering this
1565
01:10:54,780 --> 01:10:58,080
mui dummy component we can render a list
1566
01:10:58,080 --> 01:11:01,800
of all properties
1567
01:11:01,800 --> 01:11:04,560
and if you remember correctly that was
1568
01:11:04,560 --> 01:11:07,320
one of the pages that we imported at the
1569
01:11:07,320 --> 01:11:09,540
top as a matter of fact while we're
1570
01:11:09,540 --> 01:11:12,060
still here let's put all of our pages to
1571
01:11:12,060 --> 01:11:12,900
use
1572
01:11:12,900 --> 01:11:15,360
we're going to show all properties on a
1573
01:11:15,360 --> 01:11:17,580
list but if we want to show an
1574
01:11:17,580 --> 01:11:19,560
individual property then we can show
1575
01:11:19,560 --> 01:11:22,380
property details if we want to create a
1576
01:11:22,380 --> 01:11:24,120
property we're going to render create
1577
01:11:24,120 --> 01:11:26,400
property and if you want to edit
1578
01:11:26,400 --> 01:11:28,140
property we're going to render the edit
1579
01:11:28,140 --> 01:11:30,960
property page refine provides all of
1580
01:11:30,960 --> 01:11:33,060
these out of the box so you don't have
1581
01:11:33,060 --> 01:11:35,400
to worry about crowd functionalities you
1582
01:11:35,400 --> 01:11:37,620
just have to create pages that implement
1583
01:11:37,620 --> 01:11:39,960
it and then everything is going to work
1584
01:11:39,960 --> 01:11:41,699
right out of the box
1585
01:11:41,699 --> 01:11:44,219
so now if we go to properties you can
1586
01:11:44,219 --> 01:11:46,440
see all properties and then later on
1587
01:11:46,440 --> 01:11:48,600
once we re-navigate to one of these
1588
01:11:48,600 --> 01:11:50,340
individual properties
1589
01:11:50,340 --> 01:11:52,440
refine is automatically going to render
1590
01:11:52,440 --> 01:11:55,199
the property details now we can do a
1591
01:11:55,199 --> 01:11:57,719
similar thing with our agent we're going
1592
01:11:57,719 --> 01:12:01,320
to render a list of Agents
1593
01:12:01,320 --> 01:12:03,120
and we're going to render a show of
1594
01:12:03,120 --> 01:12:04,800
agent profile
1595
01:12:04,800 --> 01:12:07,440
for our review that's just a dummy list
1596
01:12:07,440 --> 01:12:09,600
item so we can re-navigate it back to
1597
01:12:09,600 --> 01:12:10,560
home
1598
01:12:10,560 --> 01:12:12,659
same thing for message
1599
01:12:12,659 --> 01:12:15,659
but then our profile is a real component
1600
01:12:15,659 --> 01:12:19,560
where we can render the my profile page
1601
01:12:19,560 --> 01:12:22,980
great with that said we can now navigate
1602
01:12:22,980 --> 01:12:25,260
between all of those pages
1603
01:12:25,260 --> 01:12:27,600
which is looking great and we're going
1604
01:12:27,600 --> 01:12:29,159
to start with implementing all
1605
01:12:29,159 --> 01:12:32,159
properties first so we can close our app
1606
01:12:32,159 --> 01:12:34,980
DSX and we can go to
1607
01:12:34,980 --> 01:12:37,800
that's going to be pages and all
1608
01:12:37,800 --> 01:12:40,800
properties we're finally diving into the
1609
01:12:40,800 --> 01:12:41,760
action
1610
01:12:41,760 --> 01:12:43,920
to get started with creating our
1611
01:12:43,920 --> 01:12:46,080
properties we're first going to import a
1612
01:12:46,080 --> 01:12:48,060
couple of things our properties are
1613
01:12:48,060 --> 01:12:49,980
going to be the first page which we're
1614
01:12:49,980 --> 01:12:52,800
going to code completely on our own so
1615
01:12:52,800 --> 01:12:56,760
let's get started first we can import an
1616
01:12:56,760 --> 01:12:59,760
add icon coming from that's going to be
1617
01:12:59,760 --> 01:13:01,500
add mui
1618
01:13:01,500 --> 01:13:04,440
forward slash icons Dash material
1619
01:13:04,440 --> 01:13:06,960
then we're going to import a special
1620
01:13:06,960 --> 01:13:10,320
hook called use list this is going to
1621
01:13:10,320 --> 01:13:12,360
allow us to fetch all of the properties
1622
01:13:12,360 --> 01:13:16,020
later on and that is coming from add pan
1623
01:13:16,020 --> 01:13:20,340
card forward slash refine Dash core then
1624
01:13:20,340 --> 01:13:21,840
we're going to import a couple of things
1625
01:13:21,840 --> 01:13:25,440
from mui that's going to be a box
1626
01:13:25,440 --> 01:13:30,300
stack and a typography coming from add
1627
01:13:30,300 --> 01:13:34,560
pan card forward slash refine Dash mui
1628
01:13:34,560 --> 01:13:37,320
and finally we're going to import a hook
1629
01:13:37,320 --> 01:13:39,840
called use navigate and that's coming
1630
01:13:39,840 --> 01:13:42,239
from add pan card
1631
01:13:42,239 --> 01:13:46,199
forward slash refine Dash react Dash
1632
01:13:46,199 --> 01:13:49,380
router Dash V6 as you can see all of
1633
01:13:49,380 --> 01:13:51,659
these features are provided to us by
1634
01:13:51,659 --> 01:13:53,640
refine so we don't have to worry about
1635
01:13:53,640 --> 01:13:56,100
setting up mui manually or setting up
1636
01:13:56,100 --> 01:13:58,980
react router great finally we can import
1637
01:13:58,980 --> 01:14:00,900
two components which we're gonna use
1638
01:14:00,900 --> 01:14:03,960
later on the property card
1639
01:14:03,960 --> 01:14:07,920
as well as the custom button coming from
1640
01:14:07,920 --> 01:14:10,140
components
1641
01:14:10,140 --> 01:14:12,840
right now inside of here we can
1642
01:14:12,840 --> 01:14:15,659
immediately initialize some hooks for
1643
01:14:15,659 --> 01:14:18,960
example cons navigate is equal to use
1644
01:14:18,960 --> 01:14:22,140
navigate and we call it as a hook I just
1645
01:14:22,140 --> 01:14:23,640
noticed that I misspelled it so that's
1646
01:14:23,640 --> 01:14:27,780
going to be Navi gate there we go and we
1647
01:14:27,780 --> 01:14:30,480
can fix it right here and immediately if
1648
01:14:30,480 --> 01:14:31,980
you reload we're going to get an error
1649
01:14:31,980 --> 01:14:34,320
saying that react hook use navigate is
1650
01:14:34,320 --> 01:14:36,659
called in all properties which is not a
1651
01:14:36,659 --> 01:14:38,699
react functional component but
1652
01:14:38,699 --> 01:14:40,739
technically it is there's just one slide
1653
01:14:40,739 --> 01:14:43,199
mistake when we're using that snippet of
1654
01:14:43,199 --> 01:14:45,900
code it created all properties with a
1655
01:14:45,900 --> 01:14:48,540
lowercase first letter but since it is a
1656
01:14:48,540 --> 01:14:50,580
component we have to rename it to all
1657
01:14:50,580 --> 01:14:53,340
properties where a has to be capitalized
1658
01:14:53,340 --> 01:14:55,140
and there we go now we're good because
1659
01:14:55,140 --> 01:14:57,360
our IDE knows that we're working with
1660
01:14:57,360 --> 01:14:59,880
the react component great
1661
01:14:59,880 --> 01:15:02,580
now we can start creating the layout of
1662
01:15:02,580 --> 01:15:04,679
our application so that's going to be
1663
01:15:04,679 --> 01:15:07,020
inside of a return and we can see that
1664
01:15:07,020 --> 01:15:09,000
we don't have access to a custom button
1665
01:15:09,000 --> 01:15:12,060
because I misspelled it that is supposed
1666
01:15:12,060 --> 01:15:14,520
to be an N at the end and there we go
1667
01:15:14,520 --> 01:15:17,040
we're good so instead of this div we're
1668
01:15:17,040 --> 01:15:20,100
going to have a box element and within
1669
01:15:20,100 --> 01:15:22,199
that box we're going to have a stack
1670
01:15:22,199 --> 01:15:23,280
element
1671
01:15:23,280 --> 01:15:25,500
that stack is going to have a direction
1672
01:15:25,500 --> 01:15:27,480
equal to row
1673
01:15:27,480 --> 01:15:31,500
a justify content equal to
1674
01:15:31,500 --> 01:15:34,080
space Dash between
1675
01:15:34,080 --> 01:15:38,159
and align items equal to Center
1676
01:15:38,159 --> 01:15:40,260
inside of there we can render our
1677
01:15:40,260 --> 01:15:43,140
typography this typography is going to
1678
01:15:43,140 --> 01:15:45,420
say all properties
1679
01:15:45,420 --> 01:15:47,640
and we can of course style it a bit by
1680
01:15:47,640 --> 01:15:51,120
giving it a font size of 25
1681
01:15:51,120 --> 01:15:54,900
font weight of 700
1682
01:15:54,900 --> 01:15:58,500
and a color of hash
1683
01:15:58,500 --> 01:16:01,500
11142d
1684
01:16:02,159 --> 01:16:04,380
and we can save that
1685
01:16:04,380 --> 01:16:07,199
and we get this wonderful heading and
1686
01:16:07,199 --> 01:16:09,420
immediately below that typography we're
1687
01:16:09,420 --> 01:16:12,900
going to create our custom button it is
1688
01:16:12,900 --> 01:16:15,179
going to be a self-closing component and
1689
01:16:15,179 --> 01:16:17,040
we can pass a couple of props to it
1690
01:16:17,040 --> 01:16:20,100
we're first going to pass a title equal
1691
01:16:20,100 --> 01:16:22,679
to add property
1692
01:16:22,679 --> 01:16:25,440
then we're going to add a handle click
1693
01:16:25,440 --> 01:16:27,659
functionality which for now we can leave
1694
01:16:27,659 --> 01:16:30,480
as an empty callback function then we
1695
01:16:30,480 --> 01:16:33,420
can pass a background color
1696
01:16:33,420 --> 01:16:36,620
equal to Hash
1697
01:16:36,620 --> 01:16:40,020
475b E8
1698
01:16:40,020 --> 01:16:42,179
and then we can pass a cooler which is
1699
01:16:42,179 --> 01:16:43,699
going to be
1700
01:16:43,699 --> 01:16:47,040
fcfcfc and finally we can pass an icon
1701
01:16:47,040 --> 01:16:48,900
which is going to be a self-closing
1702
01:16:48,900 --> 01:16:52,380
component of add great now we can
1703
01:16:52,380 --> 01:16:54,360
immediately see that typescript says hey
1704
01:16:54,360 --> 01:16:56,699
you cannot pass a title to a custom
1705
01:16:56,699 --> 01:16:59,340
button because it's not accepting it so
1706
01:16:59,340 --> 01:17:01,739
let's move into creating a custom button
1707
01:17:01,739 --> 01:17:05,280
and we can add custom props to it
1708
01:17:05,280 --> 01:17:08,880
so right here we can import a button
1709
01:17:08,880 --> 01:17:11,940
coming from that's going to be add
1710
01:17:11,940 --> 01:17:15,840
pancod forward slash refine Dash mui
1711
01:17:15,840 --> 01:17:19,100
then we can also import our custom
1712
01:17:19,100 --> 01:17:23,280
button props coming from interfaces
1713
01:17:23,280 --> 01:17:25,560
forward slash common
1714
01:17:25,560 --> 01:17:28,199
and if you control click into it you can
1715
01:17:28,199 --> 01:17:30,360
notice that our custom button has a type
1716
01:17:30,360 --> 01:17:33,840
but the type is not needed sometimes and
1717
01:17:33,840 --> 01:17:36,540
it has title background color color full
1718
01:17:36,540 --> 01:17:40,020
width icon and so on so now our button
1719
01:17:40,020 --> 01:17:41,520
knows what we need
1720
01:17:41,520 --> 01:17:43,800
so let's get all of those props by
1721
01:17:43,800 --> 01:17:46,739
saying type title
1722
01:17:46,739 --> 01:17:49,699
background color
1723
01:17:49,699 --> 01:17:53,640
full width and finally icon and most
1724
01:17:53,640 --> 01:17:56,580
importantly handle click and then we can
1725
01:17:56,580 --> 01:17:57,420
say
1726
01:17:57,420 --> 01:17:59,340
Colin
1727
01:17:59,340 --> 01:18:02,640
custom button prompts we're saying the
1728
01:18:02,640 --> 01:18:04,620
props are going to follow this structure
1729
01:18:04,620 --> 01:18:07,860
and with that said the error is gone but
1730
01:18:07,860 --> 01:18:09,600
now at the top right we have a text
1731
01:18:09,600 --> 01:18:11,940
saying custom button so let's implement
1732
01:18:11,940 --> 01:18:12,719
it
1733
01:18:12,719 --> 01:18:16,020
we can simply return in this case a
1734
01:18:16,020 --> 01:18:18,540
button of course so that's going to be a
1735
01:18:18,540 --> 01:18:20,280
button component
1736
01:18:20,280 --> 01:18:23,640
and that button is going to render the
1737
01:18:23,640 --> 01:18:25,860
icon so we can render the icon right
1738
01:18:25,860 --> 01:18:27,840
here and we're going to render the title
1739
01:18:27,840 --> 01:18:30,840
just below if we save this immediately
1740
01:18:30,840 --> 01:18:32,760
we should see add property which looks
1741
01:18:32,760 --> 01:18:34,679
much better but now let's style it
1742
01:18:34,679 --> 01:18:37,380
further that button is going to have an
1743
01:18:37,380 --> 01:18:39,659
SX property which is used for styling
1744
01:18:39,659 --> 01:18:42,480
and it's going to have a flex if it is
1745
01:18:42,480 --> 01:18:45,140
full width then it's going to have one
1746
01:18:45,140 --> 01:18:48,840
usually it's going to be unset then we
1747
01:18:48,840 --> 01:18:50,580
also want to give it a padding of 10
1748
01:18:50,580 --> 01:18:53,340
pixels horizontal and then 15 pixels
1749
01:18:53,340 --> 01:18:54,420
vertical
1750
01:18:54,420 --> 01:18:56,820
we also want to give it a width which is
1751
01:18:56,820 --> 01:19:00,540
going to be if full width then we want
1752
01:19:00,540 --> 01:19:02,219
to give it 100 percent
1753
01:19:02,219 --> 01:19:06,000
otherwise we can say fit Dash content
1754
01:19:06,000 --> 01:19:08,820
then we can also give it a Min width of
1755
01:19:08,820 --> 01:19:10,679
130
1756
01:19:10,679 --> 01:19:12,900
we can give it a background color equal
1757
01:19:12,900 --> 01:19:14,940
to the background color we passed as
1758
01:19:14,940 --> 01:19:16,739
well as color equal to the color we
1759
01:19:16,739 --> 01:19:18,300
passed through props
1760
01:19:18,300 --> 01:19:22,080
then we can give it font size of 16.
1761
01:19:22,080 --> 01:19:27,840
font weight of 600 gap of 10 pixels text
1762
01:19:27,840 --> 01:19:30,239
transform
1763
01:19:30,239 --> 01:19:33,480
equal to capitalize
1764
01:19:33,480 --> 01:19:36,960
and we can do and column hover so
1765
01:19:36,960 --> 01:19:39,060
meaning on Hover we want to set the
1766
01:19:39,060 --> 01:19:40,199
opacity
1767
01:19:40,199 --> 01:19:44,580
to 0.9 like this as numbers and then we
1768
01:19:44,580 --> 01:19:46,320
can also give it the same background
1769
01:19:46,320 --> 01:19:50,460
color there we go finally the last thing
1770
01:19:50,460 --> 01:19:53,880
we have to do below the SX prop is we
1771
01:19:53,880 --> 01:19:56,219
can pass an on click equal to handle
1772
01:19:56,219 --> 01:19:58,739
click meaning whatever we pass to it
1773
01:19:58,739 --> 01:20:01,080
it's going to do that thing now if we
1774
01:20:01,080 --> 01:20:02,699
save it you can see we have this
1775
01:20:02,699 --> 01:20:05,520
wonderful wonderful button add property
1776
01:20:05,520 --> 01:20:08,340
and right now it doesn't do anything but
1777
01:20:08,340 --> 01:20:10,860
if we go back to all properties we can
1778
01:20:10,860 --> 01:20:14,219
add a real handle click to it and that
1779
01:20:14,219 --> 01:20:17,280
handle click is going to use the
1780
01:20:17,280 --> 01:20:20,340
navigate hook so we can say navigate
1781
01:20:20,340 --> 01:20:22,800
and we want to navigate to forward slash
1782
01:20:22,800 --> 01:20:25,199
property
1783
01:20:25,199 --> 01:20:27,840
forward slash create but now that I
1784
01:20:27,840 --> 01:20:29,880
think about it better thing would be to
1785
01:20:29,880 --> 01:20:31,199
say properties
1786
01:20:31,199 --> 01:20:33,480
create this way we're following better
1787
01:20:33,480 --> 01:20:36,780
crowd naming conventions so we have to
1788
01:20:36,780 --> 01:20:38,699
fix that somewhere and that is going to
1789
01:20:38,699 --> 01:20:42,540
be in the app.tsx right here under all
1790
01:20:42,540 --> 01:20:44,820
of our resources see how we name this
1791
01:20:44,820 --> 01:20:47,159
property well this right here is going
1792
01:20:47,159 --> 01:20:49,620
to be properties this is going to be
1793
01:20:49,620 --> 01:20:53,580
agents reviews messages my profile is
1794
01:20:53,580 --> 01:20:56,280
fine so we always want to use plural
1795
01:20:56,280 --> 01:20:58,800
when we talk about specific resources in
1796
01:20:58,800 --> 01:21:02,460
our crowd rest apis immediately changing
1797
01:21:02,460 --> 01:21:04,739
this change the route so if we now go
1798
01:21:04,739 --> 01:21:06,659
back and click properties it's going to
1799
01:21:06,659 --> 01:21:08,719
renavigate us to the correct route now
1800
01:21:08,719 --> 01:21:12,000
and we can go back and we're no longer
1801
01:21:12,000 --> 01:21:15,659
going to navigate to property but rather
1802
01:21:15,659 --> 01:21:18,420
properties now if we click right here
1803
01:21:18,420 --> 01:21:20,520
you can see we have properties create
1804
01:21:20,520 --> 01:21:23,940
and that opened up a new page now how
1805
01:21:23,940 --> 01:21:26,280
did it know to show create property at
1806
01:21:26,280 --> 01:21:29,159
the route properties create well it's as
1807
01:21:29,159 --> 01:21:31,800
easy as checking our app DSX and
1808
01:21:31,800 --> 01:21:34,380
checking out the resources right here we
1809
01:21:34,380 --> 01:21:36,480
added everything it needs to know the
1810
01:21:36,480 --> 01:21:38,159
name properties which is going to
1811
01:21:38,159 --> 01:21:41,460
correspond to this URL the list showing
1812
01:21:41,460 --> 01:21:43,260
on all properties meaning just
1813
01:21:43,260 --> 01:21:46,260
properties and then create is going to
1814
01:21:46,260 --> 01:21:48,360
be on the properties forward slash
1815
01:21:48,360 --> 01:21:50,640
create and then we render the create
1816
01:21:50,640 --> 01:21:52,380
property page
1817
01:21:52,380 --> 01:21:56,100
wonderful now I would want to keep doing
1818
01:21:56,100 --> 01:21:58,739
the old properties and now show them but
1819
01:21:58,739 --> 01:22:00,900
we cannot do that as there is nothing to
1820
01:22:00,900 --> 01:22:03,179
show so first we're going to focus on
1821
01:22:03,179 --> 01:22:05,040
the create property then we're going to
1822
01:22:05,040 --> 01:22:07,140
connect it to the back end and then we
1823
01:22:07,140 --> 01:22:09,239
can finally work on showcasing those
1824
01:22:09,239 --> 01:22:12,060
properties to get started with our
1825
01:22:12,060 --> 01:22:15,719
create property we can first import a
1826
01:22:15,719 --> 01:22:18,900
use State hook coming of course from
1827
01:22:18,900 --> 01:22:22,739
react we can also import a use get
1828
01:22:22,739 --> 01:22:25,620
identity hook coming from add pan card
1829
01:22:25,620 --> 01:22:28,920
forward slash refine Dash core this hook
1830
01:22:28,920 --> 01:22:31,739
will allow us to easily get all of the
1831
01:22:31,739 --> 01:22:33,960
user related properties such as name
1832
01:22:33,960 --> 01:22:36,960
email and profile photo we can also
1833
01:22:36,960 --> 01:22:40,739
import field values and most importantly
1834
01:22:40,739 --> 01:22:44,760
the use form hook coming from add
1835
01:22:44,760 --> 01:22:47,880
pan card forward slash refine
1836
01:22:47,880 --> 01:22:49,980
Dash react
1837
01:22:49,980 --> 01:22:53,219
Dash hook Dash form like this
1838
01:22:53,219 --> 01:22:55,440
really soon you'll see how powerful the
1839
01:22:55,440 --> 01:22:58,320
use form Hook is after that we can
1840
01:22:58,320 --> 01:23:02,219
import the use navigate hook
1841
01:23:02,219 --> 01:23:06,120
which is coming from react router V6 and
1842
01:23:06,120 --> 01:23:08,699
then finally we can import the form
1843
01:23:08,699 --> 01:23:12,900
component coming from components forward
1844
01:23:12,900 --> 01:23:15,840
slash common forward slash form this is
1845
01:23:15,840 --> 01:23:18,719
a component we are yet to create before
1846
01:23:18,719 --> 01:23:20,520
starting with the layout we can first
1847
01:23:20,520 --> 01:23:22,560
initialize all of the hooks at the top
1848
01:23:22,560 --> 01:23:25,440
so that's going to be const navigate is
1849
01:23:25,440 --> 01:23:28,440
equal to use navigate and as soon as we
1850
01:23:28,440 --> 01:23:29,880
do that you're going to get an error
1851
01:23:29,880 --> 01:23:33,719
saying you cannot create a hook inside
1852
01:23:33,719 --> 01:23:35,940
of something that's not a react function
1853
01:23:35,940 --> 01:23:38,699
and the reason why our IDE thinks that
1854
01:23:38,699 --> 01:23:41,460
is because we called it with a lowercase
1855
01:23:41,460 --> 01:23:43,320
starting letter so we have to change
1856
01:23:43,320 --> 01:23:46,020
this to create property with a Capital C
1857
01:23:46,020 --> 01:23:48,000
and we're good
1858
01:23:48,000 --> 01:23:51,420
after that we can say const data and
1859
01:23:51,420 --> 01:23:54,659
then rename it as user is equal to use
1860
01:23:54,659 --> 01:23:57,659
get identity this will allow us to get
1861
01:23:57,659 --> 01:24:00,239
all the user info because we need to
1862
01:24:00,239 --> 01:24:02,100
know who is creating this current
1863
01:24:02,100 --> 01:24:04,440
property after that we're going to have
1864
01:24:04,440 --> 01:24:06,900
a hook which is going to be a use State
1865
01:24:06,900 --> 01:24:10,140
more specifically called property image
1866
01:24:10,140 --> 01:24:13,739
and set property image and that's going
1867
01:24:13,739 --> 01:24:17,040
to be equal to a use State hook which is
1868
01:24:17,040 --> 01:24:18,719
going to be at the start an object
1869
01:24:18,719 --> 01:24:21,179
that's going to have a name equal to an
1870
01:24:21,179 --> 01:24:24,060
empty string and a URL equal to an empty
1871
01:24:24,060 --> 01:24:25,500
string
1872
01:24:25,500 --> 01:24:27,600
if you think about it all of our
1873
01:24:27,600 --> 01:24:29,580
properties will have some kind of photos
1874
01:24:29,580 --> 01:24:31,739
attached to them so we need to be able
1875
01:24:31,739 --> 01:24:34,199
to store that state in a photo but
1876
01:24:34,199 --> 01:24:36,480
absolutely everything else besides our
1877
01:24:36,480 --> 01:24:39,239
photo is going to be handled by
1878
01:24:39,239 --> 01:24:42,780
that's going to be equal to use form
1879
01:24:42,780 --> 01:24:46,440
hook coming directly from refine so what
1880
01:24:46,440 --> 01:24:48,239
specifically can we get from that hook
1881
01:24:48,239 --> 01:24:50,820
well let's expand our Visual Studio code
1882
01:24:50,820 --> 01:24:53,280
just a bit and then let me show you what
1883
01:24:53,280 --> 01:24:56,460
we can get let's type refine core
1884
01:24:56,460 --> 01:24:59,400
and from there we can destructure the on
1885
01:24:59,400 --> 01:25:03,120
finish as well as the form loading so
1886
01:25:03,120 --> 01:25:04,860
immediately know if the form is loading
1887
01:25:04,860 --> 01:25:08,100
and when we are done now next to refine
1888
01:25:08,100 --> 01:25:10,140
core we can also get the register
1889
01:25:10,140 --> 01:25:12,960
through which we can register every
1890
01:25:12,960 --> 01:25:15,420
single input or text field and then
1891
01:25:15,420 --> 01:25:16,679
we're going to also get the handle
1892
01:25:16,679 --> 01:25:18,960
submit so we can submit everything and
1893
01:25:18,960 --> 01:25:21,780
send it to the server that is it a lot
1894
01:25:21,780 --> 01:25:23,580
of functionality packed in this
1895
01:25:23,580 --> 01:25:25,739
incredibly useful hook now let's
1896
01:25:25,739 --> 01:25:28,500
collapse this back right here and we are
1897
01:25:28,500 --> 01:25:30,060
ready to start creating the layout
1898
01:25:30,060 --> 01:25:32,159
believe it or not our entire create
1899
01:25:32,159 --> 01:25:34,739
property is going to be consisted of one
1900
01:25:34,739 --> 01:25:37,320
single self-closing component and that
1901
01:25:37,320 --> 01:25:38,760
is form
1902
01:25:38,760 --> 01:25:41,280
so right here inside of the form we can
1903
01:25:41,280 --> 01:25:43,500
start sending many different properties
1904
01:25:43,500 --> 01:25:45,840
first of all we're going to send a type
1905
01:25:45,840 --> 01:25:49,080
equal to create because later on we're
1906
01:25:49,080 --> 01:25:51,900
going to reuse the same form for the
1907
01:25:51,900 --> 01:25:54,120
edit functionality that's the primary
1908
01:25:54,120 --> 01:25:56,280
reason why we are creating the separate
1909
01:25:56,280 --> 01:25:57,960
component for the form in the first
1910
01:25:57,960 --> 01:25:58,860
place
1911
01:25:58,860 --> 01:26:01,440
now we also want to pass register equal
1912
01:26:01,440 --> 01:26:06,060
to register on finish equal to on finish
1913
01:26:06,060 --> 01:26:08,040
we're going to also pass the form
1914
01:26:08,040 --> 01:26:09,300
loading
1915
01:26:09,300 --> 01:26:12,659
equal to form loading we can pass the
1916
01:26:12,659 --> 01:26:17,280
handle submit equal to handle submit and
1917
01:26:17,280 --> 01:26:20,100
finally we can pass the property image
1918
01:26:20,100 --> 01:26:23,880
equal to property image now there are
1919
01:26:23,880 --> 01:26:25,560
two additional things we have to pass
1920
01:26:25,560 --> 01:26:27,300
and these are going to be extra
1921
01:26:27,300 --> 01:26:28,679
functions which we're going to create
1922
01:26:28,679 --> 01:26:31,139
the first function is going to be called
1923
01:26:31,139 --> 01:26:35,340
handle image change and for now we can
1924
01:26:35,340 --> 01:26:38,580
simply leave it as an empty react Arrow
1925
01:26:38,580 --> 01:26:40,739
function and below that we can create
1926
01:26:40,739 --> 01:26:44,520
const on finish Handler and that's also
1927
01:26:44,520 --> 01:26:46,560
for now going to be an empty Arrow
1928
01:26:46,560 --> 01:26:50,159
function great now we can pass those as
1929
01:26:50,159 --> 01:26:53,280
well so right below handle submit we can
1930
01:26:53,280 --> 01:26:57,360
pass the handle image change it's equal
1931
01:26:57,360 --> 01:27:00,120
to handle image change and finally we
1932
01:27:00,120 --> 01:27:03,300
can pass on finish Handler is equal to
1933
01:27:03,300 --> 01:27:06,060
on finished Handler now as you can see
1934
01:27:06,060 --> 01:27:07,739
we're immediately getting the error
1935
01:27:07,739 --> 01:27:10,080
right on the type property and that's
1936
01:27:10,080 --> 01:27:11,940
because if you now control click into
1937
01:27:11,940 --> 01:27:14,280
the form you can see there's nothing
1938
01:27:14,280 --> 01:27:16,980
there so we of course have to set up our
1939
01:27:16,980 --> 01:27:20,280
props and typescript interface for our
1940
01:27:20,280 --> 01:27:23,100
form properties so let's do that right
1941
01:27:23,100 --> 01:27:25,500
away inside of a form we're going to
1942
01:27:25,500 --> 01:27:28,380
import a lot of properties from mui
1943
01:27:28,380 --> 01:27:31,920
that's going to be a box a typography
1944
01:27:31,920 --> 01:27:34,560
which is just a text element but in this
1945
01:27:34,560 --> 01:27:36,300
case we're going to have deform control
1946
01:27:36,300 --> 01:27:39,659
as well a form helper
1947
01:27:39,659 --> 01:27:42,659
text then we're going to have a text
1948
01:27:42,659 --> 01:27:46,139
field a text area
1949
01:27:46,139 --> 01:27:48,300
Auto size
1950
01:27:48,300 --> 01:27:50,340
a stack
1951
01:27:50,340 --> 01:27:54,659
a select a menu item and finally a
1952
01:27:54,659 --> 01:27:57,900
button and all of this is coming from at
1953
01:27:57,900 --> 01:28:01,520
Punk card forward slash refine Dash mui
1954
01:28:01,520 --> 01:28:04,679
now as we discussed we also have to get
1955
01:28:04,679 --> 01:28:09,480
the form props coming from interfaces
1956
01:28:09,480 --> 01:28:11,580
forward slash common
1957
01:28:11,580 --> 01:28:14,040
and let's also get our custom button
1958
01:28:14,040 --> 01:28:15,900
since we worked so hard on creating it
1959
01:28:15,900 --> 01:28:18,739
so that's going to be custom button from
1960
01:28:18,739 --> 01:28:23,820
dot slash custom button great so now
1961
01:28:23,820 --> 01:28:25,860
let's grab all of the props that we
1962
01:28:25,860 --> 01:28:28,080
passed from the create property
1963
01:28:28,080 --> 01:28:30,239
so right here inside of the prompts
1964
01:28:30,239 --> 01:28:32,040
that's going to be a type
1965
01:28:32,040 --> 01:28:33,600
register
1966
01:28:33,600 --> 01:28:35,520
handle submit
1967
01:28:35,520 --> 01:28:37,380
handle
1968
01:28:37,380 --> 01:28:40,080
image change
1969
01:28:40,080 --> 01:28:46,199
form loading on finish Handler
1970
01:28:46,199 --> 01:28:49,139
and property image
1971
01:28:49,139 --> 01:28:51,960
and all of that is going to be of an
1972
01:28:51,960 --> 01:28:53,219
interface
1973
01:28:53,219 --> 01:28:56,400
form props so now typescript shouldn't
1974
01:28:56,400 --> 01:28:58,260
complain let's see what we have here
1975
01:28:58,260 --> 01:29:01,440
that's property image property register
1976
01:29:01,440 --> 01:29:04,860
does not exist on type form props and if
1977
01:29:04,860 --> 01:29:06,900
you save you can see that typescript is
1978
01:29:06,900 --> 01:29:08,940
no longer complaining which means that
1979
01:29:08,940 --> 01:29:11,100
we're good to proceed with creating our
1980
01:29:11,100 --> 01:29:13,860
actual form so to do that we're first
1981
01:29:13,860 --> 01:29:17,060
going to wrap everything inside of a box
1982
01:29:17,060 --> 01:29:20,400
that box inside of it is going to have a
1983
01:29:20,400 --> 01:29:22,560
typography so let's create a new
1984
01:29:22,560 --> 01:29:24,239
typography element
1985
01:29:24,239 --> 01:29:26,820
and that typography is simply going to
1986
01:29:26,820 --> 01:29:27,780
say
1987
01:29:27,780 --> 01:29:31,320
type a property now of course that
1988
01:29:31,320 --> 01:29:34,080
doesn't mean type a property but type is
1989
01:29:34,080 --> 01:29:36,000
rather the type of the form it's either
1990
01:29:36,000 --> 01:29:39,780
create or edit in this case it says
1991
01:29:39,780 --> 01:29:42,900
create a property great now let's make
1992
01:29:42,900 --> 01:29:45,120
it just a bit bigger by giving it a font
1993
01:29:45,120 --> 01:29:49,440
size equal to 25 a font weight equal to
1994
01:29:49,440 --> 01:29:53,600
700 let's also give it a color equal to
1995
01:29:53,600 --> 01:29:57,719
Hash one one one four two D and let's
1996
01:29:57,719 --> 01:29:58,739
save it
1997
01:29:58,739 --> 01:30:01,679
that should give us a pretty title great
1998
01:30:01,679 --> 01:30:04,500
now below that we can create a box
1999
01:30:04,500 --> 01:30:07,260
that's going to act as a wrapper for our
2000
01:30:07,260 --> 01:30:10,139
form it's going to have a margin top or
2001
01:30:10,139 --> 01:30:13,739
empty of 2.5 to divide it a bit from the
2002
01:30:13,739 --> 01:30:15,840
typography above we're going to give it
2003
01:30:15,840 --> 01:30:20,340
a border radius of about 15 pixels let's
2004
01:30:20,340 --> 01:30:23,460
also give it a padding of 20 pixels and
2005
01:30:23,460 --> 01:30:26,340
most importantly a BG color equal to
2006
01:30:26,340 --> 01:30:27,620
Hash
2007
01:30:27,620 --> 01:30:31,800
fcfc FC if we save that we'll be able to
2008
01:30:31,800 --> 01:30:34,139
just barely see our form and this is
2009
01:30:34,139 --> 01:30:37,080
where all the inputs will go so inside
2010
01:30:37,080 --> 01:30:39,900
of the Box we can finally create a form
2011
01:30:39,900 --> 01:30:43,020
component to that form we can pass a
2012
01:30:43,020 --> 01:30:48,179
style of margin top is 20 pixels we can
2013
01:30:48,179 --> 01:30:51,480
also give it a width of 100 percent
2014
01:30:51,480 --> 01:30:55,980
we can give it a display equal to flex
2015
01:30:55,980 --> 01:30:58,320
and it looks like I missed a comma right
2016
01:30:58,320 --> 01:30:59,400
here
2017
01:30:59,400 --> 01:31:02,040
and finally after display Flex we can
2018
01:31:02,040 --> 01:31:05,400
give it a flex Direction equal to column
2019
01:31:05,400 --> 01:31:06,960
since we're going to show all of our
2020
01:31:06,960 --> 01:31:09,540
text Fields one on top of another and
2021
01:31:09,540 --> 01:31:12,840
finally a gap of 20 pixels now if we
2022
01:31:12,840 --> 01:31:14,460
save this you won't be able to see
2023
01:31:14,460 --> 01:31:17,520
anything because there's nothing in it
2024
01:31:17,520 --> 01:31:19,800
and finally we're going to have an on
2025
01:31:19,800 --> 01:31:22,199
submit on our form which is for now
2026
01:31:22,199 --> 01:31:24,960
going to be equal to handle submit
2027
01:31:24,960 --> 01:31:28,380
remember this was created for us by
2028
01:31:28,380 --> 01:31:31,380
refine and then to it we can pass the on
2029
01:31:31,380 --> 01:31:34,199
finish Handler again everything is
2030
01:31:34,199 --> 01:31:36,239
already done for us we'll simply have to
2031
01:31:36,239 --> 01:31:38,760
pass the right things when we call the
2032
01:31:38,760 --> 01:31:41,760
on submit and inside of the form we can
2033
01:31:41,760 --> 01:31:43,679
start creating our inputs so let's
2034
01:31:43,679 --> 01:31:46,980
create our first form control A4 control
2035
01:31:46,980 --> 01:31:50,400
is an element that wraps the form helper
2036
01:31:50,400 --> 01:31:52,620
text
2037
01:31:52,620 --> 01:31:56,100
and also it wraps the text field so they
2038
01:31:56,100 --> 01:31:59,040
act together as one text field is going
2039
01:31:59,040 --> 01:32:00,960
to be a self-closing component that
2040
01:32:00,960 --> 01:32:03,480
looks like this so if we save this and
2041
01:32:03,480 --> 01:32:04,920
if we write something in this form
2042
01:32:04,920 --> 01:32:07,620
control something like enter
2043
01:32:07,620 --> 01:32:09,719
property
2044
01:32:09,719 --> 01:32:11,639
name
2045
01:32:11,639 --> 01:32:13,739
you can see that we have a text field
2046
01:32:13,739 --> 01:32:16,860
and we have the helper text so the user
2047
01:32:16,860 --> 01:32:19,139
knows what to type in now let's style
2048
01:32:19,139 --> 01:32:21,659
them now to style it we can give it an
2049
01:32:21,659 --> 01:32:26,239
SX property equal to font weight of 500
2050
01:32:26,239 --> 01:32:29,639
we can give it a margin of 10 pixels on
2051
01:32:29,639 --> 01:32:32,400
top and bottom and 0 on left and right
2052
01:32:32,400 --> 01:32:36,540
let's also give it a font size of 16.
2053
01:32:36,540 --> 01:32:38,940
and finally let's give it a color equal
2054
01:32:38,940 --> 01:32:41,239
to Hash
2055
01:32:41,239 --> 01:32:44,699
11142d now if we save this that's going
2056
01:32:44,699 --> 01:32:47,639
to look just a bit better and we can
2057
01:32:47,639 --> 01:32:50,520
start creating our first text field this
2058
01:32:50,520 --> 01:32:52,739
text field is going to be of a full
2059
01:32:52,739 --> 01:32:56,100
width it's also going to be required
2060
01:32:56,100 --> 01:32:58,860
we can give it an ID equal to outline
2061
01:32:58,860 --> 01:33:00,540
Dash basic
2062
01:33:00,540 --> 01:33:03,840
we can give it a color equal to info
2063
01:33:03,840 --> 01:33:06,179
and we can give it a variant equal to
2064
01:33:06,179 --> 01:33:08,880
outline now if we save this we're going
2065
01:33:08,880 --> 01:33:10,560
to just have a bit of a better looking
2066
01:33:10,560 --> 01:33:13,380
input now if we save this you can see
2067
01:33:13,380 --> 01:33:15,960
that our input is looking great
2068
01:33:15,960 --> 01:33:19,139
and now for the most important part we
2069
01:33:19,139 --> 01:33:22,620
can spread dot dot register
2070
01:33:22,620 --> 01:33:24,480
and then we can call it as a function
2071
01:33:24,480 --> 01:33:27,780
and pass the title of that text field in
2072
01:33:27,780 --> 01:33:31,380
this case it's title and we can set the
2073
01:33:31,380 --> 01:33:32,460
required
2074
01:33:32,460 --> 01:33:35,880
equaled to true this is the only thing
2075
01:33:35,880 --> 01:33:38,940
you have to do to manage the data or to
2076
01:33:38,940 --> 01:33:41,760
manage the state of that input refine is
2077
01:33:41,760 --> 01:33:43,920
going to handle everything else once
2078
01:33:43,920 --> 01:33:46,739
called the handle submit Handler
2079
01:33:46,739 --> 01:33:49,500
great with that said we can proceed to
2080
01:33:49,500 --> 01:33:53,100
our second form control and since it is
2081
01:33:53,100 --> 01:33:55,080
really similar to this one let's simply
2082
01:33:55,080 --> 01:33:58,020
take this one and duplicate it below
2083
01:33:58,020 --> 01:34:00,239
the form helper text is going to be the
2084
01:34:00,239 --> 01:34:02,100
same but rather it's just going to say
2085
01:34:02,100 --> 01:34:05,040
property description and we can save
2086
01:34:05,040 --> 01:34:08,159
that but instead of having a text field
2087
01:34:08,159 --> 01:34:10,620
we're going to have a text area Auto
2088
01:34:10,620 --> 01:34:13,739
size so let's delete the text field and
2089
01:34:13,739 --> 01:34:17,340
let's create a text area Auto size it's
2090
01:34:17,340 --> 01:34:18,960
also going to be a self-causing
2091
01:34:18,960 --> 01:34:23,460
component we can set Min rows to 5 and
2092
01:34:23,460 --> 01:34:24,960
if we save that that's already going to
2093
01:34:24,960 --> 01:34:27,179
look just a bit different we can also
2094
01:34:27,179 --> 01:34:29,159
give it a required property
2095
01:34:29,159 --> 01:34:33,960
a placeholder equal to write description
2096
01:34:33,960 --> 01:34:36,360
that's good we can give it a color equal
2097
01:34:36,360 --> 01:34:37,920
to info
2098
01:34:37,920 --> 01:34:40,920
and we can give it a style now bear with
2099
01:34:40,920 --> 01:34:43,440
me we're going to give it a width of 100
2100
01:34:43,440 --> 01:34:45,000
percent
2101
01:34:45,000 --> 01:34:47,159
let's give it a background
2102
01:34:47,159 --> 01:34:50,719
equal to transparent
2103
01:34:51,179 --> 01:34:54,840
let's give it a font size equal to 16
2104
01:34:54,840 --> 01:34:57,239
pixels to make it a bit bigger we can
2105
01:34:57,239 --> 01:35:01,040
give it a border color equal to
2106
01:35:01,040 --> 01:35:04,980
rgba 0 0 0
2107
01:35:04,980 --> 01:35:09,480
and then 0.23 for the a or the opacity
2108
01:35:09,480 --> 01:35:11,940
we can close that string right here we
2109
01:35:11,940 --> 01:35:14,340
can give it a border radius
2110
01:35:14,340 --> 01:35:17,100
of 6 to make it a bit rounded and let's
2111
01:35:17,100 --> 01:35:18,600
save it and see how does it look like
2112
01:35:18,600 --> 01:35:19,620
right now
2113
01:35:19,620 --> 01:35:22,560
okay that's just a bit better after the
2114
01:35:22,560 --> 01:35:23,880
Border radius we can give it some
2115
01:35:23,880 --> 01:35:26,760
padding like 10 and we can change the
2116
01:35:26,760 --> 01:35:31,500
color to Hash nine one nine one nine one
2117
01:35:31,500 --> 01:35:34,139
and if we save that
2118
01:35:34,139 --> 01:35:37,260
this is looking much better
2119
01:35:37,260 --> 01:35:40,320
finally to register it we can simply
2120
01:35:40,320 --> 01:35:42,060
copy the registration from the last
2121
01:35:42,060 --> 01:35:45,659
input and paste it here register this
2122
01:35:45,659 --> 01:35:48,000
time not the title but rather the
2123
01:35:48,000 --> 01:35:49,440
description
2124
01:35:49,440 --> 01:35:50,580
great
2125
01:35:50,580 --> 01:35:54,120
now after our text area Auto size and
2126
01:35:54,120 --> 01:35:56,760
after form control still being inside of
2127
01:35:56,760 --> 01:35:58,980
the form we're going to create a stack
2128
01:35:58,980 --> 01:36:01,980
and that stack is going to have a
2129
01:36:01,980 --> 01:36:06,540
direction set to row as well as a gap of
2130
01:36:06,540 --> 01:36:07,440
four
2131
01:36:07,440 --> 01:36:10,080
inside of it we want to create yet
2132
01:36:10,080 --> 01:36:12,060
another form control
2133
01:36:12,060 --> 01:36:15,179
this form control is going to have an SX
2134
01:36:15,179 --> 01:36:19,080
property equal to flex set to 1. and
2135
01:36:19,080 --> 01:36:21,300
then inside of it we can create a form
2136
01:36:21,300 --> 01:36:23,159
helper text
2137
01:36:23,159 --> 01:36:26,100
form helper text rewardee created these
2138
01:36:26,100 --> 01:36:27,360
before
2139
01:36:27,360 --> 01:36:30,420
and we can give it an SX property of
2140
01:36:30,420 --> 01:36:32,520
font weight
2141
01:36:32,520 --> 01:36:34,440
of 500
2142
01:36:34,440 --> 01:36:38,400
a margin of 10 pixels and then 0.
2143
01:36:38,400 --> 01:36:41,400
a font size of 16
2144
01:36:41,400 --> 01:36:46,139
and a color of hash 11142d
2145
01:36:46,139 --> 01:36:48,540
and finally we can say
2146
01:36:48,540 --> 01:36:51,120
Select Property type
2147
01:36:51,120 --> 01:36:53,159
now if we save this we'll just see
2148
01:36:53,159 --> 01:36:55,800
another one of these helper texts but
2149
01:36:55,800 --> 01:36:58,020
below that we're not going to have a
2150
01:36:58,020 --> 01:37:00,179
text area we're not going to have a text
2151
01:37:00,179 --> 01:37:02,880
field we're going to have a select
2152
01:37:02,880 --> 01:37:05,760
element so just below the form helper
2153
01:37:05,760 --> 01:37:08,900
text let's create a new select element
2154
01:37:08,900 --> 01:37:11,940
that select is going to have a few props
2155
01:37:11,940 --> 01:37:14,340
so we can expand this give it a variant
2156
01:37:14,340 --> 01:37:17,219
equal to outlined we can give it a color
2157
01:37:17,219 --> 01:37:19,500
equal to info
2158
01:37:19,500 --> 01:37:23,520
display empty required
2159
01:37:23,520 --> 01:37:25,440
input props
2160
01:37:25,440 --> 01:37:28,260
is going to be equal to an object where
2161
01:37:28,260 --> 01:37:31,199
we can say area Dash label is going to
2162
01:37:31,199 --> 01:37:34,920
be set to a string of without label like
2163
01:37:34,920 --> 01:37:37,920
this and then default value is going to
2164
01:37:37,920 --> 01:37:40,980
be apartment so right here we can say
2165
01:37:40,980 --> 01:37:42,900
apartment
2166
01:37:42,900 --> 01:37:44,460
and of course there's going to be an
2167
01:37:44,460 --> 01:37:47,159
equal sign right here great
2168
01:37:47,159 --> 01:37:49,500
and apartment is spelled with 1p so
2169
01:37:49,500 --> 01:37:52,080
let's fix that right here finally we
2170
01:37:52,080 --> 01:37:53,760
need to register this property as well
2171
01:37:53,760 --> 01:37:56,280
and that's going to be as simple as
2172
01:37:56,280 --> 01:37:59,340
saying register
2173
01:37:59,340 --> 01:38:00,840
property
2174
01:38:00,840 --> 01:38:04,560
type and required is set to true and
2175
01:38:04,560 --> 01:38:06,659
with that you'll see this select element
2176
01:38:06,659 --> 01:38:09,540
which right now is empty so we have to
2177
01:38:09,540 --> 01:38:12,179
provide some menu items to add
2178
01:38:12,179 --> 01:38:14,520
let's do that right away by creating our
2179
01:38:14,520 --> 01:38:17,820
first menu item that menu item is going
2180
01:38:17,820 --> 01:38:20,699
to have a value equal to apartment
2181
01:38:20,699 --> 01:38:23,820
the title equal to apartment
2182
01:38:23,820 --> 01:38:27,060
with a capital A now if we save that you
2183
01:38:27,060 --> 01:38:29,100
should be able to see our first and only
2184
01:38:29,100 --> 01:38:32,040
option now we can repeat this for all of
2185
01:38:32,040 --> 01:38:34,260
our property types so let's duplicate
2186
01:38:34,260 --> 01:38:37,380
this maybe eight more times below and
2187
01:38:37,380 --> 01:38:39,540
also let's expand this just a bit so we
2188
01:38:39,540 --> 01:38:41,699
can see it better in one line
2189
01:38:41,699 --> 01:38:44,460
there we go so the second one is going
2190
01:38:44,460 --> 01:38:47,520
to be a villa so let's type Villa right
2191
01:38:47,520 --> 01:38:48,540
here
2192
01:38:48,540 --> 01:38:52,199
then we're going to have a farmhouse
2193
01:38:52,199 --> 01:38:55,440
again Farmhouse with a capital f then
2194
01:38:55,440 --> 01:38:58,320
we're going to have a condos
2195
01:38:58,320 --> 01:39:01,320
there we go again condos with a Capital
2196
01:39:01,320 --> 01:39:03,120
C
2197
01:39:03,120 --> 01:39:06,600
after that we're gonna have a townhouse
2198
01:39:06,600 --> 01:39:09,780
and a townhouse with a capital T
2199
01:39:09,780 --> 01:39:12,360
we're gonna have a duplex so let's type
2200
01:39:12,360 --> 01:39:15,659
a duplex right here and duplex
2201
01:39:15,659 --> 01:39:18,000
we're gonna have a studio
2202
01:39:18,000 --> 01:39:21,420
as well as a studio right here and
2203
01:39:21,420 --> 01:39:26,040
finally we can have a chalet like this
2204
01:39:26,040 --> 01:39:29,940
and there we go now if we save this you
2205
01:39:29,940 --> 01:39:31,980
should be able to select between all of
2206
01:39:31,980 --> 01:39:34,199
these elements and for this we're using
2207
01:39:34,199 --> 01:39:37,560
material UI they make this so easy
2208
01:39:37,560 --> 01:39:40,320
now below or next to our property type
2209
01:39:40,320 --> 01:39:43,260
we want to have another one of these
2210
01:39:43,260 --> 01:39:45,600
text Fields so let's go to our first
2211
01:39:45,600 --> 01:39:48,480
text field which was just a basic title
2212
01:39:48,480 --> 01:39:50,880
and let's copy the form control for the
2213
01:39:50,880 --> 01:39:54,060
entire title we can go down and we can
2214
01:39:54,060 --> 01:39:56,040
paste it just below this form control
2215
01:39:56,040 --> 01:39:58,620
wrapping the select we're going to keep
2216
01:39:58,620 --> 01:40:00,540
all of this the same we're just going to
2217
01:40:00,540 --> 01:40:03,020
change the form helper text to enter
2218
01:40:03,020 --> 01:40:06,000
property price
2219
01:40:06,000 --> 01:40:08,100
and when it comes to changing things in
2220
01:40:08,100 --> 01:40:09,840
the text field everything is going to be
2221
01:40:09,840 --> 01:40:12,179
the same but we're going to also add a
2222
01:40:12,179 --> 01:40:15,540
type equal to number since we're talking
2223
01:40:15,540 --> 01:40:16,860
about a price
2224
01:40:16,860 --> 01:40:18,600
and right here we're going to register
2225
01:40:18,600 --> 01:40:22,620
it as a price input and if we save this
2226
01:40:22,620 --> 01:40:24,900
you can see we have enter property price
2227
01:40:24,900 --> 01:40:27,659
on the right side and if we collapse
2228
01:40:27,659 --> 01:40:29,880
this you can see everything is still
2229
01:40:29,880 --> 01:40:32,580
fully responsive even on smaller screens
2230
01:40:32,580 --> 01:40:35,520
with that said we can copy the same form
2231
01:40:35,520 --> 01:40:37,980
control that we just created and go
2232
01:40:37,980 --> 01:40:40,139
below this form control and below the
2233
01:40:40,139 --> 01:40:42,540
stack and there we can create one more
2234
01:40:42,540 --> 01:40:45,199
form control that's going to say enter
2235
01:40:45,199 --> 01:40:48,239
location so right here we can say enter
2236
01:40:48,239 --> 01:40:50,940
location and it's not going to be a type
2237
01:40:50,940 --> 01:40:53,639
number so we can remove that and we can
2238
01:40:53,639 --> 01:40:56,760
just say register location there we go
2239
01:40:56,760 --> 01:40:59,100
so now we should have location as well
2240
01:40:59,100 --> 01:41:01,320
and this is already looking like a real
2241
01:41:01,320 --> 01:41:05,280
form finally below that form control we
2242
01:41:05,280 --> 01:41:08,040
can create one stack
2243
01:41:08,040 --> 01:41:10,620
this stack is going to have a direction
2244
01:41:10,620 --> 01:41:14,760
equal to column as well as a gap equal
2245
01:41:14,760 --> 01:41:18,659
to one and a justify content equal to
2246
01:41:18,659 --> 01:41:19,620
Center
2247
01:41:19,620 --> 01:41:23,880
as well as a margin bottom of two inside
2248
01:41:23,880 --> 01:41:26,159
of there we'll want to create our button
2249
01:41:26,159 --> 01:41:28,260
that's going to be used to upload the
2250
01:41:28,260 --> 01:41:31,139
photo but first to style it better we're
2251
01:41:31,139 --> 01:41:34,020
going to create another inner stack that
2252
01:41:34,020 --> 01:41:36,360
stack is going to have a direction equal
2253
01:41:36,360 --> 01:41:39,719
to rho as well as a gap equal to two
2254
01:41:39,719 --> 01:41:41,820
inside of there we can create a
2255
01:41:41,820 --> 01:41:43,679
typography element
2256
01:41:43,679 --> 01:41:47,100
and that typography can say property
2257
01:41:47,100 --> 01:41:49,320
photo
2258
01:41:49,320 --> 01:41:52,080
we can style it a bit by giving it a
2259
01:41:52,080 --> 01:41:56,520
color equal to hash 11142d
2260
01:41:56,520 --> 01:41:59,820
a font size of 16.
2261
01:41:59,820 --> 01:42:04,800
a font weight of 500. and a margin y
2262
01:42:04,800 --> 01:42:08,159
meaning on top and bottom 10 pixels if
2263
01:42:08,159 --> 01:42:10,440
we save this that's going to give us an
2264
01:42:10,440 --> 01:42:14,040
error and that's because I missed a t on
2265
01:42:14,040 --> 01:42:16,320
weight so if you fix that we should be
2266
01:42:16,320 --> 01:42:18,600
able to have a property photo down below
2267
01:42:18,600 --> 01:42:21,500
and with that we can create our button
2268
01:42:21,500 --> 01:42:24,900
so still inside of the stack just below
2269
01:42:24,900 --> 01:42:27,119
the typography let's create a button
2270
01:42:27,119 --> 01:42:28,320
component
2271
01:42:28,320 --> 01:42:31,380
that button is going to say upload and
2272
01:42:31,380 --> 01:42:32,940
then we can put an asterisk right here
2273
01:42:32,940 --> 01:42:35,820
meaning it is mandatory and we can start
2274
01:42:35,820 --> 01:42:38,219
styling it by setting the component
2275
01:42:38,219 --> 01:42:41,520
equal to a label and giving it an SX
2276
01:42:41,520 --> 01:42:44,880
property equal to width set to fit Dash
2277
01:42:44,880 --> 01:42:48,659
content color is going to be set to Hash
2278
01:42:48,659 --> 01:42:51,500
to E
2279
01:42:51,500 --> 01:42:56,960
d480 and we can say text transform
2280
01:42:57,840 --> 01:43:01,080
is going to be set to capitalize to make
2281
01:43:01,080 --> 01:43:03,179
it like a call to action button and we
2282
01:43:03,179 --> 01:43:05,699
can give it a font size of 16 for it to
2283
01:43:05,699 --> 01:43:07,679
be more easily noticeable
2284
01:43:07,679 --> 01:43:10,260
great let's save that
2285
01:43:10,260 --> 01:43:13,739
okay that's looking great and below that
2286
01:43:13,739 --> 01:43:15,960
or inside of that we can create an input
2287
01:43:15,960 --> 01:43:19,739
that input is going to be a self-closing
2288
01:43:19,739 --> 01:43:22,980
hidden property or tag
2289
01:43:22,980 --> 01:43:25,560
and we can say accept
2290
01:43:25,560 --> 01:43:27,179
is equal to
2291
01:43:27,179 --> 01:43:30,600
image and then forward slash asterisk
2292
01:43:30,600 --> 01:43:33,000
meaning everything type is going to be
2293
01:43:33,000 --> 01:43:36,360
set to file and then on change is going
2294
01:43:36,360 --> 01:43:38,940
to be set to a callback function where
2295
01:43:38,940 --> 01:43:40,260
we get an event
2296
01:43:40,260 --> 01:43:43,739
and then we can call handle image change
2297
01:43:43,739 --> 01:43:46,340
and then we can call it with e.target
2298
01:43:46,340 --> 01:43:50,159
DOT files zero so we want to pass the
2299
01:43:50,159 --> 01:43:52,380
first and only image to add
2300
01:43:52,380 --> 01:43:54,060
now you can see that tapse is
2301
01:43:54,060 --> 01:43:55,980
complaining that we might not have a
2302
01:43:55,980 --> 01:43:58,320
file right here that maybe it is null
2303
01:43:58,320 --> 01:44:00,780
but will make this field mandatory
2304
01:44:00,780 --> 01:44:03,239
meaning it will have to be filled so for
2305
01:44:03,239 --> 01:44:05,280
now we can simply create a comment and
2306
01:44:05,280 --> 01:44:08,340
say at TS Dash ignore that's going to
2307
01:44:08,340 --> 01:44:11,699
ignore that warning right here great now
2308
01:44:11,699 --> 01:44:14,100
below the button and then below the
2309
01:44:14,100 --> 01:44:17,760
stack we can create one final typography
2310
01:44:17,760 --> 01:44:21,540
this typography is going to say property
2311
01:44:21,540 --> 01:44:24,480
image question mark dot name so we're
2312
01:44:24,480 --> 01:44:26,340
going to Simply render the name of that
2313
01:44:26,340 --> 01:44:28,679
uploaded image we can give it a font
2314
01:44:28,679 --> 01:44:30,239
size
2315
01:44:30,239 --> 01:44:36,199
equal to 14. a color equal to hash
2316
01:44:36,500 --> 01:44:40,860
808191 and we can give it an SX property
2317
01:44:40,860 --> 01:44:43,260
of word break
2318
01:44:43,260 --> 01:44:47,280
equal to break Dash all great now if we
2319
01:44:47,280 --> 01:44:49,739
save this you cannot see it now but if
2320
01:44:49,739 --> 01:44:51,420
we upload something you will be able to
2321
01:44:51,420 --> 01:44:53,940
see the name of that photo below the
2322
01:44:53,940 --> 01:44:56,460
stack still inside of the form we want
2323
01:44:56,460 --> 01:44:58,500
to create our last and most important
2324
01:44:58,500 --> 01:45:01,280
button that's going to be a custom
2325
01:45:01,280 --> 01:45:04,920
button it is a self-closing button and
2326
01:45:04,920 --> 01:45:07,440
it's going to be of a type is equal to
2327
01:45:07,440 --> 01:45:08,580
submit
2328
01:45:08,580 --> 01:45:11,100
it's going to have a title if we are
2329
01:45:11,100 --> 01:45:13,500
loading the form then it's going to say
2330
01:45:13,500 --> 01:45:17,040
submitting dot dot else it's going to
2331
01:45:17,040 --> 01:45:18,900
say submit
2332
01:45:18,900 --> 01:45:21,000
and finally it's going to have a
2333
01:45:21,000 --> 01:45:24,320
background color equal to hash
2334
01:45:24,320 --> 01:45:26,060
475
2335
01:45:26,060 --> 01:45:29,639
be8 and it's going to have a color equal
2336
01:45:29,639 --> 01:45:31,820
to Hash
2337
01:45:31,820 --> 01:45:34,260
fcfc FC
2338
01:45:34,260 --> 01:45:37,260
and if we save that you can see it right
2339
01:45:37,260 --> 01:45:40,619
here great with that said we have
2340
01:45:40,619 --> 01:45:43,920
completed our entire form and it's
2341
01:45:43,920 --> 01:45:46,739
looking great so now if we expand it you
2342
01:45:46,739 --> 01:45:48,659
can see it is fully responsive and it
2343
01:45:48,659 --> 01:45:51,780
looks great even on mobile devices and
2344
01:45:51,780 --> 01:45:55,080
we are ready to start testing it out so
2345
01:45:55,080 --> 01:45:57,540
now we have the form we have the create
2346
01:45:57,540 --> 01:45:59,699
property but of course we have to do the
2347
01:45:59,699 --> 01:46:02,219
logic to connect it handle image change
2348
01:46:02,219 --> 01:46:05,159
and on finish Handler these are the two
2349
01:46:05,159 --> 01:46:07,500
last missing pieces of the puzzle so
2350
01:46:07,500 --> 01:46:09,239
when it comes to the handle image change
2351
01:46:09,239 --> 01:46:11,100
I'm gonna make this one easy for you
2352
01:46:11,100 --> 01:46:13,380
down in the description below in that
2353
01:46:13,380 --> 01:46:15,360
same GitHub gist you'll be able to find
2354
01:46:15,360 --> 01:46:17,219
the finished handle image change
2355
01:46:17,219 --> 01:46:19,679
function code so you can simply get it
2356
01:46:19,679 --> 01:46:22,199
from there and paste it here the reason
2357
01:46:22,199 --> 01:46:24,360
why we're doing this is because this is
2358
01:46:24,360 --> 01:46:26,580
simply some regular Javascript file
2359
01:46:26,580 --> 01:46:28,560
reader stuff we're simply getting the
2360
01:46:28,560 --> 01:46:30,659
file and then we are reading the data
2361
01:46:30,659 --> 01:46:32,880
from it once we read it we're simply
2362
01:46:32,880 --> 01:46:34,920
setting it to the state now nothing more
2363
01:46:34,920 --> 01:46:37,739
nothing less but what really matters and
2364
01:46:37,739 --> 01:46:39,900
what I want to focus on is the on finish
2365
01:46:39,900 --> 01:46:42,780
Handler this is where we're using refine
2366
01:46:42,780 --> 01:46:44,940
we're passing all the data that we're
2367
01:46:44,940 --> 01:46:46,739
getting from the form and finally
2368
01:46:46,739 --> 01:46:49,020
submitting it so that our backend can
2369
01:46:49,020 --> 01:46:51,360
create a record in the database and that
2370
01:46:51,360 --> 01:46:53,639
we can experience all of the best crowd
2371
01:46:53,639 --> 01:46:56,280
functionalities we can start by
2372
01:46:56,280 --> 01:46:58,679
accessing all the data that we have from
2373
01:46:58,679 --> 01:47:01,320
our form so we can say data and that is
2374
01:47:01,320 --> 01:47:04,860
going to be of a type field values
2375
01:47:04,860 --> 01:47:09,119
great then we can check if there is no
2376
01:47:09,119 --> 01:47:12,900
property image dot name that means that
2377
01:47:12,900 --> 01:47:15,420
the user hasn't uploaded the image so in
2378
01:47:15,420 --> 01:47:17,880
that case we can return an alert saying
2379
01:47:17,880 --> 01:47:21,540
please select an image and finally if we
2380
01:47:21,540 --> 01:47:24,719
do have an image we can await
2381
01:47:24,719 --> 01:47:27,119
on finish remember that's coming from
2382
01:47:27,119 --> 01:47:29,580
refine and we can pass everything to it
2383
01:47:29,580 --> 01:47:32,760
by everything I mean an object inside of
2384
01:47:32,760 --> 01:47:35,100
which we can spread all of our data from
2385
01:47:35,100 --> 01:47:38,040
inputs we can add our photo which is
2386
01:47:38,040 --> 01:47:41,460
equal to property image dot URL and we
2387
01:47:41,460 --> 01:47:43,500
can add the email of the user that
2388
01:47:43,500 --> 01:47:45,540
created that property that's equal to
2389
01:47:45,540 --> 01:47:48,840
user dot email remember that's again
2390
01:47:48,840 --> 01:47:51,679
coming from refines use identity hook
2391
01:47:51,679 --> 01:47:54,420
great and of course since we're using a
2392
01:47:54,420 --> 01:47:56,219
weight here we have to make this
2393
01:47:56,219 --> 01:47:59,940
function async great and this alone
2394
01:47:59,940 --> 01:48:03,300
should allow us to create our post but
2395
01:48:03,300 --> 01:48:05,520
if you think about it this is only
2396
01:48:05,520 --> 01:48:07,980
allowing us to pass the data to the
2397
01:48:07,980 --> 01:48:10,080
right backend endpoint
2398
01:48:10,080 --> 01:48:12,179
and since we're building a full stack
2399
01:48:12,179 --> 01:48:15,239
application it is our job to create that
2400
01:48:15,239 --> 01:48:17,280
backend to create that endpoint that's
2401
01:48:17,280 --> 01:48:19,260
going to listen for this request to
2402
01:48:19,260 --> 01:48:21,900
create a record in the database and then
2403
01:48:21,900 --> 01:48:25,199
to Showcase it later on on the front end
2404
01:48:25,199 --> 01:48:27,480
and that's exactly what we're going to
2405
01:48:27,480 --> 01:48:30,239
do next now we are at a breaking point
2406
01:48:30,239 --> 01:48:32,880
we are the point where we can start
2407
01:48:32,880 --> 01:48:35,699
creating our backend so let's go ahead
2408
01:48:35,699 --> 01:48:37,980
and close all for currently open files
2409
01:48:37,980 --> 01:48:40,920
and open up the file explorer to start
2410
01:48:40,920 --> 01:48:43,080
creating our backend from scratch we can
2411
01:48:43,080 --> 01:48:45,480
right click here in the Explorer create
2412
01:48:45,480 --> 01:48:48,119
a new folder called server
2413
01:48:48,119 --> 01:48:50,600
we can then go to view and then terminal
2414
01:48:50,600 --> 01:48:54,119
make sure that you see the dot dot to
2415
01:48:54,119 --> 01:48:56,159
move to the root of our directory and
2416
01:48:56,159 --> 01:49:00,300
then CD to server so that we are in here
2417
01:49:00,300 --> 01:49:04,320
now we can run npm in net Dash y this is
2418
01:49:04,320 --> 01:49:07,320
going to initialize an empty packet Json
2419
01:49:07,320 --> 01:49:10,619
now while we're here we can also add a
2420
01:49:10,619 --> 01:49:13,560
type is equal to module right here
2421
01:49:13,560 --> 01:49:15,659
that's going to allow us to use the
2422
01:49:15,659 --> 01:49:19,080
modern import export syntax and we also
2423
01:49:19,080 --> 01:49:20,699
have to install a couple of dependencies
2424
01:49:20,699 --> 01:49:24,719
so let's clear the terminal and run npm
2425
01:49:24,719 --> 01:49:25,860
installed
2426
01:49:25,860 --> 01:49:28,320
we're gonna need cloudinery
2427
01:49:28,320 --> 01:49:30,300
and we're going to use that to serve our
2428
01:49:30,300 --> 01:49:32,460
images then we're going to have course
2429
01:49:32,460 --> 01:49:34,980
for cross origin requests we're going to
2430
01:49:34,980 --> 01:49:37,619
have dot EnV for safely storing our
2431
01:49:37,619 --> 01:49:39,960
environment variables of course Express
2432
01:49:39,960 --> 01:49:43,619
and Mongoose as well as an old man with
2433
01:49:43,619 --> 01:49:45,840
that said you can run this command it
2434
01:49:45,840 --> 01:49:48,060
should take just about a minute and then
2435
01:49:48,060 --> 01:49:51,060
we can move into the packet Json to see
2436
01:49:51,060 --> 01:49:52,679
if all of the dependencies have been
2437
01:49:52,679 --> 01:49:55,260
installed correctly and it seems they
2438
01:49:55,260 --> 01:49:56,100
have
2439
01:49:56,100 --> 01:49:58,560
now we also need to change our scripts
2440
01:49:58,560 --> 01:50:01,380
so from test what we can do is we can
2441
01:50:01,380 --> 01:50:03,600
create a start script which is simply
2442
01:50:03,600 --> 01:50:05,159
going to run
2443
01:50:05,159 --> 01:50:08,400
a command node mod Index this is going
2444
01:50:08,400 --> 01:50:10,320
to make sure that our server gets
2445
01:50:10,320 --> 01:50:13,560
started gets spinning with that said we
2446
01:50:13,560 --> 01:50:15,840
need to create that starting index file
2447
01:50:15,840 --> 01:50:17,940
in the server so right click right here
2448
01:50:17,940 --> 01:50:22,380
new file and do index.js
2449
01:50:22,380 --> 01:50:25,199
instead of here we can import of course
2450
01:50:25,199 --> 01:50:28,260
Express from Express which we'll be
2451
01:50:28,260 --> 01:50:30,179
using to create routes for our entire
2452
01:50:30,179 --> 01:50:31,260
application
2453
01:50:31,260 --> 01:50:34,679
then we can import everything as dot EnV
2454
01:50:34,679 --> 01:50:38,040
from dot EnV this allows us to use
2455
01:50:38,040 --> 01:50:40,440
environment variables we're going to
2456
01:50:40,440 --> 01:50:43,679
also import course from course for cross
2457
01:50:43,679 --> 01:50:46,500
origin requests now we can configure dot
2458
01:50:46,500 --> 01:50:49,800
EnV by running the dot env.config and
2459
01:50:49,800 --> 01:50:52,080
calling it as a function and we can also
2460
01:50:52,080 --> 01:50:54,719
initialize our app by saying const app
2461
01:50:54,719 --> 01:50:57,300
is equal to express and we call it as a
2462
01:50:57,300 --> 01:50:58,560
function
2463
01:50:58,560 --> 01:51:01,980
we also need to say app.use which is the
2464
01:51:01,980 --> 01:51:03,659
way we're adding middleware to our
2465
01:51:03,659 --> 01:51:06,719
application and there you can use course
2466
01:51:06,719 --> 01:51:09,119
and also we can add an additional piece
2467
01:51:09,119 --> 01:51:11,659
of middleware by saying app.use
2468
01:51:11,659 --> 01:51:14,219
express.json and then inside of there
2469
01:51:14,219 --> 01:51:18,000
you can pass limit is 50 megabytes we
2470
01:51:18,000 --> 01:51:20,280
want to specify the limit for the files
2471
01:51:20,280 --> 01:51:22,679
we'll be sending from the front end
2472
01:51:22,679 --> 01:51:25,860
and we can create a dummy route app.get
2473
01:51:25,860 --> 01:51:28,199
is just forward slash meaning a root
2474
01:51:28,199 --> 01:51:29,219
route
2475
01:51:29,219 --> 01:51:32,280
and then we have a callback function of
2476
01:51:32,280 --> 01:51:34,860
request and response that looks like
2477
01:51:34,860 --> 01:51:38,400
this for now we can simply do res dot
2478
01:51:38,400 --> 01:51:39,239
send
2479
01:51:39,239 --> 01:51:42,659
message is equal to hello world that way
2480
01:51:42,659 --> 01:51:44,219
we know that our backend is running
2481
01:51:44,219 --> 01:51:47,159
finally we have to start the server so
2482
01:51:47,159 --> 01:51:49,560
let's create a new function const start
2483
01:51:49,560 --> 01:51:50,580
server
2484
01:51:50,580 --> 01:51:54,300
is equal to an async function like this
2485
01:51:54,300 --> 01:51:56,340
we're going to have a try and catch
2486
01:51:56,340 --> 01:51:58,320
block so if something goes right we're
2487
01:51:58,320 --> 01:52:00,420
going to be in the try and if we catch
2488
01:52:00,420 --> 01:52:02,100
an error it's going to be caught right
2489
01:52:02,100 --> 01:52:04,440
here so if we have an error we're simply
2490
01:52:04,440 --> 01:52:06,420
going to console log it
2491
01:52:06,420 --> 01:52:08,400
and what do we want to do in the try
2492
01:52:08,400 --> 01:52:12,179
well we want to try to connect to the
2493
01:52:12,179 --> 01:52:14,460
database that is a really important part
2494
01:52:14,460 --> 01:52:17,699
and to keep our code tidy we're going to
2495
01:52:17,699 --> 01:52:20,159
create a new function and a new folder
2496
01:52:20,159 --> 01:52:23,940
in the server called mongodb
2497
01:52:23,940 --> 01:52:26,159
and inside of there we're going to have
2498
01:52:26,159 --> 01:52:29,880
a function called connect.js inside of
2499
01:52:29,880 --> 01:52:31,020
that connect we're going to import
2500
01:52:31,020 --> 01:52:34,380
Mongoose coming from monogous
2501
01:52:34,380 --> 01:52:36,540
Mongoose is a modeling library for
2502
01:52:36,540 --> 01:52:38,940
mongodb it's going to allow us to make
2503
01:52:38,940 --> 01:52:41,760
models more easily in schemas and then
2504
01:52:41,760 --> 01:52:45,060
we can here create a const connect the B
2505
01:52:45,060 --> 01:52:49,500
function that accepts a URL or a URI and
2506
01:52:49,500 --> 01:52:51,199
it's going to look something like this
2507
01:52:51,199 --> 01:52:54,239
Mongoose that set
2508
01:52:54,239 --> 01:52:56,159
strict
2509
01:52:56,159 --> 01:52:58,739
query like this is going to be set to
2510
01:52:58,739 --> 01:53:01,980
true this is going to save us later on
2511
01:53:01,980 --> 01:53:04,980
after that we want to run Mongoose dot
2512
01:53:04,980 --> 01:53:06,960
connect like this and we want to pass
2513
01:53:06,960 --> 01:53:08,159
the URL
2514
01:53:08,159 --> 01:53:10,679
now this is an async function so we can
2515
01:53:10,679 --> 01:53:12,960
chain a DOT then on it
2516
01:53:12,960 --> 01:53:15,420
and if we're successful we can simply
2517
01:53:15,420 --> 01:53:19,920
type console.log mongodb connected
2518
01:53:19,920 --> 01:53:22,440
otherwise we can catch an error and
2519
01:53:22,440 --> 01:53:25,380
simply console log it and of course we
2520
01:53:25,380 --> 01:53:28,860
have to export default connect to DB so
2521
01:53:28,860 --> 01:53:31,440
we can use it within our index
2522
01:53:31,440 --> 01:53:34,860
now it looks like we have some typing
2523
01:53:34,860 --> 01:53:36,239
errors right here
2524
01:53:36,239 --> 01:53:39,060
Mongoose dot set expected something else
2525
01:53:39,060 --> 01:53:41,340
I think we should be good hopefully
2526
01:53:41,340 --> 01:53:42,900
we're not gonna have problems with
2527
01:53:42,900 --> 01:53:45,119
Visual Studio code because the syntax
2528
01:53:45,119 --> 01:53:48,179
indeed is valid great
2529
01:53:48,179 --> 01:53:50,340
so what we can do now is go back to
2530
01:53:50,340 --> 01:53:53,820
index and we can import
2531
01:53:53,820 --> 01:53:57,900
connect DB coming from dot slash mongodb
2532
01:53:57,900 --> 01:54:00,840
forward slash connect and since we're
2533
01:54:00,840 --> 01:54:02,760
not in react I think we have to specify
2534
01:54:02,760 --> 01:54:05,580
the extension as well that's connect.js
2535
01:54:05,580 --> 01:54:08,340
now we can use this function connect DB
2536
01:54:08,340 --> 01:54:11,219
right here inside of the start server we
2537
01:54:11,219 --> 01:54:13,619
want to connect to the DB and then in
2538
01:54:13,619 --> 01:54:16,679
here we need to pass a special mongodb
2539
01:54:16,679 --> 01:54:20,580
URL right now we don't have it so that's
2540
01:54:20,580 --> 01:54:22,320
going to be the next step let's go to
2541
01:54:22,320 --> 01:54:24,719
mongodb atlas to get it
2542
01:54:24,719 --> 01:54:27,960
you can visit mongodb.com forward slash
2543
01:54:27,960 --> 01:54:30,480
Atlas forward slash database and then
2544
01:54:30,480 --> 01:54:32,880
click try for free in my case I already
2545
01:54:32,880 --> 01:54:36,060
have an account so I'm gonna sign in
2546
01:54:36,060 --> 01:54:38,219
you can log in or register using Google
2547
01:54:38,219 --> 01:54:41,040
or GitHub once you register or log in
2548
01:54:41,040 --> 01:54:42,719
you should be able to see something like
2549
01:54:42,719 --> 01:54:44,880
this you should find a place where you
2550
01:54:44,880 --> 01:54:47,580
can create a new project
2551
01:54:47,580 --> 01:54:49,440
in this case we're going to name our
2552
01:54:49,440 --> 01:54:51,659
project yariga which is the name of our
2553
01:54:51,659 --> 01:54:53,880
real estate application and I'm going to
2554
01:54:53,880 --> 01:54:56,100
click create project
2555
01:54:56,100 --> 01:54:58,560
now inside of here we'll have to build a
2556
01:54:58,560 --> 01:55:01,560
database so click that button and we're
2557
01:55:01,560 --> 01:55:04,739
going to choose a shared free cluster
2558
01:55:04,739 --> 01:55:06,060
it's going to ask you a couple of
2559
01:55:06,060 --> 01:55:08,400
questions choose the region closest to
2560
01:55:08,400 --> 01:55:12,199
you and click create cluster
2561
01:55:13,260 --> 01:55:15,780
now you'll have to enter a username and
2562
01:55:15,780 --> 01:55:17,760
a password in this case I'm going to do
2563
01:55:17,760 --> 01:55:20,520
JavaScript Mastery and I'm going to
2564
01:55:20,520 --> 01:55:23,520
choose my password make sure to remember
2565
01:55:23,520 --> 01:55:25,500
this password because we'll have to use
2566
01:55:25,500 --> 01:55:27,540
it later on within our code
2567
01:55:27,540 --> 01:55:29,639
great that's it when it comes to quick
2568
01:55:29,639 --> 01:55:32,119
start now we can go to network access
2569
01:55:32,119 --> 01:55:35,540
and make sure to click add IP address
2570
01:55:35,540 --> 01:55:38,820
and then allow access from anywhere this
2571
01:55:38,820 --> 01:55:40,500
is going to allow us to access our
2572
01:55:40,500 --> 01:55:43,139
database now locally but also later on
2573
01:55:43,139 --> 01:55:45,780
once we deploy our application great
2574
01:55:45,780 --> 01:55:49,619
finally we can go to database
2575
01:55:49,619 --> 01:55:51,659
connect
2576
01:55:51,659 --> 01:55:53,699
and then we want to connect using your
2577
01:55:53,699 --> 01:55:55,920
application and in here you're going to
2578
01:55:55,920 --> 01:55:57,900
get your url but as you can see you'll
2579
01:55:57,900 --> 01:55:59,880
have to replace your password right here
2580
01:55:59,880 --> 01:56:02,280
so let's copy it
2581
01:56:02,280 --> 01:56:05,280
and now inside of the server you have to
2582
01:56:05,280 --> 01:56:09,179
create a new DOT EnV file
2583
01:56:09,179 --> 01:56:12,480
we called it mongodb URL so let's do
2584
01:56:12,480 --> 01:56:17,400
DB underscore URL is equal to
2585
01:56:17,400 --> 01:56:20,639
and then you can pass your url again as
2586
01:56:20,639 --> 01:56:22,320
you can see you'll have to type in your
2587
01:56:22,320 --> 01:56:24,540
password right here I chose one two
2588
01:56:24,540 --> 01:56:27,780
three one two three a like this make
2589
01:56:27,780 --> 01:56:30,300
sure to type in your own password and
2590
01:56:30,300 --> 01:56:33,239
your own username for this to work great
2591
01:56:33,239 --> 01:56:35,580
now that we have that we are now
2592
01:56:35,580 --> 01:56:38,400
referencing that mongodb URL right here
2593
01:56:38,400 --> 01:56:40,159
by saying
2594
01:56:40,159 --> 01:56:42,600
process.env.mongodb underscore URL and
2595
01:56:42,600 --> 01:56:44,480
we are trying to connect to our database
2596
01:56:44,480 --> 01:56:47,600
once we are connected we can then run
2597
01:56:47,600 --> 01:56:51,900
app.listen on port 8080 like this and
2598
01:56:51,900 --> 01:56:53,940
once we are listening we can create a
2599
01:56:53,940 --> 01:56:55,860
callback function that's going to
2600
01:56:55,860 --> 01:56:58,260
console.log and say something like
2601
01:56:58,260 --> 01:57:01,920
server has started on Port 8080. you can
2602
01:57:01,920 --> 01:57:04,260
even type HTTP colon forward slash
2603
01:57:04,260 --> 01:57:08,040
forward slash localhost Colin 8080 that
2604
01:57:08,040 --> 01:57:10,500
way you'll be able to click it and since
2605
01:57:10,500 --> 01:57:12,179
we have this function we can of course
2606
01:57:12,179 --> 01:57:15,540
call it start server and this is all
2607
01:57:15,540 --> 01:57:17,699
that we need to properly connect to the
2608
01:57:17,699 --> 01:57:21,119
database and start our server so let's
2609
01:57:21,119 --> 01:57:23,159
close all the currently opened files
2610
01:57:23,159 --> 01:57:26,460
let's go to view and then terminal and
2611
01:57:26,460 --> 01:57:30,380
let's run npm start
2612
01:57:30,540 --> 01:57:33,060
if everything goes right well this is
2613
01:57:33,060 --> 01:57:35,520
not right right so it says Mongoose that
2614
01:57:35,520 --> 01:57:38,340
set unexpected token this is what I was
2615
01:57:38,340 --> 01:57:41,040
scared about it looks like it is giving
2616
01:57:41,040 --> 01:57:42,960
us some issues right here even though
2617
01:57:42,960 --> 01:57:45,119
the syntax seems to be correct
2618
01:57:45,119 --> 01:57:47,580
oh it is not correct I had a mistake
2619
01:57:47,580 --> 01:57:49,560
hopefully you caught that much earlier
2620
01:57:49,560 --> 01:57:51,780
than I did right here we're missing an
2621
01:57:51,780 --> 01:57:53,880
end of an arrow for our function so
2622
01:57:53,880 --> 01:57:55,920
hopefully you caught that mistakes and
2623
01:57:55,920 --> 01:57:57,239
typos happen
2624
01:57:57,239 --> 01:57:59,099
now we can stop it from running by
2625
01:57:59,099 --> 01:58:01,560
pressing Ctrl C and then Y and we can
2626
01:58:01,560 --> 01:58:04,560
simply Run npm start one more time and
2627
01:58:04,560 --> 01:58:07,500
hopefully now everything goes smoothly
2628
01:58:07,500 --> 01:58:09,960
still it didn't it looks like strict
2629
01:58:09,960 --> 01:58:12,420
policy or strict query was not typed
2630
01:58:12,420 --> 01:58:14,340
right this right here was supposed to be
2631
01:58:14,340 --> 01:58:16,920
strict so hopefully you caught that as
2632
01:58:16,920 --> 01:58:19,619
well and third time's the charm if we
2633
01:58:19,619 --> 01:58:21,719
run it one more time hopefully it's
2634
01:58:21,719 --> 01:58:24,480
going to work there we go server started
2635
01:58:24,480 --> 01:58:28,440
on localhost 8080 mongodb connected now
2636
01:58:28,440 --> 01:58:32,540
you can hold Ctrl and click this URL
2637
01:58:33,360 --> 01:58:35,760
and you should be able to see a Json
2638
01:58:35,760 --> 01:58:38,280
output that says message hello world
2639
01:58:38,280 --> 01:58:41,580
which means that we are live also in
2640
01:58:41,580 --> 01:58:43,679
this quick process I also taught you how
2641
01:58:43,679 --> 01:58:46,440
to create a new mongodb database Cloud
2642
01:58:46,440 --> 01:58:49,139
cluster which essentially is completely
2643
01:58:49,139 --> 01:58:51,360
free and allows you to store data on the
2644
01:58:51,360 --> 01:58:53,820
cloud with that said we're now done with
2645
01:58:53,820 --> 01:58:56,760
the mongodb function but we are yet to
2646
01:58:56,760 --> 01:58:59,400
create our models or schemas for the
2647
01:58:59,400 --> 01:59:01,980
data we'll be using later on so let's
2648
01:59:01,980 --> 01:59:04,560
right click mongodb create a new folder
2649
01:59:04,560 --> 01:59:06,480
called models
2650
01:59:06,480 --> 01:59:08,520
inside of our models we're going to have
2651
01:59:08,520 --> 01:59:12,840
a user.js model so what we can do is
2652
01:59:12,840 --> 01:59:16,619
import Mongoose from mongoose
2653
01:59:16,619 --> 01:59:20,040
and then we can say const user schema
2654
01:59:20,040 --> 01:59:24,239
is equal to new Mongoose dot schema and
2655
01:59:24,239 --> 01:59:27,239
then we pass an object for options there
2656
01:59:27,239 --> 01:59:29,880
we can have a name which is going to be
2657
01:59:29,880 --> 01:59:32,219
of a type is equal to string and
2658
01:59:32,219 --> 01:59:34,920
required equal to true then we're going
2659
01:59:34,920 --> 01:59:37,679
to have the email also a string and also
2660
01:59:37,679 --> 01:59:39,780
required finally we're going to have an
2661
01:59:39,780 --> 01:59:42,659
avatar which is going to be also a type
2662
01:59:42,659 --> 01:59:44,820
string and also required that's the
2663
01:59:44,820 --> 01:59:46,980
photo and then we're going to have all
2664
01:59:46,980 --> 01:59:48,060
properties
2665
01:59:48,060 --> 01:59:50,340
every user will have a list of their own
2666
01:59:50,340 --> 01:59:52,500
properties so this right here is going
2667
01:59:52,500 --> 01:59:54,659
to be an array so make sure to put it in
2668
01:59:54,659 --> 01:59:57,679
square brackets an array of objects
2669
01:59:57,679 --> 02:00:01,520
where type is going to be of mongoose
2670
02:00:01,520 --> 02:00:06,599
dot schema dot types dot object ID so
2671
02:00:06,599 --> 02:00:08,239
we're going to have a type of object ID
2672
02:00:08,239 --> 02:00:11,580
and it's going to be a reference a ref
2673
02:00:11,580 --> 02:00:15,119
to a property object like this
2674
02:00:15,119 --> 02:00:18,900
great that's it for our user schema so
2675
02:00:18,900 --> 02:00:20,820
we have to create it into a model right
2676
02:00:20,820 --> 02:00:24,060
now by saying const user model is equal
2677
02:00:24,060 --> 02:00:28,860
to Mongoose dot model called user based
2678
02:00:28,860 --> 02:00:31,739
on the user schema and then we can
2679
02:00:31,739 --> 02:00:33,179
export
2680
02:00:33,179 --> 02:00:37,619
default user model great and let's fix
2681
02:00:37,619 --> 02:00:39,540
the spelling right here
2682
02:00:39,540 --> 02:00:40,560
great
2683
02:00:40,560 --> 02:00:43,380
now we can create another model called
2684
02:00:43,380 --> 02:00:44,820
property
2685
02:00:44,820 --> 02:00:46,380
dot Js
2686
02:00:46,380 --> 02:00:48,420
we have to follow the same rules that's
2687
02:00:48,420 --> 02:00:51,300
going to be import Mongoose from
2688
02:00:51,300 --> 02:00:52,860
mongoose
2689
02:00:52,860 --> 02:00:56,400
then we can const property schema is
2690
02:00:56,400 --> 02:01:00,540
equal to new Mongoose dot schema and
2691
02:01:00,540 --> 02:01:02,219
then we can start giving it properties
2692
02:01:02,219 --> 02:01:04,739
it's going to have a title which is
2693
02:01:04,739 --> 02:01:07,080
going to be of a type string and
2694
02:01:07,080 --> 02:01:09,599
required equal to true it's going to
2695
02:01:09,599 --> 02:01:12,840
have a description also string required
2696
02:01:12,840 --> 02:01:16,380
to true it's going to have a property
2697
02:01:16,380 --> 02:01:19,619
type which is going to be also believe
2698
02:01:19,619 --> 02:01:22,139
it or not a string and required to true
2699
02:01:22,139 --> 02:01:25,500
then it's going to have a location
2700
02:01:25,500 --> 02:01:28,020
which is going to be a string required
2701
02:01:28,020 --> 02:01:30,540
to true it's going to have a price which
2702
02:01:30,540 --> 02:01:32,639
is going to be of a type number and
2703
02:01:32,639 --> 02:01:34,920
required to 2. it's going to have a
2704
02:01:34,920 --> 02:01:37,020
photo which is going to be of a type
2705
02:01:37,020 --> 02:01:39,900
string because it's a URL and required
2706
02:01:39,900 --> 02:01:42,900
to true and finally it's going to have a
2707
02:01:42,900 --> 02:01:45,440
Creator which is going to be of a type
2708
02:01:45,440 --> 02:01:49,440
Mongoose dot schema dot types dot object
2709
02:01:49,440 --> 02:01:52,139
ID and then we are referring it to a
2710
02:01:52,139 --> 02:01:54,420
user that created it so we have a
2711
02:01:54,420 --> 02:01:56,940
two-way reference a user can create
2712
02:01:56,940 --> 02:01:59,340
multiple as you can see this is an array
2713
02:01:59,340 --> 02:02:03,480
multiple posts or properties and one
2714
02:02:03,480 --> 02:02:06,300
property can belong to one user or a
2715
02:02:06,300 --> 02:02:07,139
creator
2716
02:02:07,139 --> 02:02:10,020
finally we can say const property model
2717
02:02:10,020 --> 02:02:12,420
to define the model out of that schema
2718
02:02:12,420 --> 02:02:15,480
by saying Mongoose that model property
2719
02:02:15,480 --> 02:02:18,239
based on the property schema
2720
02:02:18,239 --> 02:02:21,199
and finally we can export default
2721
02:02:21,199 --> 02:02:24,840
property model great now we can use
2722
02:02:24,840 --> 02:02:27,599
those models to create the instances of
2723
02:02:27,599 --> 02:02:29,940
these documents in our database
2724
02:02:29,940 --> 02:02:32,699
so we have mongodb we have models we
2725
02:02:32,699 --> 02:02:35,340
have index but we don't yet have the
2726
02:02:35,340 --> 02:02:37,679
routes if you remember correctly on the
2727
02:02:37,679 --> 02:02:39,719
front end we set something like forward
2728
02:02:39,719 --> 02:02:43,199
slash API forward slash V1 forward slash
2729
02:02:43,199 --> 02:02:45,540
properties and then maybe for slash
2730
02:02:45,540 --> 02:02:48,599
create we'll have to see but we have to
2731
02:02:48,599 --> 02:02:51,960
have this route right now we only have
2732
02:02:51,960 --> 02:02:54,599
forward slash localhost 8080 and just
2733
02:02:54,599 --> 02:02:57,599
slash that's it nothing's there so let's
2734
02:02:57,599 --> 02:03:00,119
go ahead and create the routes for our
2735
02:03:00,119 --> 02:03:03,179
application by creating a new folder on
2736
02:03:03,179 --> 02:03:06,540
our server called routes inside of our
2737
02:03:06,540 --> 02:03:10,500
routes we're gonna have a new property
2738
02:03:10,500 --> 02:03:14,520
Dot routes.js and we can create one for
2739
02:03:14,520 --> 02:03:18,780
our users by saying user Dot routes.js
2740
02:03:18,780 --> 02:03:20,599
inside of here we're going to import
2741
02:03:20,599 --> 02:03:25,460
Express coming from Express
2742
02:03:25,860 --> 02:03:28,460
and then we have to import
2743
02:03:28,460 --> 02:03:32,219
all the controllers now if you're new to
2744
02:03:32,219 --> 02:03:33,780
the backend development you might be
2745
02:03:33,780 --> 02:03:36,659
wondering what is a controller route is
2746
02:03:36,659 --> 02:03:38,520
pretty much self-explanatory right it's
2747
02:03:38,520 --> 02:03:40,380
a specific route we can visit or ping
2748
02:03:40,380 --> 02:03:43,080
from the front end but what is the
2749
02:03:43,080 --> 02:03:44,099
controller
2750
02:03:44,099 --> 02:03:47,760
well to simplify my explanation mdn web
2751
02:03:47,760 --> 02:03:50,219
docs comes to rescue especially Express
2752
02:03:50,219 --> 02:03:52,980
tutorial part 4 routes and controllers
2753
02:03:52,980 --> 02:03:55,500
right here we can see that from the
2754
02:03:55,500 --> 02:03:57,599
front end we're gonna make an HTTP
2755
02:03:57,599 --> 02:04:00,599
request right here then that's going to
2756
02:04:00,599 --> 02:04:03,659
be forwarded to routes and then every
2757
02:04:03,659 --> 02:04:05,880
single route is going to forward the
2758
02:04:05,880 --> 02:04:07,860
request to the appropriate controller
2759
02:04:07,860 --> 02:04:09,179
right here
2760
02:04:09,179 --> 02:04:11,580
and then that controller is the one
2761
02:04:11,580 --> 02:04:13,320
that's connected to the models and the
2762
02:04:13,320 --> 02:04:16,199
database controller is the logic for
2763
02:04:16,199 --> 02:04:18,179
each route and the route is just the
2764
02:04:18,179 --> 02:04:21,360
endpoint so before creating routes we
2765
02:04:21,360 --> 02:04:23,880
also have to create controllers so let's
2766
02:04:23,880 --> 02:04:26,520
say controllers
2767
02:04:26,520 --> 02:04:29,280
and then let's create two separate files
2768
02:04:29,280 --> 02:04:31,679
that's going to be property dot
2769
02:04:31,679 --> 02:04:32,940
controller
2770
02:04:32,940 --> 02:04:34,500
.js
2771
02:04:34,500 --> 02:04:39,840
and also user Dot controller.js
2772
02:04:39,840 --> 02:04:42,000
let's start by defining all of the
2773
02:04:42,000 --> 02:04:44,699
controllers for the user first we have
2774
02:04:44,699 --> 02:04:48,679
to import user coming from that slash
2775
02:04:48,679 --> 02:04:51,840
mongodb forward slash models forward
2776
02:04:51,840 --> 02:04:55,199
slash user.js
2777
02:04:55,199 --> 02:04:57,780
and a controller is nothing more than a
2778
02:04:57,780 --> 02:05:00,179
simple function so we can say const get
2779
02:05:00,179 --> 02:05:02,880
all users that's going to be one of the
2780
02:05:02,880 --> 02:05:05,040
controllers and controllers are usually
2781
02:05:05,040 --> 02:05:07,020
asynchronous because it takes some time
2782
02:05:07,020 --> 02:05:09,420
to do something with the database
2783
02:05:09,420 --> 02:05:11,040
for now we're going to leave it as an
2784
02:05:11,040 --> 02:05:13,199
empty callback function then we can
2785
02:05:13,199 --> 02:05:16,199
create the second one const create user
2786
02:05:16,199 --> 02:05:20,460
is equal to async rec res then we can
2787
02:05:20,460 --> 02:05:22,320
create another one which is going to be
2788
02:05:22,320 --> 02:05:28,139
called const get user info by ID like
2789
02:05:28,139 --> 02:05:30,780
this that's also going to be an async
2790
02:05:30,780 --> 02:05:33,480
empty function for now and that's it we
2791
02:05:33,480 --> 02:05:35,460
need to be able to create the user get
2792
02:05:35,460 --> 02:05:39,360
all users at get user info by ID finally
2793
02:05:39,360 --> 02:05:41,760
we need to export them by saying export
2794
02:05:41,760 --> 02:05:44,219
get all users
2795
02:05:44,219 --> 02:05:48,119
create user and then get user info by ID
2796
02:05:48,119 --> 02:05:49,920
great
2797
02:05:49,920 --> 02:05:51,840
now we can repeat the procedure for
2798
02:05:51,840 --> 02:05:53,159
properties
2799
02:05:53,159 --> 02:05:54,780
inside of here we're going to also
2800
02:05:54,780 --> 02:05:57,179
import the property model that's going
2801
02:05:57,179 --> 02:06:00,480
to be property coming from dot slash
2802
02:06:00,480 --> 02:06:03,360
mongodb forward slash models forward
2803
02:06:03,360 --> 02:06:06,480
slash propertyjs and in this case we'll
2804
02:06:06,480 --> 02:06:08,460
also have to have the user model so we
2805
02:06:08,460 --> 02:06:12,560
can say import user from mongodb models
2806
02:06:12,560 --> 02:06:15,179
user.js and let's create those
2807
02:06:15,179 --> 02:06:18,719
controllers const get all properties
2808
02:06:18,719 --> 02:06:21,420
is equal to an async function where we
2809
02:06:21,420 --> 02:06:23,219
have a wreck and a res and a callback
2810
02:06:23,219 --> 02:06:24,960
function which right now doesn't do
2811
02:06:24,960 --> 02:06:25,860
anything
2812
02:06:25,860 --> 02:06:27,540
then we're going to have another one
2813
02:06:27,540 --> 02:06:31,800
const get property detail is equal to an
2814
02:06:31,800 --> 02:06:35,760
async Rec and res function like this
2815
02:06:35,760 --> 02:06:38,699
then after that we're going to have a
2816
02:06:38,699 --> 02:06:42,659
create property cons to create property
2817
02:06:42,659 --> 02:06:45,840
is equal to an async reconrest function
2818
02:06:45,840 --> 02:06:47,639
as before
2819
02:06:47,639 --> 02:06:50,040
and then also we need to have an update
2820
02:06:50,040 --> 02:06:52,860
property const update property is equal
2821
02:06:52,860 --> 02:06:55,139
to an async Rec and res empty function
2822
02:06:55,139 --> 02:06:56,219
for now
2823
02:06:56,219 --> 02:06:58,260
again we're working with full crowd
2824
02:06:58,260 --> 02:07:00,599
functionalities so the last missing
2825
02:07:00,599 --> 02:07:03,300
piece is cons the lead property is equal
2826
02:07:03,300 --> 02:07:06,780
to async rack and res and with that said
2827
02:07:06,780 --> 02:07:10,500
we have get everything get detail create
2828
02:07:10,500 --> 02:07:14,280
update delete that is it create read
2829
02:07:14,280 --> 02:07:16,920
update and delete full crud so we can
2830
02:07:16,920 --> 02:07:18,360
say export
2831
02:07:18,360 --> 02:07:21,179
and we can export get all properties get
2832
02:07:21,179 --> 02:07:24,599
property detail create property update
2833
02:07:24,599 --> 02:07:29,040
property and delete property great now
2834
02:07:29,040 --> 02:07:30,780
we can utilize all of these controllers
2835
02:07:30,780 --> 02:07:33,900
inside of our routes let me show you how
2836
02:07:33,900 --> 02:07:36,060
that's going to work we can start with
2837
02:07:36,060 --> 02:07:38,639
our user routes first and here we can
2838
02:07:38,639 --> 02:07:41,460
import create user
2839
02:07:41,460 --> 02:07:44,219
get all users
2840
02:07:44,219 --> 02:07:48,420
and get user info by ID and we can
2841
02:07:48,420 --> 02:07:51,300
import all of that from dot slash
2842
02:07:51,300 --> 02:07:53,639
controllers
2843
02:07:53,639 --> 02:07:57,119
forward slash user dot controller.js
2844
02:07:57,119 --> 02:08:00,000
then we can initialize an instance of a
2845
02:08:00,000 --> 02:08:02,880
router by saying const router is equal
2846
02:08:02,880 --> 02:08:05,580
to express.router and then we call it as
2847
02:08:05,580 --> 02:08:06,599
a function
2848
02:08:06,599 --> 02:08:09,300
and finally we can start creating a
2849
02:08:09,300 --> 02:08:11,639
route we're going to have as many routes
2850
02:08:11,639 --> 02:08:14,099
as many we have controllers so that's
2851
02:08:14,099 --> 02:08:16,860
going to be router dot route
2852
02:08:16,860 --> 02:08:18,960
in this case forward slash
2853
02:08:18,960 --> 02:08:21,119
and then dot get
2854
02:08:21,119 --> 02:08:23,940
and then we're going to get all users
2855
02:08:23,940 --> 02:08:26,820
like this now we can duplicate this two
2856
02:08:26,820 --> 02:08:29,460
times the second one is also going to be
2857
02:08:29,460 --> 02:08:31,860
on the forward slash but it's going to
2858
02:08:31,860 --> 02:08:33,540
be a post
2859
02:08:33,540 --> 02:08:36,719
so we're gonna call a create user
2860
02:08:36,719 --> 02:08:39,239
controller and then the third one is
2861
02:08:39,239 --> 02:08:41,820
going to be on forward slash column ID
2862
02:08:41,820 --> 02:08:44,940
meaning once we reach a specific ID then
2863
02:08:44,940 --> 02:08:49,139
we want to get user info by ID and
2864
02:08:49,139 --> 02:08:52,260
finally you need to export that router
2865
02:08:52,260 --> 02:08:54,719
so export default router
2866
02:08:54,719 --> 02:08:58,080
hopefully all this makes sense now we do
2867
02:08:58,080 --> 02:08:59,940
have a couple of folders a couple of
2868
02:08:59,940 --> 02:09:01,980
files everything divided in a couple of
2869
02:09:01,980 --> 02:09:03,840
places but that's for a good reason
2870
02:09:03,840 --> 02:09:06,000
imagine if you had all the routes and
2871
02:09:06,000 --> 02:09:07,800
all the controls in one place it would
2872
02:09:07,800 --> 02:09:10,260
be a mess but like this we note that we
2873
02:09:10,260 --> 02:09:12,540
have our user routes and each route
2874
02:09:12,540 --> 02:09:14,699
corresponds to a specific function we're
2875
02:09:14,699 --> 02:09:16,860
going to call from within our user
2876
02:09:16,860 --> 02:09:18,780
controller now we can repeat the
2877
02:09:18,780 --> 02:09:21,239
procedure for our property routes there
2878
02:09:21,239 --> 02:09:25,560
we can import Express from Express
2879
02:09:25,560 --> 02:09:28,760
we can also import all of the different
2880
02:09:28,760 --> 02:09:31,260
controllers first one being create
2881
02:09:31,260 --> 02:09:32,520
property
2882
02:09:32,520 --> 02:09:35,820
then we're going to have delete property
2883
02:09:35,820 --> 02:09:39,179
get all properties
2884
02:09:39,179 --> 02:09:40,980
then we're going to have get property
2885
02:09:40,980 --> 02:09:42,960
detail
2886
02:09:42,960 --> 02:09:46,739
and the last one is update property
2887
02:09:46,739 --> 02:09:49,920
and all of that is coming from dot slash
2888
02:09:49,920 --> 02:09:54,119
controllers forward slash property dot
2889
02:09:54,119 --> 02:09:57,420
controller dot JS and again make sure to
2890
02:09:57,420 --> 02:09:59,340
have that extension because I don't
2891
02:09:59,340 --> 02:10:01,860
think it will work without it then we
2892
02:10:01,860 --> 02:10:03,599
need to create an instance of our router
2893
02:10:03,599 --> 02:10:06,060
const Router is equal to express that
2894
02:10:06,060 --> 02:10:08,159
router and we can create all of our
2895
02:10:08,159 --> 02:10:11,520
routes router dot route
2896
02:10:11,520 --> 02:10:15,119
forward slash dot get and then that's
2897
02:10:15,119 --> 02:10:17,820
going to get us all properties we can
2898
02:10:17,820 --> 02:10:20,280
duplicate this a couple of times the
2899
02:10:20,280 --> 02:10:23,580
second one is going to go to column ID
2900
02:10:23,580 --> 02:10:27,659
we want to get property detail by that
2901
02:10:27,659 --> 02:10:30,540
specific ID the next one is going to be
2902
02:10:30,540 --> 02:10:32,760
just slash but it's going to be a post
2903
02:10:32,760 --> 02:10:35,760
route because we want to create a
2904
02:10:35,760 --> 02:10:36,719
property
2905
02:10:36,719 --> 02:10:39,780
then we're going to have again a column
2906
02:10:39,780 --> 02:10:43,020
ID but this time it's going to be a
2907
02:10:43,020 --> 02:10:45,719
patch route meaning we want to update a
2908
02:10:45,719 --> 02:10:48,300
property or patch it up and finally
2909
02:10:48,300 --> 02:10:50,760
we're going to have again a column ID
2910
02:10:50,760 --> 02:10:54,119
but this time it is going to be a delete
2911
02:10:54,119 --> 02:10:56,699
so we can call a delete property
2912
02:10:56,699 --> 02:10:59,960
controller finally we can export
2913
02:10:59,960 --> 02:11:03,900
default router once again I hope this
2914
02:11:03,900 --> 02:11:06,360
makes sense imagine if we had all the
2915
02:11:06,360 --> 02:11:09,000
controllers in one file mixed property
2916
02:11:09,000 --> 02:11:11,099
users and then all the routes in one
2917
02:11:11,099 --> 02:11:13,320
file mixed that would just be a mess
2918
02:11:13,320 --> 02:11:16,320
this way we can know which routes we
2919
02:11:16,320 --> 02:11:18,119
have that correspond with specific
2920
02:11:18,119 --> 02:11:20,400
resources and refine has done a
2921
02:11:20,400 --> 02:11:22,080
wonderful job with this because every
2922
02:11:22,080 --> 02:11:24,900
single resource is listed right here we
2923
02:11:24,900 --> 02:11:27,119
have properties which is great with that
2924
02:11:27,119 --> 02:11:29,400
said we can go back to the index.js of
2925
02:11:29,400 --> 02:11:31,679
the backend and we can import those
2926
02:11:31,679 --> 02:11:35,340
routes so at the top right below are
2927
02:11:35,340 --> 02:11:38,699
import connectdb we can import user
2928
02:11:38,699 --> 02:11:42,300
router coming from dot slash routes
2929
02:11:42,300 --> 02:11:46,199
forward slash user Dot routes.js
2930
02:11:46,199 --> 02:11:50,099
and we can also import property router
2931
02:11:50,099 --> 02:11:53,699
coming from dot slash routes forward
2932
02:11:53,699 --> 02:11:58,560
slash property dot routes dot Js
2933
02:11:58,560 --> 02:12:00,960
and now we can make use of them by
2934
02:12:00,960 --> 02:12:03,119
calling middleware so that's going to be
2935
02:12:03,119 --> 02:12:04,560
app.use
2936
02:12:04,560 --> 02:12:08,099
forward slash API four slash V1 forward
2937
02:12:08,099 --> 02:12:11,460
slash users and then we attach a user
2938
02:12:11,460 --> 02:12:15,239
router one more time app.use forward
2939
02:12:15,239 --> 02:12:18,659
slash API forward slash V1 forward slash
2940
02:12:18,659 --> 02:12:20,760
properties and then we pass in the
2941
02:12:20,760 --> 02:12:23,639
property router now all of the routes
2942
02:12:23,639 --> 02:12:26,880
are hooked up and we are good to go but
2943
02:12:26,880 --> 02:12:29,460
whenever we call any one of these routes
2944
02:12:29,460 --> 02:12:33,199
be that API V1 properties and then maybe
2945
02:12:33,199 --> 02:12:36,000
a route to get properties to get
2946
02:12:36,000 --> 02:12:37,860
property details to create a property
2947
02:12:37,860 --> 02:12:39,900
it's all going to be good they're
2948
02:12:39,900 --> 02:12:42,599
actually going to get cold but if we go
2949
02:12:42,599 --> 02:12:45,360
into controllers of those properties you
2950
02:12:45,360 --> 02:12:47,040
can see that they're not going to do
2951
02:12:47,040 --> 02:12:49,980
anything so now is our time to actually
2952
02:12:49,980 --> 02:12:52,320
implement the logic of creating
2953
02:12:52,320 --> 02:12:54,480
instances and documents in the database
2954
02:12:54,480 --> 02:12:57,420
on creating users creating properties
2955
02:12:57,420 --> 02:13:00,239
and linking it all together so the fun
2956
02:13:00,239 --> 02:13:04,020
part begins now even though we were
2957
02:13:04,020 --> 02:13:06,540
about to create the create property
2958
02:13:06,540 --> 02:13:09,480
functionality there is one thing we have
2959
02:13:09,480 --> 02:13:12,420
to do before if you think about it right
2960
02:13:12,420 --> 02:13:15,659
now once we log in that's it we just log
2961
02:13:15,659 --> 02:13:18,420
in but we don't officially create an
2962
02:13:18,420 --> 02:13:21,480
account in our database so if we were to
2963
02:13:21,480 --> 02:13:23,940
proceed with create a property now we
2964
02:13:23,940 --> 02:13:26,040
wouldn't be able to link it with a user
2965
02:13:26,040 --> 02:13:28,260
in our database because it doesn't exist
2966
02:13:28,260 --> 02:13:30,599
it just exists right here in the browser
2967
02:13:30,599 --> 02:13:34,020
so what we have to do is now that we
2968
02:13:34,020 --> 02:13:36,360
have the backend controllers we can hook
2969
02:13:36,360 --> 02:13:38,579
up the client side to our server to
2970
02:13:38,579 --> 02:13:41,099
create a user in the database and then
2971
02:13:41,099 --> 02:13:42,900
that user will be able to create a
2972
02:13:42,900 --> 02:13:45,540
property so hopefully that order makes
2973
02:13:45,540 --> 02:13:48,840
sense and to implement our user creation
2974
02:13:48,840 --> 02:13:52,199
we're going to go to app.tsx and then
2975
02:13:52,199 --> 02:13:54,239
we're going to scroll a bit up and you
2976
02:13:54,239 --> 02:13:56,460
can see right here that we have the
2977
02:13:56,460 --> 02:14:00,119
login functionality right now yes we are
2978
02:14:00,119 --> 02:14:02,699
logging Us in and we're setting the user
2979
02:14:02,699 --> 02:14:06,060
login to local storage but we're not
2980
02:14:06,060 --> 02:14:07,860
doing anything with the database and
2981
02:14:07,860 --> 02:14:10,500
that's exactly what we will do right now
2982
02:14:10,500 --> 02:14:13,980
so once we get this profile object then
2983
02:14:13,980 --> 02:14:16,560
we want to save user
2984
02:14:16,560 --> 02:14:20,579
to mongodb great so let's get started
2985
02:14:20,579 --> 02:14:23,340
with that right away to save our user to
2986
02:14:23,340 --> 02:14:25,260
the database we first have to of course
2987
02:14:25,260 --> 02:14:27,780
check if there is a profile object
2988
02:14:27,780 --> 02:14:30,599
meaning if a user is logged in and then
2989
02:14:30,599 --> 02:14:33,119
if that is the case we can say const
2990
02:14:33,119 --> 02:14:36,000
response is equal to a weight
2991
02:14:36,000 --> 02:14:39,480
Fetch and then we need to trigger our
2992
02:14:39,480 --> 02:14:43,500
API by saying HTTP colon forward slash
2993
02:14:43,500 --> 02:14:47,460
forward slash localhost 8080 forward
2994
02:14:47,460 --> 02:14:51,599
slash API forward slash V1 forward slash
2995
02:14:51,599 --> 02:14:52,920
users
2996
02:14:52,920 --> 02:14:55,980
there we want to create a second
2997
02:14:55,980 --> 02:14:58,199
parameter which is going to be an object
2998
02:14:58,199 --> 02:14:59,760
with options
2999
02:14:59,760 --> 02:15:02,280
in those options we need to provide a
3000
02:15:02,280 --> 02:15:03,960
method which is going to be a post
3001
02:15:03,960 --> 02:15:06,420
method because we want to create a user
3002
02:15:06,420 --> 02:15:09,659
we also want to provide headers which in
3003
02:15:09,659 --> 02:15:11,940
this case will be content type
3004
02:15:11,940 --> 02:15:14,579
application Json and make sure to type
3005
02:15:14,579 --> 02:15:16,920
it exactly like it is typed here content
3006
02:15:16,920 --> 02:15:20,219
Capital C type capital T with a dash in
3007
02:15:20,219 --> 02:15:22,760
between and then application Json
3008
02:15:22,760 --> 02:15:27,360
finally we can pass our body our body is
3009
02:15:27,360 --> 02:15:31,139
going to be Json Dot stringify and then
3010
02:15:31,139 --> 02:15:33,659
we're going to pass in an object we want
3011
02:15:33,659 --> 02:15:37,079
to pass a name equal to profile obj.name
3012
02:15:37,079 --> 02:15:39,360
we want to pass an email equal to
3013
02:15:39,360 --> 02:15:42,840
profile obj dot email and finally we
3014
02:15:42,840 --> 02:15:45,060
want to pass an avatar equal to profile
3015
02:15:45,060 --> 02:15:48,719
obj dot picture and with that said we're
3016
02:15:48,719 --> 02:15:51,000
passing everything we need but you can
3017
02:15:51,000 --> 02:15:53,340
notice that we cannot use in a weight
3018
02:15:53,340 --> 02:15:55,560
right here because we're not in an async
3019
02:15:55,560 --> 02:15:58,320
function so simply make the login an
3020
02:15:58,320 --> 02:16:01,079
async function Gray rate
3021
02:16:01,079 --> 02:16:03,300
and then once we get the response back
3022
02:16:03,300 --> 02:16:06,599
from the database we can do that right
3023
02:16:06,599 --> 02:16:09,360
here below closing it we can see Khan's
3024
02:16:09,360 --> 02:16:11,780
data is equal to a weight
3025
02:16:11,780 --> 02:16:14,340
response.json this is going to contain
3026
02:16:14,340 --> 02:16:16,800
the data of our actual user in the
3027
02:16:16,800 --> 02:16:17,760
database
3028
02:16:17,760 --> 02:16:20,219
and then we can do what we're doing here
3029
02:16:20,219 --> 02:16:22,500
we can remove this if by checking for
3030
02:16:22,500 --> 02:16:24,300
the profile object because we already
3031
02:16:24,300 --> 02:16:26,940
have that and then we can bring this a
3032
02:16:26,940 --> 02:16:30,000
bit above inside of this if right here
3033
02:16:30,000 --> 02:16:32,700
so we're getting the data and then we
3034
02:16:32,700 --> 02:16:36,620
want to set local storage user to be
3035
02:16:36,620 --> 02:16:40,859
json.stringify dot dot profile obj and
3036
02:16:40,859 --> 02:16:43,260
we also want to pass the Avatar and
3037
02:16:43,260 --> 02:16:46,500
finally we want to pass the user ID to
3038
02:16:46,500 --> 02:16:49,740
data dot underscore ID and that's all
3039
02:16:49,740 --> 02:16:52,138
that we need to do but this is only
3040
02:16:52,138 --> 02:16:54,840
going to happen if the response is 200
3041
02:16:54,840 --> 02:16:58,138
so we can say if response that status is
3042
02:16:58,138 --> 02:17:01,740
equal to 200 then we can call this
3043
02:17:01,740 --> 02:17:03,240
entire block of code
3044
02:17:03,240 --> 02:17:06,478
and if it is not meaning else we can
3045
02:17:06,478 --> 02:17:09,240
simply say return promise dot reject
3046
02:17:09,240 --> 02:17:10,740
like this
3047
02:17:10,740 --> 02:17:12,718
and then we're closing this if statement
3048
02:17:12,718 --> 02:17:15,599
and finally we're going to set our user
3049
02:17:15,599 --> 02:17:18,439
to the local storage and return
3050
02:17:18,439 --> 02:17:21,179
promise.resolve so what we have done is
3051
02:17:21,179 --> 02:17:23,280
we're not only storing the user in local
3052
02:17:23,280 --> 02:17:25,859
storage but we're also creating it in
3053
02:17:25,859 --> 02:17:28,620
the database hopefully that makes sense
3054
02:17:28,620 --> 02:17:32,218
and while we're here why stop there why
3055
02:17:32,218 --> 02:17:35,160
not also look into the logout function
3056
02:17:35,160 --> 02:17:37,679
inside of the logout we won't have to do
3057
02:17:37,679 --> 02:17:40,260
a lot because we are not going to
3058
02:17:40,260 --> 02:17:42,240
actually delete a user once we log it
3059
02:17:42,240 --> 02:17:45,299
out so this one is already done
3060
02:17:45,299 --> 02:17:47,280
when it comes to the check auth and all
3061
02:17:47,280 --> 02:17:50,700
of that that is already all done for us
3062
02:17:50,700 --> 02:17:53,760
by refine so with that said we
3063
02:17:53,760 --> 02:17:55,920
successfully have the ability to create
3064
02:17:55,920 --> 02:17:57,718
the users in the database
3065
02:17:57,718 --> 02:18:00,780
now to show you I can log out
3066
02:18:00,780 --> 02:18:03,898
and before logging in again we need to
3067
02:18:03,898 --> 02:18:06,240
go back to the back end and we need to
3068
02:18:06,240 --> 02:18:09,359
create our create user controller so we
3069
02:18:09,359 --> 02:18:13,099
can go to server controllers
3070
02:18:13,099 --> 02:18:14,939
user.controller.js and we have to
3071
02:18:14,939 --> 02:18:17,939
implement the create user function to do
3072
02:18:17,939 --> 02:18:20,879
that we can expand it a bit
3073
02:18:20,879 --> 02:18:24,478
we can also get all the data we just
3074
02:18:24,478 --> 02:18:26,580
sent from the front end right here that
3075
02:18:26,580 --> 02:18:30,000
is name email and Avatar and we're going
3076
02:18:30,000 --> 02:18:32,040
to extract that or destructure that from
3077
02:18:32,040 --> 02:18:35,218
reg.body then we need to check if a user
3078
02:18:35,218 --> 02:18:37,679
exists in the database by saying const
3079
02:18:37,679 --> 02:18:41,340
user exists is equal to a weight user
3080
02:18:41,340 --> 02:18:44,580
dot find one and then we want to find it
3081
02:18:44,580 --> 02:18:46,620
by email
3082
02:18:46,620 --> 02:18:50,280
if a user exists then we can simply
3083
02:18:50,280 --> 02:18:54,660
return res dot status of 200 and then
3084
02:18:54,660 --> 02:18:57,359
we're going to return a Json of user
3085
02:18:57,359 --> 02:18:59,760
exists this is going to contain the
3086
02:18:59,760 --> 02:19:02,280
entire data for our user
3087
02:19:02,280 --> 02:19:05,040
else if a user doesn't exist we can say
3088
02:19:05,040 --> 02:19:08,398
const new user is equal to a weight
3089
02:19:08,398 --> 02:19:11,398
user dot create we're going to pass in
3090
02:19:11,398 --> 02:19:15,299
an object containing a name an email and
3091
02:19:15,299 --> 02:19:19,040
an avatar and finally we can also return
3092
02:19:19,040 --> 02:19:24,718
res dot status 200 dot Json
3093
02:19:24,718 --> 02:19:28,080
where we want to return a new user like
3094
02:19:28,080 --> 02:19:29,099
this
3095
02:19:29,099 --> 02:19:32,218
great and we can wrap all of this in a
3096
02:19:32,218 --> 02:19:34,558
try and catch block because sometimes
3097
02:19:34,558 --> 02:19:37,019
something might not go right so we can
3098
02:19:37,019 --> 02:19:39,780
wrap it in a try and catch block but all
3099
02:19:39,780 --> 02:19:43,620
the code we had so far inside of the try
3100
02:19:43,620 --> 02:19:46,859
like so and then in the catch we can
3101
02:19:46,859 --> 02:19:49,500
return an error that can be res that
3102
02:19:49,500 --> 02:19:51,000
status
3103
02:19:51,000 --> 02:19:55,920
of 500 dot Json where the message is
3104
02:19:55,920 --> 02:19:59,600
equal to let's do error Dot message
3105
02:19:59,600 --> 02:20:03,060
great and with that said we have create
3106
02:20:03,060 --> 02:20:06,120
user functionality so to show you how it
3107
02:20:06,120 --> 02:20:09,180
works we can now sign in which would not
3108
02:20:09,180 --> 02:20:11,220
only sign us in locally in the browser
3109
02:20:11,220 --> 02:20:14,220
but also within the database so let's
3110
02:20:14,220 --> 02:20:16,200
sign in you're going to get a Google
3111
02:20:16,200 --> 02:20:19,380
sign-in form like this
3112
02:20:19,380 --> 02:20:22,740
and we are in but what matters the most
3113
02:20:22,740 --> 02:20:26,040
is to go to database to go to your
3114
02:20:26,040 --> 02:20:27,600
cluster 0
3115
02:20:27,600 --> 02:20:31,320
and then to go to collections
3116
02:20:31,320 --> 02:20:33,960
inside of collections we should be able
3117
02:20:33,960 --> 02:20:35,939
to see our users
3118
02:20:35,939 --> 02:20:38,520
but right now we cannot seem to see them
3119
02:20:38,520 --> 02:20:42,060
so let's go to the console and we can
3120
02:20:42,060 --> 02:20:46,319
see an error it says right here
3121
02:20:46,319 --> 02:20:49,200
event emitter memory League detected 11
3122
02:20:49,200 --> 02:20:51,899
exit listeners added to bus interesting
3123
02:20:51,899 --> 02:20:55,260
so it seems like our app crashed let me
3124
02:20:55,260 --> 02:20:58,200
try to reload it and let me try to rerun
3125
02:20:58,200 --> 02:21:00,420
it again npm start
3126
02:21:00,420 --> 02:21:03,420
okay so this error is not related to the
3127
02:21:03,420 --> 02:21:05,939
login it happens immediately once we do
3128
02:21:05,939 --> 02:21:08,899
this and it seems to be in the
3129
02:21:08,899 --> 02:21:13,020
user.routs.js so we simply wrongly
3130
02:21:13,020 --> 02:21:14,939
imported it at least it looks like so
3131
02:21:14,939 --> 02:21:17,760
let's go to server index.js
3132
02:21:17,760 --> 02:21:19,680
that is right here
3133
02:21:19,680 --> 02:21:20,939
and
3134
02:21:20,939 --> 02:21:23,700
it's routes here what I told you I made
3135
02:21:23,700 --> 02:21:25,500
a mistake that I was trying to warn you
3136
02:21:25,500 --> 02:21:28,500
about you have to add a DOT JS extension
3137
02:21:28,500 --> 02:21:31,560
at the end so if we fix this and rerun
3138
02:21:31,560 --> 02:21:33,780
it one more time
3139
02:21:33,780 --> 02:21:36,540
it crashes again okay let's see cannot
3140
02:21:36,540 --> 02:21:39,600
find controller properly looks like I
3141
02:21:39,600 --> 02:21:41,939
misspelled that again so that's going to
3142
02:21:41,939 --> 02:21:43,979
be in the routes
3143
02:21:43,979 --> 02:21:46,500
file let's go here
3144
02:21:46,500 --> 02:21:50,939
and we want to do property okay so again
3145
02:21:50,939 --> 02:21:52,800
I want to leave this errors in to show
3146
02:21:52,800 --> 02:21:55,200
you that typos happen and we are back
3147
02:21:55,200 --> 02:21:58,200
and running now we can go back to our
3148
02:21:58,200 --> 02:22:02,040
application we can log out and we can
3149
02:22:02,040 --> 02:22:04,200
sign in one more time which should
3150
02:22:04,200 --> 02:22:06,600
create a user in our database
3151
02:22:06,600 --> 02:22:09,780
there's the form right here I'm gonna
3152
02:22:09,780 --> 02:22:12,060
sign in
3153
02:22:12,060 --> 02:22:14,880
and we are in nothing happened on the
3154
02:22:14,880 --> 02:22:16,800
back end which should make me assume
3155
02:22:16,800 --> 02:22:21,180
that now if we go right here and refresh
3156
02:22:21,180 --> 02:22:25,080
we can see properties zero but users
3157
02:22:25,080 --> 02:22:28,560
is still zero which means that our user
3158
02:22:28,560 --> 02:22:31,439
wasn't created so let's see what it was
3159
02:22:31,439 --> 02:22:33,899
about now we're gonna recheck everything
3160
02:22:33,899 --> 02:22:37,200
so let's start from scratch we have a
3161
02:22:37,200 --> 02:22:41,100
user route to create a user which is a
3162
02:22:41,100 --> 02:22:44,520
post route on forward slash and we can
3163
02:22:44,520 --> 02:22:49,020
look that right here API V1 users there
3164
02:22:49,020 --> 02:22:51,720
we are calling this specific post route
3165
02:22:51,720 --> 02:22:56,060
to create a user then that right here
3166
02:22:56,060 --> 02:22:59,819
executes and we should send back a
3167
02:22:59,819 --> 02:23:03,420
status of 200 so maybe going back to our
3168
02:23:03,420 --> 02:23:05,939
app and opening a console
3169
02:23:05,939 --> 02:23:08,160
right here we should be able to see what
3170
02:23:08,160 --> 02:23:08,939
happened
3171
02:23:08,939 --> 02:23:11,100
so we have a couple of Errors right here
3172
02:23:11,100 --> 02:23:14,040
but what we can do is go to the network
3173
02:23:14,040 --> 02:23:17,340
Tab and just try to repeat that same
3174
02:23:17,340 --> 02:23:19,200
procedure one more time to see what
3175
02:23:19,200 --> 02:23:20,160
happens
3176
02:23:20,160 --> 02:23:23,760
so let's go here let's reload
3177
02:23:23,760 --> 02:23:25,740
oh of course it's not going to work our
3178
02:23:25,740 --> 02:23:28,200
app is actually not running believe it
3179
02:23:28,200 --> 02:23:30,240
or not I closed it when I opened up our
3180
02:23:30,240 --> 02:23:33,240
backend application but refine is so
3181
02:23:33,240 --> 02:23:36,240
good that apparently it even has some
3182
02:23:36,240 --> 02:23:38,760
offline functionalities so we were able
3183
02:23:38,760 --> 02:23:40,500
to go through everything even when we
3184
02:23:40,500 --> 02:23:42,899
were offline that's cool so what we're
3185
02:23:42,899 --> 02:23:44,640
going to do is I'm going to start a new
3186
02:23:44,640 --> 02:23:47,399
terminal put it at the start and we're
3187
02:23:47,399 --> 02:23:49,680
going to see D dot dot and then we can
3188
02:23:49,680 --> 02:23:52,020
run it with npm run Dev
3189
02:23:52,020 --> 02:23:54,840
okay this was funny our client side was
3190
02:23:54,840 --> 02:23:56,939
offline so it couldn't actually make any
3191
02:23:56,939 --> 02:23:59,220
requests to the backhand but now we're
3192
02:23:59,220 --> 02:24:01,200
gonna be back and running our server is
3193
02:24:01,200 --> 02:24:03,180
running our client will be running soon
3194
02:24:03,180 --> 02:24:05,700
and then we'll be able to try it out one
3195
02:24:05,700 --> 02:24:08,280
more time to create a user in a database
3196
02:24:08,280 --> 02:24:10,680
I'm going to close all of the currently
3197
02:24:10,680 --> 02:24:14,640
open tabs besides our localhost and
3198
02:24:14,640 --> 02:24:18,240
besides our mongodb Atlas database
3199
02:24:18,240 --> 02:24:20,340
and there we go we're back right here
3200
02:24:20,340 --> 02:24:22,200
I'm going to open up the terminal and
3201
02:24:22,200 --> 02:24:24,300
I'm going to click sign in with Google
3202
02:24:24,300 --> 02:24:26,819
that just opened up this window and I'm
3203
02:24:26,819 --> 02:24:29,580
gonna sign in
3204
02:24:29,580 --> 02:24:33,060
there we go if we go back right here and
3205
02:24:33,060 --> 02:24:34,560
refresh
3206
02:24:34,560 --> 02:24:37,380
we can see our user with a name email
3207
02:24:37,380 --> 02:24:40,200
Avatar and all properties which is
3208
02:24:40,200 --> 02:24:43,620
currently an empty array wonderful this
3209
02:24:43,620 --> 02:24:46,260
works now that we have the user we are
3210
02:24:46,260 --> 02:24:49,740
ready for that user to go right here if
3211
02:24:49,740 --> 02:24:52,439
I zoom this out a bit go to properties
3212
02:24:52,439 --> 02:24:55,800
go to add property and now we are ready
3213
02:24:55,800 --> 02:24:58,680
to add the property in this user's
3214
02:24:58,680 --> 02:25:02,040
account so to do that we can go all the
3215
02:25:02,040 --> 02:25:03,660
way to
3216
02:25:03,660 --> 02:25:05,340
the back end part
3217
02:25:05,340 --> 02:25:08,760
controllers property controller and then
3218
02:25:08,760 --> 02:25:11,399
create property this is going to be the
3219
02:25:11,399 --> 02:25:13,979
next controller we'll focus on creating
3220
02:25:13,979 --> 02:25:17,160
a property will be a lot like creating a
3221
02:25:17,160 --> 02:25:20,220
user we first have to destructure the
3222
02:25:20,220 --> 02:25:21,660
properties we're sending from the front
3223
02:25:21,660 --> 02:25:25,520
end and these are the title description
3224
02:25:25,520 --> 02:25:28,979
we're gonna also have a property type
3225
02:25:28,979 --> 02:25:31,920
right we're going to have a location a
3226
02:25:31,920 --> 02:25:35,760
price a photo and an email and all of
3227
02:25:35,760 --> 02:25:39,359
that is equal to rec.body that's how the
3228
02:25:39,359 --> 02:25:41,520
front end and the back end speak
3229
02:25:41,520 --> 02:25:43,680
then we're going to do something really
3230
02:25:43,680 --> 02:25:47,100
interesting we're going to start a new
3231
02:25:47,100 --> 02:25:48,420
session
3232
02:25:48,420 --> 02:25:52,620
now what is a session con session is
3233
02:25:52,620 --> 02:25:55,859
equal to a weight Mongoose dot start
3234
02:25:55,859 --> 02:25:59,300
session Mongoose has special sessions
3235
02:25:59,300 --> 02:26:02,760
and these sessions ensure that what
3236
02:26:02,760 --> 02:26:05,399
happens in this create property function
3237
02:26:05,399 --> 02:26:09,600
is atomic meaning the entire creation of
3238
02:26:09,600 --> 02:26:12,180
a property is going to be considered an
3239
02:26:12,180 --> 02:26:14,760
atomic Transaction what does it mean it
3240
02:26:14,760 --> 02:26:17,700
can either work or it cannot work but we
3241
02:26:17,700 --> 02:26:19,020
cannot get stuck somewhere in between
3242
02:26:19,020 --> 02:26:22,260
and this is what helps to ensure that so
3243
02:26:22,260 --> 02:26:24,359
once we start the session we have to
3244
02:26:24,359 --> 02:26:28,140
also session dot start transaction
3245
02:26:28,140 --> 02:26:30,780
and again this ensures that we go
3246
02:26:30,780 --> 02:26:32,939
through all the way now that we have
3247
02:26:32,939 --> 02:26:34,620
that put in place we first have to get
3248
02:26:34,620 --> 02:26:37,319
the user by email by saying const user
3249
02:26:37,319 --> 02:26:41,220
is equal to a weight user dot find one
3250
02:26:41,220 --> 02:26:43,500
by email
3251
02:26:43,500 --> 02:26:47,160
and then we also can do that session
3252
02:26:47,160 --> 02:26:49,680
and pass in the session we can make a
3253
02:26:49,680 --> 02:26:53,520
check if no user then we can throw new
3254
02:26:53,520 --> 02:26:56,760
error user not found
3255
02:26:56,760 --> 02:26:59,880
if there is a user we have to get their
3256
02:26:59,880 --> 02:27:02,939
photo and upload it to cloudinery so we
3257
02:27:02,939 --> 02:27:06,960
can say const photo URL is equal to and
3258
02:27:06,960 --> 02:27:09,600
now we're diving into the logic of using
3259
02:27:09,600 --> 02:27:12,960
cloudinery so we of course first have to
3260
02:27:12,960 --> 02:27:15,359
set it up so let me show you how to set
3261
02:27:15,359 --> 02:27:17,040
up cloudinery
3262
02:27:17,040 --> 02:27:20,819
first go to cloudinary.com the most
3263
02:27:20,819 --> 02:27:23,700
powerful media API and products and then
3264
02:27:23,700 --> 02:27:26,340
click get started
3265
02:27:26,340 --> 02:27:28,800
there you can sign up with Google or
3266
02:27:28,800 --> 02:27:30,060
with GitHub
3267
02:27:30,060 --> 02:27:32,220
and once you sign up you should see a
3268
02:27:32,220 --> 02:27:34,260
page that looks like this a dashboard
3269
02:27:34,260 --> 02:27:37,140
there we have a cloud name an API key
3270
02:27:37,140 --> 02:27:40,260
and an API secret we also have an API
3271
02:27:40,260 --> 02:27:42,840
environment variable all of these are
3272
02:27:42,840 --> 02:27:45,300
right here so let me show you how to
3273
02:27:45,300 --> 02:27:47,880
collect these and save them we're going
3274
02:27:47,880 --> 02:27:50,040
to need a cloudinary cloud name so you
3275
02:27:50,040 --> 02:27:53,340
can copy it go to our DOT EnV and right
3276
02:27:53,340 --> 02:27:55,439
here let's add cloudinery
3277
02:27:55,439 --> 02:27:58,140
underscore Cloud underscore name is
3278
02:27:58,140 --> 02:28:01,800
equal to this key right here we can copy
3279
02:28:01,800 --> 02:28:03,960
the API key as well that's going to be
3280
02:28:03,960 --> 02:28:07,380
cloudinary underscore API underscore key
3281
02:28:07,380 --> 02:28:10,380
equal to this and finally we're going to
3282
02:28:10,380 --> 02:28:12,359
have a cloudinary
3283
02:28:12,359 --> 02:28:16,200
underscore API underscore secret and now
3284
02:28:16,200 --> 02:28:19,680
we can simply get the secret as well
3285
02:28:19,680 --> 02:28:21,960
great so now we have all of these
3286
02:28:21,960 --> 02:28:24,240
variables and we can utilize them when
3287
02:28:24,240 --> 02:28:26,160
setting up our new instance of
3288
02:28:26,160 --> 02:28:28,979
cloudinery that's going to be at the top
3289
02:28:28,979 --> 02:28:31,979
of our property controller
3290
02:28:31,979 --> 02:28:36,600
so right here at the top we can import
3291
02:28:36,600 --> 02:28:38,100
everything
3292
02:28:38,100 --> 02:28:40,439
as dot EnV
3293
02:28:40,439 --> 02:28:42,899
IR from dot EnV which is going to allow
3294
02:28:42,899 --> 02:28:45,960
us to use environment variables and we
3295
02:28:45,960 --> 02:28:48,479
can also import V2
3296
02:28:48,479 --> 02:28:51,000
as cloudinary
3297
02:28:51,000 --> 02:28:54,720
coming from cloudinary then we can set
3298
02:28:54,720 --> 02:28:57,720
up our DOT env.config
3299
02:28:57,720 --> 02:28:59,640
call it as a function
3300
02:28:59,640 --> 02:29:01,500
and below that we can call
3301
02:29:01,500 --> 02:29:04,080
cloudinery.config
3302
02:29:04,080 --> 02:29:06,479
and we can pass in all the necessary
3303
02:29:06,479 --> 02:29:09,680
Keys such as Cloud name equal to
3304
02:29:09,680 --> 02:29:13,200
process.env dot cloudinery underscore
3305
02:29:13,200 --> 02:29:15,060
Cloud underscore name
3306
02:29:15,060 --> 02:29:17,040
we also need to provide the API
3307
02:29:17,040 --> 02:29:20,000
underscore key equal to
3308
02:29:20,000 --> 02:29:22,140
process.env.cloudinary underscore API
3309
02:29:22,140 --> 02:29:24,479
underscore key and we also need to
3310
02:29:24,479 --> 02:29:28,100
provide an API secret equal to
3311
02:29:28,100 --> 02:29:30,120
process.env.cloudinery underscore API
3312
02:29:30,120 --> 02:29:33,180
underscore secret and with that we have
3313
02:29:33,180 --> 02:29:36,479
everything we need to move down and get
3314
02:29:36,479 --> 02:29:39,300
that photo URL of the photo we just
3315
02:29:39,300 --> 02:29:42,000
uploaded to cloudinery
3316
02:29:42,000 --> 02:29:45,540
and to do that you simply need to await
3317
02:29:45,540 --> 02:29:50,520
cloudinary dot uploader dot upload and
3318
02:29:50,520 --> 02:29:53,399
then you simply pass a photo it is as
3319
02:29:53,399 --> 02:29:56,220
easy as it can be and finally we have to
3320
02:29:56,220 --> 02:29:58,500
create a new property by saying const
3321
02:29:58,500 --> 02:30:00,180
new property
3322
02:30:00,180 --> 02:30:03,660
is equal to a weight property dot create
3323
02:30:03,660 --> 02:30:06,000
remember we're referring to the property
3324
02:30:06,000 --> 02:30:06,899
model
3325
02:30:06,899 --> 02:30:09,840
and then we can pass an object in that's
3326
02:30:09,840 --> 02:30:13,020
going to have a title a description
3327
02:30:13,020 --> 02:30:17,640
a property type a location a price it's
3328
02:30:17,640 --> 02:30:19,920
going to have a photo as well which is
3329
02:30:19,920 --> 02:30:23,460
going to be photo URL dot URL and
3330
02:30:23,460 --> 02:30:25,319
finally it's going to have a Creator
3331
02:30:25,319 --> 02:30:27,600
which is going to be a user dot
3332
02:30:27,600 --> 02:30:30,420
underscore ID this is where we're making
3333
02:30:30,420 --> 02:30:32,760
a connection between a user and a
3334
02:30:32,760 --> 02:30:33,899
property
3335
02:30:33,899 --> 02:30:37,500
finally we also need to update the user
3336
02:30:37,500 --> 02:30:41,880
so we can say user dot all properties
3337
02:30:41,880 --> 02:30:44,700
dot push and we want to push the new
3338
02:30:44,700 --> 02:30:48,000
property dot underscore ID to make sure
3339
02:30:48,000 --> 02:30:50,040
that they are connected
3340
02:30:50,040 --> 02:30:53,060
finally we want to await
3341
02:30:53,060 --> 02:30:57,000
user.save to save this new session that
3342
02:30:57,000 --> 02:31:00,260
will be opened and then we want to await
3343
02:31:00,260 --> 02:31:03,840
session dot commit transaction meaning
3344
02:31:03,840 --> 02:31:05,819
we are done with this transaction and we
3345
02:31:05,819 --> 02:31:07,620
are ready to move on
3346
02:31:07,620 --> 02:31:11,240
finally we can rest that status of 200
3347
02:31:11,240 --> 02:31:13,439
dot Json
3348
02:31:13,439 --> 02:31:15,300
and we can send a message property
3349
02:31:15,300 --> 02:31:17,760
created successfully
3350
02:31:17,760 --> 02:31:20,520
what we can do as well is wrap this
3351
02:31:20,520 --> 02:31:23,399
entire thing with a try and catch block
3352
02:31:23,399 --> 02:31:26,580
so at the start we can open up a new try
3353
02:31:26,580 --> 02:31:29,399
and catch block take this entire code
3354
02:31:29,399 --> 02:31:35,100
and put it inside of the try right here
3355
02:31:35,100 --> 02:31:38,640
and then we can finally do the same
3356
02:31:38,640 --> 02:31:41,100
thing for the catch by same thing I mean
3357
02:31:41,100 --> 02:31:43,020
just returning an error press that
3358
02:31:43,020 --> 02:31:46,859
status all 500 dot Json
3359
02:31:46,859 --> 02:31:49,260
and then we can simply pass the message
3360
02:31:49,260 --> 02:31:53,819
as error.message and that is it we
3361
02:31:53,819 --> 02:31:56,460
successfully created the controller or
3362
02:31:56,460 --> 02:32:00,000
the logic for creating a property now
3363
02:32:00,000 --> 02:32:03,660
going back to client source
3364
02:32:03,660 --> 02:32:07,859
pages and then create property we have
3365
02:32:07,859 --> 02:32:09,840
our on finish to which we're passing
3366
02:32:09,840 --> 02:32:13,260
data and then refine by refine I mean
3367
02:32:13,260 --> 02:32:15,660
the refines use form and handle submit
3368
02:32:15,660 --> 02:32:17,700
functions are going to do the rest of
3369
02:32:17,700 --> 02:32:20,700
the work for us so let's go ahead and
3370
02:32:20,700 --> 02:32:22,740
give it a shot I'm going to collapse
3371
02:32:22,740 --> 02:32:25,080
this right here and let's try to create
3372
02:32:25,080 --> 02:32:27,720
a new property let's give it a name of
3373
02:32:27,720 --> 02:32:31,020
something like Star Sun Hotel and
3374
02:32:31,020 --> 02:32:33,780
apartment let's write something of lorem
3375
02:32:33,780 --> 02:32:37,260
ipsum dot dot dot let's make it an
3376
02:32:37,260 --> 02:32:40,260
apartment and give it a price of 500.
3377
02:32:40,260 --> 02:32:42,359
and let's enter location something like
3378
02:32:42,359 --> 02:32:45,080
San Francisco
3379
02:32:45,300 --> 02:32:47,939
finally let's upload a photo and by the
3380
02:32:47,939 --> 02:32:49,439
way if you want to get some great photos
3381
02:32:49,439 --> 02:32:52,080
you can go to the figma design go to
3382
02:32:52,080 --> 02:32:56,340
property and then right here you can get
3383
02:32:56,340 --> 02:32:58,920
any one of these images by simply
3384
02:32:58,920 --> 02:33:00,899
selecting that image clicking it a few
3385
02:33:00,899 --> 02:33:01,920
times
3386
02:33:01,920 --> 02:33:03,960
and then going to export and then you
3387
02:33:03,960 --> 02:33:07,200
can do 3x to have a better quality with
3388
02:33:07,200 --> 02:33:09,240
that said
3389
02:33:09,240 --> 02:33:11,819
I'm going to go with this one right here
3390
02:33:11,819 --> 02:33:16,260
add an m to lorem ipsum and submit
3391
02:33:16,260 --> 02:33:18,540
now as you can see nothing really
3392
02:33:18,540 --> 02:33:20,460
happened and I think I know the reason
3393
02:33:20,460 --> 02:33:24,240
why we inside of the form have a submit
3394
02:33:24,240 --> 02:33:25,979
button that's the thing that triggers
3395
02:33:25,979 --> 02:33:28,740
everything and that is our custom button
3396
02:33:28,740 --> 02:33:31,200
with a type of submit but if we dive
3397
02:33:31,200 --> 02:33:33,720
into that custom button you can notice
3398
02:33:33,720 --> 02:33:35,399
that we're never ever checking for the
3399
02:33:35,399 --> 02:33:37,620
type and this button is simply calling
3400
02:33:37,620 --> 02:33:40,380
the handle click so what we can do is we
3401
02:33:40,380 --> 02:33:43,380
can pass a type to this button and type
3402
02:33:43,380 --> 02:33:46,319
is going to be equal to if type is
3403
02:33:46,319 --> 02:33:48,780
triple equal to submit then we're going
3404
02:33:48,780 --> 02:33:52,020
to render submit like this so first we
3405
02:33:52,020 --> 02:33:54,359
have to do a check and then once we
3406
02:33:54,359 --> 02:33:56,819
check we can do submit or we can do
3407
02:33:56,819 --> 02:34:00,660
simply button great now the error is
3408
02:34:00,660 --> 02:34:02,880
gone and we can try resubmitting this
3409
02:34:02,880 --> 02:34:05,460
one more time before we do that let's
3410
02:34:05,460 --> 02:34:08,280
open up our Terminals and let's also
3411
02:34:08,280 --> 02:34:10,740
open up the console so we can see if
3412
02:34:10,740 --> 02:34:13,680
there are any errors if they appear so
3413
02:34:13,680 --> 02:34:16,020
right here I'm going to Simply close the
3414
02:34:16,020 --> 02:34:17,939
net Network and everything let's go
3415
02:34:17,939 --> 02:34:19,920
ahead and put this on the right side and
3416
02:34:19,920 --> 02:34:21,600
if we submit
3417
02:34:21,600 --> 02:34:25,800
we get a 404 and that 404 right here
3418
02:34:25,800 --> 02:34:27,660
says that we're trying to make a request
3419
02:34:27,660 --> 02:34:31,340
to some kind of a API fake rest
3420
02:34:31,340 --> 02:34:34,260
refine.dev properties but that's not
3421
02:34:34,260 --> 02:34:36,359
what we want to go for we have worked
3422
02:34:36,359 --> 02:34:40,020
hard on creating our own backend API so
3423
02:34:40,020 --> 02:34:42,840
there's a simple fix to that let's go to
3424
02:34:42,840 --> 02:34:44,000
our
3425
02:34:44,000 --> 02:34:47,060
app.tsx and then on line
3426
02:34:47,060 --> 02:34:50,819
129 you'll see this data provider inside
3427
02:34:50,819 --> 02:34:53,520
of the refine component there we have to
3428
02:34:53,520 --> 02:34:56,700
specify the root of our API so let's do
3429
02:34:56,700 --> 02:34:59,819
HTTP Colin forward slash forward slash
3430
02:34:59,819 --> 02:35:02,939
localhost 8080
3431
02:35:02,939 --> 02:35:07,620
forward slash API forward slash V1
3432
02:35:07,620 --> 02:35:10,319
let's save that and let's clear our
3433
02:35:10,319 --> 02:35:12,780
Network and let's resubmit it one more
3434
02:35:12,780 --> 02:35:14,960
time
3435
02:35:15,240 --> 02:35:18,359
and we got 200 successfully created
3436
02:35:18,359 --> 02:35:22,020
that's great now at this point we cannot
3437
02:35:22,020 --> 02:35:24,300
really see our properties because we
3438
02:35:24,300 --> 02:35:25,979
haven't yet created the cards for them
3439
02:35:25,979 --> 02:35:28,859
but as you can see property created
3440
02:35:28,859 --> 02:35:31,200
successfully we just have to create the
3441
02:35:31,200 --> 02:35:33,840
card to display that property so let's
3442
02:35:33,840 --> 02:35:36,120
collapse this right here
3443
02:35:36,120 --> 02:35:38,700
we're going to expand our code editor
3444
02:35:38,700 --> 02:35:40,979
just a bit right here and we're going to
3445
02:35:40,979 --> 02:35:43,020
close all of the currently open files
3446
02:35:43,020 --> 02:35:46,260
open the file explorer and go all the
3447
02:35:46,260 --> 02:35:47,760
way to client
3448
02:35:47,760 --> 02:35:49,620
source
3449
02:35:49,620 --> 02:35:51,000
pages
3450
02:35:51,000 --> 02:35:54,359
all properties and right here below our
3451
02:35:54,359 --> 02:35:56,520
custom button and the typography we have
3452
02:35:56,520 --> 02:35:59,040
to render or map over all of our
3453
02:35:59,040 --> 02:36:01,200
properties and then we can create a
3454
02:36:01,200 --> 02:36:03,960
property card so this is getting excited
3455
02:36:03,960 --> 02:36:06,359
with that said let's proceed with
3456
02:36:06,359 --> 02:36:08,640
fetching all of the posts and displaying
3457
02:36:08,640 --> 02:36:11,640
them in the all properties section below
3458
02:36:11,640 --> 02:36:14,220
the stack containing our custom button
3459
02:36:14,220 --> 02:36:17,460
we can create a box and this box is
3460
02:36:17,460 --> 02:36:19,859
going to have an empty or margin top of
3461
02:36:19,859 --> 02:36:22,380
20 pixels it's going to have an SX
3462
02:36:22,380 --> 02:36:24,540
property for Styles that's going to have
3463
02:36:24,540 --> 02:36:28,020
a display equal to flex and it's also
3464
02:36:28,020 --> 02:36:30,740
going to have a flex wrap equal to wrap
3465
02:36:30,740 --> 02:36:33,600
finally it's going to have a gap of
3466
02:36:33,600 --> 02:36:36,720
three with that we should be able to
3467
02:36:36,720 --> 02:36:40,979
Loop over all of our properties now if
3468
02:36:40,979 --> 02:36:43,080
we look into our code we don't seem to
3469
02:36:43,080 --> 02:36:45,060
have the properties yet but let me show
3470
02:36:45,060 --> 02:36:47,580
you how simple it is to get them using
3471
02:36:47,580 --> 02:36:50,700
refine remember that use list hook we
3472
02:36:50,700 --> 02:36:54,000
import 4 well instead of that we'll be
3473
02:36:54,000 --> 02:36:57,600
using use table hook this Hook is much
3474
02:36:57,600 --> 02:36:59,700
more powerful and will allow us to do
3475
02:36:59,700 --> 02:37:03,120
pagination filtering and sorting all in
3476
02:37:03,120 --> 02:37:05,819
one hook let me show you how we can
3477
02:37:05,819 --> 02:37:08,819
initialize it just below the navigate we
3478
02:37:08,819 --> 02:37:10,680
can say const and then we can
3479
02:37:10,680 --> 02:37:13,500
destructure something from or rather is
3480
02:37:13,500 --> 02:37:17,520
equal to use table and what will be the
3481
02:37:17,520 --> 02:37:20,340
structure well we can destructure the
3482
02:37:20,340 --> 02:37:23,700
table query result which is going to
3483
02:37:23,700 --> 02:37:27,660
contain the beta that is loading as well
3484
02:37:27,660 --> 02:37:30,600
as the is error props
3485
02:37:30,600 --> 02:37:32,939
these will just allow us to more easily
3486
02:37:32,939 --> 02:37:35,640
handle and represent the data that we're
3487
02:37:35,640 --> 02:37:37,140
getting right here
3488
02:37:37,140 --> 02:37:40,439
now this data should be populated with
3489
02:37:40,439 --> 02:37:41,880
all of our properties that we have
3490
02:37:41,880 --> 02:37:44,580
created but for that to happen we have
3491
02:37:44,580 --> 02:37:46,920
to create a new get all properties
3492
02:37:46,920 --> 02:37:49,380
inside of the property controller page
3493
02:37:49,380 --> 02:37:51,780
so let's go there
3494
02:37:51,780 --> 02:37:53,700
this one is going to be pretty
3495
02:37:53,700 --> 02:37:56,160
straightforward we just have to create a
3496
02:37:56,160 --> 02:37:59,100
try and catch block instead of try we
3497
02:37:59,100 --> 02:38:02,280
can say Khan's properties is equal to a
3498
02:38:02,280 --> 02:38:03,000
weight
3499
02:38:03,000 --> 02:38:06,180
property dot find pass in an empty
3500
02:38:06,180 --> 02:38:07,859
object because we want to find all of
3501
02:38:07,859 --> 02:38:11,399
them and then dot limit Rec dot query
3502
02:38:11,399 --> 02:38:14,220
dot underscore end so we want to Simply
3503
02:38:14,220 --> 02:38:17,460
limit it to however many there are and
3504
02:38:17,460 --> 02:38:18,899
then we can send the press that status
3505
02:38:18,899 --> 02:38:22,319
of 200 and then that Json
3506
02:38:22,319 --> 02:38:24,840
properties that's it that's all that we
3507
02:38:24,840 --> 02:38:27,479
need to get all the properties and then
3508
02:38:27,479 --> 02:38:29,880
we can also send an error which we can
3509
02:38:29,880 --> 02:38:33,540
copy here below res that status 500 that
3510
02:38:33,540 --> 02:38:34,560
Json
3511
02:38:34,560 --> 02:38:37,380
message his error message
3512
02:38:37,380 --> 02:38:40,859
great and now we can conserlock the data
3513
02:38:40,859 --> 02:38:43,620
to see what we have in there so let's
3514
02:38:43,620 --> 02:38:45,899
collapse this just a bit
3515
02:38:45,899 --> 02:38:49,560
and let's expand our browser as well go
3516
02:38:49,560 --> 02:38:52,140
away from the mobile mode Let's expand
3517
02:38:52,140 --> 02:38:54,899
it and go to the console now if we
3518
02:38:54,899 --> 02:38:58,020
reload the page on the localhost 3004
3519
02:38:58,020 --> 02:39:00,359
slash properties you can see that we
3520
02:39:00,359 --> 02:39:03,359
have data containing an array of one
3521
02:39:03,359 --> 02:39:06,120
single element which is our star Sun
3522
02:39:06,120 --> 02:39:08,700
Hotel and apartment that we created in
3523
02:39:08,700 --> 02:39:11,160
San Francisco and you might be wondering
3524
02:39:11,160 --> 02:39:15,720
how is this even working well since in
3525
02:39:15,720 --> 02:39:19,200
the app.tsx we have created our base
3526
02:39:19,200 --> 02:39:23,280
root route of our API API V1 on
3527
02:39:23,280 --> 02:39:27,000
localhost 8080 and now we are inside of
3528
02:39:27,000 --> 02:39:30,479
all properties meaning list right here
3529
02:39:30,479 --> 02:39:33,720
the use table Hook is so smart that it's
3530
02:39:33,720 --> 02:39:36,479
going to read the URL automatically and
3531
02:39:36,479 --> 02:39:38,340
it's going to know that we want to get
3532
02:39:38,340 --> 02:39:41,220
the data for the properties resource and
3533
02:39:41,220 --> 02:39:44,280
that's exactly what we get this is why I
3534
02:39:44,280 --> 02:39:46,140
love refine
3535
02:39:46,140 --> 02:39:49,080
now let's make use of those properties
3536
02:39:49,080 --> 02:39:51,420
you can notice that data is actually
3537
02:39:51,420 --> 02:39:54,720
within one more object called beta so to
3538
02:39:54,720 --> 02:39:56,880
get that data or to get old properties
3539
02:39:56,880 --> 02:40:00,180
we can say const old properties
3540
02:40:00,180 --> 02:40:04,140
is equal to data question mark dot data
3541
02:40:04,140 --> 02:40:06,000
and then we can say question mark
3542
02:40:06,000 --> 02:40:08,760
question mark array this is going to
3543
02:40:08,760 --> 02:40:10,680
ensure that if we don't have the data
3544
02:40:10,680 --> 02:40:12,960
it's going to default to an empty array
3545
02:40:12,960 --> 02:40:15,479
so we don't have any errors and then
3546
02:40:15,479 --> 02:40:17,939
below that we can utilize the is loading
3547
02:40:17,939 --> 02:40:21,120
and is error states by saying if is
3548
02:40:21,120 --> 02:40:23,880
loading we can return a typography of
3549
02:40:23,880 --> 02:40:27,540
loading dot dot and then else if is
3550
02:40:27,540 --> 02:40:30,300
error we can return the error right here
3551
02:40:30,300 --> 02:40:33,960
and most importantly we can map over all
3552
02:40:33,960 --> 02:40:36,000
of our properties right here at the
3553
02:40:36,000 --> 02:40:40,020
bottom by saying all properties that map
3554
02:40:40,020 --> 02:40:41,939
we're going to get each individual
3555
02:40:41,939 --> 02:40:44,040
property and then we want to return
3556
02:40:44,040 --> 02:40:46,380
something instantly meaning we're going
3557
02:40:46,380 --> 02:40:49,200
to have this instant return parenthesis
3558
02:40:49,200 --> 02:40:50,939
right there and I think we're missing
3559
02:40:50,939 --> 02:40:53,819
just one here now what do we want to
3560
02:40:53,819 --> 02:40:56,220
return for each property well it's going
3561
02:40:56,220 --> 02:41:00,300
to be a property card a self-closing
3562
02:41:00,300 --> 02:41:03,060
custom component we have created and to
3563
02:41:03,060 --> 02:41:05,280
it we have to pass a key to make it
3564
02:41:05,280 --> 02:41:07,859
unique it's not going to be ID but
3565
02:41:07,859 --> 02:41:10,439
rather underscore ID
3566
02:41:10,439 --> 02:41:12,960
then we also have to give it an ID which
3567
02:41:12,960 --> 02:41:14,760
is going to be property dot underscore
3568
02:41:14,760 --> 02:41:15,720
ID
3569
02:41:15,720 --> 02:41:18,420
we can also pass it a title equal to
3570
02:41:18,420 --> 02:41:21,600
property dot title we can pass it a
3571
02:41:21,600 --> 02:41:24,660
price equal to property.price location
3572
02:41:24,660 --> 02:41:27,359
equal to property.location
3573
02:41:27,359 --> 02:41:29,939
and then we're going to do photo equal
3574
02:41:29,939 --> 02:41:33,420
to property dot photo and finally a
3575
02:41:33,420 --> 02:41:37,680
title equal to property dot title these
3576
02:41:37,680 --> 02:41:39,359
are all the props we have to pass to a
3577
02:41:39,359 --> 02:41:40,979
property card and as you can see
3578
02:41:40,979 --> 02:41:43,439
typescript is complaining again and
3579
02:41:43,439 --> 02:41:45,000
that's for a reason that's because we
3580
02:41:45,000 --> 02:41:46,680
didn't Define these properties on the
3581
02:41:46,680 --> 02:41:48,420
property card but also we have a
3582
02:41:48,420 --> 02:41:50,580
duplicate title property which I can
3583
02:41:50,580 --> 02:41:53,340
remove so let's go into the property
3584
02:41:53,340 --> 02:41:56,220
card and let's start setting up all of
3585
02:41:56,220 --> 02:41:58,500
the Imports and props so the typescript
3586
02:41:58,500 --> 02:42:01,859
doesn't complain we can import
3587
02:42:01,859 --> 02:42:05,340
something called a place coming from add
3588
02:42:05,340 --> 02:42:08,520
mui forward slash icons material this is
3589
02:42:08,520 --> 02:42:12,000
simply an icon we can also import a link
3590
02:42:12,000 --> 02:42:15,359
coming from add pan card forward slash
3591
02:42:15,359 --> 02:42:20,040
refine Dash react router V6 and we can
3592
02:42:20,040 --> 02:42:21,960
also import a couple of material UI
3593
02:42:21,960 --> 02:42:25,319
properties import typography
3594
02:42:25,319 --> 02:42:28,859
let's do a box a card
3595
02:42:28,859 --> 02:42:32,340
a card media for the image a card
3596
02:42:32,340 --> 02:42:35,340
content for the content and a stack
3597
02:42:35,340 --> 02:42:41,340
coming from add pancod refine mui
3598
02:42:41,340 --> 02:42:44,600
and finally we have to import property
3599
02:42:44,600 --> 02:42:47,520
card props
3600
02:42:47,520 --> 02:42:51,000
from interfaces property
3601
02:42:51,000 --> 02:42:53,100
then we can accept all of these
3602
02:42:53,100 --> 02:42:55,680
properties right here by destructuring
3603
02:42:55,680 --> 02:42:56,939
the ID
3604
02:42:56,939 --> 02:43:01,620
the title the location the price and the
3605
02:43:01,620 --> 02:43:04,560
photo and we can say we are expecting
3606
02:43:04,560 --> 02:43:08,100
these props to be off type property card
3607
02:43:08,100 --> 02:43:11,399
props and now we can dive into creating
3608
02:43:11,399 --> 02:43:13,740
a property card as you can see right now
3609
02:43:13,740 --> 02:43:16,319
we have only one property so let's make
3610
02:43:16,319 --> 02:43:18,960
it happen to get started with the layout
3611
02:43:18,960 --> 02:43:21,540
of our property card we can wrap it in
3612
02:43:21,540 --> 02:43:25,020
what it is and that is a card material
3613
02:43:25,020 --> 02:43:27,000
UI has a special card element which is
3614
02:43:27,000 --> 02:43:28,319
going to make the styling of our
3615
02:43:28,319 --> 02:43:31,200
application much simpler there we're
3616
02:43:31,200 --> 02:43:33,120
going to provide it a component equal to
3617
02:43:33,120 --> 02:43:35,700
link meaning once we click on this card
3618
02:43:35,700 --> 02:43:37,800
it's going to link us to the property
3619
02:43:37,800 --> 02:43:40,740
details of that property where is it
3620
02:43:40,740 --> 02:43:42,600
going to link us to well that's going to
3621
02:43:42,600 --> 02:43:44,640
be forward slash properties forward
3622
02:43:44,640 --> 02:43:48,420
slash and then ID of that property then
3623
02:43:48,420 --> 02:43:51,180
we can do some light styling like giving
3624
02:43:51,180 --> 02:43:54,240
it a Max width right here
3625
02:43:54,240 --> 02:43:58,920
of something like let's do 330 pixels
3626
02:43:58,920 --> 02:44:01,380
we can also give it some padding like 10
3627
02:44:01,380 --> 02:44:04,319
pixels and then on Hover meaning we have
3628
02:44:04,319 --> 02:44:06,600
to put it in a string and put an end
3629
02:44:06,600 --> 02:44:10,020
sign there column hover we want to give
3630
02:44:10,020 --> 02:44:12,960
it a box Shadow now this box Shadow
3631
02:44:12,960 --> 02:44:15,240
accepts many properties so we can do 0
3632
02:44:15,240 --> 02:44:22,700
22 pixels 45 pixels 2 pixels RGB a 176
3633
02:44:22,700 --> 02:44:24,260
176
3634
02:44:24,260 --> 02:44:29,280
176 0.1 I found these values to work the
3635
02:44:29,280 --> 02:44:32,280
best so let's do it like this
3636
02:44:32,280 --> 02:44:36,479
and finally we can also give it a cursor
3637
02:44:36,479 --> 02:44:39,479
of pointer meaning we can click on it
3638
02:44:39,479 --> 02:44:41,399
great and we can also give it an
3639
02:44:41,399 --> 02:44:44,580
elevation equal to zero meaning we don't
3640
02:44:44,580 --> 02:44:47,040
want any additional Shadow on top of it
3641
02:44:47,040 --> 02:44:49,680
now if we save this we might not be able
3642
02:44:49,680 --> 02:44:51,720
to see anything oh we just see a little
3643
02:44:51,720 --> 02:44:53,880
card right here that's because we are
3644
02:44:53,880 --> 02:44:57,180
yet to add the card media so card media
3645
02:44:57,180 --> 02:44:58,740
is going to show us our beautiful
3646
02:44:58,740 --> 02:45:01,439
property that we have entered before we
3647
02:45:01,439 --> 02:45:06,120
can set it as a component meaning IMG
3648
02:45:06,120 --> 02:45:10,319
we can give it a width of 100 percent
3649
02:45:10,319 --> 02:45:13,859
we can give it a height of 210.
3650
02:45:13,859 --> 02:45:16,140
we can give it an image equal to a photo
3651
02:45:16,140 --> 02:45:18,479
that we're passing through props we can
3652
02:45:18,479 --> 02:45:21,380
give it an ALT tag equal to let's do
3653
02:45:21,380 --> 02:45:24,479
card image
3654
02:45:24,479 --> 02:45:27,780
and let's also do an SX property of
3655
02:45:27,780 --> 02:45:30,660
Border radius of 10 pixels
3656
02:45:30,660 --> 02:45:33,120
now if we save this you can see our
3657
02:45:33,120 --> 02:45:35,220
beautiful property image right here that
3658
02:45:35,220 --> 02:45:37,859
we used when creating this property now
3659
02:45:37,859 --> 02:45:40,260
let's go for card content just below
3660
02:45:40,260 --> 02:45:42,540
card media and we can collapse this so
3661
02:45:42,540 --> 02:45:46,260
we can see the changes that we make live
3662
02:45:46,260 --> 02:45:48,780
we can open up a new card content
3663
02:45:48,780 --> 02:45:49,740
element
3664
02:45:49,740 --> 02:45:51,780
and inside of there we're going to have
3665
02:45:51,780 --> 02:45:55,200
a stack that stack is going to be of a
3666
02:45:55,200 --> 02:45:57,479
direction equal to column
3667
02:45:57,479 --> 02:46:00,120
and it's going to have a gap equal to
3668
02:46:00,120 --> 02:46:01,200
one
3669
02:46:01,200 --> 02:46:03,060
inside of there we want to have a
3670
02:46:03,060 --> 02:46:04,260
typography
3671
02:46:04,260 --> 02:46:06,180
and that typography is going to render
3672
02:46:06,180 --> 02:46:07,620
the title
3673
02:46:07,620 --> 02:46:09,840
below that typography we're going to
3674
02:46:09,840 --> 02:46:12,300
have a stack another one that's going to
3675
02:46:12,300 --> 02:46:15,240
have a direction equal to row it's going
3676
02:46:15,240 --> 02:46:18,120
to have a gap equal to 0.5
3677
02:46:18,120 --> 02:46:21,060
and it's also going to have an align
3678
02:46:21,060 --> 02:46:22,979
items
3679
02:46:22,979 --> 02:46:26,819
equal to flex Dash start and inside of
3680
02:46:26,819 --> 02:46:29,280
there we can simply put an icon meaning
3681
02:46:29,280 --> 02:46:31,680
that's going to be a place icon we had
3682
02:46:31,680 --> 02:46:34,439
before we can give it an SX property
3683
02:46:34,439 --> 02:46:40,200
equal to font size of 18. like this we
3684
02:46:40,200 --> 02:46:42,840
can give it a color equal to
3685
02:46:42,840 --> 02:46:46,920
hash one one one four two d and a margin
3686
02:46:46,920 --> 02:46:50,640
top equal to 0.5
3687
02:46:50,640 --> 02:46:53,939
great below that place we can also
3688
02:46:53,939 --> 02:46:56,520
render a typography where we're going to
3689
02:46:56,520 --> 02:46:59,819
show the location like this now if we
3690
02:46:59,819 --> 02:47:01,080
save this
3691
02:47:01,080 --> 02:47:02,939
it should already start coming together
3692
02:47:02,939 --> 02:47:05,220
just a bit there we go
3693
02:47:05,220 --> 02:47:08,460
but if we go below this stack and Below
3694
02:47:08,460 --> 02:47:11,640
another stack we can add a box
3695
02:47:11,640 --> 02:47:14,399
and that box is going to render another
3696
02:47:14,399 --> 02:47:17,280
typography that's going to Simply show a
3697
02:47:17,280 --> 02:47:18,479
dollar sign
3698
02:47:18,479 --> 02:47:21,840
and then a price like this
3699
02:47:21,840 --> 02:47:24,120
great now we have all the content we
3700
02:47:24,120 --> 02:47:26,520
need but let's go ahead and let's style
3701
02:47:26,520 --> 02:47:28,979
it just a bit better so to discard
3702
02:47:28,979 --> 02:47:32,700
content we can give one SX property of
3703
02:47:32,700 --> 02:47:35,100
display is equal to flex that's
3704
02:47:35,100 --> 02:47:36,600
immediately going to change some things
3705
02:47:36,600 --> 02:47:39,420
we can also give it a flex Direction
3706
02:47:39,420 --> 02:47:42,660
equal to rho
3707
02:47:42,660 --> 02:47:45,600
we can give it a justify content equal
3708
02:47:45,600 --> 02:47:48,420
to space Dash between
3709
02:47:48,420 --> 02:47:50,939
and we can give it a gap equal to 10
3710
02:47:50,939 --> 02:47:55,319
pixels as well as padding x equal to 5
3711
02:47:55,319 --> 02:47:57,960
pixels if we save that you can see
3712
02:47:57,960 --> 02:47:59,640
that's going to change the layout just a
3713
02:47:59,640 --> 02:48:01,859
bit put the price on the right side
3714
02:48:01,859 --> 02:48:04,979
now we have this typography of title so
3715
02:48:04,979 --> 02:48:06,780
let's style it a bit let's give it a
3716
02:48:06,780 --> 02:48:09,720
font size equal to 16 to make it just a
3717
02:48:09,720 --> 02:48:13,260
bit bigger font weight of 500
3718
02:48:13,260 --> 02:48:15,359
right here
3719
02:48:15,359 --> 02:48:19,380
and a color of your the Noid one one one
3720
02:48:19,380 --> 02:48:24,120
four two D now if we save it it's just a
3721
02:48:24,120 --> 02:48:26,399
bit more pronounced then we have the
3722
02:48:26,399 --> 02:48:28,319
place which is fine and then this bottom
3723
02:48:28,319 --> 02:48:31,080
typography we can give it a font size
3724
02:48:31,080 --> 02:48:37,939
equal to 14. and a color equal to Hash
3725
02:48:37,939 --> 02:48:41,760
808191 that's for the location there we
3726
02:48:41,760 --> 02:48:45,000
go finally we can style the Box this box
3727
02:48:45,000 --> 02:48:48,420
is going to have a px of 1.5 that's for
3728
02:48:48,420 --> 02:48:51,120
padding horizontal we can also give it a
3729
02:48:51,120 --> 02:48:55,560
py of 0.5 for padding vertical and a
3730
02:48:55,560 --> 02:49:00,000
border radius of one like this
3731
02:49:00,000 --> 02:49:03,200
we can also give it a BG cooler equal to
3732
02:49:03,200 --> 02:49:08,939
Hash d a d e f a and also we can give it
3733
02:49:08,939 --> 02:49:12,240
a height equal to fit
3734
02:49:12,240 --> 02:49:16,500
Dash content if we save that you can see
3735
02:49:16,500 --> 02:49:19,080
this price box appear and we can style
3736
02:49:19,080 --> 02:49:21,420
the typography right here by giving it a
3737
02:49:21,420 --> 02:49:24,000
font size equal to 12.
3738
02:49:24,000 --> 02:49:28,140
font weight equal to 600 as well as a
3739
02:49:28,140 --> 02:49:32,819
color equal to Hash four seven
3740
02:49:32,819 --> 02:49:37,200
five b E8 if we save that you can see it
3741
02:49:37,200 --> 02:49:39,300
looks just a bit better but still it's
3742
02:49:39,300 --> 02:49:41,580
not as close as to what I showed you at
3743
02:49:41,580 --> 02:49:44,460
the start all of these seem to have this
3744
02:49:44,460 --> 02:49:46,620
bottom border which indicates it's a
3745
02:49:46,620 --> 02:49:49,439
link so we have to get rid of that and
3746
02:49:49,439 --> 02:49:51,300
of course to get rid of that we can go
3747
02:49:51,300 --> 02:49:54,840
to our card and add one more property of
3748
02:49:54,840 --> 02:49:58,020
text decoration is going to be set to
3749
02:49:58,020 --> 02:50:01,920
none so if we do this you can see it
3750
02:50:01,920 --> 02:50:04,200
disappears and we have a wonderful
3751
02:50:04,200 --> 02:50:07,439
property card now let's go ahead and add
3752
02:50:07,439 --> 02:50:10,020
one more so let's go to add property
3753
02:50:10,020 --> 02:50:13,020
let's go with lavender apartment let's
3754
02:50:13,020 --> 02:50:15,660
do test property type is going to be a
3755
02:50:15,660 --> 02:50:18,540
villa let's do 1000 right here enter a
3756
02:50:18,540 --> 02:50:21,300
location let's do Italy and I'm gonna
3757
02:50:21,300 --> 02:50:24,240
upload a photo with that I'm gonna click
3758
02:50:24,240 --> 02:50:26,340
submit
3759
02:50:26,340 --> 02:50:28,859
and immediately we are redirected right
3760
02:50:28,859 --> 02:50:31,500
here and it is immediately showing we
3761
02:50:31,500 --> 02:50:34,200
even get a success message that is great
3762
02:50:34,200 --> 02:50:37,020
so we have successfully completed two
3763
02:50:37,020 --> 02:50:39,780
out of four crowd operations create and
3764
02:50:39,780 --> 02:50:42,120
read now of course there's also delete
3765
02:50:42,120 --> 02:50:45,180
and the update and hey we still have to
3766
02:50:45,180 --> 02:50:48,060
show the details for a specific property
3767
02:50:48,060 --> 02:50:50,520
as you can see we immediately route to
3768
02:50:50,520 --> 02:50:53,399
it and we can go back to dashboard but
3769
02:50:53,399 --> 02:50:55,500
already I think you can see how great
3770
02:50:55,500 --> 02:50:57,960
this app is becoming now we're just
3771
02:50:57,960 --> 02:51:00,600
gonna focus on adding the delete update
3772
02:51:00,600 --> 02:51:04,200
and also show the property detail now as
3773
02:51:04,200 --> 02:51:06,720
an extra added bonus I wanted to show
3774
02:51:06,720 --> 02:51:09,560
you how simple it is to do pagination
3775
02:51:09,560 --> 02:51:14,160
sorting and filtering all using refine
3776
02:51:14,160 --> 02:51:16,500
what you can do right here is we can
3777
02:51:16,500 --> 02:51:19,380
utilize the use table hook to its full
3778
02:51:19,380 --> 02:51:20,399
potential
3779
02:51:20,399 --> 02:51:23,160
from you stable below table query result
3780
02:51:23,160 --> 02:51:26,100
we can also get current meaning the
3781
02:51:26,100 --> 02:51:28,620
current page Set current which is going
3782
02:51:28,620 --> 02:51:31,080
to allow us to set the page we can get
3783
02:51:31,080 --> 02:51:33,479
the set page size which is going to
3784
02:51:33,479 --> 02:51:34,740
allow us to change the number of
3785
02:51:34,740 --> 02:51:36,899
elements on the page we can get the
3786
02:51:36,899 --> 02:51:40,380
total page count and finally incredibly
3787
02:51:40,380 --> 02:51:43,080
handy utilities such as sorter set
3788
02:51:43,080 --> 02:51:44,220
sorter
3789
02:51:44,220 --> 02:51:48,060
for sorting as well as filters and set
3790
02:51:48,060 --> 02:51:51,180
filters for filtering so let me show you
3791
02:51:51,180 --> 02:51:53,460
how to use all of those
3792
02:51:53,460 --> 02:51:56,580
on top of our old properties so right
3793
02:51:56,580 --> 02:51:58,560
here inside of the Box we're going to
3794
02:51:58,560 --> 02:52:00,120
make some space and we're going to
3795
02:52:00,120 --> 02:52:02,460
create another box
3796
02:52:02,460 --> 02:52:05,640
this box is going to have an empty of 20
3797
02:52:05,640 --> 02:52:08,520
pixels to divide it from the top it's
3798
02:52:08,520 --> 02:52:10,740
going to have an SX property of display
3799
02:52:10,740 --> 02:52:15,240
is set to flex as well as Flex wrap is
3800
02:52:15,240 --> 02:52:19,200
set to wrap and finally Gap is set to 3.
3801
02:52:19,200 --> 02:52:22,200
inside of there we can have a stack and
3802
02:52:22,200 --> 02:52:24,000
that stack is going to have a direction
3803
02:52:24,000 --> 02:52:28,859
set to column as well as a width set to
3804
02:52:28,859 --> 02:52:31,020
100 percent
3805
02:52:31,020 --> 02:52:33,180
inside of there we can move this
3806
02:52:33,180 --> 02:52:35,580
typography that before we head down here
3807
02:52:35,580 --> 02:52:39,560
so let's move this typography
3808
02:52:39,600 --> 02:52:42,779
it's going to say all properties but
3809
02:52:42,779 --> 02:52:44,700
what we can also do is we can make it
3810
02:52:44,700 --> 02:52:47,700
Dynamic so let's say open a new Dynamic
3811
02:52:47,700 --> 02:52:51,540
block if no all properties dot length
3812
02:52:51,540 --> 02:52:54,479
then we can show a dynamic string of
3813
02:52:54,479 --> 02:52:56,479
their
3814
02:52:56,479 --> 02:52:59,220
there are no properties
3815
02:52:59,220 --> 02:53:02,520
otherwise we can show a string off all
3816
02:53:02,520 --> 02:53:04,800
properties there we go so now we can
3817
02:53:04,800 --> 02:53:07,800
remove the static one right here
3818
02:53:07,800 --> 02:53:11,100
now immediately below that typography
3819
02:53:11,100 --> 02:53:14,160
still inside of the stack we want to
3820
02:53:14,160 --> 02:53:16,319
create a new box
3821
02:53:16,319 --> 02:53:19,140
this box is going to have an MB of 2
3822
02:53:19,140 --> 02:53:21,180
meaning margin bottom it's going to have
3823
02:53:21,180 --> 02:53:24,600
an Mt of 3 meaning margin top a display
3824
02:53:24,600 --> 02:53:26,340
of flex
3825
02:53:26,340 --> 02:53:30,600
a width of about 84 percent this is
3826
02:53:30,600 --> 02:53:33,420
where our filters and sorting will go
3827
02:53:33,420 --> 02:53:36,960
we can also do justify content equal to
3828
02:53:36,960 --> 02:53:39,720
space Dash between
3829
02:53:39,720 --> 02:53:42,779
and finally a flex wrap equal to wrap
3830
02:53:42,779 --> 02:53:45,779
now if we save this nothing really
3831
02:53:45,779 --> 02:53:47,520
should happen we just created some space
3832
02:53:47,520 --> 02:53:50,040
for adding our filters now we're going
3833
02:53:50,040 --> 02:53:52,680
to create one more inner box
3834
02:53:52,680 --> 02:53:55,439
that box is going to have a display is
3835
02:53:55,439 --> 02:53:59,399
equal to flex a gap equal to two
3836
02:53:59,399 --> 02:54:02,580
a flex wrap equal to wrap
3837
02:54:02,580 --> 02:54:05,220
and a margin bottom that's going to be
3838
02:54:05,220 --> 02:54:08,819
on extra small devices 20 pixels and on
3839
02:54:08,819 --> 02:54:10,920
small devices and higher it's going to
3840
02:54:10,920 --> 02:54:13,859
be zero and finally inside of there we
3841
02:54:13,859 --> 02:54:16,920
can render our custom button our custom
3842
02:54:16,920 --> 02:54:18,960
button is going to be used for sorting
3843
02:54:18,960 --> 02:54:21,180
so we can give it a title that's going
3844
02:54:21,180 --> 02:54:22,920
to be dynamic
3845
02:54:22,920 --> 02:54:26,220
sort price like this
3846
02:54:26,220 --> 02:54:28,380
and for now we can leave this as it is
3847
02:54:28,380 --> 02:54:30,420
later on we'll be able to sort it better
3848
02:54:30,420 --> 02:54:32,760
we also have to give it a handle click
3849
02:54:32,760 --> 02:54:36,120
so let's set a handle click and for now
3850
02:54:36,120 --> 02:54:37,680
we can leave it as an empty callback
3851
02:54:37,680 --> 02:54:39,240
function
3852
02:54:39,240 --> 02:54:40,859
we're also going to set a background
3853
02:54:40,859 --> 02:54:46,680
color equal to 475 be8 and then also a
3854
02:54:46,680 --> 02:54:51,479
color equal to fcfc FC and there we have
3855
02:54:51,479 --> 02:54:54,840
our sort price button that's great
3856
02:54:54,840 --> 02:54:57,620
so this is going to be used for sorting
3857
02:54:57,620 --> 02:55:01,140
just below that button we can have a
3858
02:55:01,140 --> 02:55:02,819
text field
3859
02:55:02,819 --> 02:55:05,160
this text field is a self-closing
3860
02:55:05,160 --> 02:55:07,260
material UI tag and of course we need to
3861
02:55:07,260 --> 02:55:09,540
import it at the top so scrolling all
3862
02:55:09,540 --> 02:55:11,760
the way there we can import the text
3863
02:55:11,760 --> 02:55:13,140
field
3864
02:55:13,140 --> 02:55:15,420
later on we're going to also use a
3865
02:55:15,420 --> 02:55:17,100
select element
3866
02:55:17,100 --> 02:55:20,939
as well as a menu item element so we can
3867
02:55:20,939 --> 02:55:23,580
import the menu item as well
3868
02:55:23,580 --> 02:55:26,040
finally we can scroll down
3869
02:55:26,040 --> 02:55:29,100
and this text field is going to have a
3870
02:55:29,100 --> 02:55:33,359
variant equal to outlined a color equal
3871
02:55:33,359 --> 02:55:34,680
to info
3872
02:55:34,680 --> 02:55:37,740
a placeholder
3873
02:55:37,740 --> 02:55:40,260
equal to search
3874
02:55:40,260 --> 02:55:43,859
by title now if we save this you should
3875
02:55:43,859 --> 02:55:46,080
be able to see an outlined
3876
02:55:46,080 --> 02:55:48,120
text field appear and there we go we're
3877
02:55:48,120 --> 02:55:52,080
going to use this for filtering by title
3878
02:55:52,080 --> 02:55:55,080
for now we can add the value equal to
3879
02:55:55,080 --> 02:55:57,540
just an empty string and we can also add
3880
02:55:57,540 --> 02:56:00,000
an on change equal to an empty callback
3881
02:56:00,000 --> 02:56:01,380
function because we're going to fill
3882
02:56:01,380 --> 02:56:03,420
this soon enough for now we're just
3883
02:56:03,420 --> 02:56:05,399
focusing on the layout
3884
02:56:05,399 --> 02:56:07,859
now below that text field we're going to
3885
02:56:07,859 --> 02:56:09,779
have a select element
3886
02:56:09,779 --> 02:56:13,020
this select element is going to have a
3887
02:56:13,020 --> 02:56:17,520
variant equal to outlined a color
3888
02:56:17,520 --> 02:56:19,560
equal to info
3889
02:56:19,560 --> 02:56:24,140
a display empty property
3890
02:56:24,180 --> 02:56:27,000
it's also going to have a required
3891
02:56:27,000 --> 02:56:29,100
property
3892
02:56:29,100 --> 02:56:32,939
it's going to have an input props of
3893
02:56:32,939 --> 02:56:36,960
area label without label written like
3894
02:56:36,960 --> 02:56:40,680
this also a default value set to an
3895
02:56:40,680 --> 02:56:42,240
empty string
3896
02:56:42,240 --> 02:56:44,700
for now the value can be set to an empty
3897
02:56:44,700 --> 02:56:47,760
string as well and the on change is also
3898
02:56:47,760 --> 02:56:49,800
going to be set to an empty callback
3899
02:56:49,800 --> 02:56:52,800
function looking like this now you can
3900
02:56:52,800 --> 02:56:55,200
see our select but it's looking a bit
3901
02:56:55,200 --> 02:56:58,500
empty without any menu items so for now
3902
02:56:58,500 --> 02:57:02,460
let's simply add a demo menu item
3903
02:57:02,460 --> 02:57:04,920
that's going to have a value of an empty
3904
02:57:04,920 --> 02:57:06,540
string
3905
02:57:06,540 --> 02:57:09,359
and inside of it we can say all so we
3906
02:57:09,359 --> 02:57:11,700
want to see properties of all types and
3907
02:57:11,700 --> 02:57:13,680
there we go we immediately created the
3908
02:57:13,680 --> 02:57:16,140
layout for three different things for
3909
02:57:16,140 --> 02:57:18,779
sorting for filtering and some more
3910
02:57:18,779 --> 02:57:22,620
filtering as well based on the type
3911
02:57:22,620 --> 02:57:25,080
now that's happening at the top of the
3912
02:57:25,080 --> 02:57:27,359
page but now I promise that we're gonna
3913
02:57:27,359 --> 02:57:30,359
do pagination as well so below our
3914
02:57:30,359 --> 02:57:33,180
property items meaning that is right
3915
02:57:33,180 --> 02:57:35,340
here below this stack containing the
3916
02:57:35,340 --> 02:57:37,260
property cards
3917
02:57:37,260 --> 02:57:40,439
and below that box right here we're
3918
02:57:40,439 --> 02:57:42,899
going to create our pagination we first
3919
02:57:42,899 --> 02:57:44,279
have to check if there are any
3920
02:57:44,279 --> 02:57:46,859
properties left to paginate so we can do
3921
02:57:46,859 --> 02:57:48,420
all properties
3922
02:57:48,420 --> 02:57:52,920
dot length is greater than zero and end
3923
02:57:52,920 --> 02:57:56,340
and then we can show R by generation the
3924
02:57:56,340 --> 02:57:58,380
pagination is actually going to be just
3925
02:57:58,380 --> 02:58:01,800
a box for the start so that box can have
3926
02:58:01,800 --> 02:58:04,740
a display is equal to flex and it can
3927
02:58:04,740 --> 02:58:07,680
have a gap equal to two gap between the
3928
02:58:07,680 --> 02:58:09,779
buttons that we are yet to create and
3929
02:58:09,779 --> 02:58:11,939
then we can have a margin top of three
3930
02:58:11,939 --> 02:58:13,680
to divide it from the properties above
3931
02:58:13,680 --> 02:58:18,240
and flex wrap set to wrap great now
3932
02:58:18,240 --> 02:58:20,640
inside of there we can start with our
3933
02:58:20,640 --> 02:58:23,399
custom button this button is going to
3934
02:58:23,399 --> 02:58:26,399
have a title equal to previous
3935
02:58:26,399 --> 02:58:28,020
so this is going to move us to the
3936
02:58:28,020 --> 02:58:30,600
previous page we can also give it a
3937
02:58:30,600 --> 02:58:32,279
handle click
3938
02:58:32,279 --> 02:58:35,700
and there we can set current remember
3939
02:58:35,700 --> 02:58:38,160
that utility function that we got from
3940
02:58:38,160 --> 02:58:41,520
the use table Set current and whenever
3941
02:58:41,520 --> 02:58:43,020
you're setting the state with the
3942
02:58:43,020 --> 02:58:44,760
previous version of that state you want
3943
02:58:44,760 --> 02:58:46,500
to create a callback function called
3944
02:58:46,500 --> 02:58:50,040
prev and then we can say prev minus one
3945
02:58:50,040 --> 02:58:52,920
we're simply decreasing one from the
3946
02:58:52,920 --> 02:58:54,180
number of pages
3947
02:58:54,180 --> 02:58:56,640
then we can set the background color to
3948
02:58:56,640 --> 02:59:02,399
be equal to Hash 475 be8 as well as a
3949
02:59:02,399 --> 02:59:04,580
caller equal to FC
3950
02:59:04,580 --> 02:59:08,160
fcfc and finally we need to disable the
3951
02:59:08,160 --> 02:59:10,800
button if we are on the first page so we
3952
02:59:10,800 --> 02:59:14,700
can say disabled is equal to no current
3953
02:59:14,700 --> 02:59:17,399
is greater than one so if this is the
3954
02:59:17,399 --> 02:59:20,279
case then we cannot go back so now if we
3955
02:59:20,279 --> 02:59:22,380
save this you can see that we have a
3956
02:59:22,380 --> 02:59:25,020
previous button now even though we are
3957
02:59:25,020 --> 02:59:26,580
on the first page the button doesn't
3958
02:59:26,580 --> 02:59:28,800
seem to be disabled so let's go into the
3959
02:59:28,800 --> 02:59:31,680
custom button and let's get disabled
3960
02:59:31,680 --> 02:59:33,000
from props
3961
02:59:33,000 --> 02:59:35,279
and then right here we can say disabled
3962
02:59:35,279 --> 02:59:38,760
is equal to disabled
3963
02:59:38,760 --> 02:59:41,700
there we go now as you can see we cannot
3964
02:59:41,700 --> 02:59:43,200
click the button because we're on the
3965
02:59:43,200 --> 02:59:44,340
first page
3966
02:59:44,340 --> 02:59:47,520
great now below that custom button we
3967
02:59:47,520 --> 02:59:50,520
can create a box this box is going to
3968
02:59:50,520 --> 02:59:53,160
only be visible on large devices so we
3969
02:59:53,160 --> 02:59:55,740
can give it a display equal to on extra
3970
02:59:55,740 --> 02:59:58,740
small devices hidden and then on small
3971
02:59:58,740 --> 03:00:02,040
and larger it's going to be Flex we can
3972
03:00:02,040 --> 03:00:04,979
also give it align items equal to Center
3973
03:00:04,979 --> 03:00:07,979
and we can give it a gap of 5 pixels
3974
03:00:07,979 --> 03:00:11,760
inside of there we can simply say page
3975
03:00:11,760 --> 03:00:15,300
we can provide an empty space like this
3976
03:00:15,300 --> 03:00:17,760
and then we can give it a strong tag to
3977
03:00:17,760 --> 03:00:19,020
make it bolded
3978
03:00:19,020 --> 03:00:20,939
and then inside of there we can see
3979
03:00:20,939 --> 03:00:24,000
current like this off
3980
03:00:24,000 --> 03:00:26,640
page count so this is going to let us
3981
03:00:26,640 --> 03:00:29,640
know on which page are we right now
3982
03:00:29,640 --> 03:00:32,040
and there we go you can see page one of
3983
03:00:32,040 --> 03:00:34,140
Nan and that is fine that's because we
3984
03:00:34,140 --> 03:00:35,700
didn't yet implement the back end for
3985
03:00:35,700 --> 03:00:38,100
pagination to work but soon enough we'll
3986
03:00:38,100 --> 03:00:40,319
do that so we'll be able to see one of
3987
03:00:40,319 --> 03:00:41,279
one
3988
03:00:41,279 --> 03:00:44,100
then below this box we can duplicate
3989
03:00:44,100 --> 03:00:46,279
this button that we have created before
3990
03:00:46,279 --> 03:00:49,140
and this is going to be our button to go
3991
03:00:49,140 --> 03:00:51,240
to the next page so right here we can
3992
03:00:51,240 --> 03:00:53,520
set current prev and it's going to be
3993
03:00:53,520 --> 03:00:57,120
prev plus one instead of -1 the color
3994
03:00:57,120 --> 03:00:58,979
and the background color are going to be
3995
03:00:58,979 --> 03:01:01,560
the same but it's going to be disabled
3996
03:01:01,560 --> 03:01:04,380
if current is triple equal to page count
3997
03:01:04,380 --> 03:01:07,260
that means that we are on the last page
3998
03:01:07,260 --> 03:01:09,479
and now we have previous we have next
3999
03:01:09,479 --> 03:01:13,500
and we also have the number of pages
4000
03:01:13,500 --> 03:01:15,479
now we're going to also do one
4001
03:01:15,479 --> 03:01:17,520
additional functionality which is
4002
03:01:17,520 --> 03:01:20,520
creating a select element that select
4003
03:01:20,520 --> 03:01:23,220
element is going to have a variant
4004
03:01:23,220 --> 03:01:25,979
equal to outlined
4005
03:01:25,979 --> 03:01:29,060
it's going to have a color equal to info
4006
03:01:29,060 --> 03:01:32,580
a display empty and as a matter of fact
4007
03:01:32,580 --> 03:01:34,800
I think that we can completely copy the
4008
03:01:34,800 --> 03:01:36,899
select that we have above so right here
4009
03:01:36,899 --> 03:01:39,840
remember to select you can copy it all
4010
03:01:39,840 --> 03:01:42,540
the way to the ending tag and we can
4011
03:01:42,540 --> 03:01:45,620
paste it right here
4012
03:01:46,260 --> 03:01:48,899
we can also fix the indentation by
4013
03:01:48,899 --> 03:01:50,640
moving all of this a couple of lines
4014
03:01:50,640 --> 03:01:53,040
back everything is going to be the same
4015
03:01:53,040 --> 03:01:55,080
but the value and the on change are
4016
03:01:55,080 --> 03:01:57,060
going to remain empty for now and of
4017
03:01:57,060 --> 03:01:59,580
course we have to add some menu items so
4018
03:01:59,580 --> 03:02:01,920
in this case we're going to map over
4019
03:02:01,920 --> 03:02:04,500
some array items so let's create a
4020
03:02:04,500 --> 03:02:07,200
dynamic block of code with an array of
4021
03:02:07,200 --> 03:02:08,040
10
4022
03:02:08,040 --> 03:02:12,600
20 30 40 and 50. and then we can say dot
4023
03:02:12,600 --> 03:02:13,680
map
4024
03:02:13,680 --> 03:02:16,020
all of these are page sizes so we can
4025
03:02:16,020 --> 03:02:18,660
say size and then for each size we want
4026
03:02:18,660 --> 03:02:21,840
to instantly return a menu item
4027
03:02:21,840 --> 03:02:24,479
and of course we can add a key because
4028
03:02:24,479 --> 03:02:27,359
We're looping over it as a size the
4029
03:02:27,359 --> 03:02:30,000
value is going to be size as well and
4030
03:02:30,000 --> 03:02:32,700
then the text is going to be show
4031
03:02:32,700 --> 03:02:35,880
size like this this will allow us to
4032
03:02:35,880 --> 03:02:38,220
switch between many different page sizes
4033
03:02:38,220 --> 03:02:40,800
so later on if we have more elements and
4034
03:02:40,800 --> 03:02:42,359
we want to see more in the same page
4035
03:02:42,359 --> 03:02:44,819
we'll be able to show 50 on the same
4036
03:02:44,819 --> 03:02:47,819
page and the best thing about it is that
4037
03:02:47,819 --> 03:02:49,500
our pagination is going to immediately
4038
03:02:49,500 --> 03:02:51,300
calculate the number of elements per
4039
03:02:51,300 --> 03:02:53,279
page and it's going to decrease the
4040
03:02:53,279 --> 03:02:54,600
number of pages
4041
03:02:54,600 --> 03:02:56,399
and of course we can set the default
4042
03:02:56,399 --> 03:02:59,399
value to be a number 10 so that it shows
4043
03:02:59,399 --> 03:03:02,040
right here in this case the value can be
4044
03:03:02,040 --> 03:03:04,859
removed great later on once we implement
4045
03:03:04,859 --> 03:03:06,660
the on change we'll be able to see the
4046
03:03:06,660 --> 03:03:09,300
changes that we make right here but with
4047
03:03:09,300 --> 03:03:11,220
that said believe it or not we're done
4048
03:03:11,220 --> 03:03:13,260
with the layout for our sorting
4049
03:03:13,260 --> 03:03:16,979
filtering and pagination now we're going
4050
03:03:16,979 --> 03:03:18,899
to dive into implementing the back end
4051
03:03:18,899 --> 03:03:21,060
for all of these functionalities and
4052
03:03:21,060 --> 03:03:22,859
then finally we're going to come back
4053
03:03:22,859 --> 03:03:25,500
right here at the top of our layout and
4054
03:03:25,500 --> 03:03:27,660
I'll show you how easy it is to
4055
03:03:27,660 --> 03:03:30,540
implement everything using refine
4056
03:03:30,540 --> 03:03:32,880
with that said we can now go to the back
4057
03:03:32,880 --> 03:03:37,200
end so file explorer server controllers
4058
03:03:37,200 --> 03:03:39,660
property controller
4059
03:03:39,660 --> 03:03:42,180
and inside of the get all properties I'm
4060
03:03:42,180 --> 03:03:44,160
gonna show you how to add additional
4061
03:03:44,160 --> 03:03:46,620
logic so we can fetch all of the
4062
03:03:46,620 --> 03:03:49,439
properties based on pagination filtering
4063
03:03:49,439 --> 03:03:52,560
and sorting so let's get started
4064
03:03:52,560 --> 03:03:54,899
now we have created the layout for all
4065
03:03:54,899 --> 03:03:56,580
of these and the refine will
4066
03:03:56,580 --> 03:03:59,340
automatically pass it back to the server
4067
03:03:59,340 --> 03:04:01,140
so it's going to pass it of course
4068
03:04:01,140 --> 03:04:04,439
through rec.query so right at the top we
4069
03:04:04,439 --> 03:04:06,779
can say cons and we can destructure
4070
03:04:06,779 --> 03:04:09,600
something from reg.query or rather is
4071
03:04:09,600 --> 03:04:12,060
equal to reg.query the first thing is
4072
03:04:12,060 --> 03:04:14,100
going to be underscore end we're going
4073
03:04:14,100 --> 03:04:16,200
to have underscore order is it ascending
4074
03:04:16,200 --> 03:04:18,000
or descending it's going to be
4075
03:04:18,000 --> 03:04:20,100
underscore start from where are we
4076
03:04:20,100 --> 03:04:22,020
starting from which element we're going
4077
03:04:22,020 --> 03:04:24,120
to have an underscore sort and we're
4078
03:04:24,120 --> 03:04:27,180
going to have title underscore like so
4079
03:04:27,180 --> 03:04:28,800
that's going to be what the title is
4080
03:04:28,800 --> 03:04:31,260
like used for filtering right here by
4081
03:04:31,260 --> 03:04:32,580
title
4082
03:04:32,580 --> 03:04:34,800
and we can set the default value for
4083
03:04:34,800 --> 03:04:37,439
that to be equal to an empty string and
4084
03:04:37,439 --> 03:04:39,180
finally we're going to have a property
4085
03:04:39,180 --> 03:04:41,399
type which is also going to have a
4086
03:04:41,399 --> 03:04:43,680
default value of an empty string if it
4087
03:04:43,680 --> 03:04:47,399
doesn't exist great now we can also form
4088
03:04:47,399 --> 03:04:50,040
our query so we can say const query is
4089
03:04:50,040 --> 03:04:52,920
equal to an empty object and then only
4090
03:04:52,920 --> 03:04:56,399
if we have property type so if property
4091
03:04:56,399 --> 03:04:59,160
type is not equal to an empty string
4092
03:04:59,160 --> 03:05:02,399
then we want to add our query to the
4093
03:05:02,399 --> 03:05:06,180
query so query dot property type
4094
03:05:06,180 --> 03:05:09,000
is equal to property type so this is
4095
03:05:09,000 --> 03:05:11,640
ensuring that we only query or filter if
4096
03:05:11,640 --> 03:05:14,460
we do have that query passed in and the
4097
03:05:14,460 --> 03:05:16,920
same things goes for the if title like
4098
03:05:16,920 --> 03:05:19,680
so if it actually exists
4099
03:05:19,680 --> 03:05:23,760
like this then we can say query.title is
4100
03:05:23,760 --> 03:05:27,359
equal to dollar sign regex or regex is
4101
03:05:27,359 --> 03:05:29,939
equal to title like and then options I
4102
03:05:29,939 --> 03:05:32,580
that means case insensitive meaning if
4103
03:05:32,580 --> 03:05:34,800
we type it all uppercase or lowercase
4104
03:05:34,800 --> 03:05:37,740
it's still going to find it great so now
4105
03:05:37,740 --> 03:05:40,500
we have created a query based on which
4106
03:05:40,500 --> 03:05:43,020
we can search for these properties so
4107
03:05:43,020 --> 03:05:44,939
what we can do first is we can get the
4108
03:05:44,939 --> 03:05:47,040
count of all properties
4109
03:05:47,040 --> 03:05:48,660
that's going to be helpful with the
4110
03:05:48,660 --> 03:05:52,020
pagination const count is equal to a
4111
03:05:52,020 --> 03:05:55,340
weight property dot count
4112
03:05:55,340 --> 03:05:56,939
documents
4113
03:05:56,939 --> 03:05:58,979
like this and then we can pass in the
4114
03:05:58,979 --> 03:06:01,380
query make sure that it is passed inside
4115
03:06:01,380 --> 03:06:04,680
of brackets like this then we can get
4116
03:06:04,680 --> 03:06:06,840
the properties but we will no longer
4117
03:06:06,840 --> 03:06:08,520
simply get them by finding everything
4118
03:06:08,520 --> 03:06:10,740
we're going to pass additional filters
4119
03:06:10,740 --> 03:06:14,399
so let's put that in a new line
4120
03:06:14,399 --> 03:06:17,640
dot find and we have that limit later on
4121
03:06:17,640 --> 03:06:20,100
so let's modify the find not everything
4122
03:06:20,100 --> 03:06:22,080
but rather we're going to pass in our
4123
03:06:22,080 --> 03:06:24,540
query to only find elements based on the
4124
03:06:24,540 --> 03:06:26,880
specific parameters then we're going to
4125
03:06:26,880 --> 03:06:29,760
limit it to that's the underscore end
4126
03:06:29,760 --> 03:06:32,819
then we want to skip a specific number
4127
03:06:32,819 --> 03:06:35,580
of elements that is underscore start and
4128
03:06:35,580 --> 03:06:37,680
then we want to sort things and that's
4129
03:06:37,680 --> 03:06:39,300
going to be sorted by the parameter
4130
03:06:39,300 --> 03:06:42,000
underscore sort and the Order of
4131
03:06:42,000 --> 03:06:44,160
underscore order that can be ascending
4132
03:06:44,160 --> 03:06:45,779
or descending and that's going to be
4133
03:06:45,779 --> 03:06:48,420
this sort price right here and finally
4134
03:06:48,420 --> 03:06:50,399
we want to refine to know the total
4135
03:06:50,399 --> 03:06:51,960
number of elements and we're going to
4136
03:06:51,960 --> 03:06:53,819
pass that through headers so we can say
4137
03:06:53,819 --> 03:06:56,100
res dot header
4138
03:06:56,100 --> 03:07:00,120
of x dash total Dash count is going to
4139
03:07:00,120 --> 03:07:02,880
be set to count and then also rest that
4140
03:07:02,880 --> 03:07:08,160
header of axis Dash control Dash expose
4141
03:07:08,160 --> 03:07:12,479
Dash headers is going to be set to x
4142
03:07:12,479 --> 03:07:15,120
dash total Dash count this will allow us
4143
03:07:15,120 --> 03:07:17,399
to expose this header to the front end
4144
03:07:17,399 --> 03:07:19,439
so that we know the total count of our
4145
03:07:19,439 --> 03:07:20,580
resources
4146
03:07:20,580 --> 03:07:22,680
and finally the only thing we have to do
4147
03:07:22,680 --> 03:07:26,700
is res that status of 200 and pass over
4148
03:07:26,700 --> 03:07:30,779
all of the properties that is it and now
4149
03:07:30,779 --> 03:07:33,359
a refine is going to have all the data
4150
03:07:33,359 --> 03:07:35,640
it needs to really easily Implement
4151
03:07:35,640 --> 03:07:38,939
machination sorting and filtering let me
4152
03:07:38,939 --> 03:07:40,979
show you how simple that is let's start
4153
03:07:40,979 --> 03:07:42,899
from top to bottom and from left to
4154
03:07:42,899 --> 03:07:45,479
right that means that our first sorting
4155
03:07:45,479 --> 03:07:47,660
ability is going to be to sort the price
4156
03:07:47,660 --> 03:07:50,700
to sort the price we need to know what
4157
03:07:50,700 --> 03:07:52,979
is the current price sort so we can say
4158
03:07:52,979 --> 03:07:56,939
const current price is equal to sorter
4159
03:07:56,939 --> 03:08:00,660
dot find we want to find the item and
4160
03:08:00,660 --> 03:08:02,580
then item.field
4161
03:08:02,580 --> 03:08:05,399
is triple equal to price so that's what
4162
03:08:05,399 --> 03:08:07,260
we're trying to get and then we want to
4163
03:08:07,260 --> 03:08:10,140
do questionmark dot order this will give
4164
03:08:10,140 --> 03:08:12,300
us the current order of the price
4165
03:08:12,300 --> 03:08:14,760
property now that we have that we can
4166
03:08:14,760 --> 03:08:18,060
create a special const toggle sort
4167
03:08:18,060 --> 03:08:20,460
function which is going to take in a
4168
03:08:20,460 --> 03:08:23,580
field of a type string and it's going to
4169
03:08:23,580 --> 03:08:27,300
return set sorter like this we want to
4170
03:08:27,300 --> 03:08:30,060
pass in an array and then an object
4171
03:08:30,060 --> 03:08:32,640
where we pass in the field and then we
4172
03:08:32,640 --> 03:08:35,220
pass in an order so order is going to be
4173
03:08:35,220 --> 03:08:38,220
if the current price is currently set to
4174
03:08:38,220 --> 03:08:41,160
ASC meaning ascending then we want to
4175
03:08:41,160 --> 03:08:43,200
change it to descending otherwise it's
4176
03:08:43,200 --> 03:08:45,720
going to be ascending and now we can use
4177
03:08:45,720 --> 03:08:48,300
this current price and toggle sort on
4178
03:08:48,300 --> 03:08:51,180
this button so let's scroll down
4179
03:08:51,180 --> 03:08:53,760
there we go this is our first button
4180
03:08:53,760 --> 03:08:55,800
right here sword price doesn't really
4181
03:08:55,800 --> 03:08:59,779
say a lot so we can go to Google
4182
03:09:00,540 --> 03:09:02,939
and we can search for Arrow up and we
4183
03:09:02,939 --> 03:09:05,340
can copy this character right here so we
4184
03:09:05,340 --> 03:09:07,640
can say sort price and then we can check
4185
03:09:07,640 --> 03:09:11,580
if current price is triple equal to
4186
03:09:11,580 --> 03:09:14,760
ascending then we can show
4187
03:09:14,760 --> 03:09:16,920
D Arrow up
4188
03:09:16,920 --> 03:09:19,800
otherwise we can show the arrow down you
4189
03:09:19,800 --> 03:09:21,300
can also search for that arrow down
4190
03:09:21,300 --> 03:09:24,180
simply right here arrow down and then
4191
03:09:24,180 --> 03:09:25,560
you can copy it
4192
03:09:25,560 --> 03:09:28,500
there we go now if we save this and go
4193
03:09:28,500 --> 03:09:30,060
back
4194
03:09:30,060 --> 03:09:32,640
you can see we have sort price down and
4195
03:09:32,640 --> 03:09:33,899
of course we have to add the handle
4196
03:09:33,899 --> 03:09:36,779
click and that is as easy as setting the
4197
03:09:36,779 --> 03:09:40,200
toggle sort and then passing the price
4198
03:09:40,200 --> 03:09:42,000
as the parameter
4199
03:09:42,000 --> 03:09:44,939
there we go if we save that you can see
4200
03:09:44,939 --> 03:09:48,600
right now we have 1500 and if I click
4201
03:09:48,600 --> 03:09:51,060
five hundred one thousand of course this
4202
03:09:51,060 --> 03:09:53,460
is not maybe as interesting as if we had
4203
03:09:53,460 --> 03:09:56,279
like 10 or 50 elements but you can still
4204
03:09:56,279 --> 03:09:58,800
see that sorting fully works right out
4205
03:09:58,800 --> 03:10:00,720
of the box and this was so simple to
4206
03:10:00,720 --> 03:10:03,240
implement using our own custom backend
4207
03:10:03,240 --> 03:10:06,660
and refine now we're going to focus on
4208
03:10:06,660 --> 03:10:10,439
filtering by title so we can scroll up
4209
03:10:10,439 --> 03:10:13,380
and same as we got the current price we
4210
03:10:13,380 --> 03:10:15,240
also need to get the current filter
4211
03:10:15,240 --> 03:10:18,660
values so we can say cons current filter
4212
03:10:18,660 --> 03:10:23,100
values is equal to use memo we're going
4213
03:10:23,100 --> 03:10:24,960
to use memo just to save some memory and
4214
03:10:24,960 --> 03:10:26,520
to make it more efficient
4215
03:10:26,520 --> 03:10:28,680
now that use memo is only going to
4216
03:10:28,680 --> 03:10:31,260
change once we change the filters like
4217
03:10:31,260 --> 03:10:33,720
this and then that use memo has to be
4218
03:10:33,720 --> 03:10:36,120
imported from react so at the top you
4219
03:10:36,120 --> 03:10:39,540
can import use Memo from react inside of
4220
03:10:39,540 --> 03:10:41,580
there we first need to get all of our
4221
03:10:41,580 --> 03:10:45,120
logical filters so const logical filters
4222
03:10:45,120 --> 03:10:49,620
is equal to filters dot flat map now
4223
03:10:49,620 --> 03:10:51,359
flat map is a special JavaScript
4224
03:10:51,359 --> 03:10:53,700
structure it is similar to an array but
4225
03:10:53,700 --> 03:10:56,040
in this case refine theme recommends to
4226
03:10:56,040 --> 03:10:57,840
use a flat map to make this more
4227
03:10:57,840 --> 03:10:58,740
efficient
4228
03:10:58,740 --> 03:11:01,200
now inside of here we're gonna have an
4229
03:11:01,200 --> 03:11:03,359
item and then we want to instantly
4230
03:11:03,359 --> 03:11:06,060
return meaning like this
4231
03:11:06,060 --> 03:11:07,439
field
4232
03:11:07,439 --> 03:11:10,200
in item
4233
03:11:10,200 --> 03:11:12,420
so if that exists then we want to return
4234
03:11:12,420 --> 03:11:14,700
an item otherwise we want to return an
4235
03:11:14,700 --> 03:11:17,460
empty array like this and it looks like
4236
03:11:17,460 --> 03:11:19,979
I'm missing one closing parenthesis now
4237
03:11:19,979 --> 03:11:22,080
that we have these logical filters we
4238
03:11:22,080 --> 03:11:24,840
can return an object where we're going
4239
03:11:24,840 --> 03:11:28,380
to change the title logical filters dot
4240
03:11:28,380 --> 03:11:30,660
find where we're going to get an item
4241
03:11:30,660 --> 03:11:33,439
and then we're gonna return
4242
03:11:33,439 --> 03:11:37,740
item.field is triple equal to title and
4243
03:11:37,740 --> 03:11:40,080
then we can do question mark dot value
4244
03:11:40,080 --> 03:11:42,899
or an empty string this is going to
4245
03:11:42,899 --> 03:11:45,840
allow us to filter everything by title
4246
03:11:45,840 --> 03:11:47,880
now we can use this current filter
4247
03:11:47,880 --> 03:11:51,600
values inside of our text field so right
4248
03:11:51,600 --> 03:11:54,060
here we can go to the text field the
4249
03:11:54,060 --> 03:11:57,080
value is going to be current filter
4250
03:11:57,080 --> 03:12:00,899
values dot title and then the on change
4251
03:12:00,899 --> 03:12:04,200
we always get a key press down event
4252
03:12:04,200 --> 03:12:07,380
and there we can call these set filters
4253
03:12:07,380 --> 03:12:10,319
pass in an array and then pass in an
4254
03:12:10,319 --> 03:12:12,899
object where the field is going to be
4255
03:12:12,899 --> 03:12:16,500
set to title the operator is going to be
4256
03:12:16,500 --> 03:12:18,660
set to contains so that's not going to
4257
03:12:18,660 --> 03:12:20,819
be just the exact match we can also make
4258
03:12:20,819 --> 03:12:23,100
it just contains which is great usually
4259
03:12:23,100 --> 03:12:24,359
you would have to make this work
4260
03:12:24,359 --> 03:12:27,240
manually but refine did it for us and
4261
03:12:27,240 --> 03:12:30,600
then finally we have value now value is
4262
03:12:30,600 --> 03:12:33,840
going to be e dot current Target
4263
03:12:33,840 --> 03:12:35,880
dot value
4264
03:12:35,880 --> 03:12:38,700
if that exists then we want to have the
4265
03:12:38,700 --> 03:12:41,460
E dot current Target
4266
03:12:41,460 --> 03:12:44,399
dot value else we want to leave it as
4267
03:12:44,399 --> 03:12:46,200
undefined
4268
03:12:46,200 --> 03:12:47,640
there we go
4269
03:12:47,640 --> 03:12:49,979
and with that done our filtering should
4270
03:12:49,979 --> 03:12:52,439
work so let's test it out we have a
4271
03:12:52,439 --> 03:12:54,600
lavender apartment and we have a star
4272
03:12:54,600 --> 03:12:56,700
Sun Hotel Apartment so if we start
4273
03:12:56,700 --> 03:12:58,859
typing for apartment
4274
03:12:58,859 --> 03:13:01,500
both of them should be here if we try
4275
03:13:01,500 --> 03:13:04,200
with lavender you can see immediately
4276
03:13:04,200 --> 03:13:06,779
that only Lavender is here but even if
4277
03:13:06,779 --> 03:13:09,960
you just type L A immediately it's there
4278
03:13:09,960 --> 03:13:12,319
and if we start typing stars and hotel
4279
03:13:12,319 --> 03:13:15,359
immediately that works again right now
4280
03:13:15,359 --> 03:13:17,279
you can only imagine how functional this
4281
03:13:17,279 --> 03:13:20,460
would be if we had like 50 elements that
4282
03:13:20,460 --> 03:13:22,319
would make it so handy for us to be able
4283
03:13:22,319 --> 03:13:24,960
to search through it sort by price and
4284
03:13:24,960 --> 03:13:27,720
do all of this and now we're gonna also
4285
03:13:27,720 --> 03:13:31,439
implement the filter by property type so
4286
03:13:31,439 --> 03:13:34,020
right now we just have all but maybe we
4287
03:13:34,020 --> 03:13:36,600
just want to search for Villas or condos
4288
03:13:36,600 --> 03:13:39,359
or apartments so let's Implement that
4289
03:13:39,359 --> 03:13:42,060
right away we can scroll above to our
4290
03:13:42,060 --> 03:13:44,640
filters and we can return right below
4291
03:13:44,640 --> 03:13:47,580
the title property type
4292
03:13:47,580 --> 03:13:50,640
that's going to be logical filters
4293
03:13:50,640 --> 03:13:52,080
dot find
4294
03:13:52,080 --> 03:13:54,260
there we have an item
4295
03:13:54,260 --> 03:13:57,359
item.field is triple equal to property
4296
03:13:57,359 --> 03:14:00,359
type and then question mark.value or an
4297
03:14:00,359 --> 03:14:02,760
empty string with that we can scroll
4298
03:14:02,760 --> 03:14:05,160
down to where we have our select
4299
03:14:05,160 --> 03:14:07,500
and then we can essentially copy what we
4300
03:14:07,500 --> 03:14:10,439
had right here in our search by text
4301
03:14:10,439 --> 03:14:14,040
field so we can copy the on change as
4302
03:14:14,040 --> 03:14:15,720
well as the value so let's go ahead and
4303
03:14:15,720 --> 03:14:18,300
copy that and let's override the current
4304
03:14:18,300 --> 03:14:20,399
value in the on change now we are
4305
03:14:20,399 --> 03:14:22,439
missing one closing parenthesis right
4306
03:14:22,439 --> 03:14:25,140
here and we're missing one more so if
4307
03:14:25,140 --> 03:14:26,640
you properly close this that should be
4308
03:14:26,640 --> 03:14:28,500
looking good but now there are just some
4309
03:14:28,500 --> 03:14:29,760
minor differences we have to make
4310
03:14:29,760 --> 03:14:32,700
current filter values dot is going to be
4311
03:14:32,700 --> 03:14:36,060
property type and Below field is going
4312
03:14:36,060 --> 03:14:38,340
to be property type the operator is
4313
03:14:38,340 --> 03:14:41,040
going to be EQ meaning equals and then
4314
03:14:41,040 --> 03:14:43,380
the value is simply going to be e dot
4315
03:14:43,380 --> 03:14:46,979
Target dot value there we go now if we
4316
03:14:46,979 --> 03:14:48,660
save you can see we're good but we only
4317
03:14:48,660 --> 03:14:50,040
have one property
4318
03:14:50,040 --> 03:14:52,979
and now right here still inside of set
4319
03:14:52,979 --> 03:14:55,319
filters meaning right here after this
4320
03:14:55,319 --> 03:14:58,319
array we want to say replace because we
4321
03:14:58,319 --> 03:14:59,880
want to immediately replace the value
4322
03:14:59,880 --> 03:15:01,620
that we click
4323
03:15:01,620 --> 03:15:04,020
and now we just have one value so let's
4324
03:15:04,020 --> 03:15:07,020
add additional ones we can have value of
4325
03:15:07,020 --> 03:15:09,960
nothing equal to all
4326
03:15:09,960 --> 03:15:12,000
but then we can create a dynamic block
4327
03:15:12,000 --> 03:15:14,819
of code and there we can create an array
4328
03:15:14,819 --> 03:15:17,279
web apartment
4329
03:15:17,279 --> 03:15:19,740
then we can do Villa
4330
03:15:19,740 --> 03:15:22,200
we can do a farmhouse
4331
03:15:22,200 --> 03:15:24,540
let's do a condos
4332
03:15:24,540 --> 03:15:27,420
let's do a townhouse
4333
03:15:27,420 --> 03:15:30,300
let's do a duplex
4334
03:15:30,300 --> 03:15:32,760
finally we can do a studio
4335
03:15:32,760 --> 03:15:34,800
and a chalet
4336
03:15:34,800 --> 03:15:36,840
there we go and then we can map over
4337
03:15:36,840 --> 03:15:40,080
that by type and then for each one of
4338
03:15:40,080 --> 03:15:42,300
these types we're going to return a menu
4339
03:15:42,300 --> 03:15:46,740
item that menu item is going to have a
4340
03:15:46,740 --> 03:15:49,020
key equal to type since they're all
4341
03:15:49,020 --> 03:15:53,340
unique and the value equal to type dot
4342
03:15:53,340 --> 03:15:57,180
to lower case that's important and then
4343
03:15:57,180 --> 03:15:59,340
finally they're going to render the type
4344
03:15:59,340 --> 03:16:02,100
now if we save that you should be able
4345
03:16:02,100 --> 03:16:04,080
to see all of these appear right there
4346
03:16:04,080 --> 03:16:06,180
and right off the bat since we
4347
03:16:06,180 --> 03:16:07,979
implemented filtering right here at the
4348
03:16:07,979 --> 03:16:10,319
top it should work so if we search for
4349
03:16:10,319 --> 03:16:12,300
apartment there we go this is the
4350
03:16:12,300 --> 03:16:14,819
apartment and if I'm not mistaken the
4351
03:16:14,819 --> 03:16:17,279
other one was set as a villa so if you
4352
03:16:17,279 --> 03:16:19,380
click you can see that the Villa remains
4353
03:16:19,380 --> 03:16:21,479
for every other one there are no
4354
03:16:21,479 --> 03:16:24,180
properties so we have apartment we have
4355
03:16:24,180 --> 03:16:26,760
a villa and we have all again imagine
4356
03:16:26,760 --> 03:16:28,200
how this would look if we had more
4357
03:16:28,200 --> 03:16:31,260
properties great finally the last
4358
03:16:31,260 --> 03:16:33,000
missing piece of the puzzle is the
4359
03:16:33,000 --> 03:16:36,540
pagination and would you believe me if I
4360
03:16:36,540 --> 03:16:39,000
told you that there's nothing else that
4361
03:16:39,000 --> 03:16:40,979
we have to do to make the pagination
4362
03:16:40,979 --> 03:16:43,979
work previous and next pages are already
4363
03:16:43,979 --> 03:16:46,380
fully functional but are right now
4364
03:16:46,380 --> 03:16:48,720
disabled and for a reason that's because
4365
03:16:48,720 --> 03:16:51,479
we only have two elements and our
4366
03:16:51,479 --> 03:16:54,120
current page is showing 10. so the last
4367
03:16:54,120 --> 03:16:55,920
thing we have to do is we can use the
4368
03:16:55,920 --> 03:16:57,359
set page size
4369
03:16:57,359 --> 03:17:00,779
down below that is right here
4370
03:17:00,779 --> 03:17:03,540
inside of this custom button instead of
4371
03:17:03,540 --> 03:17:06,359
this custom select for that matter where
4372
03:17:06,359 --> 03:17:07,979
we can get the event
4373
03:17:07,979 --> 03:17:11,640
and then we can say set page size
4374
03:17:11,640 --> 03:17:16,680
to be equal to e dot Target dot value
4375
03:17:16,680 --> 03:17:19,380
if we have that then we want to return a
4376
03:17:19,380 --> 03:17:20,660
number of
4377
03:17:20,660 --> 03:17:23,460
e.target.value else we want to return
4378
03:17:23,460 --> 03:17:26,700
10. so with this we'll be able to set
4379
03:17:26,700 --> 03:17:29,100
the total number of elements on the page
4380
03:17:29,100 --> 03:17:33,479
30 40 50. now this was just a phenomenal
4381
03:17:33,479 --> 03:17:35,939
bonus that I decided to include in this
4382
03:17:35,939 --> 03:17:36,779
video
4383
03:17:36,779 --> 03:17:39,840
the pagination sorting and filtering The
4384
03:17:39,840 --> 03:17:42,000
crucial parts of every single crud
4385
03:17:42,000 --> 03:17:43,140
application
4386
03:17:43,140 --> 03:17:44,939
since this was an addition to this video
4387
03:17:44,939 --> 03:17:47,100
that wasn't initially planned you can
4388
03:17:47,100 --> 03:17:49,020
keep it here and keep working on the
4389
03:17:49,020 --> 03:17:50,700
application it's still gonna work for
4390
03:17:50,700 --> 03:17:53,040
you perfectly but in future scenes of
4391
03:17:53,040 --> 03:17:55,020
this video when I am viewing the old
4392
03:17:55,020 --> 03:17:57,120
properties these features are not going
4393
03:17:57,120 --> 03:17:59,399
to be here but not to worry you have
4394
03:17:59,399 --> 03:18:01,200
them implemented and they're going to
4395
03:18:01,200 --> 03:18:03,240
work perfectly for you when you deploy
4396
03:18:03,240 --> 03:18:06,120
the application great with that said we
4397
03:18:06,120 --> 03:18:08,520
can go to file explorer and then that's
4398
03:18:08,520 --> 03:18:12,060
going to be property details to get
4399
03:18:12,060 --> 03:18:14,399
started with property details we can
4400
03:18:14,399 --> 03:18:16,560
first import a couple of things from
4401
03:18:16,560 --> 03:18:19,740
Material UI such as typography
4402
03:18:19,740 --> 03:18:23,279
a box and a stack we're already used to
4403
03:18:23,279 --> 03:18:25,800
all of these already let's also say from
4404
03:18:25,800 --> 03:18:28,859
add pan card forward slash refine Dash
4405
03:18:28,859 --> 03:18:31,979
mui now we also want to get a couple of
4406
03:18:31,979 --> 03:18:34,260
hooks coming from refine that's going to
4407
03:18:34,260 --> 03:18:36,779
be use delete because from The Details
4408
03:18:36,779 --> 03:18:38,960
page we're going to delete our resources
4409
03:18:38,960 --> 03:18:42,180
the use get identity
4410
03:18:42,180 --> 03:18:45,120
this is to determine whether the
4411
03:18:45,120 --> 03:18:46,920
property that we're looking at is
4412
03:18:46,920 --> 03:18:49,500
created by us or another user and then
4413
03:18:49,500 --> 03:18:51,660
finally the use show which is going to
4414
03:18:51,660 --> 03:18:53,760
allow us to pull all of the data for
4415
03:18:53,760 --> 03:18:55,920
this specific property and that is
4416
03:18:55,920 --> 03:18:58,380
coming from at pan card forward slash
4417
03:18:58,380 --> 03:19:01,620
refine Dash core finally we can also
4418
03:19:01,620 --> 03:19:05,160
import the use params to get the ID of a
4419
03:19:05,160 --> 03:19:07,800
specific property as well as use
4420
03:19:07,800 --> 03:19:10,319
navigate and this is coming from add
4421
03:19:10,319 --> 03:19:13,260
punkod forward slash refine Dash react
4422
03:19:13,260 --> 03:19:16,859
Dash router Dash V6 and we can also get
4423
03:19:16,859 --> 03:19:20,220
a couple of icons so let's import a chat
4424
03:19:20,220 --> 03:19:21,720
bubble
4425
03:19:21,720 --> 03:19:23,580
a delete
4426
03:19:23,580 --> 03:19:25,859
edit phone
4427
03:19:25,859 --> 03:19:29,580
place and a star and all of that is
4428
03:19:29,580 --> 03:19:30,779
coming from
4429
03:19:30,779 --> 03:19:35,100
add mui forward slash icons material and
4430
03:19:35,100 --> 03:19:36,899
we'll be also utilizing our custom
4431
03:19:36,899 --> 03:19:39,600
button so we can say import custom
4432
03:19:39,600 --> 03:19:41,100
button
4433
03:19:41,100 --> 03:19:42,660
coming from
4434
03:19:42,660 --> 03:19:44,580
components
4435
03:19:44,580 --> 03:19:48,120
great now let's make use of all of these
4436
03:19:48,120 --> 03:19:50,340
great hooks that we have imported
4437
03:19:50,340 --> 03:19:53,760
that's going to be const navigate
4438
03:19:53,760 --> 03:19:57,060
is equal to use navigate
4439
03:19:57,060 --> 03:19:59,700
and immediately we have to rename our
4440
03:19:59,700 --> 03:20:02,040
property details to property details
4441
03:20:02,040 --> 03:20:04,979
with a capital p
4442
03:20:04,979 --> 03:20:07,319
then let's try to get our current user
4443
03:20:07,319 --> 03:20:11,939
by saying const data rename as user is
4444
03:20:11,939 --> 03:20:14,580
equal to use get identity
4445
03:20:14,580 --> 03:20:17,939
then we can get the ID from params this
4446
03:20:17,939 --> 03:20:20,580
is the ID of the current resource we're
4447
03:20:20,580 --> 03:20:23,640
trying to view then we can get const
4448
03:20:23,640 --> 03:20:27,660
mutate is equal to use delete this
4449
03:20:27,660 --> 03:20:29,460
function will allow us to quickly delete
4450
03:20:29,460 --> 03:20:32,819
a resource and most importantly we can
4451
03:20:32,819 --> 03:20:37,859
say const query result is equal to use
4452
03:20:37,859 --> 03:20:41,040
show and we don't have to pass it
4453
03:20:41,040 --> 03:20:42,420
anything
4454
03:20:42,420 --> 03:20:44,939
refine is going to be smart enough to
4455
03:20:44,939 --> 03:20:47,399
check our URL and to understand that we
4456
03:20:47,399 --> 03:20:49,680
are on the forward slash properties show
4457
03:20:49,680 --> 03:20:52,260
and then the ID it's going to grab it
4458
03:20:52,260 --> 03:20:54,420
and it's immediately going to make a
4459
03:20:54,420 --> 03:20:57,600
call to our backend to get the data for
4460
03:20:57,600 --> 03:20:59,460
the resource we're currently looking at
4461
03:20:59,460 --> 03:21:01,620
isn't that great
4462
03:21:01,620 --> 03:21:03,899
now we can destructure that resource
4463
03:21:03,899 --> 03:21:06,600
further by getting the data that is
4464
03:21:06,600 --> 03:21:09,840
loading as well as the as error from it
4465
03:21:09,840 --> 03:21:12,479
so that's going to be equal to query
4466
03:21:12,479 --> 03:21:15,000
result now of course it doesn't even
4467
03:21:15,000 --> 03:21:17,220
make sense to consulate the data because
4468
03:21:17,220 --> 03:21:19,620
it won't be there we haven't yet created
4469
03:21:19,620 --> 03:21:22,020
the backend endpoint to get the data
4470
03:21:22,020 --> 03:21:24,720
about one specific resource so to get
4471
03:21:24,720 --> 03:21:27,600
the property detail we can first get the
4472
03:21:27,600 --> 03:21:30,240
ID of the property we're trying to get
4473
03:21:30,240 --> 03:21:33,899
by going to rec params and then we can
4474
03:21:33,899 --> 03:21:36,840
check if the property exists
4475
03:21:36,840 --> 03:21:39,660
and then if it does and we can check
4476
03:21:39,660 --> 03:21:42,240
that by trying to reach it by saying a
4477
03:21:42,240 --> 03:21:46,380
weight property dot find one we can pass
4478
03:21:46,380 --> 03:21:48,840
in an object checking the underscore ID
4479
03:21:48,840 --> 03:21:51,660
if it is equal to the underscore ID we
4480
03:21:51,660 --> 03:21:54,060
have or rather just the ID that we got
4481
03:21:54,060 --> 03:21:55,680
from params
4482
03:21:55,680 --> 03:21:58,020
and then we can do dot populate
4483
03:21:58,020 --> 03:22:00,779
Creator if it is there because we want
4484
03:22:00,779 --> 03:22:02,819
to add the Creator to it
4485
03:22:02,819 --> 03:22:06,720
finally if it exists meaning if property
4486
03:22:06,720 --> 03:22:08,939
exists
4487
03:22:08,939 --> 03:22:11,460
then we can rest that status
4488
03:22:11,460 --> 03:22:16,140
of 200 and then dot Json property exists
4489
03:22:16,140 --> 03:22:17,939
so we're going to essentially return it
4490
03:22:17,939 --> 03:22:20,279
back home
4491
03:22:20,279 --> 03:22:22,740
else if it doesn't exist so we can do
4492
03:22:22,740 --> 03:22:25,680
that right here else we can rest that
4493
03:22:25,680 --> 03:22:28,740
status of 404 and then pass something
4494
03:22:28,740 --> 03:22:32,580
like property not found like this
4495
03:22:32,580 --> 03:22:34,620
of course we have to properly close this
4496
03:22:34,620 --> 03:22:38,040
if so if we do it right here that is
4497
03:22:38,040 --> 03:22:40,580
looking good to me now if we save that
4498
03:22:40,580 --> 03:22:44,520
and if we go back to our front end we
4499
03:22:44,520 --> 03:22:47,399
can now console log the data and see if
4500
03:22:47,399 --> 03:22:50,100
we get it back let's open up inspect
4501
03:22:50,100 --> 03:22:53,640
element go to console and reload the
4502
03:22:53,640 --> 03:22:54,660
page
4503
03:22:54,660 --> 03:22:57,060
and would you look at that the data
4504
03:22:57,060 --> 03:23:00,060
object is there containing one property
4505
03:23:00,060 --> 03:23:02,399
that we have created before and one that
4506
03:23:02,399 --> 03:23:05,000
we're trying to fetch isn't that great
4507
03:23:05,000 --> 03:23:08,460
now as you can see the data is inside of
4508
03:23:08,460 --> 03:23:10,979
another object called Data so what we
4509
03:23:10,979 --> 03:23:14,180
can do right here below is say const
4510
03:23:14,180 --> 03:23:18,479
property details is equal to data
4511
03:23:18,479 --> 03:23:21,600
question mark dot data or it's going to
4512
03:23:21,600 --> 03:23:23,880
be an object like this in case it
4513
03:23:23,880 --> 03:23:26,040
doesn't exist and then we can also
4514
03:23:26,040 --> 03:23:28,800
utilize the is loading and is error by
4515
03:23:28,800 --> 03:23:31,859
saying if is loading we can simply
4516
03:23:31,859 --> 03:23:34,920
return a div that's going to say loading
4517
03:23:34,920 --> 03:23:37,920
dot dot and we're going to do the same
4518
03:23:37,920 --> 03:23:41,160
thing for error if is error
4519
03:23:41,160 --> 03:23:44,580
we're going to Simply return error
4520
03:23:44,580 --> 03:23:46,979
we don't have to have any dots in that
4521
03:23:46,979 --> 03:23:47,819
case
4522
03:23:47,819 --> 03:23:50,220
great let's fix the spelling
4523
03:23:50,220 --> 03:23:53,220
and this is looking good we can close
4524
03:23:53,220 --> 03:23:56,640
the console and now we can code the UI
4525
03:23:56,640 --> 03:23:59,580
part which are our property details
4526
03:23:59,580 --> 03:24:01,739
everything in this application and in
4527
03:24:01,739 --> 03:24:03,660
life is a box so let's create a box
4528
03:24:03,660 --> 03:24:05,100
right here
4529
03:24:05,100 --> 03:24:09,060
and then we can have a border radius
4530
03:24:09,060 --> 03:24:11,700
is equal to 15 pixels we want to make
4531
03:24:11,700 --> 03:24:14,939
this box really nice and round let's see
4532
03:24:14,939 --> 03:24:16,979
how that looks like it shouldn't be
4533
03:24:16,979 --> 03:24:19,080
anything at the start of course then
4534
03:24:19,080 --> 03:24:20,819
we're going to add a padding of 20
4535
03:24:20,819 --> 03:24:24,239
pixels as well as a BG color equal to
4536
03:24:24,239 --> 03:24:25,340
Hash
4537
03:24:25,340 --> 03:24:29,640
fcfc FC and we can add a width equal to
4538
03:24:29,640 --> 03:24:31,739
fit Dash content
4539
03:24:31,739 --> 03:24:35,160
and immediately we get this card inside
4540
03:24:35,160 --> 03:24:37,020
of that card we're gonna have a
4541
03:24:37,020 --> 03:24:40,979
typography this typography right here is
4542
03:24:40,979 --> 03:24:44,040
going to say of course details we can
4543
03:24:44,040 --> 03:24:46,920
style it just a bit by giving it a font
4544
03:24:46,920 --> 03:24:51,779
size equal to 25 and a font weight of
4545
03:24:51,779 --> 03:24:53,279
700.
4546
03:24:53,279 --> 03:24:58,080
finally a color of hash 11142d
4547
03:24:58,080 --> 03:25:00,840
and we can save that below our
4548
03:25:00,840 --> 03:25:03,660
typography we can have a box
4549
03:25:03,660 --> 03:25:06,660
and that box is going to have an empty
4550
03:25:06,660 --> 03:25:09,600
or margin top of 20 pixels
4551
03:25:09,600 --> 03:25:13,200
a display equal to flex and a flex
4552
03:25:13,200 --> 03:25:14,580
Direction
4553
03:25:14,580 --> 03:25:15,840
which is going to be a bit more
4554
03:25:15,840 --> 03:25:18,420
complicated on extra small devices it's
4555
03:25:18,420 --> 03:25:20,640
going to be a column and then on large
4556
03:25:20,640 --> 03:25:23,340
devices and larger it's going to be a
4557
03:25:23,340 --> 03:25:28,080
row and we can give it a gap equal to 4.
4558
03:25:28,080 --> 03:25:30,359
great the column of course is supposed
4559
03:25:30,359 --> 03:25:32,279
to be inside of quotes
4560
03:25:32,279 --> 03:25:35,040
now inside of that box we're gonna have
4561
03:25:35,040 --> 03:25:38,460
a couple of other boxes so right here we
4562
03:25:38,460 --> 03:25:40,859
can create a new box
4563
03:25:40,859 --> 03:25:43,500
and within that box we're going to have
4564
03:25:43,500 --> 03:25:45,300
an image
4565
03:25:45,300 --> 03:25:47,580
so we can render a self-closing image
4566
03:25:47,580 --> 03:25:50,279
tag that's going to have a source equal
4567
03:25:50,279 --> 03:25:55,260
to property details dot photo
4568
03:25:55,260 --> 03:25:57,779
and we can try to save it
4569
03:25:57,779 --> 03:25:59,760
as you can see we get this beautiful
4570
03:25:59,760 --> 03:26:02,580
Apartment image right here
4571
03:26:02,580 --> 03:26:05,580
now to this box we can give it a flex
4572
03:26:05,580 --> 03:26:09,779
equal to one as well as Max width
4573
03:26:09,779 --> 03:26:11,600
of
4574
03:26:11,600 --> 03:26:15,420
764. I found this value to work best
4575
03:26:15,420 --> 03:26:17,399
that's going to contain the image just a
4576
03:26:17,399 --> 03:26:20,520
bit we can give it an ALT tag equal to
4577
03:26:20,520 --> 03:26:24,120
property details dot title a height
4578
03:26:24,120 --> 03:26:28,080
equal to 546 I found to work the best
4579
03:26:28,080 --> 03:26:32,279
and then a style equal to object fit
4580
03:26:32,279 --> 03:26:34,500
which is going to be set to cover
4581
03:26:34,500 --> 03:26:37,319
as well as a border radius
4582
03:26:37,319 --> 03:26:39,420
set to 10 pixels
4583
03:26:39,420 --> 03:26:41,040
like this
4584
03:26:41,040 --> 03:26:43,080
if we save that it's going to become
4585
03:26:43,080 --> 03:26:45,720
just a bit more rounded and we can give
4586
03:26:45,720 --> 03:26:48,359
it a class name equal to property
4587
03:26:48,359 --> 03:26:52,800
underscore details Dash IMG this is a
4588
03:26:52,800 --> 03:26:54,840
special property or a class that was
4589
03:26:54,840 --> 03:26:56,279
provided to you at the start of the
4590
03:26:56,279 --> 03:26:58,680
video but as you can see it's not really
4591
03:26:58,680 --> 03:27:00,540
getting applied
4592
03:27:00,540 --> 03:27:03,000
and that just made me think remember
4593
03:27:03,000 --> 03:27:05,700
when we had to add that special not
4594
03:27:05,700 --> 03:27:08,819
underlined property right here that was
4595
03:27:08,819 --> 03:27:10,739
in the property
4596
03:27:10,739 --> 03:27:13,260
card right there we had to add this
4597
03:27:13,260 --> 03:27:15,420
special text decoration none we can
4598
03:27:15,420 --> 03:27:17,819
remove that the reason for that was
4599
03:27:17,819 --> 03:27:19,800
looks like our styles are now getting
4600
03:27:19,800 --> 03:27:23,160
applied not here and also not here
4601
03:27:23,160 --> 03:27:27,120
so inside of our app.tsx
4602
03:27:27,120 --> 03:27:28,680
if we go here
4603
03:27:28,680 --> 03:27:31,620
I think that I imported the index.css
4604
03:27:31,620 --> 03:27:35,279
Styles but I might be wrong yep they're
4605
03:27:35,279 --> 03:27:39,420
not here so let's go to our index.tsx
4606
03:27:39,420 --> 03:27:42,300
and inside of here we have to just add
4607
03:27:42,300 --> 03:27:45,500
one line and that is import
4608
03:27:45,500 --> 03:27:49,020
index.css this is going to add a few of
4609
03:27:49,020 --> 03:27:50,399
those styles that we had at the
4610
03:27:50,399 --> 03:27:52,979
beginning that I provide you with so if
4611
03:27:52,979 --> 03:27:54,960
we look into here
4612
03:27:54,960 --> 03:27:56,819
there we go
4613
03:27:56,819 --> 03:27:59,040
and as you can see that already made it
4614
03:27:59,040 --> 03:28:00,720
just a bit better and if you go here
4615
03:28:00,720 --> 03:28:03,120
that image is just styled in a better
4616
03:28:03,120 --> 03:28:05,100
way so now those styles are being
4617
03:28:05,100 --> 03:28:07,140
applied and we can continue with our
4618
03:28:07,140 --> 03:28:09,239
life we're gonna go back to property
4619
03:28:09,239 --> 03:28:13,260
details in that box and then below that
4620
03:28:13,260 --> 03:28:15,899
image we're gonna have yet another box
4621
03:28:15,899 --> 03:28:18,660
believe it or not this box is going to
4622
03:28:18,660 --> 03:28:21,899
have a margin top or empty equal to 15
4623
03:28:21,899 --> 03:28:23,819
pixels
4624
03:28:23,819 --> 03:28:26,580
and inside of there we're gonna have a
4625
03:28:26,580 --> 03:28:28,560
stack
4626
03:28:28,560 --> 03:28:31,439
that stack is going to contain a
4627
03:28:31,439 --> 03:28:33,660
typography
4628
03:28:33,660 --> 03:28:35,939
and that typography is going to render
4629
03:28:35,939 --> 03:28:37,800
the property details
4630
03:28:37,800 --> 03:28:41,100
dot property type
4631
03:28:41,100 --> 03:28:43,380
there we go so if we save it you should
4632
03:28:43,380 --> 03:28:45,500
be able to see that this is an apartment
4633
03:28:45,500 --> 03:28:48,600
now of course let's style it just a bit
4634
03:28:48,600 --> 03:28:52,080
now below the property type let's also
4635
03:28:52,080 --> 03:28:54,180
create a box
4636
03:28:54,180 --> 03:28:56,460
and that box is going to render
4637
03:28:56,460 --> 03:29:00,600
something dynamically an array of 1 2 3
4638
03:29:00,600 --> 03:29:02,760
4 5 elements
4639
03:29:02,760 --> 03:29:05,880
through which we're going to map over do
4640
03:29:05,880 --> 03:29:07,560
you know what this is
4641
03:29:07,560 --> 03:29:10,500
well these are stars so for now we're
4642
03:29:10,500 --> 03:29:12,420
going to just say that every single
4643
03:29:12,420 --> 03:29:14,939
object has five stars and later on if
4644
03:29:14,939 --> 03:29:17,700
you want to add a star ability of the
4645
03:29:17,700 --> 03:29:20,160
ability to add stars to each object you
4646
03:29:20,160 --> 03:29:22,020
can do that dynamically that's a
4647
03:29:22,020 --> 03:29:23,340
challenge for you
4648
03:29:23,340 --> 03:29:26,100
and of course we can add a key
4649
03:29:26,100 --> 03:29:28,979
equal to a template string of star Dash
4650
03:29:28,979 --> 03:29:31,680
and Then star like this
4651
03:29:31,680 --> 03:29:35,040
and we can give it an SX equal to cooler
4652
03:29:35,040 --> 03:29:36,359
is
4653
03:29:36,359 --> 03:29:39,859
hash F2
4654
03:29:39,859 --> 03:29:43,080
c94c and now if we save this
4655
03:29:43,080 --> 03:29:45,180
you should be able to see five stars
4656
03:29:45,180 --> 03:29:46,920
appear right here
4657
03:29:46,920 --> 03:29:51,060
great now let's style this stack above
4658
03:29:51,060 --> 03:29:53,580
our typography by giving it a direction
4659
03:29:53,580 --> 03:29:55,560
equal to rho
4660
03:29:55,560 --> 03:29:57,779
this is going to make the stars appear
4661
03:29:57,779 --> 03:30:00,800
next to the apartment
4662
03:30:00,960 --> 03:30:03,720
let's also give it a justify content
4663
03:30:03,720 --> 03:30:07,140
equal to space between which is going to
4664
03:30:07,140 --> 03:30:10,200
make the stars go to the right side
4665
03:30:10,200 --> 03:30:13,620
let's give it a flex wrap equal to wrap
4666
03:30:13,620 --> 03:30:16,620
and align items
4667
03:30:16,620 --> 03:30:18,660
equal to Center
4668
03:30:18,660 --> 03:30:21,779
great to this typography we can apply
4669
03:30:21,779 --> 03:30:24,899
the font size equal to 18
4670
03:30:24,899 --> 03:30:29,279
a font weight equal to 500 and a color
4671
03:30:29,279 --> 03:30:32,060
equal to hash
4672
03:30:32,060 --> 03:30:36,720
11142d and finally text transform equal
4673
03:30:36,720 --> 03:30:37,859
to
4674
03:30:37,859 --> 03:30:40,620
capitalize
4675
03:30:40,620 --> 03:30:42,600
now if we save that
4676
03:30:42,600 --> 03:30:44,880
it's looking just a bit better
4677
03:30:44,880 --> 03:30:48,120
great now we can go below this stack
4678
03:30:48,120 --> 03:30:50,160
containing this box
4679
03:30:50,160 --> 03:30:53,640
and we can create another stack below
4680
03:30:53,640 --> 03:30:55,380
this stack is going to contain
4681
03:30:55,380 --> 03:30:58,020
absolutely everything almost the same as
4682
03:30:58,020 --> 03:31:00,479
the stack above so we can simply copy
4683
03:31:00,479 --> 03:31:03,239
this entire stack and replace our new
4684
03:31:03,239 --> 03:31:04,080
one
4685
03:31:04,080 --> 03:31:06,180
of course it's not going to be property
4686
03:31:06,180 --> 03:31:08,760
type anymore this time it is going to be
4687
03:31:08,760 --> 03:31:10,380
property
4688
03:31:10,380 --> 03:31:12,540
title
4689
03:31:12,540 --> 03:31:16,200
there we go and then we're not gonna go
4690
03:31:16,200 --> 03:31:18,600
over the Stars we want to show the
4691
03:31:18,600 --> 03:31:21,720
property location so right here we're
4692
03:31:21,720 --> 03:31:24,120
not going to have this box but rather
4693
03:31:24,120 --> 03:31:26,460
immediately below the typography we're
4694
03:31:26,460 --> 03:31:28,739
going to have a place which is a
4695
03:31:28,739 --> 03:31:32,399
self-flowsing icon equal to SX
4696
03:31:32,399 --> 03:31:34,560
and we're going to give it a color of
4697
03:31:34,560 --> 03:31:38,640
eight zero eight one nine one
4698
03:31:38,640 --> 03:31:40,920
and just below that we're gonna have
4699
03:31:40,920 --> 03:31:43,680
another typography
4700
03:31:43,680 --> 03:31:46,340
which is going to render the property
4701
03:31:46,340 --> 03:31:49,859
details dot location
4702
03:31:49,859 --> 03:31:52,500
there we go so if we save this you can
4703
03:31:52,500 --> 03:31:53,760
see apartment
4704
03:31:53,760 --> 03:31:56,880
and you can see location and La USA
4705
03:31:56,880 --> 03:31:58,620
right here
4706
03:31:58,620 --> 03:32:00,540
but of course we have to style it a bit
4707
03:32:00,540 --> 03:32:04,080
so let's first focus on this big title
4708
03:32:04,080 --> 03:32:06,180
that title of course has to be bigger
4709
03:32:06,180 --> 03:32:08,460
than the type of the apartment so we're
4710
03:32:08,460 --> 03:32:11,220
going to give it a font size of 22 and
4711
03:32:11,220 --> 03:32:14,040
font weight of 600. the caller can
4712
03:32:14,040 --> 03:32:16,200
remain the same there we go that's just
4713
03:32:16,200 --> 03:32:18,779
a bit better now regarding the place and
4714
03:32:18,779 --> 03:32:21,300
the typography we can wrap them in a
4715
03:32:21,300 --> 03:32:24,479
stack so let's create a stack right here
4716
03:32:24,479 --> 03:32:28,680
let's give it a margin top of 0.5
4717
03:32:28,680 --> 03:32:31,580
let's give it a direction equal to rho
4718
03:32:31,580 --> 03:32:35,279
align items equal to Center
4719
03:32:35,279 --> 03:32:39,000
and let's give it a gap equal to 0.5 and
4720
03:32:39,000 --> 03:32:41,040
now we can place those place and
4721
03:32:41,040 --> 03:32:44,399
typography inside of that stack that
4722
03:32:44,399 --> 03:32:45,840
should make it look just a bit better
4723
03:32:45,840 --> 03:32:47,520
and closer together
4724
03:32:47,520 --> 03:32:49,200
and now we can style this last
4725
03:32:49,200 --> 03:32:51,840
typography by giving it a font size of
4726
03:32:51,840 --> 03:32:56,279
14 and giving it a color equal to hash
4727
03:32:56,279 --> 03:33:00,000
eight zero eight one nine one
4728
03:33:00,000 --> 03:33:02,279
there we go so this is looking just a
4729
03:33:02,279 --> 03:33:03,359
bit better
4730
03:33:03,359 --> 03:33:06,180
finally we have more details about this
4731
03:33:06,180 --> 03:33:08,580
entire apartment it's going to be the
4732
03:33:08,580 --> 03:33:10,080
price of course
4733
03:33:10,080 --> 03:33:13,319
So Below this stack we can have another
4734
03:33:13,319 --> 03:33:17,100
box right here and I just noticed this
4735
03:33:17,100 --> 03:33:18,899
typography should be wrapped together
4736
03:33:18,899 --> 03:33:23,100
with this stack within another box so I
4737
03:33:23,100 --> 03:33:24,960
know this is getting a bit confusing but
4738
03:33:24,960 --> 03:33:26,939
here we have the typography with the
4739
03:33:26,939 --> 03:33:30,300
title and we want to wrap that with a
4740
03:33:30,300 --> 03:33:31,620
box element
4741
03:33:31,620 --> 03:33:34,800
and that box element can be closed right
4742
03:33:34,800 --> 03:33:38,340
after our stack right here so now if we
4743
03:33:38,340 --> 03:33:40,020
save that you're going to notice that
4744
03:33:40,020 --> 03:33:42,300
now the location appears right here
4745
03:33:42,300 --> 03:33:44,160
which is a bit better
4746
03:33:44,160 --> 03:33:47,880
and then a new box begins now since the
4747
03:33:47,880 --> 03:33:50,040
rest of this property Details page is
4748
03:33:50,040 --> 03:33:51,960
just taking the elements and then laying
4749
03:33:51,960 --> 03:33:54,300
them one on top of another you can do
4750
03:33:54,300 --> 03:33:56,760
that on your own way you can do it a bit
4751
03:33:56,760 --> 03:33:58,739
differently from the design you can have
4752
03:33:58,739 --> 03:34:01,500
your own style for that reason you can
4753
03:34:01,500 --> 03:34:03,540
pause this video right now and implement
4754
03:34:03,540 --> 03:34:06,239
the rest of the details coming from the
4755
03:34:06,239 --> 03:34:08,520
property details component you can
4756
03:34:08,520 --> 03:34:10,439
simply console log it see what's in
4757
03:34:10,439 --> 03:34:12,540
there and then somehow showcase them on
4758
03:34:12,540 --> 03:34:14,520
the screen in case you want to follow
4759
03:34:14,520 --> 03:34:16,979
along I'm going to leave the rest of the
4760
03:34:16,979 --> 03:34:19,380
code for the property details down in
4761
03:34:19,380 --> 03:34:21,120
the description below it's going to be
4762
03:34:21,120 --> 03:34:23,160
in that same GitHub gist so you can
4763
03:34:23,160 --> 03:34:25,859
simply override our current code and
4764
03:34:25,859 --> 03:34:28,020
we're gonna get the rest of our property
4765
03:34:28,020 --> 03:34:29,819
Details page which is going to look
4766
03:34:29,819 --> 03:34:31,380
something like this
4767
03:34:31,380 --> 03:34:33,960
it's going to contain the price which
4768
03:34:33,960 --> 03:34:37,080
you can see right here a description and
4769
03:34:37,080 --> 03:34:39,899
then a card with the current agent that
4770
03:34:39,899 --> 03:34:41,880
created that property with buttons to
4771
03:34:41,880 --> 03:34:44,340
edit it and delete it another thing
4772
03:34:44,340 --> 03:34:46,319
right here that is currently static is
4773
03:34:46,319 --> 03:34:49,200
the photo of a map but if you really
4774
03:34:49,200 --> 03:34:52,200
want to you could take the geographic
4775
03:34:52,200 --> 03:34:55,680
location of this place and then embed a
4776
03:34:55,680 --> 03:34:58,020
real Google map right here if you want
4777
03:34:58,020 --> 03:35:00,000
to add on to this project this would be
4778
03:35:00,000 --> 03:35:03,000
a great thing to do but with that said
4779
03:35:03,000 --> 03:35:05,640
if we now expand this you can see how
4780
03:35:05,640 --> 03:35:07,800
great our property Details page looks
4781
03:35:07,800 --> 03:35:10,500
like and how simple it was to make using
4782
03:35:10,500 --> 03:35:13,739
refine now there is one piece of logic
4783
03:35:13,739 --> 03:35:15,779
that we imported with the code right
4784
03:35:15,779 --> 03:35:19,200
here and that is right here checking if
4785
03:35:19,200 --> 03:35:21,120
the current user is the one that's
4786
03:35:21,120 --> 03:35:24,000
currently looking at this property so if
4787
03:35:24,000 --> 03:35:26,220
we are a currently logged in user then
4788
03:35:26,220 --> 03:35:28,560
we can see the edit and delete buttons
4789
03:35:28,560 --> 03:35:31,080
and if we are not which we can mock
4790
03:35:31,080 --> 03:35:33,180
right here here just for a second then
4791
03:35:33,180 --> 03:35:35,340
we can see this dummy message and call
4792
03:35:35,340 --> 03:35:37,859
buttons but in this case we of course
4793
03:35:37,859 --> 03:35:40,319
are so we can get back the edit and
4794
03:35:40,319 --> 03:35:42,899
delete another thing of course is the
4795
03:35:42,899 --> 03:35:45,000
deletion so right here we have the
4796
03:35:45,000 --> 03:35:47,220
handle delete property where we are
4797
03:35:47,220 --> 03:35:49,319
checking whether we want to do that and
4798
03:35:49,319 --> 03:35:51,479
then if we do we're simply using the
4799
03:35:51,479 --> 03:35:53,939
mutate and then we are referring to the
4800
03:35:53,939 --> 03:35:56,279
resource under properties with a
4801
03:35:56,279 --> 03:35:58,979
specific ID and then on success we're
4802
03:35:58,979 --> 03:36:02,279
navigating back to properties great
4803
03:36:02,279 --> 03:36:05,100
but of course the backhand side for the
4804
03:36:05,100 --> 03:36:07,260
deletion of a property hasn't yet been
4805
03:36:07,260 --> 03:36:09,960
implemented so let's go to property
4806
03:36:09,960 --> 03:36:11,220
controller
4807
03:36:11,220 --> 03:36:14,279
to delete a property we can create a new
4808
03:36:14,279 --> 03:36:17,580
try and catch block inside of the try we
4809
03:36:17,580 --> 03:36:19,979
need to get the ID of the property we
4810
03:36:19,979 --> 03:36:21,720
want to create and that's going to be
4811
03:36:21,720 --> 03:36:24,540
const ID which we destructure from rack
4812
03:36:24,540 --> 03:36:27,739
params then we want to get that property
4813
03:36:27,739 --> 03:36:31,100
so const property
4814
03:36:31,100 --> 03:36:36,859
to delete is equal to a weight property
4815
03:36:36,859 --> 03:36:41,460
dot find by ID and then we find it where
4816
03:36:41,460 --> 03:36:45,060
we say underscore ID is equal to ID and
4817
03:36:45,060 --> 03:36:47,819
then we populate the Creator
4818
03:36:47,819 --> 03:36:49,500
the reason why we just deleted
4819
03:36:49,500 --> 03:36:51,840
immediately is because we also need to
4820
03:36:51,840 --> 03:36:54,840
delete its ID from the Creator the
4821
03:36:54,840 --> 03:36:57,359
person that created it so what we can do
4822
03:36:57,359 --> 03:37:01,200
is we can check if there is no property
4823
03:37:01,200 --> 03:37:04,979
to delete then we can throw a new error
4824
03:37:04,979 --> 03:37:07,020
property not found
4825
03:37:07,020 --> 03:37:09,779
else we can create a new session by
4826
03:37:09,779 --> 03:37:12,420
saying con session is equal to await
4827
03:37:12,420 --> 03:37:15,600
Mongoose dot start session and then of
4828
03:37:15,600 --> 03:37:17,399
course we have to start the transaction
4829
03:37:17,399 --> 03:37:20,040
as well to make everything Atomic to
4830
03:37:20,040 --> 03:37:22,140
make sure that it either goes through or
4831
03:37:22,140 --> 03:37:24,239
it doesn't stack in the middle now we
4832
03:37:24,239 --> 03:37:26,399
can say property
4833
03:37:26,399 --> 03:37:27,840
to delete
4834
03:37:27,840 --> 03:37:31,200
and then simply say remove and remove it
4835
03:37:31,200 --> 03:37:33,239
from this session
4836
03:37:33,239 --> 03:37:38,340
then we also do property to delete
4837
03:37:38,340 --> 03:37:42,540
that Creator dot all properties
4838
03:37:42,540 --> 03:37:46,020
dot pool and then property
4839
03:37:46,020 --> 03:37:48,979
to delete
4840
03:37:49,620 --> 03:37:51,359
like this
4841
03:37:51,359 --> 03:37:54,600
finally we have to await
4842
03:37:54,600 --> 03:37:59,180
property to delete
4843
03:37:59,340 --> 03:38:01,319
dot creator
4844
03:38:01,319 --> 03:38:04,020
dot save and then we pass in that
4845
03:38:04,020 --> 03:38:04,859
session
4846
03:38:04,859 --> 03:38:08,880
and finally we do a weight
4847
03:38:08,880 --> 03:38:12,239
session dot commit transaction meaning
4848
03:38:12,239 --> 03:38:14,760
everywhere what we did remove the
4849
03:38:14,760 --> 03:38:16,620
property remove the Creator from the
4850
03:38:16,620 --> 03:38:18,660
property remove the property from the
4851
03:38:18,660 --> 03:38:20,880
Creator we now want to commit to
4852
03:38:20,880 --> 03:38:22,920
everything we said we would do and
4853
03:38:22,920 --> 03:38:27,439
finally we can say res that status of
4854
03:38:27,439 --> 03:38:30,180
200.json and then we're going to send a
4855
03:38:30,180 --> 03:38:34,020
message property deleted successfully
4856
03:38:34,020 --> 03:38:36,060
there we go that should be good to go
4857
03:38:36,060 --> 03:38:39,000
and we can also in the catch send the
4858
03:38:39,000 --> 03:38:42,540
500 with a message saying error Dot
4859
03:38:42,540 --> 03:38:45,779
message great with that said we can go
4860
03:38:45,779 --> 03:38:48,479
back and this should now be working
4861
03:38:48,479 --> 03:38:50,880
because refine makes it so easy we
4862
03:38:50,880 --> 03:38:52,380
simply need to call this one function
4863
03:38:52,380 --> 03:38:56,160
and pass the ID so let's click delete
4864
03:38:56,160 --> 03:38:59,220
function and hopefully it works we get
4865
03:38:59,220 --> 03:39:02,220
an alert asking us if we are sure yes we
4866
03:39:02,220 --> 03:39:05,160
are and there we go success it was
4867
03:39:05,160 --> 03:39:09,120
immediate it was incredibly fast great
4868
03:39:09,120 --> 03:39:11,640
now while there is one property left to
4869
03:39:11,640 --> 03:39:13,920
work with we can implement the edit
4870
03:39:13,920 --> 03:39:16,140
functionality as well
4871
03:39:16,140 --> 03:39:18,420
so that's going to be in that same
4872
03:39:18,420 --> 03:39:21,060
controller right here in the update
4873
03:39:21,060 --> 03:39:23,939
property controller function so let's go
4874
03:39:23,939 --> 03:39:26,640
ahead and implement it right away as
4875
03:39:26,640 --> 03:39:28,680
when deleting or fetching a specific
4876
03:39:28,680 --> 03:39:31,800
property when updating it we also need
4877
03:39:31,800 --> 03:39:34,140
to know which property are we updating
4878
03:39:34,140 --> 03:39:36,960
so let's open up a new try and catch
4879
03:39:36,960 --> 03:39:39,779
block and let's get const
4880
03:39:39,779 --> 03:39:42,120
and then we need to get the ID from
4881
03:39:42,120 --> 03:39:44,279
direct params so that we know which one
4882
03:39:44,279 --> 03:39:47,520
are we updating but for the update we
4883
03:39:47,520 --> 03:39:49,739
also have to get all of the properties
4884
03:39:49,739 --> 03:39:52,220
from the front end const title
4885
03:39:52,220 --> 03:39:56,479
description property type and location
4886
03:39:56,479 --> 03:39:59,640
price and the photo as well from the
4887
03:39:59,640 --> 03:40:02,040
front end so this is the part that we
4888
03:40:02,040 --> 03:40:04,620
didn't yet do on the front end if we
4889
03:40:04,620 --> 03:40:06,899
click on the edit you can see that it is
4890
03:40:06,899 --> 03:40:11,520
a 404 it doesn't exist so we have to go
4891
03:40:11,520 --> 03:40:14,939
not to the property detail but rather 2D
4892
03:40:14,939 --> 03:40:18,660
property edit edit property there we
4893
03:40:18,660 --> 03:40:21,000
have to implement the form to send all
4894
03:40:21,000 --> 03:40:23,399
of the updated fields from the front end
4895
03:40:23,399 --> 03:40:25,319
to the back end
4896
03:40:25,319 --> 03:40:27,479
but don't worry that's going to be much
4897
03:40:27,479 --> 03:40:29,340
simpler than you might think because
4898
03:40:29,340 --> 03:40:31,020
we're going to use the same form
4899
03:40:31,020 --> 03:40:33,840
component that we used in the create if
4900
03:40:33,840 --> 03:40:35,880
remember right here this is going to be
4901
03:40:35,880 --> 03:40:38,939
the add property and we can copy most of
4902
03:40:38,939 --> 03:40:41,220
these functions to create our edit
4903
03:40:41,220 --> 03:40:44,220
property as well so let's go here and
4904
03:40:44,220 --> 03:40:46,920
let's go to edit and start with the edit
4905
03:40:46,920 --> 03:40:49,200
property page in the GitHub just down
4906
03:40:49,200 --> 03:40:52,220
below you can find the entire edit
4907
03:40:52,220 --> 03:40:54,960
property.tsx file and simply paste it
4908
03:40:54,960 --> 03:40:56,520
right here
4909
03:40:56,520 --> 03:40:59,880
as you can see this is the exact same
4910
03:40:59,880 --> 03:41:03,859
thing as we had inside
4911
03:41:08,040 --> 03:41:10,739
as you can see this is exactly the same
4912
03:41:10,739 --> 03:41:13,800
form we had inside of the create
4913
03:41:13,800 --> 03:41:16,920
property you can see that right here as
4914
03:41:16,920 --> 03:41:19,020
a matter of fact the create property
4915
03:41:19,020 --> 03:41:21,840
also had on finish Handler it had a
4916
03:41:21,840 --> 03:41:24,120
handle image change and it had some of
4917
03:41:24,120 --> 03:41:26,760
these props and if you look at the edit
4918
03:41:26,760 --> 03:41:29,819
property on finish Handler it has the
4919
03:41:29,819 --> 03:41:32,100
handle image change and some props right
4920
03:41:32,100 --> 03:41:35,580
here as well it is mostly the same so I
4921
03:41:35,580 --> 03:41:37,020
simply wanted to provide it to you
4922
03:41:37,020 --> 03:41:39,120
because you have already done all the
4923
03:41:39,120 --> 03:41:40,800
great work of creating the form
4924
03:41:40,800 --> 03:41:43,319
component and now we can simply reuse it
4925
03:41:43,319 --> 03:41:46,200
for the edit property and now if we go
4926
03:41:46,200 --> 03:41:48,540
to properties we click on a specific
4927
03:41:48,540 --> 03:41:51,479
property and click edit as you can see
4928
03:41:51,479 --> 03:41:55,140
here we are we immediately have all of
4929
03:41:55,140 --> 03:41:57,359
the values pre-filled lavender apartment
4930
03:41:57,359 --> 03:42:00,600
test we can select a property type such
4931
03:42:00,600 --> 03:42:02,939
as apartment enter the property price
4932
03:42:02,939 --> 03:42:05,760
and the location and we can re-upload
4933
03:42:05,760 --> 03:42:06,840
the image
4934
03:42:06,840 --> 03:42:08,819
and of course the best thing about this
4935
03:42:08,819 --> 03:42:11,760
is the use form hook which automatically
4936
03:42:11,760 --> 03:42:13,920
gives us all the data that we can
4937
03:42:13,920 --> 03:42:16,620
pre-fill in all of these inputs
4938
03:42:16,620 --> 03:42:19,380
with that said now we can go back to the
4939
03:42:19,380 --> 03:42:21,239
controller and we know that we're
4940
03:42:21,239 --> 03:42:22,920
accepting all these properties the
4941
03:42:22,920 --> 03:42:25,260
property name description type price
4942
03:42:25,260 --> 03:42:28,380
location and so on and let's try to make
4943
03:42:28,380 --> 03:42:30,600
sure that there aren't any typos so
4944
03:42:30,600 --> 03:42:33,060
that's going to be description
4945
03:42:33,060 --> 03:42:35,640
great so now that we have all of these
4946
03:42:35,640 --> 03:42:38,340
properties how do we actually edit it
4947
03:42:38,340 --> 03:42:40,380
well we're going to do it like this
4948
03:42:40,380 --> 03:42:42,899
we're going to do a weight
4949
03:42:42,899 --> 03:42:44,660
property
4950
03:42:44,660 --> 03:42:48,359
dot find by ID
4951
03:42:48,359 --> 03:42:51,600
and update and there that's going to be
4952
03:42:51,600 --> 03:42:54,720
underscore ID is equal to ID we're going
4953
03:42:54,720 --> 03:42:57,479
to find it and then we need to pass all
4954
03:42:57,479 --> 03:42:59,819
of the updated properties such as title
4955
03:42:59,819 --> 03:43:01,500
description
4956
03:43:01,500 --> 03:43:04,260
property type location
4957
03:43:04,260 --> 03:43:08,340
price and then finally the photo but we
4958
03:43:08,340 --> 03:43:10,140
have to re-upload that photo to
4959
03:43:10,140 --> 03:43:13,560
cloudinery so we can say const photo URL
4960
03:43:13,560 --> 03:43:18,359
is equal to a weight cloudinery
4961
03:43:18,359 --> 03:43:21,600
dot uploader
4962
03:43:21,600 --> 03:43:23,760
dot upload
4963
03:43:23,760 --> 03:43:27,180
and then we pass that photo great and
4964
03:43:27,180 --> 03:43:30,060
now we can right here say photo
4965
03:43:30,060 --> 03:43:34,500
is equal to photo URL dot URL or we can
4966
03:43:34,500 --> 03:43:36,840
use the same old photo if the old one
4967
03:43:36,840 --> 03:43:40,380
wasn't provided great finally we can do
4968
03:43:40,380 --> 03:43:43,920
res dot status of 200 and then say
4969
03:43:43,920 --> 03:43:47,040
property updated successfully or we can
4970
03:43:47,040 --> 03:43:49,739
do res dot status
4971
03:43:49,739 --> 03:43:54,300
of 500 and say there is an error
4972
03:43:54,300 --> 03:43:57,779
great that is the controller for the
4973
03:43:57,779 --> 03:44:00,359
update property now let's go ahead and
4974
03:44:00,359 --> 03:44:01,979
try to change the property description
4975
03:44:01,979 --> 03:44:04,020
from test
4976
03:44:04,020 --> 03:44:06,720
to something more interesting and for
4977
03:44:06,720 --> 03:44:08,760
that let's use chat GPT so let's say
4978
03:44:08,760 --> 03:44:11,100
that we have a lavender apartment which
4979
03:44:11,100 --> 03:44:16,080
is a villa in Italy so let's do create a
4980
03:44:16,080 --> 03:44:18,359
comprehensive
4981
03:44:18,359 --> 03:44:20,100
description
4982
03:44:20,100 --> 03:44:23,279
for lavender apartment or let's do
4983
03:44:23,279 --> 03:44:26,700
lavender Villa in Italy and let's see
4984
03:44:26,700 --> 03:44:28,460
what is it going to come up with
4985
03:44:28,460 --> 03:44:31,920
luxurious vacation rental located in the
4986
03:44:31,920 --> 03:44:35,100
Rolling Hills of Tuscany Italy this is
4987
03:44:35,100 --> 03:44:37,319
crazy it keeps typing but I'm just gonna
4988
03:44:37,319 --> 03:44:39,960
get this one that's the new lorem ipsum
4989
03:44:39,960 --> 03:44:41,340
you're always going to have some great
4990
03:44:41,340 --> 03:44:44,040
content to submit and we can also
4991
03:44:44,040 --> 03:44:47,279
resubmit the photo after adding it you
4992
03:44:47,279 --> 03:44:49,859
can submit
4993
03:44:49,859 --> 03:44:51,779
and there we go you can see the value
4994
03:44:51,779 --> 03:44:54,239
changed immediately I can notice that I
4995
03:44:54,239 --> 03:44:56,880
uploaded a really grainy image so I can
4996
03:44:56,880 --> 03:44:59,479
go back and I can really quickly
4997
03:44:59,479 --> 03:45:02,580
re-upload a better image let's see if
4998
03:45:02,580 --> 03:45:05,880
that works and it does so that means
4999
03:45:05,880 --> 03:45:08,220
that our update or edit functionality is
5000
03:45:08,220 --> 03:45:11,340
done delete is done as well the
5001
03:45:11,340 --> 03:45:14,040
dashboard is done as well and what we
5002
03:45:14,040 --> 03:45:17,100
can do is we can Now list out all of the
5003
03:45:17,100 --> 03:45:19,979
agents and that is available on our
5004
03:45:19,979 --> 03:45:22,380
pages on top
5005
03:45:22,380 --> 03:45:26,520
there we go pages and then we have agent
5006
03:45:26,520 --> 03:45:30,540
profile but we also have agent that is
5007
03:45:30,540 --> 03:45:33,720
it to get started with the agents page
5008
03:45:33,720 --> 03:45:36,120
we can first import
5009
03:45:36,120 --> 03:45:40,380
the famous use list that is coming from
5010
03:45:40,380 --> 03:45:44,100
at pan card forward slash refine core
5011
03:45:44,100 --> 03:45:45,840
this is going to allow us to quickly
5012
03:45:45,840 --> 03:45:49,080
fetch a list of users and we can also
5013
03:45:49,080 --> 03:45:53,460
import our very known box and typography
5014
03:45:53,460 --> 03:45:57,420
coming from add punkod forward slash
5015
03:45:57,420 --> 03:46:01,140
refine mui
5016
03:46:01,200 --> 03:46:03,660
and we can also import a special
5017
03:46:03,660 --> 03:46:07,260
component called Agent card coming from
5018
03:46:07,260 --> 03:46:09,000
components
5019
03:46:09,000 --> 03:46:12,180
great inside of the agent we can rename
5020
03:46:12,180 --> 03:46:15,239
that to agents with a capital a
5021
03:46:15,239 --> 03:46:17,640
there we go
5022
03:46:17,640 --> 03:46:20,399
and we can make use of that list by
5023
03:46:20,399 --> 03:46:24,840
saying const beta is loading and is
5024
03:46:24,840 --> 03:46:28,979
error and then we can use the list
5025
03:46:28,979 --> 03:46:31,380
and then pass the resource we want to
5026
03:46:31,380 --> 03:46:34,560
get in this case it's going to be users
5027
03:46:34,560 --> 03:46:36,660
hopefully you're starting to get the
5028
03:46:36,660 --> 03:46:39,960
point of how refine works you have a lot
5029
03:46:39,960 --> 03:46:42,120
of different resources that correspond
5030
03:46:42,120 --> 03:46:44,220
to resources on the back end and to the
5031
03:46:44,220 --> 03:46:45,600
models on the back end and in the
5032
03:46:45,600 --> 03:46:48,180
database and you can simply use the list
5033
03:46:48,180 --> 03:46:50,520
to fetch them right here and you get the
5034
03:46:50,520 --> 03:46:53,220
hooks for loading errors and finally the
5035
03:46:53,220 --> 03:46:56,640
data so one more time to get the agents
5036
03:46:56,640 --> 03:47:00,600
we can say const all agents is equal to
5037
03:47:00,600 --> 03:47:03,899
data question mark dot data
5038
03:47:03,899 --> 03:47:07,080
they are stored right inside of here but
5039
03:47:07,080 --> 03:47:09,420
of course we have to implement that API
5040
03:47:09,420 --> 03:47:11,880
endpoint and that's not going to be in
5041
03:47:11,880 --> 03:47:14,520
the controller for properties but rather
5042
03:47:14,520 --> 03:47:17,399
for users we have only implemented the
5043
03:47:17,399 --> 03:47:19,979
create user but we are yet to implement
5044
03:47:19,979 --> 03:47:22,979
the get all users endpoint and that's
5045
03:47:22,979 --> 03:47:25,859
exactly what we're gonna do right now
5046
03:47:25,859 --> 03:47:28,800
that one is the simplest one we can
5047
03:47:28,800 --> 03:47:31,380
simply create a try and catch block if
5048
03:47:31,380 --> 03:47:33,600
something doesn't go right we can rest
5049
03:47:33,600 --> 03:47:38,120
that status of 500
5050
03:47:39,060 --> 03:47:41,640
and we can simply send the error message
5051
03:47:41,640 --> 03:47:44,700
like so but if everything goes right we
5052
03:47:44,700 --> 03:47:47,960
can see const users is equal to a weight
5053
03:47:47,960 --> 03:47:50,399
user dot find
5054
03:47:50,399 --> 03:47:53,279
we get all users right here
5055
03:47:53,279 --> 03:47:56,279
and then we can pass a limit of reg dot
5056
03:47:56,279 --> 03:48:00,840
query dot underscore end
5057
03:48:00,840 --> 03:48:03,479
if there is a specific end in this case
5058
03:48:03,479 --> 03:48:06,120
we don't want to end it and finally we
5059
03:48:06,120 --> 03:48:09,600
can say rest that status of 200 and we
5060
03:48:09,600 --> 03:48:12,540
can do that Json users to bring them
5061
03:48:12,540 --> 03:48:14,040
back to the front end
5062
03:48:14,040 --> 03:48:17,520
now inside of here we can for now let's
5063
03:48:17,520 --> 03:48:20,880
simply alert all agents and see what do
5064
03:48:20,880 --> 03:48:22,439
we get
5065
03:48:22,439 --> 03:48:24,479
and there we go object object which
5066
03:48:24,479 --> 03:48:27,180
means something is there maybe we can do
5067
03:48:27,180 --> 03:48:30,180
all agents and then zero
5068
03:48:30,180 --> 03:48:31,800
that's again going to give us an object
5069
03:48:31,800 --> 03:48:34,260
object I'm guessing but agents have
5070
03:48:34,260 --> 03:48:36,899
their name right so we can do dot name
5071
03:48:36,899 --> 03:48:39,000
or rather email I'm sure they have an
5072
03:48:39,000 --> 03:48:41,700
email but this time typescript saves us
5073
03:48:41,700 --> 03:48:44,040
and says all agents is possibly
5074
03:48:44,040 --> 03:48:46,500
undefined so we can use that same syntax
5075
03:48:46,500 --> 03:48:48,960
and make it into an array to ensure that
5076
03:48:48,960 --> 03:48:51,960
we always have access to it great thank
5077
03:48:51,960 --> 03:48:54,239
you typescript for saving us right here
5078
03:48:54,239 --> 03:48:56,760
now we do have an error we cannot seem
5079
03:48:56,760 --> 03:48:58,739
to alert this but no worries we can
5080
03:48:58,739 --> 03:49:01,560
simply do a quick console log to check
5081
03:49:01,560 --> 03:49:03,239
all agents
5082
03:49:03,239 --> 03:49:06,600
so let's go ahead and go to inspect
5083
03:49:06,600 --> 03:49:09,779
console and we do get an array of one
5084
03:49:09,779 --> 03:49:12,560
user and it did indeed have an email
5085
03:49:12,560 --> 03:49:16,080
great so finally we can showcase those
5086
03:49:16,080 --> 03:49:19,200
users we can of course before add the if
5087
03:49:19,200 --> 03:49:22,020
is loading we can return loading and if
5088
03:49:22,020 --> 03:49:25,260
there's an error we can return the error
5089
03:49:25,260 --> 03:49:27,899
and now we can create the layout to show
5090
03:49:27,899 --> 03:49:30,899
all of our agents we can do that by
5091
03:49:30,899 --> 03:49:33,239
creating a box
5092
03:49:33,239 --> 03:49:35,399
and then within that box we're going to
5093
03:49:35,399 --> 03:49:38,160
have a typography
5094
03:49:38,160 --> 03:49:40,979
and that typography is going to have a
5095
03:49:40,979 --> 03:49:45,180
font size equal to 25 and font weight
5096
03:49:45,180 --> 03:49:49,500
equal to 700. it's also going to have a
5097
03:49:49,500 --> 03:49:52,160
color equal to hash
5098
03:49:52,160 --> 03:49:58,020
11142d and it's going to say agents list
5099
03:49:58,020 --> 03:50:00,600
there we go that should be looking good
5100
03:50:00,600 --> 03:50:03,720
and immediately below that we can have a
5101
03:50:03,720 --> 03:50:06,420
box that box is going to have a couple
5102
03:50:06,420 --> 03:50:09,600
of properties such as Mt 20 pixels for
5103
03:50:09,600 --> 03:50:11,040
margin top
5104
03:50:11,040 --> 03:50:13,260
and it's going to have an SX property
5105
03:50:13,260 --> 03:50:15,420
with some additional Styles such as
5106
03:50:15,420 --> 03:50:18,660
display in this case going to be Flex
5107
03:50:18,660 --> 03:50:21,420
it's also going to have a flexor wrap of
5108
03:50:21,420 --> 03:50:26,100
wrap a gap equal to 20 pixels and
5109
03:50:26,100 --> 03:50:28,859
finally a background color
5110
03:50:28,859 --> 03:50:33,720
equal to Hash fcfc FC
5111
03:50:33,720 --> 03:50:36,239
there we go now if we save this we
5112
03:50:36,239 --> 03:50:37,979
should be able to see that box appear
5113
03:50:37,979 --> 03:50:39,300
right here
5114
03:50:39,300 --> 03:50:41,640
so we can fill it up with something and
5115
03:50:41,640 --> 03:50:43,739
that something is going to be a dynamic
5116
03:50:43,739 --> 03:50:47,520
list of all agents dot map
5117
03:50:47,520 --> 03:50:49,739
and then we get each individual agent
5118
03:50:49,739 --> 03:50:53,520
and for each agent we want to return an
5119
03:50:53,520 --> 03:50:58,260
agent card a self-closing card component
5120
03:50:58,260 --> 03:51:00,600
with that we should be able to see one
5121
03:51:00,600 --> 03:51:03,120
card right here and that's exactly what
5122
03:51:03,120 --> 03:51:06,120
we get finally we can pass some props to
5123
03:51:06,120 --> 03:51:09,779
it we can pass a key equal to agent dot
5124
03:51:09,779 --> 03:51:11,880
underscore ID
5125
03:51:11,880 --> 03:51:14,939
we can also pass an ID equal to agent
5126
03:51:14,939 --> 03:51:16,739
dot underscore ID
5127
03:51:16,739 --> 03:51:19,800
we can pass a name equal to agent.name
5128
03:51:19,800 --> 03:51:23,040
we can pass an email equal to agent dot
5129
03:51:23,040 --> 03:51:26,760
email we can pass an avatar or an image
5130
03:51:26,760 --> 03:51:30,600
equal to agent dot Avatar
5131
03:51:30,600 --> 03:51:34,200
and we can pass a number of properties
5132
03:51:34,200 --> 03:51:38,040
and O of properties is equal to agent
5133
03:51:38,040 --> 03:51:42,840
dot all properties dot length there we
5134
03:51:42,840 --> 03:51:43,739
go
5135
03:51:43,739 --> 03:51:46,140
finally we can control click into the
5136
03:51:46,140 --> 03:51:49,260
agent card and implement it right now
5137
03:51:49,260 --> 03:51:50,819
tabscript is going to give us some
5138
03:51:50,819 --> 03:51:53,819
errors but that is just fine
5139
03:51:53,819 --> 03:51:55,739
as you already know it's giving us
5140
03:51:55,739 --> 03:51:57,779
errors because of the props we're
5141
03:51:57,779 --> 03:52:00,420
passing in so we can first get those
5142
03:52:00,420 --> 03:52:04,800
props such as ID name email
5143
03:52:04,800 --> 03:52:06,300
Avatar
5144
03:52:06,300 --> 03:52:09,060
and an O of properties number of
5145
03:52:09,060 --> 03:52:11,939
properties and we can set that to be of
5146
03:52:11,939 --> 03:52:14,399
a type which we can import so we're
5147
03:52:14,399 --> 03:52:16,920
going to import two types that's going
5148
03:52:16,920 --> 03:52:21,840
to be agent card prop as well as info
5149
03:52:21,840 --> 03:52:24,779
bar props which we're going to use later
5150
03:52:24,779 --> 03:52:28,680
on coming from interfaces forward slash
5151
03:52:28,680 --> 03:52:30,060
agent
5152
03:52:30,060 --> 03:52:32,220
and now we can say our properties of
5153
03:52:32,220 --> 03:52:35,340
agent card are equal to agent card prop
5154
03:52:35,340 --> 03:52:38,000
if we save that the error goes away
5155
03:52:38,000 --> 03:52:41,279
great now we can import all of the other
5156
03:52:41,279 --> 03:52:42,899
things we're going to need for our agent
5157
03:52:42,899 --> 03:52:46,260
card we can import
5158
03:52:46,260 --> 03:52:50,460
a few icons such as email outlined
5159
03:52:50,460 --> 03:52:52,859
location City
5160
03:52:52,859 --> 03:52:57,359
phone and a place coming from add mui
5161
03:52:57,359 --> 03:52:59,939
forward slash icons material
5162
03:52:59,939 --> 03:53:03,540
we can also import the use get identity
5163
03:53:03,540 --> 03:53:06,420
that is a hook coming from refine core
5164
03:53:06,420 --> 03:53:08,939
allowing us to get our currently logged
5165
03:53:08,939 --> 03:53:10,080
in user
5166
03:53:10,080 --> 03:53:12,720
then we can also import a couple of
5167
03:53:12,720 --> 03:53:16,979
components from Material UI such as box
5168
03:53:16,979 --> 03:53:20,640
and typography coming from I had Punk
5169
03:53:20,640 --> 03:53:24,300
card forward slash refine Dash mui
5170
03:53:24,300 --> 03:53:26,580
and we'll also need to redirect to that
5171
03:53:26,580 --> 03:53:28,800
user's profile page so we're going to
5172
03:53:28,800 --> 03:53:32,340
have a link component coming from at pan
5173
03:53:32,340 --> 03:53:35,359
card forward slash refine dash
5174
03:53:35,359 --> 03:53:39,899
react-router dash V6 great and with that
5175
03:53:39,899 --> 03:53:41,580
we have everything we need to start
5176
03:53:41,580 --> 03:53:43,380
creating our agent card
5177
03:53:43,380 --> 03:53:45,060
first we're going to get our current
5178
03:53:45,060 --> 03:53:48,479
user by saying Khan's data rename it as
5179
03:53:48,479 --> 03:53:52,080
current user is equal to use get
5180
03:53:52,080 --> 03:53:54,720
identity it's so easy to get the current
5181
03:53:54,720 --> 03:53:58,380
logged in user with refine
5182
03:53:58,380 --> 03:54:00,479
then we can start with creating that
5183
03:54:00,479 --> 03:54:03,239
user card let's collapse this just a bit
5184
03:54:03,239 --> 03:54:06,680
so we can see it right here
5185
03:54:06,899 --> 03:54:08,939
and let's get started
5186
03:54:08,939 --> 03:54:12,180
we're going to have a box and that box
5187
03:54:12,180 --> 03:54:15,479
is going to have a couple of properties
5188
03:54:15,479 --> 03:54:17,700
first of all it's going to be of a
5189
03:54:17,700 --> 03:54:20,399
component link because once we click it
5190
03:54:20,399 --> 03:54:22,560
we want to link to somewhere we want to
5191
03:54:22,560 --> 03:54:24,960
link to the user profile of that
5192
03:54:24,960 --> 03:54:27,600
specific agent so we can say it's going
5193
03:54:27,600 --> 03:54:30,660
to go to and we can create the logic of
5194
03:54:30,660 --> 03:54:32,880
where is it going to go in a special
5195
03:54:32,880 --> 03:54:36,479
function called const generate link
5196
03:54:36,479 --> 03:54:39,420
which is going to be a single react
5197
03:54:39,420 --> 03:54:40,380
function
5198
03:54:40,380 --> 03:54:44,699
there we can check if current user dot
5199
03:54:44,699 --> 03:54:47,279
email is triple equal to the email of
5200
03:54:47,279 --> 03:54:51,920
that specific user then we can return
5201
03:54:52,080 --> 03:54:55,680
my profile so then we want to go to my
5202
03:54:55,680 --> 03:54:57,120
Dash profile
5203
03:54:57,120 --> 03:55:00,180
else we can simply return go to forward
5204
03:55:00,180 --> 03:55:02,640
slash agent
5205
03:55:02,640 --> 03:55:05,520
forward slash show forward slash and
5206
03:55:05,520 --> 03:55:08,279
then ID inside of dollar sign and curly
5207
03:55:08,279 --> 03:55:10,979
braces and now we can use that generate
5208
03:55:10,979 --> 03:55:13,920
link right here and we call it as a
5209
03:55:13,920 --> 03:55:15,000
function
5210
03:55:15,000 --> 03:55:18,060
that's where we want to navigate to
5211
03:55:18,060 --> 03:55:21,120
once again if it's another agent then we
5212
03:55:21,120 --> 03:55:23,819
want to go to their agent profile else
5213
03:55:23,819 --> 03:55:26,160
if it's us we want to go to our profile
5214
03:55:26,160 --> 03:55:27,300
page
5215
03:55:27,300 --> 03:55:29,640
then the next property is going to be
5216
03:55:29,640 --> 03:55:32,340
with this card is going to have a width
5217
03:55:32,340 --> 03:55:33,720
of 100 percent
5218
03:55:33,720 --> 03:55:36,239
and then we want to have an SX property
5219
03:55:36,239 --> 03:55:39,060
so right here we can say s x
5220
03:55:39,060 --> 03:55:42,420
we can give it a display equal to flex
5221
03:55:42,420 --> 03:55:45,239
we can give it a flex Direction
5222
03:55:45,239 --> 03:55:46,979
equal to
5223
03:55:46,979 --> 03:55:49,739
on extra small devices it's going to be
5224
03:55:49,739 --> 03:55:51,120
column
5225
03:55:51,120 --> 03:55:53,819
and usually on small it's going to be
5226
03:55:53,819 --> 03:55:55,080
row
5227
03:55:55,080 --> 03:55:58,199
we're going to also give it a gap of 20
5228
03:55:58,199 --> 03:56:01,199
pixels so we can have some space between
5229
03:56:01,199 --> 03:56:03,420
the elements we're going to give it a
5230
03:56:03,420 --> 03:56:05,699
padding of 20 pixels and this should
5231
03:56:05,699 --> 03:56:07,800
already look much better if you look
5232
03:56:07,800 --> 03:56:09,479
into it there we go
5233
03:56:09,479 --> 03:56:12,180
and we also want to give it some box
5234
03:56:12,180 --> 03:56:14,699
Shadow on Hover so we can say inside of
5235
03:56:14,699 --> 03:56:18,180
a string and column hover
5236
03:56:18,180 --> 03:56:20,640
in that case we want to give it a box
5237
03:56:20,640 --> 03:56:22,620
shadow
5238
03:56:22,620 --> 03:56:29,279
of a string 0 22 pixels 45 pixels 2
5239
03:56:29,279 --> 03:56:33,979
pixels and then rgba 176
5240
03:56:33,979 --> 03:56:40,140
176 176 and then 0.1 we already had this
5241
03:56:40,140 --> 03:56:42,720
before so now if we hover over it you
5242
03:56:42,720 --> 03:56:46,199
should see this Shadow appear great and
5243
03:56:46,199 --> 03:56:48,180
of course what is an agent without an
5244
03:56:48,180 --> 03:56:51,540
image so inside of that box we're now
5245
03:56:51,540 --> 03:56:56,420
going to render a self-closing image tag
5246
03:56:57,060 --> 03:56:59,699
this image is going to have a source
5247
03:56:59,699 --> 03:57:01,739
equal to Avatar
5248
03:57:01,739 --> 03:57:04,260
it's going to have an ALT tag equal to
5249
03:57:04,260 --> 03:57:08,160
user it's going to have a width of 90
5250
03:57:08,160 --> 03:57:09,479
pixels
5251
03:57:09,479 --> 03:57:13,979
just 90 and a height equal to 90 as well
5252
03:57:13,979 --> 03:57:16,439
finally we can give it a style equal to
5253
03:57:16,439 --> 03:57:22,020
border radius of 8 as well as object fit
5254
03:57:22,020 --> 03:57:24,600
equal to cover
5255
03:57:24,600 --> 03:57:27,239
and we can close it and there we go the
5256
03:57:27,239 --> 03:57:28,859
image just appeared
5257
03:57:28,859 --> 03:57:31,920
below our image we're going to have a
5258
03:57:31,920 --> 03:57:33,300
stack element
5259
03:57:33,300 --> 03:57:35,939
that stack is going to have a direction
5260
03:57:35,939 --> 03:57:38,699
equal to column we want to show some
5261
03:57:38,699 --> 03:57:40,680
elements one on top of another we're
5262
03:57:40,680 --> 03:57:43,380
going to also have a justify content
5263
03:57:43,380 --> 03:57:47,880
equal to space Dash between
5264
03:57:47,880 --> 03:57:50,760
we're going to give it a flex of one and
5265
03:57:50,760 --> 03:57:54,300
a gap on extra small devices meaning XS
5266
03:57:54,300 --> 03:57:57,359
equal to four and on small devices equal
5267
03:57:57,359 --> 03:57:58,739
to two
5268
03:57:58,739 --> 03:58:00,660
and we're going to create another stack
5269
03:58:00,660 --> 03:58:04,380
within it that stack is going to have a
5270
03:58:04,380 --> 03:58:06,840
gap of two it's going to have a
5271
03:58:06,840 --> 03:58:09,600
direction of rho so this is going to be
5272
03:58:09,600 --> 03:58:11,220
for two elements that are going to
5273
03:58:11,220 --> 03:58:12,899
appear next to each other
5274
03:58:12,899 --> 03:58:15,660
it's going to have a flex wrap equal to
5275
03:58:15,660 --> 03:58:17,760
wrap in case the width of the browser
5276
03:58:17,760 --> 03:58:19,560
shrinks a lot and then we're going to
5277
03:58:19,560 --> 03:58:22,680
have an align items off center
5278
03:58:22,680 --> 03:58:25,260
inside of there we want to have two
5279
03:58:25,260 --> 03:58:26,760
different typographies
5280
03:58:26,760 --> 03:58:29,160
the first typography is going to render
5281
03:58:29,160 --> 03:58:32,100
the name of that agent and the second
5282
03:58:32,100 --> 03:58:34,500
typography just below is going to say
5283
03:58:34,500 --> 03:58:37,920
what they really are and they are a real
5284
03:58:37,920 --> 03:58:39,960
estate
5285
03:58:39,960 --> 03:58:41,520
agent
5286
03:58:41,520 --> 03:58:43,800
so I guess guys I'm changing the careers
5287
03:58:43,800 --> 03:58:47,399
GSM is now a real estate agent
5288
03:58:47,399 --> 03:58:50,760
we can now give it a font size of course
5289
03:58:50,760 --> 03:58:53,040
the name itself must be larger than the
5290
03:58:53,040 --> 03:58:54,000
title
5291
03:58:54,000 --> 03:58:58,140
give it a font weight as well of 600 and
5292
03:58:58,140 --> 03:59:03,120
give it a color as well of hash1142d
5293
03:59:04,140 --> 03:59:06,359
and to this real estate agent we can
5294
03:59:06,359 --> 03:59:08,340
also give some class names or Styles
5295
03:59:08,340 --> 03:59:11,819
such as changing the font size to 14.
5296
03:59:11,819 --> 03:59:16,640
changing the color to hash
5297
03:59:16,880 --> 03:59:20,460
808191 this is already looking so much
5298
03:59:20,460 --> 03:59:21,779
better
5299
03:59:21,779 --> 03:59:24,660
now if we go below this stack we're
5300
03:59:24,660 --> 03:59:27,439
going to create a new stack just below
5301
03:59:27,439 --> 03:59:30,120
that stack is going to have a direction
5302
03:59:30,120 --> 03:59:33,720
equal to row it's going to have a flex
5303
03:59:33,720 --> 03:59:35,939
wrap equal to wrap
5304
03:59:35,939 --> 03:59:39,960
a justify content equal to space Dash
5305
03:59:39,960 --> 03:59:41,100
between
5306
03:59:41,100 --> 03:59:45,180
and align items equal to Center as well
5307
03:59:45,180 --> 03:59:48,840
as Gap equal to 2. inside of there we're
5308
03:59:48,840 --> 03:59:52,260
gonna show four different elements we
5309
03:59:52,260 --> 03:59:54,540
want to show the phone number the email
5310
03:59:54,540 --> 03:59:56,880
the place and the location
5311
03:59:56,880 --> 03:59:59,939
so let's create a new component to do
5312
03:59:59,939 --> 04:00:02,580
that just at the top
5313
04:00:02,580 --> 04:00:06,120
above our agent card we can create a new
5314
04:00:06,120 --> 04:00:10,020
quick functional component const info
5315
04:00:10,020 --> 04:00:11,100
bar
5316
04:00:11,100 --> 04:00:13,979
our info bar is going to accept an icon
5317
04:00:13,979 --> 04:00:17,760
and a name as props and we can say these
5318
04:00:17,760 --> 04:00:21,060
are of a type info bar props and it's
5319
04:00:21,060 --> 04:00:22,620
going to instantly return something
5320
04:00:22,620 --> 04:00:25,260
meaning we just have the parentheses
5321
04:00:25,260 --> 04:00:26,819
right here
5322
04:00:26,819 --> 04:00:29,520
so what are we going to return it's just
5323
04:00:29,520 --> 04:00:32,640
going to be another stack element
5324
04:00:32,640 --> 04:00:34,979
and that stack is going to render an
5325
04:00:34,979 --> 04:00:36,060
icon
5326
04:00:36,060 --> 04:00:38,760
and below that icon we want to render a
5327
04:00:38,760 --> 04:00:41,220
typography right here
5328
04:00:41,220 --> 04:00:43,560
that typography is going to render the
5329
04:00:43,560 --> 04:00:44,819
name
5330
04:00:44,819 --> 04:00:47,340
so now if we save nothing's going to
5331
04:00:47,340 --> 04:00:49,319
happen because we're not yet utilizing
5332
04:00:49,319 --> 04:00:52,979
this info bar but if we go down
5333
04:00:52,979 --> 04:00:55,500
inside of this stack we can now render
5334
04:00:55,500 --> 04:00:57,960
this bar as a matter of fact we can
5335
04:00:57,960 --> 04:01:01,460
render it four different times info bar
5336
04:01:01,460 --> 04:01:04,680
and we need to pass an icon and a name
5337
04:01:04,680 --> 04:01:07,140
to it so let's expand it a bit
5338
04:01:07,140 --> 04:01:10,979
let's pass an icon equal to an email
5339
04:01:10,979 --> 04:01:13,080
outlined
5340
04:01:13,080 --> 04:01:18,380
with an SX equal to color of
5341
04:01:18,800 --> 04:01:22,020
808191 like this
5342
04:01:22,020 --> 04:01:24,960
and we can also pass a name
5343
04:01:24,960 --> 04:01:28,140
which is going to be email
5344
04:01:28,140 --> 04:01:30,779
now it looks like we didn't import this
5345
04:01:30,779 --> 04:01:34,080
email outlined so let's go up it looks
5346
04:01:34,080 --> 04:01:36,960
like it's here but why is it complaining
5347
04:01:36,960 --> 04:01:38,760
let's check it out
5348
04:01:38,760 --> 04:01:41,880
module build failed we have an icon and
5349
04:01:41,880 --> 04:01:44,279
it looks like we have one extra closing
5350
04:01:44,279 --> 04:01:46,080
bracket right here
5351
04:01:46,080 --> 04:01:48,960
so if I delete that
5352
04:01:48,960 --> 04:01:51,899
nope I think we needed that let's see
5353
04:01:51,899 --> 04:01:54,600
why is it giving us an error
5354
04:01:54,600 --> 04:01:56,880
on extra small device
5355
04:01:56,880 --> 04:01:59,760
this is supposed to be SX prop not extra
5356
04:01:59,760 --> 04:02:03,120
small so if we fix this oh yes we have
5357
04:02:03,120 --> 04:02:06,300
to close the actual email outline it is
5358
04:02:06,300 --> 04:02:08,760
a self-closing tag there we go that's
5359
04:02:08,760 --> 04:02:11,100
much better now we can duplicate this
5360
04:02:11,100 --> 04:02:13,020
three more times
5361
04:02:13,020 --> 04:02:14,880
for the second one we're going to change
5362
04:02:14,880 --> 04:02:18,180
the email outlined to place
5363
04:02:18,180 --> 04:02:19,500
like this
5364
04:02:19,500 --> 04:02:21,660
for the third one we're gonna change it
5365
04:02:21,660 --> 04:02:23,580
to phone
5366
04:02:23,580 --> 04:02:25,260
for the fourth one we're going to change
5367
04:02:25,260 --> 04:02:28,620
it to location City
5368
04:02:28,620 --> 04:02:30,779
there we go we of course have to change
5369
04:02:30,779 --> 04:02:33,779
the name as well so the name is going to
5370
04:02:33,779 --> 04:02:36,660
be let's do something like
5371
04:02:36,660 --> 04:02:39,420
static string of London let's say this
5372
04:02:39,420 --> 04:02:41,160
agent is from London
5373
04:02:41,160 --> 04:02:43,800
and for the third one we have to add a
5374
04:02:43,800 --> 04:02:46,020
phone number we don't yet have that so
5375
04:02:46,020 --> 04:02:48,960
let's add some random numbers as the
5376
04:02:48,960 --> 04:02:53,160
phone number let's do this there we go
5377
04:02:53,160 --> 04:02:55,560
and the last one is going to be the
5378
04:02:55,560 --> 04:02:57,600
number of properties so here we can
5379
04:02:57,600 --> 04:03:00,540
render a real template string of number
5380
04:03:00,540 --> 04:03:03,960
of properties properties like so
5381
04:03:03,960 --> 04:03:07,260
there we go if we now save this
5382
04:03:07,260 --> 04:03:09,720
and of course we have to correct our
5383
04:03:09,720 --> 04:03:11,520
template string
5384
04:03:11,520 --> 04:03:14,160
there we go we now have four different
5385
04:03:14,160 --> 04:03:17,160
icons and titles appear right here but
5386
04:03:17,160 --> 04:03:19,560
of course let's style them just a bit by
5387
04:03:19,560 --> 04:03:23,040
styling our individual info bar stack
5388
04:03:23,040 --> 04:03:25,380
hopefully now to get the point of why we
5389
04:03:25,380 --> 04:03:28,020
created this individual card why we
5390
04:03:28,020 --> 04:03:29,580
created this individual component
5391
04:03:29,580 --> 04:03:31,800
because we are reusing it four different
5392
04:03:31,800 --> 04:03:34,739
times and it's easier to just re-edit it
5393
04:03:34,739 --> 04:03:38,040
once then re-editing it four times this
5394
04:03:38,040 --> 04:03:42,239
typography can have a font size equal to
5395
04:03:42,239 --> 04:03:46,560
14. and a cooler equal to Hash eight
5396
04:03:46,560 --> 04:03:50,279
zero eight one nine one that's going to
5397
04:03:50,279 --> 04:03:52,439
make it just a bit better and let's also
5398
04:03:52,439 --> 04:03:54,899
change the stack by giving it a flex
5399
04:03:54,899 --> 04:03:57,300
equal to one
5400
04:03:57,300 --> 04:04:00,000
let's give it a Min width equal to
5401
04:04:00,000 --> 04:04:02,399
that's going to be on extra small
5402
04:04:02,399 --> 04:04:05,100
devices 100 percent
5403
04:04:05,100 --> 04:04:08,819
and on small devices 300
5404
04:04:08,819 --> 04:04:13,080
let's give it a gap equal to 1.5 and a
5405
04:04:13,080 --> 04:04:16,979
direction equal to rho this should make
5406
04:04:16,979 --> 04:04:19,260
it look so much better
5407
04:04:19,260 --> 04:04:21,540
okay this is good as you can see on
5408
04:04:21,540 --> 04:04:23,399
smaller devices they go one below
5409
04:04:23,399 --> 04:04:26,520
another but if we expand this is the
5410
04:04:26,520 --> 04:04:29,580
flex wrap property in action as you can
5411
04:04:29,580 --> 04:04:32,699
see we've wrapped them in a flex wrap
5412
04:04:32,699 --> 04:04:35,640
meaning if we run smaller it's going to
5413
04:04:35,640 --> 04:04:38,399
be one line but as we expand they're
5414
04:04:38,399 --> 04:04:40,920
going to nicely wrap all around which is
5415
04:04:40,920 --> 04:04:44,160
great and there we go there is our first
5416
04:04:44,160 --> 04:04:46,739
and only agent right now what we can do
5417
04:04:46,739 --> 04:04:50,040
now is I can log out right here
5418
04:04:50,040 --> 04:04:53,160
and then log in with another account
5419
04:04:53,160 --> 04:04:55,620
I'll choose GSM masterclass experience
5420
04:04:55,620 --> 04:04:57,779
this is a new email account we created
5421
04:04:57,779 --> 04:05:00,420
to post testimonials of students that
5422
04:05:00,420 --> 04:05:02,699
complete our comprehensive GSM
5423
04:05:02,699 --> 04:05:04,620
masterclass bootcamp if you're
5424
04:05:04,620 --> 04:05:06,359
interested in checking that out you can
5425
04:05:06,359 --> 04:05:08,580
just YouTube JSM masterclass experience
5426
04:05:08,580 --> 04:05:12,359
with that said I'm going to log in
5427
04:05:12,359 --> 04:05:16,380
and then go to agents and there we go we
5428
04:05:16,380 --> 04:05:18,000
have Adrian and we have JavaScript
5429
04:05:18,000 --> 04:05:19,859
Mastery we can see the number of
5430
04:05:19,859 --> 04:05:22,620
properties and we can see the email here
5431
04:05:22,620 --> 04:05:24,420
as well
5432
04:05:24,420 --> 04:05:27,120
now on important difference is if we go
5433
04:05:27,120 --> 04:05:29,640
to Adrian profile which is the currently
5434
04:05:29,640 --> 04:05:31,680
logged in user we're going to go to the
5435
04:05:31,680 --> 04:05:34,620
my profile tab but if we go to the
5436
04:05:34,620 --> 04:05:36,300
profile of another user we're going to
5437
04:05:36,300 --> 04:05:40,080
go to the agent show profile which is a
5438
04:05:40,080 --> 04:05:41,819
completely separate thing
5439
04:05:41,819 --> 04:05:44,220
so since we're currently logged in into
5440
04:05:44,220 --> 04:05:48,239
Adrian we can do the my profile page so
5441
04:05:48,239 --> 04:05:50,580
to do that we can collapse this right
5442
04:05:50,580 --> 04:05:52,140
here
5443
04:05:52,140 --> 04:05:55,260
and then we can go to pages
5444
04:05:55,260 --> 04:05:59,220
and then my profile but don't worry once
5445
04:05:59,220 --> 04:06:01,260
we Implement one the second one is going
5446
04:06:01,260 --> 04:06:04,080
to be incredibly similar as that's what
5447
04:06:04,080 --> 04:06:06,660
they are profile Pages no matter if it's
5448
04:06:06,660 --> 04:06:09,300
our currently logged in user or not to
5449
04:06:09,300 --> 04:06:11,640
get started with the profile page we can
5450
04:06:11,640 --> 04:06:16,380
import our trusted use get identity from
5451
04:06:16,380 --> 04:06:21,199
pan card refine core as well as use one
5452
04:06:21,199 --> 04:06:25,319
great below that we can also import our
5453
04:06:25,319 --> 04:06:27,239
profile component which we're going to
5454
04:06:27,239 --> 04:06:29,399
soon Implement and that's going to be in
5455
04:06:29,399 --> 04:06:31,199
the components folder
5456
04:06:31,199 --> 04:06:34,560
now my profile is a functional react
5457
04:06:34,560 --> 04:06:37,020
component so we can use the capital M at
5458
04:06:37,020 --> 04:06:39,779
the start and we can first get the data
5459
04:06:39,779 --> 04:06:43,859
about our user const data we rename it
5460
04:06:43,859 --> 04:06:47,819
as user is equal to use get identity
5461
04:06:47,819 --> 04:06:50,340
then we also want to get more info about
5462
04:06:50,340 --> 04:06:52,859
the user from our database so we can use
5463
04:06:52,859 --> 04:06:57,899
the use one const data is loading and is
5464
04:06:57,899 --> 04:07:00,300
error is equal to
5465
04:07:00,300 --> 04:07:04,380
use one we pass in an object where the
5466
04:07:04,380 --> 04:07:07,260
resource is equal to users and then the
5467
04:07:07,260 --> 04:07:10,439
ID is equal to user question mark dot
5468
04:07:10,439 --> 04:07:14,340
user ID like so with a lowercase i
5469
04:07:14,340 --> 04:07:17,340
letter finally we can get our individual
5470
04:07:17,340 --> 04:07:20,100
profile by saying const my profile is
5471
04:07:20,100 --> 04:07:22,800
equal to data question mark dot data
5472
04:07:22,800 --> 04:07:26,399
like this or we can just leave it as an
5473
04:07:26,399 --> 04:07:30,060
empty array finally if we are loading so
5474
04:07:30,060 --> 04:07:32,699
if it is loading return loading if
5475
04:07:32,699 --> 04:07:35,699
there's an error return error and the
5476
04:07:35,699 --> 04:07:37,620
only thing that this profile is going to
5477
04:07:37,620 --> 04:07:41,100
show is going to be a render of the
5478
04:07:41,100 --> 04:07:44,279
profile self-closing component the
5479
04:07:44,279 --> 04:07:45,960
reason why we have this profile
5480
04:07:45,960 --> 04:07:48,420
component is once again to be able to
5481
04:07:48,420 --> 04:07:52,260
reuse it both on our profile and on the
5482
04:07:52,260 --> 04:07:54,800
profile of a specific other agent
5483
04:07:54,800 --> 04:07:57,840
hopefully that makes sense same way as
5484
04:07:57,840 --> 04:08:00,600
we reuse those little cards inside of of
5485
04:08:00,600 --> 04:08:03,120
the agents so our profile is going to
5486
04:08:03,120 --> 04:08:05,399
have a type and in this case that's
5487
04:08:05,399 --> 04:08:07,979
going to be my my profile
5488
04:08:07,979 --> 04:08:10,199
it's also going to have a name so we can
5489
04:08:10,199 --> 04:08:13,080
pass my profile dot name it's going to
5490
04:08:13,080 --> 04:08:16,620
have an email my profile.email it's
5491
04:08:16,620 --> 04:08:18,560
going to have an avatar my
5492
04:08:18,560 --> 04:08:21,000
profile.avatar and it's going to have
5493
04:08:21,000 --> 04:08:22,380
properties
5494
04:08:22,380 --> 04:08:27,120
equal to my profile dot all properties
5495
04:08:27,120 --> 04:08:29,399
and finally we can control click into
5496
04:08:29,399 --> 04:08:31,500
the profile component and start
5497
04:08:31,500 --> 04:08:34,260
implementing it of course first we have
5498
04:08:34,260 --> 04:08:36,660
to deal with the Imports so we can get
5499
04:08:36,660 --> 04:08:39,660
the profile props right here
5500
04:08:39,660 --> 04:08:42,420
and then get all the needed props that's
5501
04:08:42,420 --> 04:08:45,479
going to come from interfaces
5502
04:08:45,479 --> 04:08:47,760
forward slash common
5503
04:08:47,760 --> 04:08:51,180
and there we can simply get the type the
5504
04:08:51,180 --> 04:08:52,080
name
5505
04:08:52,080 --> 04:08:55,800
Avatar email and all properties
5506
04:08:55,800 --> 04:08:58,140
and say that's going to be of a type
5507
04:08:58,140 --> 04:09:00,600
profile prompts
5508
04:09:00,600 --> 04:09:04,199
and if we save this and go back to my
5509
04:09:04,199 --> 04:09:05,279
profile
5510
04:09:05,279 --> 04:09:08,279
of course if we properly spell this
5511
04:09:08,279 --> 04:09:10,140
there we go
5512
04:09:10,140 --> 04:09:12,840
we can now go to Adrian
5513
04:09:12,840 --> 04:09:14,160
and
5514
04:09:14,160 --> 04:09:16,620
we have just loading
5515
04:09:16,620 --> 04:09:19,439
and as you can see it just keeps loading
5516
04:09:19,439 --> 04:09:22,620
that means that we haven't yet gotten
5517
04:09:22,620 --> 04:09:25,260
the data for an individual user in our
5518
04:09:25,260 --> 04:09:27,720
database which is exactly what we can do
5519
04:09:27,720 --> 04:09:30,540
now so we can go to our user controller
5520
04:09:30,540 --> 04:09:34,560
and do our last backend function get
5521
04:09:34,560 --> 04:09:37,199
user info by ID
5522
04:09:37,199 --> 04:09:39,720
to implement that function we'll have to
5523
04:09:39,720 --> 04:09:42,180
get a const ID
5524
04:09:42,180 --> 04:09:46,620
is equal to rec dot params we have to
5525
04:09:46,620 --> 04:09:49,140
know which user do we want to fetch the
5526
04:09:49,140 --> 04:09:52,020
data for so we get the ID from the
5527
04:09:52,020 --> 04:09:53,100
params
5528
04:09:53,100 --> 04:09:56,520
then we say const user
5529
04:09:56,520 --> 04:10:00,720
is equal to a weight user dot find one
5530
04:10:00,720 --> 04:10:04,140
where the underscore ID is equal to ID
5531
04:10:04,140 --> 04:10:06,960
and then dot populate
5532
04:10:06,960 --> 04:10:09,540
all properties so we want to populate
5533
04:10:09,540 --> 04:10:12,000
all properties on that user
5534
04:10:12,000 --> 04:10:15,479
finally if there is a user then we can
5535
04:10:15,479 --> 04:10:18,899
rest that status of 200 and we can
5536
04:10:18,899 --> 04:10:23,340
return that Json user that's it so we're
5537
04:10:23,340 --> 04:10:25,800
returning all the data but also all the
5538
04:10:25,800 --> 04:10:28,020
properties about that specific user
5539
04:10:28,020 --> 04:10:30,180
that's what the populate function does
5540
04:10:30,180 --> 04:10:33,000
if you think about it in the model right
5541
04:10:33,000 --> 04:10:33,920
here
5542
04:10:33,920 --> 04:10:38,460
mongodb models user you can see that the
5543
04:10:38,460 --> 04:10:42,239
user itself just stores the IDS of all
5544
04:10:42,239 --> 04:10:45,000
properties but we don't need IDs in this
5545
04:10:45,000 --> 04:10:47,760
case we need complete properties so what
5546
04:10:47,760 --> 04:10:49,859
we can do is we can populate all
5547
04:10:49,859 --> 04:10:51,979
properties which is going to generate
5548
04:10:51,979 --> 04:10:55,319
individual property objects inside of
5549
04:10:55,319 --> 04:10:57,600
the user great
5550
04:10:57,600 --> 04:10:59,760
now that we have that we're simply going
5551
04:10:59,760 --> 04:11:02,160
to return it
5552
04:11:02,160 --> 04:11:04,920
but if a user doesn't exist then we can
5553
04:11:04,920 --> 04:11:08,699
simply rest that status 404 user not
5554
04:11:08,699 --> 04:11:10,800
found great
5555
04:11:10,800 --> 04:11:13,439
now if you reload the page we can see
5556
04:11:13,439 --> 04:11:15,840
barely right here but if we expand it we
5557
04:11:15,840 --> 04:11:17,939
can see the profile which is exactly
5558
04:11:17,939 --> 04:11:21,600
what it says right here great now this
5559
04:11:21,600 --> 04:11:24,120
profile page is going to be entirely
5560
04:11:24,120 --> 04:11:27,120
made of pure layout we're not going to
5561
04:11:27,120 --> 04:11:29,760
do any logic there so once again to make
5562
04:11:29,760 --> 04:11:32,100
it a bit simpler for you the complete
5563
04:11:32,100 --> 04:11:34,739
profile page will be provided for you in
5564
04:11:34,739 --> 04:11:37,140
the GitHub just down below simply find
5565
04:11:37,140 --> 04:11:40,439
it there and paste it right here as you
5566
04:11:40,439 --> 04:11:42,779
can see we're going to go together to
5567
04:11:42,779 --> 04:11:44,939
every single little detail of this page
5568
04:11:44,939 --> 04:11:47,939
but just to share with you we have a
5569
04:11:47,939 --> 04:11:50,040
name right here we have a dummy photo
5570
04:11:50,040 --> 04:11:53,340
address phone number and the email and
5571
04:11:53,340 --> 04:11:55,920
that is about it so how does that look
5572
04:11:55,920 --> 04:11:59,340
like we have boxes typographies more
5573
04:11:59,340 --> 04:12:02,760
boxes within more boxes as usual we have
5574
04:12:02,760 --> 04:12:04,319
this dummy image
5575
04:12:04,319 --> 04:12:06,660
and then we have a box for the Avatar
5576
04:12:06,660 --> 04:12:10,199
icon then we have a box where it says
5577
04:12:10,199 --> 04:12:12,420
real estate agent right here
5578
04:12:12,420 --> 04:12:15,000
then we have a stack for this specific
5579
04:12:15,000 --> 04:12:18,120
address and then the actual static
5580
04:12:18,120 --> 04:12:20,520
address and then this is copied two more
5581
04:12:20,520 --> 04:12:22,800
times for the phone number
5582
04:12:22,800 --> 04:12:25,020
and for the email which you can see
5583
04:12:25,020 --> 04:12:28,739
right here and that is about it but now
5584
04:12:28,739 --> 04:12:30,660
I'm gonna show you what really matters
5585
04:12:30,660 --> 04:12:33,239
we're done with the user controller with
5586
04:12:33,239 --> 04:12:36,180
the my profile page but we haven't yet
5587
04:12:36,180 --> 04:12:41,160
done the agent for a user that's not my
5588
04:12:41,160 --> 04:12:43,560
profile in this case JavaScript Mastery
5589
04:12:43,560 --> 04:12:46,380
it is A4 4.
5590
04:12:46,380 --> 04:12:49,439
the reason for the 404 is because we are
5591
04:12:49,439 --> 04:12:52,859
on the agent show and we redirected from
5592
04:12:52,859 --> 04:12:54,960
the agent page which means that we need
5593
04:12:54,960 --> 04:12:57,540
to go to the agent card and then look at
5594
04:12:57,540 --> 04:12:58,560
the link
5595
04:12:58,560 --> 04:13:01,080
if we see it right here this is supposed
5596
04:13:01,080 --> 04:13:05,340
to be agents plural so if we fix it and
5597
04:13:05,340 --> 04:13:08,340
then click we go to agents show and now
5598
04:13:08,340 --> 04:13:11,040
we can see the agent empty profile
5599
04:13:11,040 --> 04:13:14,100
right now it is empty but if we go to
5600
04:13:14,100 --> 04:13:16,560
agent profile page we can get started
5601
04:13:16,560 --> 04:13:18,899
with filling it out and that's the best
5602
04:13:18,899 --> 04:13:21,479
thing about this it's going to be almost
5603
04:13:21,479 --> 04:13:25,380
entirely the same as my profile page so
5604
04:13:25,380 --> 04:13:28,319
we can go to my profile and simply copy
5605
04:13:28,319 --> 04:13:30,899
and paste the entire thing into the
5606
04:13:30,899 --> 04:13:33,720
agent profile page and paste it right
5607
04:13:33,720 --> 04:13:34,560
here
5608
04:13:34,560 --> 04:13:37,620
you'll have to rename the my profile to
5609
04:13:37,620 --> 04:13:39,540
agent profile
5610
04:13:39,540 --> 04:13:40,800
like this
5611
04:13:40,800 --> 04:13:43,560
and then we don't have to use the use
5612
04:13:43,560 --> 04:13:46,199
get identity because that is for our
5613
04:13:46,199 --> 04:13:48,660
currently logged in user we just need to
5614
04:13:48,660 --> 04:13:49,859
use one
5615
04:13:49,859 --> 04:13:52,560
we're going to also use the use params
5616
04:13:52,560 --> 04:13:56,040
so we can import use params coming from
5617
04:13:56,040 --> 04:13:58,800
add pan card
5618
04:13:58,800 --> 04:14:03,060
slash refine Dash react Dash router
5619
04:14:03,060 --> 04:14:05,100
Dash V6
5620
04:14:05,100 --> 04:14:07,319
then instead of using the use get
5621
04:14:07,319 --> 04:14:10,920
identity we're gonna get the ID use
5622
04:14:10,920 --> 04:14:13,560
params like this
5623
04:14:13,560 --> 04:14:16,380
then once we have the ID we can simply
5624
04:14:16,380 --> 04:14:20,819
use it right here ID as string to get
5625
04:14:20,819 --> 04:14:23,580
the real user from the database
5626
04:14:23,580 --> 04:14:26,399
it's loading it's trying to get it but
5627
04:14:26,399 --> 04:14:28,620
it's having some issues
5628
04:14:28,620 --> 04:14:30,899
as you can see it got a status code of
5629
04:14:30,899 --> 04:14:35,699
undefined so let's try to console log
5630
04:14:35,699 --> 04:14:37,979
the data right here and see if we get
5631
04:14:37,979 --> 04:14:39,180
anything back
5632
04:14:39,180 --> 04:14:41,279
since it had trouble loading I'm
5633
04:14:41,279 --> 04:14:42,600
guessing it's not going to be there
5634
04:14:42,600 --> 04:14:45,660
immediately so if we open it up we
5635
04:14:45,660 --> 04:14:48,660
indeed do get undefined so if we try
5636
04:14:48,660 --> 04:14:51,120
JavaScript Mastery one more time yep
5637
04:14:51,120 --> 04:14:54,120
it's having trouble loading it
5638
04:14:54,120 --> 04:14:57,060
so as always in JavaScript Mastery let's
5639
04:14:57,060 --> 04:14:59,520
debug it together let's open up the
5640
04:14:59,520 --> 04:15:01,680
inspect element and go to the console
5641
04:15:01,680 --> 04:15:04,500
there we can see an object that doesn't
5642
04:15:04,500 --> 04:15:07,500
give us a lot of information but if we
5643
04:15:07,500 --> 04:15:10,500
go to the network tab and then reload
5644
04:15:10,500 --> 04:15:13,319
the page we'll see a request being made
5645
04:15:13,319 --> 04:15:16,920
to our backend and there we go it fails
5646
04:15:16,920 --> 04:15:19,500
right here if you check the headers we
5647
04:15:19,500 --> 04:15:21,120
can see that it's going to localhost
5648
04:15:21,120 --> 04:15:26,040
8080 API V1 users and then the ID of
5649
04:15:26,040 --> 04:15:28,920
that specific user which is great
5650
04:15:28,920 --> 04:15:30,779
but we're getting a status code of
5651
04:15:30,779 --> 04:15:33,600
undefined which isn't really good
5652
04:15:33,600 --> 04:15:37,800
so let's go ahead and check out our user
5653
04:15:37,800 --> 04:15:39,239
controller
5654
04:15:39,239 --> 04:15:43,319
4D get user by ID and as you can see in
5655
04:15:43,319 --> 04:15:45,840
all of our other routes such as get all
5656
04:15:45,840 --> 04:15:49,680
users and create users we have a try and
5657
04:15:49,680 --> 04:15:52,560
catch block and in this case we don't
5658
04:15:52,560 --> 04:15:55,560
have it so I'm really glad this happened
5659
04:15:55,560 --> 04:15:57,960
we now got an error and we didn't
5660
04:15:57,960 --> 04:16:00,180
properly handle or account for those
5661
04:16:00,180 --> 04:16:04,140
errors so we can now do a try and catch
5662
04:16:04,140 --> 04:16:06,840
block right here put all the code in the
5663
04:16:06,840 --> 04:16:08,100
try block
5664
04:16:08,100 --> 04:16:12,479
and then simply return the proper error
5665
04:16:12,479 --> 04:16:14,580
just console logging or returning the
5666
04:16:14,580 --> 04:16:16,859
error of course isn't going to fix it
5667
04:16:16,859 --> 04:16:18,899
but still it's going to give us more
5668
04:16:18,899 --> 04:16:21,300
information so we can do res dot status
5669
04:16:21,300 --> 04:16:25,380
and then send 500 and then pass over the
5670
04:16:25,380 --> 04:16:26,699
error message
5671
04:16:26,699 --> 04:16:31,340
so if we do that and reload the page
5672
04:16:31,560 --> 04:16:34,080
so apparently it just failed at the
5673
04:16:34,080 --> 04:16:35,939
start but then the second one returned
5674
04:16:35,939 --> 04:16:39,420
okay so I was wrong adding the error
5675
04:16:39,420 --> 04:16:41,220
handling actually did fix the problem
5676
04:16:41,220 --> 04:16:45,420
which is great so with that said now we
5677
04:16:45,420 --> 04:16:48,239
have the my profile page which is
5678
04:16:48,239 --> 04:16:51,000
wonderful what I wanted to show you is
5679
04:16:51,000 --> 04:16:54,420
that agent profile and my profile are
5680
04:16:54,420 --> 04:16:55,859
exactly the same
5681
04:16:55,859 --> 04:16:59,399
we're just reusing this profile page
5682
04:16:59,399 --> 04:17:02,040
but it still says my profile and this is
5683
04:17:02,040 --> 04:17:04,859
a profile of another agent so we can go
5684
04:17:04,859 --> 04:17:08,460
to that's going to be agent profile and
5685
04:17:08,460 --> 04:17:12,359
we can change this from my to agent
5686
04:17:12,359 --> 04:17:14,580
and more or less that's the only thing
5687
04:17:14,580 --> 04:17:16,859
that we have to do because all the other
5688
04:17:16,859 --> 04:17:19,680
data is immediately being different from
5689
04:17:19,680 --> 04:17:21,420
our profile if you want to check that
5690
04:17:21,420 --> 04:17:22,260
out
5691
04:17:22,260 --> 04:17:24,779
so we're currently logged into Adrian
5692
04:17:24,779 --> 04:17:26,699
and I was hoping to see the profile
5693
04:17:26,699 --> 04:17:28,439
right here but it looks like it's having
5694
04:17:28,439 --> 04:17:31,020
some trouble fetching it so if we go to
5695
04:17:31,020 --> 04:17:34,140
the network Tab and reload okay it gives
5696
04:17:34,140 --> 04:17:37,920
us undefined now so what we can do is I
5697
04:17:37,920 --> 04:17:39,899
will try to expand our browser to
5698
04:17:39,899 --> 04:17:41,640
explore our application in more detail
5699
04:17:41,640 --> 04:17:44,220
and I'm going to log out
5700
04:17:44,220 --> 04:17:47,279
I'm gonna go back and log in with our
5701
04:17:47,279 --> 04:17:49,620
original JavaScript Mastery account
5702
04:17:49,620 --> 04:17:52,439
and it looks like it even fails to log
5703
04:17:52,439 --> 04:17:55,979
in right now so if we go to console yep
5704
04:17:55,979 --> 04:17:58,260
nothing seems to be running going back
5705
04:17:58,260 --> 04:18:01,439
to our application it seems that while
5706
04:18:01,439 --> 04:18:04,560
testing the application we have crashed
5707
04:18:04,560 --> 04:18:07,859
it so that's entirely fine it happens so
5708
04:18:07,859 --> 04:18:10,439
what we have to do now the only thing is
5709
04:18:10,439 --> 04:18:12,720
just re-run our application and
5710
04:18:12,720 --> 04:18:15,180
everything is going to go back to normal
5711
04:18:15,180 --> 04:18:18,180
that's why it's important to always have
5712
04:18:18,180 --> 04:18:20,460
proper error handling so your app
5713
04:18:20,460 --> 04:18:21,660
doesn't break
5714
04:18:21,660 --> 04:18:24,300
now if we go back we can sign in with
5715
04:18:24,300 --> 04:18:25,140
Google
5716
04:18:25,140 --> 04:18:27,120
I'm gonna go with JavaScript Mastery
5717
04:18:27,120 --> 04:18:29,479
this time
5718
04:18:29,640 --> 04:18:32,699
and we got invalid credentials so let's
5719
04:18:32,699 --> 04:18:34,680
go to inspect
5720
04:18:34,680 --> 04:18:36,420
Network
5721
04:18:36,420 --> 04:18:39,920
and let's try it one more time
5722
04:18:40,620 --> 04:18:43,439
as you can see in the users it says res
5723
04:18:43,439 --> 04:18:46,439
that stats is not a function which means
5724
04:18:46,439 --> 04:18:48,600
that I simply misspelled one function
5725
04:18:48,600 --> 04:18:51,840
inside of the user controller so we can
5726
04:18:51,840 --> 04:18:55,199
go there and see where do I have res dot
5727
04:18:55,199 --> 04:18:56,699
stats
5728
04:18:56,699 --> 04:18:59,819
it is right here in the create user so
5729
04:18:59,819 --> 04:19:02,640
that is supposed to be status great
5730
04:19:02,640 --> 04:19:05,100
let's get that fixed and let's try to
5731
04:19:05,100 --> 04:19:07,260
log in one more time I'm gonna do
5732
04:19:07,260 --> 04:19:08,939
JavaScript mastery
5733
04:19:08,939 --> 04:19:11,399
and we are in
5734
04:19:11,399 --> 04:19:15,239
and before going to agents let's open up
5735
04:19:15,239 --> 04:19:17,640
our app and make sure that our app is
5736
04:19:17,640 --> 04:19:20,520
running fine so right now it is crashed
5737
04:19:20,520 --> 04:19:23,340
so we have to rerun it by running npm
5738
04:19:23,340 --> 04:19:24,239
start
5739
04:19:24,239 --> 04:19:28,080
then we can go to agents and let's open
5740
04:19:28,080 --> 04:19:30,779
up another agent
5741
04:19:30,779 --> 04:19:34,020
it's gonna try to load it but looks like
5742
04:19:34,020 --> 04:19:36,060
it's gonna be unsuccessful
5743
04:19:36,060 --> 04:19:40,080
yes it's still pending and it just gives
5744
04:19:40,080 --> 04:19:42,120
us an error inside of our application
5745
04:19:42,120 --> 04:19:43,859
though we can see that this request
5746
04:19:43,859 --> 04:19:47,100
broke it so if we look why it says
5747
04:19:47,100 --> 04:19:49,560
cannot set headers after they are sent
5748
04:19:49,560 --> 04:19:52,620
to the client and that was on getting us
5749
04:19:52,620 --> 04:19:55,620
the user info by ID
5750
04:19:55,620 --> 04:19:58,979
and that is another huge issue on my end
5751
04:19:58,979 --> 04:20:03,359
you must never ever have two restat
5752
04:20:03,359 --> 04:20:06,000
statuses in the same request it's trying
5753
04:20:06,000 --> 04:20:08,340
to send it two times once for successful
5754
04:20:08,340 --> 04:20:12,540
and once for a 404 you can either have a
5755
04:20:12,540 --> 04:20:15,600
return here so this is not executed or
5756
04:20:15,600 --> 04:20:17,880
maybe even better you can wrap this in
5757
04:20:17,880 --> 04:20:18,899
an if
5758
04:20:18,899 --> 04:20:22,620
and then you can wrap a 4 4 in an else
5759
04:20:22,620 --> 04:20:25,020
so hopefully this was a great lesson for
5760
04:20:25,020 --> 04:20:27,420
you once again that is the reason why I
5761
04:20:27,420 --> 04:20:29,699
want to include all of this is to teach
5762
04:20:29,699 --> 04:20:31,680
you something because that's what really
5763
04:20:31,680 --> 04:20:33,300
matters it's not just about building
5764
04:20:33,300 --> 04:20:36,300
apps it's about getting stuck and I'm
5765
04:20:36,300 --> 04:20:38,340
here right now with you to help you get
5766
04:20:38,340 --> 04:20:41,880
unstuck so once we fix this we have to
5767
04:20:41,880 --> 04:20:43,800
rerun our application
5768
04:20:43,800 --> 04:20:45,540
and then go back
5769
04:20:45,540 --> 04:20:49,319
to agents let's go to Adrian and there
5770
04:20:49,319 --> 04:20:52,080
we go it opens it up we can see agent
5771
04:20:52,080 --> 04:20:55,380
profile Adrian we can also go to my
5772
04:20:55,380 --> 04:20:58,020
profile which opens up my profile
5773
04:20:58,020 --> 04:21:00,779
JavaScript Mastery and in this case it
5774
04:21:00,779 --> 04:21:03,180
also shows us our currently owned
5775
04:21:03,180 --> 04:21:04,199
properties
5776
04:21:04,199 --> 04:21:07,380
with that said we have the dashboard we
5777
04:21:07,380 --> 04:21:09,660
have the properties we have the property
5778
04:21:09,660 --> 04:21:13,199
detail page we have the agent Pages both
5779
04:21:13,199 --> 04:21:16,260
for my profile and for other agents
5780
04:21:16,260 --> 04:21:17,939
profiles as you can see they are
5781
04:21:17,939 --> 04:21:21,120
incredibly similar but on my profile you
5782
04:21:21,120 --> 04:21:24,359
can also see my properties we have the
5783
04:21:24,359 --> 04:21:27,239
logout button and it is all getting
5784
04:21:27,239 --> 04:21:30,300
close to being fully done we also have a
5785
04:21:30,300 --> 04:21:33,180
wonderful sidebar provided to us by
5786
04:21:33,180 --> 04:21:36,000
refine and finally now that we can
5787
04:21:36,000 --> 04:21:38,699
properly fetch our properties and our
5788
04:21:38,699 --> 04:21:42,000
agents we can go back to finalize the
5789
04:21:42,000 --> 04:21:44,720
part which we started on the dashboard
5790
04:21:44,720 --> 04:21:47,580
right at the bottom of the static data
5791
04:21:47,580 --> 04:21:51,779
we can now go to the dashboard and do
5792
04:21:51,779 --> 04:21:55,080
this we can showcase a property list or
5793
04:21:55,080 --> 04:21:57,779
an agent list right on the dashboard
5794
04:21:57,779 --> 04:22:00,120
it's going to be incredibly simple now
5795
04:22:00,120 --> 04:22:02,520
because we already have all the backend
5796
04:22:02,520 --> 04:22:04,859
and all the logic setup we we simply
5797
04:22:04,859 --> 04:22:06,600
have to make the calls to the back end
5798
04:22:06,600 --> 04:22:09,720
and then reuse the same property cards
5799
04:22:09,720 --> 04:22:12,300
and agent cards that we have created
5800
04:22:12,300 --> 04:22:15,600
over here so let's go ahead and let's
5801
04:22:15,600 --> 04:22:17,819
get start with finishing our great
5802
04:22:17,819 --> 04:22:20,640
application and we can do that by
5803
04:22:20,640 --> 04:22:23,640
collapsing our browser closing all of
5804
04:22:23,640 --> 04:22:26,880
our currently open files and going all
5805
04:22:26,880 --> 04:22:29,399
the way to our home page
5806
04:22:29,399 --> 04:22:31,560
right here we have total revenue and
5807
04:22:31,560 --> 04:22:33,359
property referrals charts which are
5808
04:22:33,359 --> 04:22:35,520
these two but now we are ready to focus
5809
04:22:35,520 --> 04:22:38,580
on what goes below them and that's going
5810
04:22:38,580 --> 04:22:41,460
to be of course our properties
5811
04:22:41,460 --> 04:22:44,819
so we can create a new box right below
5812
04:22:44,819 --> 04:22:47,699
this stack that box is going to have
5813
04:22:47,699 --> 04:22:49,680
quite a few properties so we can open it
5814
04:22:49,680 --> 04:22:53,640
up that's going to be if I just fix this
5815
04:22:53,640 --> 04:22:56,460
a flex equal to one
5816
04:22:56,460 --> 04:23:00,120
a border radius as well equal to 15
5817
04:23:00,120 --> 04:23:01,739
pixels
5818
04:23:01,739 --> 04:23:04,560
and it's going to have a padding of 20
5819
04:23:04,560 --> 04:23:08,819
pixels as well as a BG color equal to
5820
04:23:08,819 --> 04:23:13,680
Hash fcfc FC now if we save that you
5821
04:23:13,680 --> 04:23:15,600
should be able to see a card appear
5822
04:23:15,600 --> 04:23:17,399
right here at the bottom
5823
04:23:17,399 --> 04:23:20,880
we can also give it a display equal to
5824
04:23:20,880 --> 04:23:22,439
flex
5825
04:23:22,439 --> 04:23:25,500
we can give it a flex Direction equal to
5826
04:23:25,500 --> 04:23:26,699
column
5827
04:23:26,699 --> 04:23:31,800
as well as a Min width equal to let's do
5828
04:23:31,800 --> 04:23:34,680
100 in this case
5829
04:23:34,680 --> 04:23:37,020
and finally we can give an empty or
5830
04:23:37,020 --> 04:23:39,479
margin top of 25 pixels to divide it
5831
04:23:39,479 --> 04:23:42,000
from the top and there we go we have our
5832
04:23:42,000 --> 04:23:43,920
card where we can put our properties
5833
04:23:43,920 --> 04:23:47,580
inside of it we can create a typography
5834
04:23:47,580 --> 04:23:50,880
and that typography is going to Simply
5835
04:23:50,880 --> 04:23:52,739
say latest
5836
04:23:52,739 --> 04:23:54,300
properties
5837
04:23:54,300 --> 04:23:57,300
just like that we can also give it a
5838
04:23:57,300 --> 04:24:00,960
font size equal to 18 pixels we can give
5839
04:24:00,960 --> 04:24:05,880
it a font weight as well of 600 and a
5840
04:24:05,880 --> 04:24:10,380
color equal to hash 11142d
5841
04:24:10,380 --> 04:24:12,600
let's check it out
5842
04:24:12,600 --> 04:24:15,180
that's looking good and right below that
5843
04:24:15,180 --> 04:24:17,640
we can create a box that's going to act
5844
04:24:17,640 --> 04:24:19,380
as a container for all of those
5845
04:24:19,380 --> 04:24:20,580
properties
5846
04:24:20,580 --> 04:24:24,420
that box can have a margin top of 2.5 to
5847
04:24:24,420 --> 04:24:26,819
divide it a bit from the title and then
5848
04:24:26,819 --> 04:24:30,060
SX property of display
5849
04:24:30,060 --> 04:24:32,220
is equal to flex
5850
04:24:32,220 --> 04:24:36,420
wrap is going to be set to wrap and GAP
5851
04:24:36,420 --> 04:24:39,600
is going to be set to 4. and inside of
5852
04:24:39,600 --> 04:24:41,580
there we can map over all of our
5853
04:24:41,580 --> 04:24:44,760
property cards but of course first we
5854
04:24:44,760 --> 04:24:48,300
have to fetch them so if we scroll up we
5855
04:24:48,300 --> 04:24:51,600
have to utilize this use list hook and
5856
04:24:51,600 --> 04:24:53,640
we already used it for a couple of times
5857
04:24:53,640 --> 04:24:55,800
so far but now we're going to really
5858
04:24:55,800 --> 04:24:57,420
make sure that you understand how it
5859
04:24:57,420 --> 04:25:00,239
works so we can say const we're going to
5860
04:25:00,239 --> 04:25:01,979
get the data we're going to get the is
5861
04:25:01,979 --> 04:25:05,760
loading and the is error coming from or
5862
04:25:05,760 --> 04:25:09,600
rather is equal to use list to it we can
5863
04:25:09,600 --> 04:25:12,239
pass the resource we want to get that's
5864
04:25:12,239 --> 04:25:14,220
going to be properties
5865
04:25:14,220 --> 04:25:16,680
and there's also a special config we can
5866
04:25:16,680 --> 04:25:17,819
pass
5867
04:25:17,819 --> 04:25:19,260
config
5868
04:25:19,260 --> 04:25:22,859
pagination and then page size is equal
5869
04:25:22,859 --> 04:25:25,739
to in this case let's do five I think we
5870
04:25:25,739 --> 04:25:27,720
can fit five properties right here at
5871
04:25:27,720 --> 04:25:29,399
the bottom
5872
04:25:29,399 --> 04:25:32,819
and use list we have it right here
5873
04:25:32,819 --> 04:25:35,220
and it needs to be in a home which is a
5874
04:25:35,220 --> 04:25:37,080
functional component so it starts with
5875
04:25:37,080 --> 04:25:40,439
an h a capital H for home so you can fix
5876
04:25:40,439 --> 04:25:42,960
that right here
5877
04:25:42,960 --> 04:25:44,819
and now we have access to the latest
5878
04:25:44,819 --> 04:25:48,239
properties just like that we're getting
5879
04:25:48,239 --> 04:25:51,060
it under the data right here and as we
5880
04:25:51,060 --> 04:25:53,699
did before we can pull the data from the
5881
04:25:53,699 --> 04:25:56,520
data object by saying const latest
5882
04:25:56,520 --> 04:25:58,680
properties
5883
04:25:58,680 --> 04:26:02,580
is equal to data question mark dot data
5884
04:26:02,580 --> 04:26:05,100
and then question mark question mark and
5885
04:26:05,100 --> 04:26:07,140
then array meaning if we don't have any
5886
04:26:07,140 --> 04:26:09,899
data just make it an empty array and as
5887
04:26:09,899 --> 04:26:12,540
we always do if we are loading we can
5888
04:26:12,540 --> 04:26:15,180
return a typography or a div of loading
5889
04:26:15,180 --> 04:26:17,760
and if there's an error we can turn a
5890
04:26:17,760 --> 04:26:20,460
typography saying something went wrong
5891
04:26:20,460 --> 04:26:24,239
with that said we can now go over all of
5892
04:26:24,239 --> 04:26:26,939
these latest Properties by saying latest
5893
04:26:26,939 --> 04:26:28,800
properties
5894
04:26:28,800 --> 04:26:31,800
dot map we're going to get a property
5895
04:26:31,800 --> 04:26:34,439
and then for each property we're going
5896
04:26:34,439 --> 04:26:36,300
to instantly return
5897
04:26:36,300 --> 04:26:39,840
guess what it's going to be a property
5898
04:26:39,840 --> 04:26:41,220
card
5899
04:26:41,220 --> 04:26:43,800
a component we have already created so
5900
04:26:43,800 --> 04:26:46,739
far the only thing we have to do is pass
5901
04:26:46,739 --> 04:26:49,319
the right props to it we can pass the
5902
04:26:49,319 --> 04:26:52,680
property dot underscore ID as the key
5903
04:26:52,680 --> 04:26:55,800
we can pass the ID equal to property dot
5904
04:26:55,800 --> 04:26:57,239
underscore ID
5905
04:26:57,239 --> 04:27:00,000
we can pass the title equal to property
5906
04:27:00,000 --> 04:27:03,239
dot title we can pass the location equal
5907
04:27:03,239 --> 04:27:06,239
to property dot location we can pass the
5908
04:27:06,239 --> 04:27:09,300
price equal to property.price and we can
5909
04:27:09,300 --> 04:27:12,600
pass the photo equal to property dot
5910
04:27:12,600 --> 04:27:14,520
photo
5911
04:27:14,520 --> 04:27:18,060
and if we save that you can see all of
5912
04:27:18,060 --> 04:27:20,340
our properties now we can only see one
5913
04:27:20,340 --> 04:27:22,859
because only one exists right now but
5914
04:27:22,859 --> 04:27:25,020
let's fill this up and let's test this
5915
04:27:25,020 --> 04:27:27,359
application further we can go to
5916
04:27:27,359 --> 04:27:30,479
properties we can go to add property and
5917
04:27:30,479 --> 04:27:33,140
let's add let's do a star Sun Hotel
5918
04:27:33,140 --> 04:27:35,819
description is going to be just dot dot
5919
04:27:35,819 --> 04:27:37,020
dot for now
5920
04:27:37,020 --> 04:27:38,760
the property type is going to be an
5921
04:27:38,760 --> 04:27:42,659
apartment price can be 550 location can
5922
04:27:42,659 --> 04:27:43,620
be
5923
04:27:43,620 --> 04:27:46,500
let's do Croatia
5924
04:27:46,500 --> 04:27:49,140
and we can upload a photo I'm gonna
5925
04:27:49,140 --> 04:27:51,720
choose this apartment right here and
5926
04:27:51,720 --> 04:27:54,120
upload
5927
04:27:54,120 --> 04:27:56,580
there we go we have two and let's add
5928
04:27:56,580 --> 04:27:58,380
one more
5929
04:27:58,380 --> 04:28:01,439
that's going to be a almunder hotel and
5930
04:28:01,439 --> 04:28:03,120
apartment
5931
04:28:03,120 --> 04:28:06,479
this one can be a condo and let's do
5932
04:28:06,479 --> 04:28:08,340
420.
5933
04:28:08,340 --> 04:28:10,439
we can give it a location of something
5934
04:28:10,439 --> 04:28:13,500
like Italy one more time
5935
04:28:13,500 --> 04:28:16,920
and we can make this one the condo and
5936
04:28:16,920 --> 04:28:19,520
let's submit
5937
04:28:19,620 --> 04:28:21,600
and as you can see we have three
5938
04:28:21,600 --> 04:28:23,939
properties and on the dashboard we can
5939
04:28:23,939 --> 04:28:26,220
see three properties as well
5940
04:28:26,220 --> 04:28:28,560
so it seems like we can only fit about
5941
04:28:28,560 --> 04:28:31,560
three with this size but if we expand we
5942
04:28:31,560 --> 04:28:34,920
can fit about four so we don't have to
5943
04:28:34,920 --> 04:28:37,020
fetch more than four so we can go back
5944
04:28:37,020 --> 04:28:39,720
to our list and see how easy it is which
5945
04:28:39,720 --> 04:28:42,899
is gonna say hey fetch for Max
5946
04:28:42,899 --> 04:28:45,840
great with that said we're gonna have a
5947
04:28:45,840 --> 04:28:47,699
layout that looks like this we have a
5948
04:28:47,699 --> 04:28:49,739
wonderful dashboard all of the latest
5949
04:28:49,739 --> 04:28:51,899
properties which by the way you can
5950
04:28:51,899 --> 04:28:53,880
simply click and visit
5951
04:28:53,880 --> 04:28:56,640
if you are the owner you can edit them
5952
04:28:56,640 --> 04:28:59,159
which works really well you can delete
5953
04:28:59,159 --> 04:29:02,100
them and you can also check the agents
5954
04:29:02,100 --> 04:29:04,080
all agents on the page we can check
5955
04:29:04,080 --> 04:29:06,120
their profiles and if you check your
5956
04:29:06,120 --> 04:29:07,920
profile you can check all of the
5957
04:29:07,920 --> 04:29:10,859
properties that you created isn't this
5958
04:29:10,859 --> 04:29:14,460
great we built all of this today in this
5959
04:29:14,460 --> 04:29:16,739
one video it might have taken you more
5960
04:29:16,739 --> 04:29:18,779
than a couple of hours
5961
04:29:18,779 --> 04:29:21,659
and that's totally okay as you noticed
5962
04:29:21,659 --> 04:29:23,760
we encountered a couple of Errors while
5963
04:29:23,760 --> 04:29:25,920
building this but that is what every
5964
04:29:25,920 --> 04:29:28,199
developer does that's the whole goal and
5965
04:29:28,199 --> 04:29:30,239
journey of building a phenomenal project
5966
04:29:30,239 --> 04:29:32,640
such as this one I gotta say I'm
5967
04:29:32,640 --> 04:29:34,920
incredibly pleased with what refine did
5968
04:29:34,920 --> 04:29:37,680
to enable us to build all of this in
5969
04:29:37,680 --> 04:29:39,840
such a simple and quick manner
5970
04:29:39,840 --> 04:29:42,180
all of the routing error handling
5971
04:29:42,180 --> 04:29:45,720
logging in and all of the abilities to
5972
04:29:45,720 --> 04:29:47,880
fetch resources and immediately be able
5973
04:29:47,880 --> 04:29:50,779
to just use the list or use identity
5974
04:29:50,779 --> 04:29:53,699
these hooks are so useful and I love
5975
04:29:53,699 --> 04:29:56,340
using them with that said as we always
5976
04:29:56,340 --> 04:29:58,739
do on the JavaScript Mastery we are now
5977
04:29:58,739 --> 04:30:01,260
going to deploy this application to the
5978
04:30:01,260 --> 04:30:02,040
web
5979
04:30:02,040 --> 04:30:05,340
so get ready for that right now before
5980
04:30:05,340 --> 04:30:07,620
deploying our application to the web
5981
04:30:07,620 --> 04:30:10,319
we're gonna first have to publish it on
5982
04:30:10,319 --> 04:30:13,680
GitHub so go to github.com and then on
5983
04:30:13,680 --> 04:30:15,540
top right you can create a new
5984
04:30:15,540 --> 04:30:16,859
Repository
5985
04:30:16,859 --> 04:30:19,739
let's call it refine underscore
5986
04:30:19,739 --> 04:30:22,380
dashboard of course feel free to use any
5987
04:30:22,380 --> 04:30:24,659
name you prefer we have to make it
5988
04:30:24,659 --> 04:30:26,220
public and then you can create
5989
04:30:26,220 --> 04:30:27,720
Repository
5990
04:30:27,720 --> 04:30:30,479
now you can collapse this to the side of
5991
04:30:30,479 --> 04:30:32,819
your code editor and we're going to
5992
04:30:32,819 --> 04:30:35,580
create a new instance of get right here
5993
04:30:35,580 --> 04:30:38,760
by going to view and then terminal first
5994
04:30:38,760 --> 04:30:41,279
make sure to delete one terminal
5995
04:30:41,279 --> 04:30:43,439
and then in the second one you have to
5996
04:30:43,439 --> 04:30:46,380
see the dot dot to go to the root of our
5997
04:30:46,380 --> 04:30:47,819
folder
5998
04:30:47,819 --> 04:30:51,239
there you can run git init that's going
5999
04:30:51,239 --> 04:30:53,819
to initialize this as a new GitHub repo
6000
04:30:53,819 --> 04:30:57,120
now I here can see this dot get folder
6001
04:30:57,120 --> 04:30:59,819
but it might be hidden for you if that
6002
04:30:59,819 --> 04:31:02,699
is the case do control or command shift
6003
04:31:02,699 --> 04:31:05,580
B and then type open
6004
04:31:05,580 --> 04:31:06,840
settings
6005
04:31:06,840 --> 04:31:08,220
Json
6006
04:31:08,220 --> 04:31:10,319
you can choose either workspace or
6007
04:31:10,319 --> 04:31:13,319
regular settings and then you have to
6008
04:31:13,319 --> 04:31:15,960
add a couple of lines you have to do
6009
04:31:15,960 --> 04:31:19,680
this files that exclude and then you
6010
04:31:19,680 --> 04:31:21,779
have to add asterisk asterisk forward
6011
04:31:21,779 --> 04:31:25,500
slash dot get is set to false copy this
6012
04:31:25,500 --> 04:31:28,199
exactly and then you should be able to
6013
04:31:28,199 --> 04:31:30,060
see your git folder
6014
04:31:30,060 --> 04:31:32,220
once you do that you might need to
6015
04:31:32,220 --> 04:31:34,439
reload your Visual Studio code but once
6016
04:31:34,439 --> 04:31:37,080
you do you can see a git folder here and
6017
04:31:37,080 --> 04:31:38,100
here
6018
04:31:38,100 --> 04:31:40,560
now what we need to do is we need to
6019
04:31:40,560 --> 04:31:42,720
delete the git folder inside of the
6020
04:31:42,720 --> 04:31:46,319
client so completely deleted and say yes
6021
04:31:46,319 --> 04:31:48,239
if it asks you any questions
6022
04:31:48,239 --> 04:31:51,659
now we are ready to add everything we
6023
04:31:51,659 --> 04:31:53,460
have from the client in the server
6024
04:31:53,460 --> 04:31:56,520
before we do that we have to add a DOT
6025
04:31:56,520 --> 04:32:00,479
get ignore file inside of the server and
6026
04:32:00,479 --> 04:32:03,960
ignore node underscore modules
6027
04:32:03,960 --> 04:32:07,080
great finally we are ready to follow the
6028
04:32:07,080 --> 04:32:10,140
commands that is git add dot to add all
6029
04:32:10,140 --> 04:32:13,880
the files git commit Dash M first commit
6030
04:32:13,880 --> 04:32:18,840
git Branch M Main get remote at origin
6031
04:32:18,840 --> 04:32:23,100
and finally git push U origin main this
6032
04:32:23,100 --> 04:32:24,899
is going to push our entire application
6033
04:32:24,899 --> 04:32:27,120
to GitHub and we should be able to see
6034
04:32:27,120 --> 04:32:30,479
it right away there we go
6035
04:32:30,479 --> 04:32:33,380
once that is ready you can open up
6036
04:32:33,380 --> 04:32:36,060
render.com we're going to use their
6037
04:32:36,060 --> 04:32:38,040
services for deploying our backend
6038
04:32:38,040 --> 04:32:40,380
application make sure to sign in with
6039
04:32:40,380 --> 04:32:42,420
GitHub as that's where we published our
6040
04:32:42,420 --> 04:32:45,120
application once you do that go to new
6041
04:32:45,120 --> 04:32:47,340
and then web service
6042
04:32:47,340 --> 04:32:49,380
if you can see right here we have to
6043
04:32:49,380 --> 04:32:52,859
enter the public git repository so find
6044
04:32:52,859 --> 04:32:55,920
your repository copy the URL and then
6045
04:32:55,920 --> 04:32:58,859
paste it right here and click continue
6046
04:32:58,859 --> 04:33:01,199
we have to enter the app name let's do
6047
04:33:01,199 --> 04:33:04,438
refine underscore dashboard
6048
04:33:04,438 --> 04:33:07,080
branch is going to be main root
6049
04:33:07,080 --> 04:33:09,778
directory is going to be server
6050
04:33:09,778 --> 04:33:11,879
and then the start command is going to
6051
04:33:11,879 --> 04:33:15,719
be npm start we can even check that in
6052
04:33:15,719 --> 04:33:18,000
our application if we go right here
6053
04:33:18,000 --> 04:33:21,480
server package Json we have a start
6054
04:33:21,480 --> 04:33:22,618
script
6055
04:33:22,618 --> 04:33:25,320
finally you can choose free and create
6056
04:33:25,320 --> 04:33:26,938
web service
6057
04:33:26,938 --> 04:33:29,458
while that is doing its thing we'll also
6058
04:33:29,458 --> 04:33:31,379
have to add environment variables to
6059
04:33:31,379 --> 04:33:34,680
here so let's wait a bit
6060
04:33:34,680 --> 04:33:38,219
let's go to environment
6061
04:33:38,219 --> 04:33:41,278
and then add environment variable now we
6062
04:33:41,278 --> 04:33:43,740
can copy the ones we have here that's
6063
04:33:43,740 --> 04:33:48,240
going to be mongodb URL as a key and
6064
04:33:48,240 --> 04:33:50,039
this value right here
6065
04:33:50,039 --> 04:33:52,379
and we have to add a couple more for
6066
04:33:52,379 --> 04:33:55,799
cloudinery so just copy the key and copy
6067
04:33:55,799 --> 04:33:56,759
the value
6068
04:33:56,759 --> 04:33:59,938
and repeat the process for all variables
6069
04:33:59,938 --> 04:34:02,160
cloudinary Secret
6070
04:34:02,160 --> 04:34:05,458
cloudinary secret and I think I missed
6071
04:34:05,458 --> 04:34:07,859
the key as well so you can add the key
6072
04:34:07,859 --> 04:34:09,660
right here
6073
04:34:09,660 --> 04:34:12,061
there we go so this looks good and you
6074
04:34:12,061 --> 04:34:13,859
can click save changes
6075
04:34:13,859 --> 04:34:18,359
once you do that you can go back to logs
6076
04:34:18,359 --> 04:34:20,458
and we can wait for our application to
6077
04:34:20,458 --> 04:34:22,680
be deployed since we change our
6078
04:34:22,680 --> 04:34:25,141
environment variables we can rerun our
6079
04:34:25,141 --> 04:34:27,359
latest deployment this process usually
6080
04:34:27,359 --> 04:34:29,699
takes just a couple of minutes so you
6081
04:34:29,699 --> 04:34:31,919
can pause this video and we'll be right
6082
04:34:31,919 --> 04:34:33,118
back
6083
04:34:33,118 --> 04:34:35,400
and there we go we can see mongodb
6084
04:34:35,400 --> 04:34:37,141
connected and everything is working
6085
04:34:37,141 --> 04:34:40,320
perfectly it is still in progress but in
6086
04:34:40,320 --> 04:34:42,299
just a couple of seconds it should be
6087
04:34:42,299 --> 04:34:46,020
running on this URL right here and there
6088
04:34:46,020 --> 04:34:49,618
we go our app is live let's copy this
6089
04:34:49,618 --> 04:34:52,561
URL and click it and as you can see we
6090
04:34:52,561 --> 04:34:55,500
get hello world but this time not from
6091
04:34:55,500 --> 04:34:58,680
localhost 8080 but from a real online
6092
04:34:58,680 --> 04:35:01,740
deployed URL the only thing we have to
6093
04:35:01,740 --> 04:35:05,160
do now is go to client and search for
6094
04:35:05,160 --> 04:35:08,641
where we used the static 8080 it is
6095
04:35:08,641 --> 04:35:11,160
listed in a couple of places so right
6096
04:35:11,160 --> 04:35:14,820
here it's in the app TSX right here in
6097
04:35:14,820 --> 04:35:17,219
the profile obj so we have to replace
6098
04:35:17,219 --> 04:35:22,020
this with this newly created URL all the
6099
04:35:22,020 --> 04:35:24,480
way to the first forward slash we have
6100
04:35:24,480 --> 04:35:26,820
to repeat this three more times one time
6101
04:35:26,820 --> 04:35:29,278
for the data provider as well so we can
6102
04:35:29,278 --> 04:35:31,919
override it and that's it so it was only
6103
04:35:31,919 --> 04:35:34,680
two times rest of Dimensions is on the
6104
04:35:34,680 --> 04:35:37,141
back end so with that said we are ready
6105
04:35:37,141 --> 04:35:40,500
to deploy our client side as well and
6106
04:35:40,500 --> 04:35:44,520
how you do it is you simply go into
6107
04:35:44,520 --> 04:35:48,840
client so CD client and then run npm run
6108
04:35:48,840 --> 04:35:51,359
build this is going to create an OP
6109
04:35:51,359 --> 04:35:53,099
optimized production build of our
6110
04:35:53,099 --> 04:35:54,299
application
6111
04:35:54,299 --> 04:35:56,719
while that is happening we can go to
6112
04:35:56,719 --> 04:35:59,641
netflixy.com they allow us to really
6113
04:35:59,641 --> 04:36:02,520
quickly and simply deploy our reactions
6114
04:36:02,520 --> 04:36:05,699
applications you can log in log in with
6115
04:36:05,699 --> 04:36:09,061
GitHub go to your sites
6116
04:36:09,061 --> 04:36:11,458
scroll all the way down
6117
04:36:11,458 --> 04:36:13,740
and this is where you'll be able to drag
6118
04:36:13,740 --> 04:36:17,039
and drop your optimized production build
6119
04:36:17,039 --> 04:36:18,900
as you can see it is still being
6120
04:36:18,900 --> 04:36:20,099
generated
6121
04:36:20,099 --> 04:36:23,160
we can right click it reveal in File
6122
04:36:23,160 --> 04:36:26,520
Explorer or finder if you're on Mac
6123
04:36:26,520 --> 04:36:28,980
and then once it is finished building
6124
04:36:28,980 --> 04:36:31,320
you'll be able to Simply drag and drop
6125
04:36:31,320 --> 04:36:34,320
the entire build folder right here but
6126
04:36:34,320 --> 04:36:36,599
let's give it a moment and before
6127
04:36:36,599 --> 04:36:38,580
dragging and dropping there's one more
6128
04:36:38,580 --> 04:36:40,799
thing you have to do in the build folder
6129
04:36:40,799 --> 04:36:44,160
right click create a new file called
6130
04:36:44,160 --> 04:36:46,799
underscore redirects
6131
04:36:46,799 --> 04:36:49,259
inside of there you have to add forward
6132
04:36:49,259 --> 04:36:51,719
slash asterisk and then you can add two
6133
04:36:51,719 --> 04:36:53,778
spaces forward slash
6134
04:36:53,778 --> 04:36:59,099
index.html 200 just like so and then
6135
04:36:59,099 --> 04:37:01,980
this is going to ensure that when you
6136
04:37:01,980 --> 04:37:04,799
reload your page on a specific route it
6137
04:37:04,799 --> 04:37:07,080
doesn't give you a 404. that's something
6138
04:37:07,080 --> 04:37:08,820
we have to do when deploying
6139
04:37:08,820 --> 04:37:11,820
applications on netlify and there we go
6140
04:37:11,820 --> 04:37:14,400
it is done we can simply drag and drop
6141
04:37:14,400 --> 04:37:16,680
it right here
6142
04:37:16,680 --> 04:37:20,840
it is uploading as we speak
6143
04:37:21,419 --> 04:37:24,061
and in just a couple of seconds oh
6144
04:37:24,061 --> 04:37:26,641
already it is published we can even
6145
04:37:26,641 --> 04:37:29,099
change the domain by going to site
6146
04:37:29,099 --> 04:37:31,561
settings change site name to something
6147
04:37:31,561 --> 04:37:34,859
like refine Dash dashboard
6148
04:37:34,859 --> 04:37:36,840
and Save
6149
04:37:36,840 --> 04:37:39,359
we can now click this link and check out
6150
04:37:39,359 --> 04:37:43,438
our deployed live man stack dashboard
6151
04:37:43,438 --> 04:37:45,900
and if you try to sign in you're going
6152
04:37:45,900 --> 04:37:47,400
to notice that it's not going to work
6153
04:37:47,400 --> 04:37:50,400
right off the bat with Google
6154
04:37:50,400 --> 04:37:53,641
there we go something breaks so that's
6155
04:37:53,641 --> 04:37:55,740
entirely fine we'll have to go back to
6156
04:37:55,740 --> 04:37:58,438
the Google console to get that fixed but
6157
04:37:58,438 --> 04:38:01,199
then we'll be Off to the Races
6158
04:38:01,199 --> 04:38:02,340
you can go back to
6159
04:38:02,340 --> 04:38:05,340
console.cloud.google.com
6160
04:38:05,938 --> 04:38:09,719
and there you can open up your oauth 2.0
6161
04:38:09,719 --> 04:38:12,539
client IDs
6162
04:38:12,539 --> 04:38:14,458
once you do that you'll see your
6163
04:38:14,458 --> 04:38:16,561
authorized JavaScript Origins and
6164
04:38:16,561 --> 04:38:20,219
redirect Uris simply go back to your
6165
04:38:20,219 --> 04:38:22,919
application and copy the URL of the
6166
04:38:22,919 --> 04:38:25,379
deployed app and then add it right here
6167
04:38:25,379 --> 04:38:28,740
at the URI it's going to be this one
6168
04:38:28,740 --> 04:38:30,719
you can simply remove the last forward
6169
04:38:30,719 --> 04:38:32,938
slash and then you can add it right here
6170
04:38:32,938 --> 04:38:35,458
for the redirect as well and click save
6171
04:38:35,458 --> 04:38:37,680
it might take a couple of minutes for
6172
04:38:37,680 --> 04:38:40,020
the changes to take effect but sometimes
6173
04:38:40,020 --> 04:38:43,320
it works immediately so now if we go
6174
04:38:43,320 --> 04:38:46,618
back to our application reload the page
6175
04:38:46,618 --> 04:38:49,980
and expand it to the entire browser we
6176
04:38:49,980 --> 04:38:52,080
can sign in and would you look at that
6177
04:38:52,080 --> 04:38:54,778
the sign in appears so let's sign in
6178
04:38:54,778 --> 04:38:58,159
with JavaScript mastery
6179
04:38:58,199 --> 04:39:00,900
and it didn't work out correctly just
6180
04:39:00,900 --> 04:39:03,599
fine so let's open up the console
6181
04:39:03,599 --> 04:39:06,000
and the network Tab and let's give that
6182
04:39:06,000 --> 04:39:08,340
one more shot we can click JavaScript
6183
04:39:08,340 --> 04:39:09,778
mastery
6184
04:39:09,778 --> 04:39:11,759
and we can see that the current origin
6185
04:39:11,759 --> 04:39:14,160
isn't registered with the Google oauth
6186
04:39:14,160 --> 04:39:17,458
so just maybe I went ahead and started
6187
04:39:17,458 --> 04:39:19,618
it too soon maybe we need to give it a
6188
04:39:19,618 --> 04:39:22,141
minute for it to work out
6189
04:39:22,141 --> 04:39:24,778
because we did just add this refine Dash
6190
04:39:24,778 --> 04:39:27,299
dashboard origin and would you look at
6191
04:39:27,299 --> 04:39:29,458
that it started working while I was
6192
04:39:29,458 --> 04:39:31,680
speaking so just to make sure it works
6193
04:39:31,680 --> 04:39:34,438
one more time I'm gonna log out and I'll
6194
04:39:34,438 --> 04:39:36,240
try to sign in again with a different
6195
04:39:36,240 --> 04:39:39,180
account so right here we're gonna use
6196
04:39:39,180 --> 04:39:41,040
the second one
6197
04:39:41,040 --> 04:39:44,700
and we are in we can see that we have
6198
04:39:44,700 --> 04:39:47,218
all of our latest properties we can see
6199
04:39:47,218 --> 04:39:49,798
them here as well and we can see our
6200
04:39:49,798 --> 04:39:52,820
agents our application is working
6201
04:39:52,820 --> 04:39:55,920
perfectly I'm incredibly happy with how
6202
04:39:55,920 --> 04:39:58,378
this turned out now there are a lot of
6203
04:39:58,378 --> 04:39:59,580
adjustments you can make this
6204
04:39:59,580 --> 04:40:01,860
application to make it even better
6205
04:40:01,860 --> 04:40:04,980
change the name change The Branding make
6206
04:40:04,980 --> 04:40:08,760
it your own make all of these stats real
6207
04:40:08,760 --> 04:40:12,240
and connected to the database either fix
6208
04:40:12,240 --> 04:40:15,120
it by changing the URL right here or
6209
04:40:15,120 --> 04:40:17,458
Implement your own Google Maps
6210
04:40:17,458 --> 04:40:19,798
integration so you can show your little
6211
04:40:19,798 --> 04:40:23,100
map right here there are a lot of
6212
04:40:23,100 --> 04:40:25,440
adjustments you can make take this app
6213
04:40:25,440 --> 04:40:28,320
and make it your own but even with that
6214
04:40:28,320 --> 04:40:31,378
said what we have built here today is
6215
04:40:31,378 --> 04:40:34,560
something special it is a full stack
6216
04:40:34,560 --> 04:40:38,000
mern application using two resources
6217
04:40:38,000 --> 04:40:42,180
properties and users we have a wonderful
6218
04:40:42,180 --> 04:40:45,600
front-end Builder to react and mui and
6219
04:40:45,600 --> 04:40:48,420
we have an Express node.js and mongodb
6220
04:40:48,420 --> 04:40:49,680
database
6221
04:40:49,680 --> 04:40:53,280
once again huge thanks to refine not
6222
04:40:53,280 --> 04:40:55,500
only for sponsoring this video but for
6223
04:40:55,500 --> 04:40:57,660
creating such an amazing tool that
6224
04:40:57,660 --> 04:40:59,640
allowed us to build this application
6225
04:40:59,640 --> 04:41:00,780
today
6226
04:41:00,780 --> 04:41:03,360
with that said thank you so much for
6227
04:41:03,360 --> 04:41:05,820
watching and I'll see you in the next
6228
04:41:05,820 --> 04:41:09,860
one have a wonderful day
6229
04:41:10,750 --> 04:41:22,709
[Music]
439733
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.