Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:02,080 --> 00:00:04,400
Now for this course section,
2
00:00:04,400 --> 00:00:07,830
I updated our project code a little bit.
3
00:00:07,830 --> 00:00:11,440
You find this updated snapshot attached.
4
00:00:11,440 --> 00:00:12,580
What did I do?
5
00:00:12,580 --> 00:00:17,500
I added a new input folder in the components folder.
6
00:00:17,500 --> 00:00:20,720
So in the components folder, there is this new input folder
7
00:00:20,720 --> 00:00:23,220
which contains a bunch of components
8
00:00:23,220 --> 00:00:26,530
which we're going to need in this module.
9
00:00:26,530 --> 00:00:31,530
These are all regular react components, no page components
10
00:00:31,880 --> 00:00:35,560
which we are going to use for fetching user input
11
00:00:35,560 --> 00:00:38,970
and for then talking to the API routes.
12
00:00:38,970 --> 00:00:42,670
Now I have not added any API routes.
13
00:00:42,670 --> 00:00:44,740
The only other changes I made
14
00:00:44,740 --> 00:00:46,730
besides adding these components
15
00:00:46,730 --> 00:00:49,950
is that I'm using these components.
16
00:00:49,950 --> 00:00:53,000
In the events folder, in the pages folder,
17
00:00:53,000 --> 00:00:55,330
in this event ID component
18
00:00:55,330 --> 00:00:58,660
I added the comments components here
19
00:00:58,660 --> 00:01:01,030
at the bottom of this js X code
20
00:01:01,920 --> 00:01:04,599
and in the index.js file.
21
00:01:04,599 --> 00:01:06,820
So in the homepage component
22
00:01:06,820 --> 00:01:10,103
there I added the newsletter registration.
23
00:01:11,080 --> 00:01:13,120
So if you install all dependencies
24
00:01:13,120 --> 00:01:15,930
and you run this updated snapshot,
25
00:01:15,930 --> 00:01:20,120
then on the starting page, you will see that email
26
00:01:20,120 --> 00:01:22,520
this newsletter sign up part here.
27
00:01:22,520 --> 00:01:24,763
And if you explore a single event,
28
00:01:26,400 --> 00:01:28,190
there if you scroll to the bottom,
29
00:01:28,190 --> 00:01:30,370
you'll see the show comments button
30
00:01:30,370 --> 00:01:34,540
which you can click to view the comments forum
31
00:01:34,540 --> 00:01:36,700
and some dummy comments
32
00:01:36,700 --> 00:01:39,433
which we're going to replace with actual comments
33
00:01:39,433 --> 00:01:41,523
throughout this section.
34
00:01:42,390 --> 00:01:44,620
Now that is the starting state.
35
00:01:44,620 --> 00:01:46,950
And now I gotta challenge for you.
36
00:01:46,950 --> 00:01:50,710
I want you to add a couple of API routes
37
00:01:50,710 --> 00:01:54,790
that handle the newsletter signup,
38
00:01:54,790 --> 00:01:58,650
so that in the end handle an incoming email address.
39
00:01:58,650 --> 00:02:02,810
And then for the moment, maybe just log it to the console,
40
00:02:02,810 --> 00:02:06,650
so you don't need to add any code that writes to a file
41
00:02:06,650 --> 00:02:08,470
or talks to a database,
42
00:02:08,470 --> 00:02:12,460
though you can also do that as an extra exercise.
43
00:02:12,460 --> 00:02:14,350
But for this task here,
44
00:02:14,350 --> 00:02:17,270
just make sure that you accept some requests
45
00:02:17,270 --> 00:02:19,610
from which you retrieve to email
46
00:02:19,610 --> 00:02:21,810
and make sure that such a request
47
00:02:21,810 --> 00:02:24,730
is then sent from the front end.
48
00:02:24,730 --> 00:02:27,460
From this newsletter registration component
49
00:02:27,460 --> 00:02:30,240
here in the registration handler.
50
00:02:30,240 --> 00:02:32,310
Make sure you send the request
51
00:02:32,310 --> 00:02:35,820
to that API route, which you should add.
52
00:02:35,820 --> 00:02:39,150
You can also add validation for the user input
53
00:02:39,150 --> 00:02:42,190
to check whether the entered email was valid,
54
00:02:42,190 --> 00:02:46,023
but that is up to you and not something you have to add.
55
00:02:47,900 --> 00:02:50,930
Now, that is the first challenge, the first task,
56
00:02:50,930 --> 00:02:52,720
it's not the only one though.
57
00:02:52,720 --> 00:02:55,460
We also got to this comments section
58
00:02:55,460 --> 00:02:58,790
and there I want you to do a similar thing.
59
00:02:58,790 --> 00:03:03,790
Add another API route that allows users to submit comments
60
00:03:04,650 --> 00:03:09,480
and make sure that this API route is kind of dynamic.
61
00:03:09,480 --> 00:03:12,010
That the ID of the event
62
00:03:12,010 --> 00:03:14,280
to which the submitted common belongs
63
00:03:14,280 --> 00:03:16,790
is part of the URL
64
00:03:16,790 --> 00:03:18,670
of the API route.
65
00:03:18,670 --> 00:03:22,510
So you'll need to create a dynamic API route here.
66
00:03:22,510 --> 00:03:25,520
Then again, handle incoming requests
67
00:03:25,520 --> 00:03:28,930
and make sure you extract that submit a data
68
00:03:28,930 --> 00:03:31,740
and also handle the case data request
69
00:03:31,740 --> 00:03:33,640
is sent to fetch the data.
70
00:03:33,640 --> 00:03:38,380
So you will need to handle two different HTTP methods.
71
00:03:38,380 --> 00:03:42,210
For the newsletter API route, it was only one method,
72
00:03:42,210 --> 00:03:44,840
you should handle post requests there.
73
00:03:44,840 --> 00:03:46,830
But for the comments API route
74
00:03:46,830 --> 00:03:50,340
you should handle two different HTTP methods.
75
00:03:50,340 --> 00:03:54,010
Incoming post requests which add a new comment
76
00:03:54,010 --> 00:03:57,393
and incoming GET requests, which fetch comments.
77
00:03:58,380 --> 00:04:02,350
Again for the moment it is enough if you just log the data,
78
00:04:02,350 --> 00:04:05,330
if you just log something in your API route.
79
00:04:05,330 --> 00:04:08,000
You don't need to write any other logic,
80
00:04:08,000 --> 00:04:11,970
just return some dummy data in the GET request case
81
00:04:11,970 --> 00:04:16,410
and make sure you do send data and fetch data.
82
00:04:16,410 --> 00:04:19,700
We have this add common handler in comments.js
83
00:04:19,700 --> 00:04:24,380
where you should send that comments data to your API route.
84
00:04:24,380 --> 00:04:28,370
And then also find a way of fetching comments
85
00:04:28,370 --> 00:04:32,780
when the list of comments here is shown.
86
00:04:32,780 --> 00:04:34,470
So when that comment list is shown
87
00:04:34,470 --> 00:04:38,000
make sure you then fetch comments from the API route.
88
00:04:38,000 --> 00:04:39,730
And again, for the moment it's okay
89
00:04:39,730 --> 00:04:42,290
if you just return some dummy data there,
90
00:04:42,290 --> 00:04:45,570
just make sure you implement the base logic
91
00:04:45,570 --> 00:04:48,670
and you add those API routes.
92
00:04:48,670 --> 00:04:51,580
Now definitely try it on your own first.
93
00:04:51,580 --> 00:04:53,780
In the next course lectures,
94
00:04:53,780 --> 00:04:57,370
we're going to add those features together step-by-step
95
00:04:57,370 --> 00:05:00,980
and therefore of course also have a look at those lectures
96
00:05:00,980 --> 00:05:04,770
once you've tried it on your own to see how I solved it
97
00:05:04,770 --> 00:05:07,090
and to compare your solution to mine
98
00:05:07,090 --> 00:05:09,690
and maybe improve or fix your solution
99
00:05:09,690 --> 00:05:11,700
if you got stuck somewhere.
100
00:05:11,700 --> 00:05:13,393
And with that, let's dive in.
7841
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.