All language subtitles for 009 Adding the _Event Detail_ Page (Dynamic Route)_Downloadly.ir_en

af Afrikaans
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bn Bengali
bs Bosnian
bg Bulgarian
ca Catalan
ceb Cebuano
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
tl Filipino
fi Finnish
fr French
fy Frisian
gl Galician
ka Georgian
de German
el Greek
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
km Khmer
ko Korean
ku Kurdish (Kurmanji)
ky Kyrgyz
lo Lao
la Latin
lv Latvian
lt Lithuanian
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mn Mongolian
my Myanmar (Burmese)
ne Nepali
no Norwegian
ps Pashto
fa Persian Download
pl Polish
pt Portuguese
pa Punjabi
ro Romanian
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
st Sesotho
sn Shona
sd Sindhi
si Sinhala
sk Slovak
sl Slovenian
so Somali
es Spanish
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
te Telugu
th Thai
tr Turkish
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu
or Odia (Oriya)
rw Kinyarwanda
tk Turkmen
tt Tatar
ug Uyghur
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 00:00:02,080 --> 00:00:05,620 So lets work on this event detail page now. 2 00:00:05,620 --> 00:00:10,500 We reach this page, if in the URL we have something like 3 00:00:10,500 --> 00:00:14,580 events slash then some event id. 4 00:00:14,580 --> 00:00:17,400 So the goal is now to output the 5 00:00:17,400 --> 00:00:21,350 detail data about this event and for that you of course need 6 00:00:21,350 --> 00:00:23,940 to fetch that data. 7 00:00:23,940 --> 00:00:28,470 Now we do have our dummy data ready with all the events and 8 00:00:28,470 --> 00:00:31,603 now we wanna get an event by id in the end. 9 00:00:32,600 --> 00:00:36,730 Now for this I did provide this get event by id helper 10 00:00:36,730 --> 00:00:40,230 function here which finds an event by id. 11 00:00:40,230 --> 00:00:43,502 And hence we can call this function and pass an id to that 12 00:00:43,502 --> 00:00:46,593 function to get an event by id. 13 00:00:47,590 --> 00:00:50,890 That means that in the event detail page component we now 14 00:00:50,890 --> 00:00:54,450 just need a way of getting hold of that id which is part of 15 00:00:54,450 --> 00:00:56,090 the URL. 16 00:00:56,090 --> 00:01:00,160 And you learn how that works we can use the userouter hook 17 00:01:00,160 --> 00:01:01,320 forwarded. 18 00:01:01,320 --> 00:01:06,320 We can import use router from next router, like this and 19 00:01:10,540 --> 00:01:15,540 then call userouter to get hold of a router object provided 20 00:01:17,730 --> 00:01:18,920 by the next JS. 21 00:01:18,920 --> 00:01:23,130 And then you'll learn that on that router object we can get 22 00:01:23,130 --> 00:01:28,130 access to a query property which has all those dynamic 23 00:01:28,390 --> 00:01:33,390 puff segments that lead to this page as keys. 24 00:01:33,460 --> 00:01:38,208 So here we have event id, with a capital 'I', as a name for 25 00:01:38,208 --> 00:01:43,208 this dynamic path segment. Hence on router.query we can 26 00:01:43,470 --> 00:01:45,740 access event id. 27 00:01:45,740 --> 00:01:49,310 This give us access to the concrete value that was inserted 28 00:01:49,310 --> 00:01:52,791 in the URL when the page was loaded. 29 00:01:52,791 --> 00:01:56,123 So in this case for example, it would be E2. 30 00:01:57,730 --> 00:02:02,600 And therefore this now is the event id we are looking for. 31 00:02:02,600 --> 00:02:06,610 Now we can call get event by id, and for that we need to 32 00:02:06,610 --> 00:02:10,500 import that from the dummy data file so make sure you add 33 00:02:10,500 --> 00:02:14,960 that import statement. And we pass the event id as an 34 00:02:14,960 --> 00:02:17,680 argument to that function. 35 00:02:17,680 --> 00:02:21,160 And that will give us the event we are looking for, at least 36 00:02:21,160 --> 00:02:21,993 hopefully. 37 00:02:21,993 --> 00:02:25,560 Ofcourse we could fail, if I for example manually enter 38 00:02:25,560 --> 00:02:30,290 something like test here, then we would not find an event 39 00:02:30,290 --> 00:02:35,050 for that, because in my dummy data I have no event with an 40 00:02:35,050 --> 00:02:36,880 id of test. 41 00:02:36,880 --> 00:02:41,880 So we should handle that case, and check if event is maybe 42 00:02:42,210 --> 00:02:45,950 false by adding an exclamation mark here, in which case I 43 00:02:45,950 --> 00:02:49,750 wanna return some error message that we didn't find an 44 00:02:49,750 --> 00:02:51,100 event. 45 00:02:51,100 --> 00:02:54,270 For the moment I'll just return a paragraph here where say 46 00:02:54,270 --> 00:02:56,733 no event found. Just like that. 47 00:02:57,660 --> 00:03:00,330 But if we make it past this check, we know 48 00:03:00,330 --> 00:03:04,500 that we did find an event, and now we wanna return an output 49 00:03:04,500 --> 00:03:09,100 data for that event. And for this ofcourse it's totally up 50 00:03:09,100 --> 00:03:13,090 to you, how you want that page to look like. 51 00:03:13,090 --> 00:03:17,650 I prepared a couple of components which we can use for 52 00:03:17,650 --> 00:03:21,080 outputting that event detail data. 53 00:03:21,080 --> 00:03:25,170 Now these are regular react components and I don't wanna 54 00:03:25,170 --> 00:03:29,990 bore you with writing them, therefore you find them attached 55 00:03:29,990 --> 00:03:34,730 Attached you find an event dash detail sit file, which you 56 00:03:34,730 --> 00:03:39,130 can extract into your components folder. So that in the 57 00:03:39,130 --> 00:03:42,900 components folder you have that brand new event dash detail 58 00:03:42,900 --> 00:03:47,610 folder. In there you'll find four components files which in 59 00:03:47,610 --> 00:03:51,983 the end will output some content and also some styles for 60 00:03:51,983 --> 00:03:54,090 various files. 61 00:03:54,090 --> 00:03:57,364 Now again you can definitely go through them this is just 62 00:03:57,364 --> 00:04:02,364 standard react code, nothing next JS specific in there which 63 00:04:02,990 --> 00:04:06,300 is why am skipping this component creation because in this 64 00:04:06,300 --> 00:04:09,370 course. While ofcourse we want to talk about react in 65 00:04:09,370 --> 00:04:13,920 general. I ofcourse also want to focus on next JS as much as 66 00:04:13,920 --> 00:04:15,530 possible. 67 00:04:15,530 --> 00:04:19,209 Therefore, these components are pre-built for you and we can 68 00:04:19,209 --> 00:04:22,439 now use those components in this square bracket event id 69 00:04:22,439 --> 00:04:24,480 file. 70 00:04:24,480 --> 00:04:29,480 Here I'll replace this overall bit with a fragment which 71 00:04:29,483 --> 00:04:34,340 will import from react, so you need to add this import to 72 00:04:35,342 --> 00:04:38,940 use the built in fragment wrapper component. Which is needed 73 00:04:38,940 --> 00:04:43,690 if you have adjacent JS x elements because normally that 74 00:04:43,690 --> 00:04:47,310 would lead to an error. With the fragment wrapper you are 75 00:04:47,310 --> 00:04:50,090 allowed to have adjacent elements. 76 00:04:50,090 --> 00:04:53,410 And then here, I'll start by adding the event summary 77 00:04:53,410 --> 00:04:57,520 component. That's one of the components I provided to you 78 00:04:57,520 --> 00:05:01,830 so we need to import event summary year from going up one 79 00:05:01,830 --> 00:05:04,131 level and another level diving into components, event detail 80 00:05:04,131 --> 00:05:09,131 and then there is this event summary file. And from that we 81 00:05:12,881 --> 00:05:15,830 import event summary. Under words here we can already import 82 00:05:15,830 --> 00:05:20,277 a number of components, the event logistics component from 83 00:05:21,240 --> 00:05:25,810 going up, going up, components, event detail, event 84 00:05:25,810 --> 00:05:30,810 logistics and import the event content component from going 85 00:05:33,770 --> 00:05:38,770 up and going up, components, event detail, event content. 86 00:05:41,610 --> 00:05:45,080 Now with those components imported, down here we output 87 00:05:45,080 --> 00:05:50,080 event summary, event logistics, and event content. 88 00:05:52,600 --> 00:05:56,063 Now between the opening and closing tags of event content we 89 00:05:56,063 --> 00:06:01,063 pass in paragraph, which then receives event.description as 90 00:06:02,250 --> 00:06:05,740 a value and event, is this event we are fetching here from 91 00:06:05,740 --> 00:06:10,080 our dummy data by id and now we are accessing the 92 00:06:10,080 --> 00:06:15,020 description key to output that description text between the 93 00:06:15,020 --> 00:06:16,573 event content text. 94 00:06:18,140 --> 00:06:22,430 Event summary needs a title property, you'll see that if you 95 00:06:22,430 --> 00:06:26,280 have a look at the component, here I want the title 96 00:06:26,280 --> 00:06:31,280 property. So we pass in a title, and that is event.title 97 00:06:31,870 --> 00:06:36,870 therefore. And for the event logistics, there we need to 98 00:06:37,240 --> 00:06:42,010 pass in the date the address, the image and the imagealt tag 99 00:06:42,010 --> 00:06:46,750 So you'll pass and event.date, then pass in an address prop 100 00:06:47,866 --> 00:06:52,866 which has a value of event.location passing the image prop, 101 00:06:53,210 --> 00:06:58,210 event.image, and the imageAlt prop, with event.title as a 102 00:07:00,760 --> 00:07:04,740 value. And just as before you can ofcourse have a look at 103 00:07:04,740 --> 00:07:08,340 event logistics and you see which prompts am expecting here 104 00:07:08,340 --> 00:07:11,810 and how am using them. In the end, the date in the end is 105 00:07:11,810 --> 00:07:15,450 being transformed again, same for the address text and then 106 00:07:15,450 --> 00:07:18,311 I just outputting those different pieces of data also with 107 00:07:18,311 --> 00:07:21,686 some icons and another component which is involved, which 108 00:07:21,686 --> 00:07:26,686 can also just handles how the icons and the text next to 109 00:07:27,020 --> 00:07:28,680 them is being rendered. 110 00:07:28,680 --> 00:07:32,810 That's what we do here, and with all of that done and added 111 00:07:32,810 --> 00:07:37,810 if we now saved this, if we save all this files, if I go 112 00:07:38,850 --> 00:07:43,550 to events slash text, I get no event found, but if I go to 113 00:07:43,550 --> 00:07:48,550 M1 as Nadir, I mean E1, not M1. E1, then we see there's 114 00:07:52,610 --> 00:07:57,000 content here. Now if you zoom in a bit more, this will kind 115 00:07:57,000 --> 00:08:01,230 of break because it did not optimize it for all screen sizes 116 00:08:01,230 --> 00:08:04,720 just some basic CSS code, because ofcourse this is not 117 00:08:04,720 --> 00:08:09,210 primarily about the styling but about the logic and about 118 00:08:09,210 --> 00:08:14,210 next JS. So this now is the output for a single event, now 119 00:08:15,610 --> 00:08:19,710 from this page, we have no easy way of getting back to the 120 00:08:19,710 --> 00:08:23,320 other pages though, we can always manually change the URL, 121 00:08:23,320 --> 00:08:26,800 but we have no navigation bar for example. 122 00:08:26,800 --> 00:08:29,793 Therefore, that's what we are going to dive in next. 10852

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