﻿1
00:00:01,200 --> 00:00:05,790
‫So let's now display some nicely formatted notifications

2
00:00:05,790 --> 00:00:08,550
‫which in the world of web design

3
00:00:08,550 --> 00:00:12,693
‫and development are also called toasts for some reason.

4
00:00:14,310 --> 00:00:19,050
‫So for that, let's bring in yet another third party library.

5
00:00:19,050 --> 00:00:20,890
‫And this is a really small one

6
00:00:23,217 --> 00:00:26,340
‫but it's still better than built all of this stuff by hand.

7
00:00:26,340 --> 00:00:31,340
‫So React Hot Toast is the name of this library.

8
00:00:33,480 --> 00:00:36,180
‫And then we will actually need to set that

9
00:00:36,180 --> 00:00:40,800
‫up right here again in our application.

10
00:00:40,800 --> 00:00:44,910
‫So in this component right here in our component tree.

11
00:00:44,910 --> 00:00:49,910
‫So similar to these global styles and these dev tools

12
00:00:50,460 --> 00:00:54,090
‫we need to add yet another self-closing component here

13
00:00:54,090 --> 00:00:56,430
‫in this case, one that is responsible

14
00:00:56,430 --> 00:01:00,543
‫for providing some options to our toaster.

15
00:01:01,860 --> 00:01:04,860
‫So let's actually do that down here

16
00:01:04,860 --> 00:01:08,883
‫in order not to clutter or mark up too much.

17
00:01:12,900 --> 00:01:15,870
‫And so this component is called a toaster

18
00:01:15,870 --> 00:01:18,450
‫because it'll produce toasts.

19
00:01:18,450 --> 00:01:21,780
‫And again, toasts are the name that we give

20
00:01:21,780 --> 00:01:24,180
‫to these notifications that we see.

21
00:01:24,180 --> 00:01:28,200
‫So these kind of alerts, so toaster

22
00:01:28,200 --> 00:01:31,053
‫and then this receives a few props.

23
00:01:32,458 --> 00:01:33,291
‫Once again, you can look all

24
00:01:33,291 --> 00:01:36,240
‫of these props up in the documentation.

25
00:01:36,240 --> 00:01:41,097
‫So if you just Google React Hot Toast, then yeah

26
00:01:43,001 --> 00:01:45,510
‫the best toast in town.

27
00:01:45,510 --> 00:01:50,490
‫And so here you can already see what's that gonna look like.

28
00:01:50,490 --> 00:01:53,343
‫And then here you have examples of all kinds of stuff.

29
00:01:55,243 --> 00:01:56,190
‫And yeah, if you want

30
00:01:56,190 --> 00:01:59,760
‫you can check out how this works over there.

31
00:01:59,760 --> 00:02:01,590
‫So here I want to display this.

32
00:02:01,590 --> 00:02:06,590
‫In the top center, the gutter should be 12

33
00:02:06,990 --> 00:02:11,990
‫which is the space between the window and the toaster.

34
00:02:13,800 --> 00:02:16,630
‫Then the container style should be

35
00:02:17,550 --> 00:02:21,123
‫and so here we need to specify now an object of styles.

36
00:02:22,560 --> 00:02:27,003
‫So let's give it a margin of eight pixels.

37
00:02:28,530 --> 00:02:33,483
‫And then here we can specify some toast options.

38
00:02:35,880 --> 00:02:37,560
‫So we can, for example, define

39
00:02:37,560 --> 00:02:41,673
‫for how long a success toast will stay on the screen.

40
00:02:42,630 --> 00:02:47,073
‫So success and then duration.

41
00:02:48,750 --> 00:02:52,410
‫And let's set it to three seconds.

42
00:02:52,410 --> 00:02:55,680
‫So 3000 milliseconds.

43
00:02:55,680 --> 00:02:59,073
‫And then we can do the same for the error.

44
00:03:00,570 --> 00:03:02,310
‫So let's make this a bit longer

45
00:03:02,310 --> 00:03:05,103
‫so that the user can see what's actually wrong.

46
00:03:06,060 --> 00:03:10,560
‫And finally, we can define some more styles here.

47
00:03:10,560 --> 00:03:14,283
‫So let's say the font size should be 16 pixels,

48
00:03:17,730 --> 00:03:22,323
‫the max width I'm gonna make it 500 pixels.

49
00:03:24,060 --> 00:03:26,130
‫Add some padding so that it's similar

50
00:03:26,130 --> 00:03:29,133
‫to the rest of the app.

51
00:03:30,240 --> 00:03:33,660
‫And then also let's give it a background color

52
00:03:33,660 --> 00:03:36,600
‫to also match our app's design.

53
00:03:36,600 --> 00:03:39,270
‫And so here we can actually now reference our CSS

54
00:03:39,270 --> 00:03:42,183
‫variables that we created earlier.

55
00:03:43,620 --> 00:03:46,173
‫So gray zero.

56
00:03:47,730 --> 00:03:52,143
‫And then let's do the same for the text color.

57
00:03:53,460 --> 00:03:55,590
‫So here, 700.

58
00:03:55,590 --> 00:03:59,880
‫And with this, we are now ready to use this toaster.

59
00:03:59,880 --> 00:04:04,880
‫So right here, let's now replace these alerts with toast.

60
00:04:08,490 --> 00:04:09,540
‫So this is the function

61
00:04:09,540 --> 00:04:12,780
‫that we can import from React Hot Toast.

62
00:04:12,780 --> 00:04:16,021
‫And then on there we can create a bunch of different toasts

63
00:04:16,021 --> 00:04:18,810
‫so styles of toasts.

64
00:04:18,810 --> 00:04:21,330
‫So here we want an arrow toast.

65
00:04:21,330 --> 00:04:25,500
‫And here we want a toast dot success.

66
00:04:25,500 --> 00:04:27,930
‫And so this will then get different icons.

67
00:04:27,930 --> 00:04:31,710
‫And also as we defined earlier, this one will be displayed

68
00:04:31,710 --> 00:04:34,413
‫for three seconds and this one for five.

69
00:04:36,060 --> 00:04:38,460
‫So let's again create ourselves an error

70
00:04:38,460 --> 00:04:40,650
‫by changing this over here.

71
00:04:40,650 --> 00:04:42,423
‫And so now as we delete,

72
00:04:44,251 --> 00:04:47,850
‫ah, this looks a lot nicer than before, doesn't it?

73
00:04:47,850 --> 00:04:52,020
‫So it stays here for a few seconds and then it disappears.

74
00:04:52,020 --> 00:04:55,590
‫And we could even add a close button there if you want it.

75
00:04:55,590 --> 00:04:57,183
‫But let's keep it simple.

76
00:04:58,680 --> 00:04:59,553
‫All right.

77
00:05:00,720 --> 00:05:03,780
‫And now let's place it back here.

78
00:05:03,780 --> 00:05:07,170
‫And just again, to simulate that situation, for example

79
00:05:07,170 --> 00:05:10,770
‫where two different employees of the hotel are working

80
00:05:10,770 --> 00:05:12,930
‫on the cabins at the same time.

81
00:05:12,930 --> 00:05:14,913
‫Let's just duplicate the tap.

82
00:05:16,500 --> 00:05:20,730
‫So let's say that one employee here deletes a cabin now

83
00:05:20,730 --> 00:05:25,730
‫so let's see if that works and yeah, nice.

84
00:05:25,890 --> 00:05:29,310
‫And so now if the other employee is using the application

85
00:05:29,310 --> 00:05:31,230
‫and navigating around

86
00:05:31,230 --> 00:05:35,580
‫then also that cabin will disappear for them.

87
00:05:35,580 --> 00:05:39,990
‫And so that's again, the power of re-validating the queries

88
00:05:39,990 --> 00:05:43,860
‫and in general of using React Query in the first place.

89
00:05:43,860 --> 00:05:47,670
‫So it gives us all this functionality so easily

90
00:05:47,670 --> 00:05:49,173
‫out of the box.

91
00:05:52,290 --> 00:05:55,710
‫Now here, let's just fix this.

92
00:05:55,710 --> 00:05:59,250
‫Maybe let's give ourselves another new cabin here.

93
00:05:59,250 --> 00:06:03,280
‫Actually, just so this looks a bit nicer

94
00:06:04,170 --> 00:06:09,170
‫for four people and a discount, let's say like this.

95
00:06:13,200 --> 00:06:16,470
‫And again, immediately it will show up here.

96
00:06:16,470 --> 00:06:21,060
‫And finally, now let's just fix something in our layout.

97
00:06:21,060 --> 00:06:24,060
‫So first of all, here we will want some space

98
00:06:24,060 --> 00:06:27,690
‫between this title and this table, and also

99
00:06:27,690 --> 00:06:31,680
‫watch what happens when we make this page really large.

100
00:06:31,680 --> 00:06:34,830
‫So then this table and all this content here

101
00:06:34,830 --> 00:06:39,000
‫simply stretches to fit the entire available width.

102
00:06:39,000 --> 00:06:40,683
‫So that's not what we wanted.

103
00:06:42,210 --> 00:06:46,290
‫And so actually let's come back to our app layout.

104
00:06:46,290 --> 00:06:49,140
‫And here we will just wrap our page

105
00:06:49,140 --> 00:06:50,763
‫inside another component.

106
00:06:54,870 --> 00:06:59,427
‫So let's call this just the standard name of container.

107
00:06:59,427 --> 00:07:02,253
‫And so this will be a styled div.

108
00:07:04,770 --> 00:07:09,100
‫And so let's give this a max width of 120 rem.

109
00:07:11,670 --> 00:07:13,980
‫And then in order to center it

110
00:07:13,980 --> 00:07:17,380
‫let's use the margin zero auto trick

111
00:07:19,740 --> 00:07:24,303
‫and then let's we need to wrap our page in there.

112
00:07:25,290 --> 00:07:26,523
‫So container.

113
00:07:29,190 --> 00:07:31,020
‫And there we go.

114
00:07:31,020 --> 00:07:35,340
‫So I think that looks correct, and indeed it does.

115
00:07:35,340 --> 00:07:38,040
‫So now it just stays nicely centered

116
00:07:38,040 --> 00:07:41,340
‫and doesn't occupy all too much space.

117
00:07:41,340 --> 00:07:44,700
‫And now to create the space between this element

118
00:07:44,700 --> 00:07:48,810
‫and the next one, let's also use the container.

119
00:07:48,810 --> 00:07:52,770
‫So that's a lot nicer than to just add some random spacing

120
00:07:52,770 --> 00:07:55,740
‫to this element right there.

121
00:07:55,740 --> 00:08:00,603
‫So again, we can just do this on the parent using flex box.

122
00:08:02,768 --> 00:08:07,768
‫So display flex and then flex direction column.

123
00:08:08,580 --> 00:08:10,893
‫And then we can simply define a gap.

124
00:08:12,960 --> 00:08:16,233
‫So 3.2 rem.

125
00:08:18,360 --> 00:08:19,503
‫And there we go.

126
00:08:20,520 --> 00:08:24,360
‫Great, so this application is starting to look better

127
00:08:24,360 --> 00:08:27,720
‫and better, and I'm really happy the way that it's turning

128
00:08:27,720 --> 00:08:29,850
‫out, and now, next up

129
00:08:29,850 --> 00:08:33,690
‫let's actually add a form to create new cabins so

130
00:08:33,690 --> 00:08:38,223
‫that we no longer have to always come here to add new ones.

