πŸ›‘ 3hrs to code ClassPass - take PAYMENTS + MANAGE BOOKINGS ! Next.js, Wix SDK (super simple)

00:00
00:00
00:00
00:00 

Hey everyone, after many requests I decided to make a fully functioning app that will actually

00:06 

take bookings. So we're going to be building this clone of class boss in order to do that.

00:12 

So what I mean by this we're of course going to have this cool landing page and if we click

00:16 

on the browse option we'll be able to browse all the classes that are available to us. Of course

00:21 

when you click on a class you'll be able to then select and time slot that you want and once

00:27 

select you we take into a booking page where you can make an actual booking. That's why

00:32 

actually purchase it because all of the management of the bookings is going to be done via the

00:37 

Wix website. So Wix provides you with this dashboard where you can see all the bookings that

00:44 

have been made you can cancel them you can email the clients you can do a lot of stuff okay including

00:50 

adding new classes and then new schedules. So this is going to be fully functional you can deploy

00:56 

it you can actually use it and in addition to this you're going to be using the map box

01:02 

API as well so if you're interested in learning how to do that we're going to be covering that too.

01:07 

This project is going to be built in next year as using the map box API as well as the Wix SDK

01:12 

so that we can manage all the back and stuff thanks to this cool dashboard powered by Wix okay

01:18 

so what are we waiting for let's do it. Okay so let's create a project I'm going to go ahead

01:23 

and select new project this is going to be a next JS project so here we go next JS and I'm

01:31 

just going to call this next JS class pass okay so here is the command we're going to be using

01:39 

if you aren't using webstorm you can just go ahead I'm going to show you how to do this navigate

01:44 

to a directory so for me it would be webstorm projects and use npx create next app here npx create

01:54 

next app and then whatever you want to call this so next JS class pass just like that and hit enter

02:02 

but as we're using webstorm I'm not going to do that I'm simply going to use this

02:07 

we can actually do at latest as well according to the documentation we probably should

02:13 

and I'm going to click create so that is now spinning up my next JS app would you like to use

02:21 

typescript with this project no would you know or should we do yes fine yes tail and no would you

02:28 

like to create a source directory I think we will so yes do we want to use app browser yes would you

02:37 

like to customize default import alias no and there we go so that is installing these dependencies

02:45 

for me based on the options that we chose we're just going to wait for that to do its thing

02:51 

so let's wait and done okay so that is now done and you should see all the files in here in a

03:00 

source directory because we did ask it to do that as well as all this other stuff so that is pretty

03:06 

cool I'm just going to go ahead and do a few things I'm just going to delete the things that we

03:11 

do not want so I actually don't want the favicon so I'm going to delete this the page CSS module

03:22 

I think we should actually just keep all our styling in one file to be honest so I'm actually

03:29 

going to maybe should we delete this I think let's just go ahead and delete this and make our

03:35 

own one so delete silly anyway we'll have page we'll have we'll get rid of layout actually so

03:43 

I'm just going to delete layer CSS page j s okay so I think this is essentially going to be our

03:52 

index j s file you know in fact I'm just going to get rid of everything so we can solve fresh so

03:58 

delete okay do factor and global CSS I'm just going to delete all of this too okay so really

04:10 

going for it with these starting fresh great so now that in our source directory we have this

04:17 

app file in fact I'm just going to move this out global CSS I'm going to put in the source

04:23 

directory and it's delete this app so I'm just going to go ahead and delete that too

04:29 

so one item in our source directory is as global CSS file which has nothing in it great and for

04:36 

those wondering why package adjacent file looks like those are the dependencies that I have

04:40 

along with their versions so something is not working it could be down to the version that you

04:44 

are using just make sure you have the same version as me right here it's going to increase that

04:51 

font size for you a little bit so everyone can see wonderful so let's carry on okay so here

05:00 

we have our global CSS next all I'm going to do is actually head over to Wix and sign up for an

05:08 

account so I'm just going to log in and I'm just going to continue with Google so it's just going

05:15 

to ask me to use an email address I'm just going to use my work on for this and continue to Wix

05:21 

okay so I'm just signing up as if I've never signed up before really and then we're going to

05:27 

carry on so I'm going to say that I'm building this for myself continue I'm going to put book vent

05:35 

and I'm just going to click next because essentially we are wanting to book events right and

05:42 

what should we call this I'm going to call it Anir's plus and next okay that week so great let's

05:51 

continue to the dashboard so this is essentially what our dashboard is going to look like and on the

06:00 

left you should be able to see once this loads all the options that we have available to us so

06:09 

we're going to be using the booking services and the booking calendar for our site so wonderful

06:16 

first off however we're going to create some classes such as you go in here so I'm going to go

06:21 

into booking services and under booking services I'm going to use one of these so essentially

06:28 

we're going to create classes so it's going to be one of these or we can start from scratch

06:35 

so I want to choose to start from scratch the service type well I'm just going to call each one

06:41 

of these by essentially what the venue is called for the class so the first one's going to be the

06:47 

platform next I'm just going to give a short tagline so I'm going to go ahead and put the

06:53 

platform studio DFC is located in index more level R1 DFC and as a short description I'm just going

07:00 

to go ahead and put something that I pre-written the platform studio in index DFC is the public

07:05 

place for a workout come join us and have fun as well as meet like mine did people just make

07:23 

sure that's for correctly while doing a fun workout for your entire body okay I think that's good

07:36 

we can even change the max participants per class I'm going to put 20 and then we can also choose

07:41 

one of these so I'm going to say per session the fixed price is going to be 200 derms and they can

07:47 

pay the entire amount online that's what I'm going to choose of course there is a dropdown if

07:51 

you want them to pay in person or other stuff like that but I'm going to be very strict and say

07:55 

that I want it to be all paid online so that we can manage it better as a business next I'm just

08:00 

going to choose the business address so let's go ahead and do it I'm just going to search for it

08:06 

add a location and now and then I can actually search for the platform studios there we go

08:16 

this is going to be optional I'm just going to use the tagline for this in case we want to use

08:23 

it so great let's save those changes just like that and save it like so wonderful okay so there

08:33 

we go I'm just going to have an image for platform studios so I'm going to choose a main image

08:39 

I'm simply just going to upload media from my computer I'm going to pick the one I need so you

08:47 

can just drag and drop it if you wish we're going to have like a main image and then a sub main

08:53 

image so this one looks good I'm going to add to the page and then also down here we can add

08:59 

more images if we want so I can add a cover image too so for my cover image let's go ahead and just

09:06 

upload some more media so once again this time I'm going to choose a picture of

09:11 

inside platform studios so just like so that's what I'm doing now and add to page great

09:18 

so we now have two images for this I'm going to click save next we're going to add a schedule

09:24 

so that has been saved for us okay here we have one service we have no sessions so I can choose

09:31 

to add it from here or I can choose to go in here to where we were before before I click the save

09:37 

button and I can add sessions here okay so here we go we'll really have one recurring session I

09:44 

have that Thursday at 2 p.m let's just pick a staff member I'm going to rename the first start

09:49 

number to be Ronnie okay and this is recurring I'm going to click save so essentially what we are

09:56 

doing is essentially just let's add some more sessions adding data to this so we can use it in our

10:02 

app when we build out the front end so let's add some more I'm going to go Friday let's go 3 p.m

10:08 

we can add Ronnie or we can have a new staff member let's go ahead and add a new one I'm going to

10:12 

call the new one Sarah and there we go let's add a few more just so we have a lot of data to work

10:20 

Ronnie can do that one and let's do another one maybe on Monday let's do it at 3 okay great so nice

10:28 

now we'll be able to see all the upcoming sessions that are available to book at the platform

10:34 

so let's go ahead and click save okay wonderful so this is looking good we can of course come back

10:41 

and change us at any point if we are going to add more then we can do that from this dashboard

10:47 

we're also going to be able to manage all the bookings on this calendar which is quite cool

10:52 

you'll already see the classes here and you'll be able to see how many participants are here you

10:57 

can change your participants and also email customers from here yeah it's really fully functional to

11:05 

actually be able to you know actually run a class boss if you want so I just wanted to show you that

11:11 

because I think this is a pretty powerful tool you can see all the classes available as well as

11:19 

how many people have books under staff you will be able to see Ronnie and Sarah that I made and

11:25 

you can also add images and add their details of course I'm not going to do this now but you can do

11:31 

that I'm showing you how to do that here and you can even get them calendar access if you wish

11:35 

when I mean this is like next level it really is like it's got so much functionality it's really

11:40 

crazy and we of course have like a work schedule where you can manage Ronnie and Sarah's work schedule

11:47 

and see which classes them and to be in charge of as well as this booking apps so this is kind of

11:54 

I guess third party apps and you can connect to this dashboard as well to really get the most out

12:00 

of it as well as orders and a lot more stuff so let's just go back here I'm just going to add one

12:07 

more service so that we have enough data to work with let's go ahead and call this so I'm going

12:13 

to start from scratch again this time this is going to be for yoga so let's call this

12:20 

trans yoga I'll put a customized fusion of different forms of yoga that will inviguate the seven

12:25 

major chakras or or just put chakras because I think we've run out of space and as the description

12:33 

I'll put explore the types of classes and different solutions we offer within it you're about to

12:37 

start the journey to nudge and better you for the strength positivity and vibrancy max class I'm

12:42 

going to put 10 let's get an image so once again I'm just going to upload some media I'm going to

12:47 

upload it from my computer I'm just going to take these two this time and then I'm going to

12:52 

just pick one and then one for the cover image so let's choose this one for this image right here

12:58 

and then let's pick a price I'm going to put 150 Durham and then also edit the location

13:05 

so let's save the service before let's meet edit the location so that is now saved let's go back

13:11 

into it however so we'll just wait for that to do its thing trans yoga and then we're going to scroll

13:22 

once that has loaded so down here let's edit this as a location and I'm just going to put onyx

13:32 

tower because that's where it is in Dubai you ready location with the same name choose another name

13:42 

let's put onyx tower

13:48 

Dubai located on the ninth floor okay and add location so let's save that and let's also add

14:00 

another image here if we want so I'm going to add a cover image it's going to be the second image

14:05 

that I have here so add to page and let's add some sessions so let's go here save and continue

14:12 

and once again we have let's have different staff members this time I'm going to have

14:19 

Gerald so I'm going to add that it's have one on Friday also reoccurring maybe at like 9 p.m.

14:29 

with emojin and new staff emojin or gen add and then let's have just a few more of these

14:43 

so just kind of spread out at random high amps great and let's maybe change these as well

14:50 

let's make Gerald take these and save okay cool so this shouldn't be too location selected we're

14:58 

just going to have onyx tower for this one keep the current location okay so there's

15:06 

above the onyx tower this is looking great I'm just going to go back and make sure that the other

15:11 

location has a different name just so it's not confusing so the platform here as the location I'm going

15:21 

edit this it's add a new location actually let's put platform studios

15:33 

to buy platform studios there we go and then located on the bottom floor great so I think let's

15:56 

just keep it there's that if I can only spell it correctly once again platform studios

16:06 

platform studios to buy located on the bottom floor great so nice let's unselect this one and

16:27 

keep that one and just save that like so so I think we've got enough data now in order to start

16:33 

populating our app let's just use these two and at the end we'll populate it more so that it has

16:37 

like a final finished look with loads of classes but sure it's good for now so great that is it

16:45 

for now let's go ahead and start actually feeding in this data into our app so let's build our app

16:53 

now we need to do one more thing and that is actually allow for our app to communicate with this

17:00 

Wix website so let's go to headless settings we're going to have to create an OAuth app so let's

17:06 

just call this class pass auth and I'm going to create it because we're going to be needing this

17:13 

code right here in order to communicate with our app so save this client ID I'm just going to put

17:19 

it in my notes for now and as the URLs we haven't actually built this out yet but I'm going to have

17:28 

to allow for a certain redirect URI and we're going to be running our next year's app on

17:35 

HTTP local history thousand and I'm going to create a root called login call back so make sure to

17:43 

add that and make sure when it comes to creating the pages that you could use exactly the same

17:49 

as mine otherwise this will not work and then if you already have a domain in mind then please go

17:54 

and add that here so for example say you were just going to launch it on whatever website

18:04 

Wix gave you so for example mine is this just make sure to add

18:13 

the redirect as well okay so that is something you're going to have to do otherwise you might get

18:17 

some funky messages or not found pages if you try visit the login callback page on your app

18:25 

so that's all you have to do please go ahead and hit save and we should now be ready to go

18:31 

great okay so that is now say it's the same as your wix domain here the moment just with a

18:38 

different endpoint added instead and then if you need to edit it again just go here and it should be

18:45 

there great cool so let's go back to our apps so before we forget about that client ID I'm just

18:55 

going to create a dot env file in the root of our project so go ahead and call it dot env because

19:01 

in here I want you to essentially save that client ID so I'm going to go next public

19:08 

and let's call this wix client ID and then just go ahead and paste the ID that client ID that

19:19 

we saved from the OAuth app so if you need a reminder it's this one right just paste that in here

19:28 

and then we're also going to need the map box token but for now I think it's fine of

19:36 

course let's leave map box to the very end so cool let's get the page structure right next

19:44 

so in fact I know I keep changing my mind but let's not have a source directory what I'm going

19:49 

to do is create another directory called pages just like that and I'm going to move the global

19:56 

CSS out of here and then create a styles directory so once again I'm going to create a new

20:02 

directory called styles and I'm just going to move global CSS into here is delete the

20:12 

source directory so this is what your file structure should look like at the moment and then I'm

20:20 

also going to create a components directory so let's create one more new directory called components

20:27 

so just like so

20:32 

this just means that on here I'm just going to delete that source just like that and save this file

20:40 

okay so we got rid of the source directory just make sure that is removed from that too wonderful

20:45 

let's carry on next I'm going to actually create some pages so let's go ahead and start with

20:54 

the actual app itself so let's create a new file and I'm going to call it app.js just like so

21:02 

and then here I'm going to define the actual app let's write make it a little bit bigger for you

21:13 

going to make this smaller and then we're going to do export default app okay and here's going

21:20 

to be the app is actually going to hold all our components all our pages and a header that is

21:24 

visible on all the pages no matter which page we go to so next I'm going to import some stuff so I'm

21:32 

going to import head from next head import link from next link and that is it and import the styles

21:43 

right so import out styles from the global CSS file which other moment has nothing in it

21:49 

and now like I said this app well we're going to use it to display all the pages right so this is

21:57 

how you would do it we're going to pass through these two things and now I'm just going to return

22:08 

just a wrapping element you can show that is not curly braces so there we go and we're going to

22:19 

get that component I'm going to pass through the page props so that will allow us to essentially see

22:24 

all the pages in our app and if we want a header to show up I'm going to create a header just like

22:31 

so I'm creating in here I'm not going to make a new component out of it because honestly this is

22:36 

not going to hold much here is our header and it's going to hold a link that is going to

22:48 

essentially wrap a h3 element for now that just says class pass okay and if we click on this it's just

22:57 

going to take us back to the home page so that's how you would do at cool I'm also going to actually

23:12 

add a head to pass through some metadata so for example what we want to call our site let's call it

23:21 

class part let's call it anions class pass so this will show up in the browser tag as remember this

23:27 

is metadata you can also have a meta tag that is for mobile view even though we're not going to

23:34 

be doing it for mobile view for this tutorial that is simply just you know too much to cover but of

23:40 

course if you want to then later do it for mobile view that will be useful and next I'm also going

23:47 

well we're not going to have a favicon so I'm just going to leave that for now great but if you

23:52 

want to have a icon that was the piece of code that you would use so maybe let's make this a little

23:56 

bit smaller so we've got our head that will hold our metadata we've got a header that will simply

24:02 

for now link a h3 element to the home page if we click on it and I'm also going to have a login bar

24:10 

here so this is a component let's go ahead and create it next so in our components I'm going to

24:17 

create a new file I'm going to call this well let's call it I think we should call it login bar

24:26 

login bar.js okay and once again const login bar equals here is the syntax for making a component

24:38 

this should hopefully be familiar to you and now we're going to do export default login bar

24:45 

and for now I'm just going to return the word again this should be in parenthesis a return

24:55 

I'm going to do it in wrapping element and for now I'm just going to put login bar so the word

25:00 

login bar because I want to show you what this looks like so cool I think it's time for us to spin

25:06 

this up I'm just going to make this a bit smaller so you can kind of see everything that is going

25:11 

on so that is my whole app at the moment let's spin this up so here you will be able to see

25:19 

that we use the command dev so what I'm going to do is just what we can do it in here so let's

25:26 

get up our terminal just make sure you're in the project next year's class bar so not somewhere else

25:31 

new npm run dev and that's it and I should spin it up on localhost 3000 so here we go

25:40 

okay and there we go we get class pass here showing up because we create a header and if we inspect

25:47 

this we should be able to see the tools that are provided to us and we're not displaying any

25:52 

page here because we haven't actually created any pages but this is the header as you can see here

25:58 

it's an issue element right in a link and if we click on it it takes us back to localhost 3000

26:04 

even though that did show me an error why is that let's go back

26:08 

it's because we don't actually have an index page yet so there's nothing to go back to so let's

26:14 

create that page for us so like I said let's go into pages and create our first page so I'm going to

26:20 

create a file called index JS so just like that and this is going to be essentially the home page

26:26 

so what we see when we visit localhost 3000 or you'll domain URL without a slash and then a page

26:33 

afterwards good before we move on though I just want to show you another way to put in that head

26:40 

I'm going to create a new file I'm going to call it document JS and in here once again I'm going

26:48 

to export document so const document equals export default document and this time I'm going to put

27:00 

a few things from next so import HTML head main and next script from next document and this time I'm

27:11 

just going to return and put out the full kind of HTML document information that we need for

27:22 

the meta information so language English and then let's have a closing HTML tag and in here I'm

27:31 

actually just going to grab the head from here so we don't actually need it in here anymore

27:36 

I think it's just I'm going to make it a little bit more readable for us and kind of keep all

27:40 

this kind of stuff separate so here we have the head and then we're going to have the body of

27:46 

the HTML document I'm going to have the main element that we've imported and then also the next

27:54 

script so essentially all the stuff that we need or essentially all the stuff that is in here

27:59 

it's going to be fed through here okay so I think that just makes it a little bit neater to keep

28:07 

everything kind of separate and it just means that our app.js file just is a bit shorter now

28:12 

and it just has all the kind of elements that are visual in here great so I'm just going to get rid

28:20 

of that document for now let's just check that still works and this class was is showing in here

28:27 

so it is being picked up this is looking good let's go back okay let's build out our first actual page

28:35 

so the home page I'm actually going to call this home so please feel free to call it whatever you

28:41 

want so let's create another component I'm just going to make it a bit bigger export default

28:53 

home just make sure that the syntax for that is correct great so what do we want for here

29:00 

well again there's just going to be very visual actually I'm just going to be creating a page

29:06 

that essentially has a kind of image and then holds all the information for us about class pass

29:14 

so I'm going to create a div I'm going to give this the class name of main

29:21 

and in here I'm going to create an article let's give this the class name I'm just going to

29:26 

close that article this is going to be for the information so I'm going to go main info container

29:37 

and close that off so make sure that is a closing tag that matches that one

29:47 

so minimize this for now so once again this is on the index j s page that we are working on so

29:54 

let's get rid of these and in my main info container I'm going to have an h1 element it's going

30:03 

to say one out for all the fitness wellness and beauty so I've already prepared this then we're

30:10 

going to have a p element that's again gonna just I'm just taking this from the class pass site

30:15 

right because we are making a clone so this is going to have all of this text so in between two

30:22 

paragraph tags which make up an element next I'm going to have a button so I'm going to create a

30:29 

div and this is indeed going to be button container I wonder how I knew that that is pretty creepy

30:35 

class name button container right because this is going to hold a button so I'm going to have

30:42 

two buttons in here actually I'll have one thanks tab nine for all the suggestions I'm going to

30:48 

have one button another button and this button is going to say try for free so try for free

30:56 

and this button is going to say tell me more about class pass okay and we're going to give

31:06 

this this styling of a primary button so this is going to be kind of a global styling that I'm

31:11 

going to apply primary and this is going to be secondary so class name sequender re for the

31:19 

button another thing I'm going to do so maybe let's also just space these out a little bit so

31:25 

it's a little bit more readable is give this one and on click on click what do I want to happen

31:37 

well I want to essentially log in so we're going to write a function to log in if this is clicked

31:52 

so essentially we're going to define log in and do the same for if we actually click on this one

31:59 

so they're both going to take us to log in okay great nearly done we just have a few more things

32:09 

to do I'm actually just going to comment this out because of course we haven't written that

32:15 

function at all so after our buttons after actually the whole button container right so just down

32:23 

here I'm then going to add a link and this link is going to take us to browse classes

32:33 

and appointment and if we click on it it's going to take us to a page which is going to be a

32:41 

such page which we are yet to write but of course we need to import this link from next to s

32:47 

so I can actually just go ahead and do that and import link from next to s for me up here

32:52 

so we really have one link just make sure that is spelled correctly and next I'm just going to have

32:56 

one more paragraph element it's going to actually be a disclaimer so again I'm just taking this

33:01 

from the actual website itself it says offer is available to new trailers only

33:08 

spa and salon appointments are available after trial and I'm going to start this up a bit

33:14 

different I'm going to put disclaimer just so we can start up the element a little bit differently

33:19 

so that is now our index jspage as you will see it's all showing up here how cool is that

33:25 

we've done the html now let's get to styling it up so great that is all on the index jspage right

33:38 

because we essentially have put it in pages and it's being fed into here right here so this

33:45 

head will be like I said visible no matter how many pages we put in here cool let's get to styling

33:52 

this up next so let's get our global CSS file and let's do it so first up I'm just going to leave

33:58 

the whole document so everything in here the same phone family again this is just the one that I found

34:03 

is kind of the closest but please feel free to you know just use whichever one you wish especially

34:09 

for when you are perhaps doing this you know not to copy class possible to build your own booking

34:15 

up next to the html and body I'm going to apply these two things apart from I'm going to spell

34:22 

body correctly so just to kind of start fresh with the margin and padding and I'm also going to not

34:31 

allow any scrolling to to the bottom so over x is going to be hidden and the max width I'm going

34:43 

to put as a hundred viewport width okay great now let's actually start the header so the thing

34:51 

that's going to hold the class box word as well as the login bar I want to essentially make sure

34:57 

that everything is aligned from left to right so I'm going to initialize flex box I'm also going

35:02 

to give a border bottom of one pixel solid and we do RGB this is a gray that I picked out earlier

35:13 

just a very light gray so as you will see here that line has now been applied to the header because

35:18 

that is the whole header and that's carry on the next thing I'm going to do is just make sure

35:26 

everything is spaced out evenly and for this I'm going to do justify content after putting in a

35:36 

semi colon here justify content space between so now everything I put in is going to have the

35:43 

same spacing in between each one and next I wanted to be stuck to the top so I'm going to do

35:48 

position fixed top zero pixels okay we actually don't need to use the pixel we could just put

35:56 

zero let's also make sure that the background is white so that you know if stuff's behind it while

36:02 

we are moving around that it will always be white so you know if we want to put a map behind it

36:10 

that will essentially cover the map if the map is placed behind it with the z index next I will

36:17 

also want to make sure it's always a hundred of the viewport width and let's also give it a box

36:23 

shadow so the box shadow I have is zero x axis 12 pixels y axis 24 pixels blur and then I'm going

36:30 

to make it transparent black with 0.06 so at the moment it looks like this kind of cool I'm really

36:38 

into it okay and now what I'm going to do is also make sure that it's always on top which is why

36:45 

I'm going to give a z index of three okay cool now let's start a button if it has a primary class

36:54 

so I'm going to grab any button anyone or all and if it has so the class so that's what that

37:01 

means has this element of button has the class of primary let's all like stuck together

37:07 

where then the background color I'm going to have a blue so this is stolen from the class

37:15 

website this is the blue they use now it's also get rid of the border so I'm going to go

37:22 

none let's also make sure that the font is white so RGB 255 255

37:34 

padding is going to be 10 pixels let's actually make it 10 pixels on top and bottom and 20

37:41 

pixels on the left and right and there's round of so I'm going to put border radius

37:46 

let's go 30 pixels to make it look more like a pill so that's what it looks like let's do

37:50 

the secondary styling next which is essentially very similar to the primary just I'm going to

37:57 

switch a few things around so I'm going to copy that and put secondary just like so

38:03 

and this time instead of a background color I'm going to put the border as this color

38:08 

we're going to put one pixel solid as well so it means that we don't have this border here

38:16 

anymore and the color of the text is going to be the same it's going to be blue and yeah I think

38:24 

we're okay with that let's also add a font size so we could have just start a button and

38:33 

essentially reuse some of these but you know I've done it this way now so I'm just going to go

38:37 

ahead and add it there too go so there we have our buttons maybe let's also let's actually give

38:43 

this a background color of white so background color RGB 255 255 and wonderful so that is looking

38:56 

good I'm happy with that so far let's move on the other thing that we need to do so

39:04 

let's go ahead and pick out the main info container or maybe just main anything right

39:14 

so in fact those are all kind of reusable let's put main page now because

39:22 

that's this is specific to the main page whereas these buttons can be used anywhere

39:27 

so first off I'm just going to pick out the wrapping element so the wrapping element is this

39:32 

divider class of main and what I'm going to do is actually just assign a height of a hundred

39:38 

viewport height I'm also going to make sure that anything in it so initialize flex boxes in the

39:45 

center so justify content center and align items center and this would not work without the height

39:54 

which is why I added that I'm also actually gonna add an image so background um yeah let's go with

40:02 

image and this is gonna take a URL and I'm simply just gonna steal it from class boss

40:09 

so there we go everything is centered and if I visit class pass what I want to do is just take

40:15 

this image which is hosted online so this one right here so I'm gonna inspect this of course

40:22 

this is you know if you don't want to use your own right like please replace this with your own

40:27 

if you want to so I'm just gonna find where it is background image

40:41 

so here's a URL I believe it's this one

40:49 

let's check it out

40:50 

okay that's a small one let's try this one

41:02 

okay and this one this one we want so I'm just gonna literally take that URL

41:06 

I'm put it in my own site so da da da da

41:11 

just pasted it in like so make sure that is closed off and make sure to put HTTPS

41:27 

and now there it is okay so there it is it is showing let's also maybe now style the

41:35 

main info container so let's grab that

41:44 

and let's give this a background color of white background color RGB 255 255 255

41:55 

so then it looks like that and we can style it up further okay so let's do it next up I'm just

42:02 

gonna add a border radius to round off so border radius 30 pixels and now I'm gonna also add some

42:11 

padding so the pattern is gonna be 60 pixels so quite a lot to essentially pad out the text

42:16 

from the actual container itself great I'm also gonna hardcode the width so I'm gonna make

42:22 

sure that the width is 140 pixels as I think that will look good and then I'm also gonna do

42:29 

text align center cool so that's what it should look like let's also style up a little bit more

42:36 

I'm gonna say that any h1 elements that live inside the main info container so any h1 element

42:46 

that lives inside of it I'm gonna say that I want the font size of this to be 40 pixels

42:53 

and I'm gonna get rid of any margin and padding so actually I believe that's

42:58 

yeah let's get rid of it so margin 0 padding 0 so that's what it should look like and let's

43:08 

also now style the disclaimer so again what I'm gonna do is just make sure that the element lives

43:15 

inside of the main info container and it has the class of disclaimer right so make sure

43:20 

this will exactly the same as you have here disclaimer and I'm gonna choose the font size to be

43:32 

it's going 12 pixels and I'm just gonna make it gray so the color of the text is gonna be

43:36 

RGB 126 126 126 so that's what it should look like at the moment cool I'm also gonna start the

43:47 

button container so the container that holds these two buttons so again just make sure that button

43:52 

container is inside this one so button container and what I want the button container to do is I'm

44:01 

gonna use display flex I'm gonna make sure that the two things are on top of each other so I'm

44:06 

gonna go flex direction column and I'm actually gonna add some margin to the bottom so margin

44:12 

bottom 20 pixels okay so already is looking a lot better now let's actually also add just a little

44:24 

bit of styling to space out the buttons to any button that lives inside the button container inside

44:29 

the main info container I'm just gonna give it a margin of five pixels okay and great so there we go

44:38 

I'm just gonna make this a little bit smaller for you so you can see because I'm doing this on a

44:43 

smaller screen than you and wonderful so for now I'm happy with that this is looking good I think

44:54 

let's start the search page next so the page here which we have not created yet let's go ahead

45:00 

and create it so let's do it let's get rid of the global CSS and I think we're now good for the

45:07 

index JS page I think we've got everything done we'll come back to these on clicks later

45:14 

and let's create a search page so in the pages directory all I'm gonna do is create a new file

45:19 

literally called search JS okay so we're creating this search page great and how do we want to

45:28 

define this I think let's just go with const search so const search equals and let's make a component

45:38 

and then export default search so other moment it will just return an H1 heading that says search

45:45 

and that will be done there is it's behind the header as we fixed that header but there it is so

45:52 

that is on the search page for such search now goes to search.js which lives inside the pages

45:59 

directory pretty cool right so let's actually fast I think get the data back to us from wicks so

46:07 

this is going to be a fun way to learn how to use the SDK let's do it okay so up here first

46:15 

off I'm gonna have to import a few things so let's go ahead and import I'm gonna import use

46:23 

effects use state from the act I also use context we're gonna be using that I'm also gonna

46:30 

import link from next link I'm also going to import a few things from wicks so let's go up our

46:42 

terminals I'm just gonna create a new tab make sure you're in that project I'm gonna install a few

46:46 

packages I'm actually going to install the wicks APA client so it looks like this I'm also going to

46:54 

install wicks bookings which looks like this I'm also going to install jas quickly so we can

47:02 

store cookies and I think that is it for now I'm just going to press enter and wait for those three

47:09 

things to install okay great so while that's doing its thing that should populate in here I'm also

47:20 

going to create some middleware so this is just from the wicks documentation right middleware jas

47:29 

so as you can see those things have now been installed with these versions make sure your versions

47:37 

are the same as somebody who's not working and you're using this in the future just revert back to these

47:42 

and now the middleware well from API client from wicks I'm going to import create client

47:53 

and I'm also going to import O of strategy from wicks API client so import those two things and we're

48:02 

also going to import next response from next server okay cool now we're going to export essentially

48:16 

a sync function middleware however we can rewrite this to be a function expression later I just

48:27 

want to get this done so we're actually going to generate a session for the visitor if no session

48:34 

exists as in like you know you're not logged in so if request cookies get we're going to look

48:42 

in the cookies and get session so if none of that exists in our cookies we know we are not logged

48:48 

in then I'm going to response new next get a next response

49:03 

and I'm going to generate that cookie so we're going to use my wicks client

49:09 

so I'm going to define it and I'm going to get create client and let's create that client

49:14 

so I'm going to get off and I'm going to pass through let's get the O of strategy

49:24 

and then I'm going to pass through my client ID which essentially is going to be

49:32 

in the ENV file so this thing right here next public wicks client is what I should be

49:39 

using here and now I'm going to get the response get the cookie and set session right because

49:48 

none existed before and now we have it I'm going to use JSON stringify await my client

49:57 

await my wicks client.auth.generate visitors tokens okay so just make sure that's a comment there

50:12 

we're essentially setting a cookie under session and then storing the generator token with it

50:20 

and then I'm just going to return the response not sure why that imported so let's get rid of it

50:28 

and this is what the whole file should look like great we will clean this up later on

50:35 

whoops that should just be just make sure that is request so that's our middle where Js file

50:44 

let's shut that down shut down the package JSON shut down the dot unv and let's work on the search

50:51 

page okay so let's carry on importing I'm going to import once again create client and also

51:02 

our strategy from wicks a client and also going to import services is that's what we need to get

51:08 

services are essentially the thing that we are searching for right because here under booking

51:17 

services these are my services right these classes are my services so that's what I'm getting

51:24 

import services from our wicks bookings I'm also going to import cookies from Js cookie

51:38 

because we're going to need to grab those cookies you know from that we are saving so the tokens

51:44 

that we just looked at I'm going to import card from I'm going to create a card that we're going

51:50 

to loop over so actually we will maybe just leave that out for now and then we're going to

51:56 

also import a map which we have not done yet so for now let's just work with this so to get those

52:01 

services again I'm going to just define my wicks client I'm going to create a client and I'm going

52:10 

to pause through modules what I want to get back is these services right so that's what I need

52:17 

and as the auth I'm going to use capital O of strategy and then I'm going to pause through the

52:27 

client ID which is let's get rid of that process.env next public wicks client ID and then the tokens

52:40 

so I'm going to send you check if I am logged in or not if there's a session so I'm going to use

52:51 

JSON parse and I'm going to use cookies get session as that's what I saved it out in my cookies

52:58 

or if none exists just no okay great so we can either be logged in or not logged in cool so that

53:07 

is essentially us communicating with our wicks dashboard now let's fetch those services so in here

53:17 

what I'm going to do is save them to state so const service list you state it's going to be

53:28 

empty or eight to start with and let's fetch services okay so this is going to be an async function

53:37 

and all I'm going to do is essentially const service list await my wicks client services

53:50 

and then I'm going to do query services this is all from the wicks documentation find and call it

54:01 

okay so that's all I'm going to do and then I'm going to use set service list and pass through

54:07 

the service list items so now in my use effect I'm going to that's right fetch services and

54:18 

that just means here if I console log the service list so up here let's see what we saved this

54:25 

state so right in here today you will see my service list you see two objects okay this one is

54:32 

the platform and this second one is for trans yoga so we're getting the information we're

54:38 

essentially getting these two services showing up here we're getting all that data so we can now

54:44 

use it let's use it to map onto little cards next so let's do it I'm going to create a card so

54:54 

let's go back in here and in components I'm going to create new file this is going to be a card

55:02 

JS and that's to find it so const card equals new export default card return so in the card

55:17 

we're going to make it from the article element the article element I'm going to get the class name

55:23 

of card because that's how we're going to pick it out because we have multiple articles in here

55:30 

let's create one div and this div is going to hold the info so I'm going to give it the class

55:35 

name of info container just like so and then in here I'm going to have another div this is

55:44 

going to be for the image container which is why I'm going to have an image here so let's give this

55:49 

the class name of image container and this image works I'm going to take a source which I'm going

56:00 

to leave blank for now and also some alternative text for the visually impaired cool so that is

56:08 

one thing the next I'm going to have in my info container is a text container sure why not thank

56:14 

you tab nine so that is going to go here and I'm going to use an h3 element to show the service

56:20 

name and then p element here to also show the service tagline so the tagline is the kind of secondary

56:28 

thing that we have with these service now outside of this info container so where this finishes

56:33 

right here I'm going to have another div and this is just going to have a p element and it's just

56:41 

going to hold the description so I'm just going to put description for now and let's give this the class

56:48 

name of this encryption container cool so that is my card shall we feed stuff into here I think

57:02 

we can if we want or for now I'm just going to actually comment out so let's go ahead this is

57:08 

going to be for the name of the service this is going to be for the tagline this is going to be

57:17 

for the descriptions so that we go and I think that's all we're going to be feeding in here for now

57:24 

so let's now import the card import card from components card and I'm going to map it out so

57:33 

I'm going to so instead of maybe having this h1 element I'm going to have an h2 element as

57:43 

this is not the most important thing on here I'm going to say choose class right because we

57:50 

want to choose a class and this is actually going to just going to get rid of now the wrapping

57:56 

element for this is going to be the search container and in the search container we're going to

58:04 

have a results container so let's create a div class name results container and in the results

58:15 

container I'm going to choose your class and then I'm going to have an unordered list and now I'm

58:21 

going to use the link let's get a closing link and I'm going to just simply wrap each of these

58:34 

in a or actually maybe let's see any speed in the list items each list item is going to have

58:41 

a link inside of it which is actually going to wrap over our card element that we just made and

58:49 

imported so that is of course what our unordered list is going to look like whoever we want to map

58:56 

the service list onto each list item so let's get the service list and I'm going to use map

59:04 

to map each service onto that's right this list item right here so just like that so now I can

59:14 

get each service that we don't really need this I can get each service and I could just pass it

59:24 

through into the cards I'm going to get the service pass through into the card which means here we

59:28 

need to de-structure it and I'm just going to console log it out for now so console log each of

59:34 

service okay cool now this we will do eventually we're going to use it from these service

59:43 

main slug name I also want to actually let's yeah let's give this a class name

59:51 

and I'm going to give it the class name of card link just like so and then after the unordered

59:59 

list I'm actually going to so actually after the results container make another div and this is

01:00:06 

going to be for the map or we can just put in the map here so I'm going to just put in the whole

01:00:13 

element we don't have it yet so I'm just going to comment it out cool and we are done so there we go

01:00:22 

at the moment we have two service lists that's why it's mapping out to two things however

01:00:28 

so here's the first one here's the second one let's actually use this right because this is

01:00:32 

what's being this whole object is being what's console logged out here and I'm going to use that

01:00:37 

information in order to pass through certain things right so the name of this is the

01:00:43 

we're going to the service and get the name so we're going to use dot notation so I'm going

01:00:57 

to go into the service that we are passing through into here right it's been console logged out

01:01:02 

and get the name of that service which means this is the platform and this is transyoga

01:01:07 

next let's get the what else can we use that we fund the tagline right so I'm going to go ahead

01:01:14 

and get that here is the tagline so once again let's get the service object and get its tagline

01:01:30 

so there we go what else can we get well let's get the image so the image is in

01:01:37 

media I believe we're looking at the color image on the main image I think we should get the

01:01:41 

main image and then we're going to get the image so a lot of dot notation going on here but

01:01:46 

also we're going to have to import something from wicks so we're going to import some of the wicks

01:01:53 

API client do we have that one yes we have the API client that's good so let's import it in

01:02:01 

here so you can work with images from wicks so import media is what we're going to have to get

01:02:08 

from at wicks API client and now I'm going to have to do a defined image I'm going to have to

01:02:19 

get media that we just supported up there I'm going to use get image URL and I'm going to pass

01:02:24 

through that URL so I'm going to get the service and then I'm going to order zix service dot media

01:02:33 

dot main image dot image so let's do it service media dot cover image dot image you can use

01:02:44 

the cover image or you can use the main image it is up to you and one was we have that

01:02:53 

I'm coming this out get that image right and get it URL right because oops what is happening

01:03:03 

here this doesn't need to be there's also pass through some text and maybe just use the service

01:03:15 

name for this and great so once again we're going into media we're getting the cover image getting

01:03:23 

the image and then getting as URL from that once we pass it through into get image URL the method

01:03:30 

that comes with media that we've imported from up here wonderful so this is looking good we're getting

01:03:38 

images we're getting text showing up let's actually style these cards up next so let's do it

01:03:44 

so I believe we are done with everything in here now oh let's also get the service description

01:03:50 

so I'm going to get the service and get the description from it as that exists on the object

01:03:54 

if you go in here to to to to to to to to description is there so that's showing up now too

01:04:05 

and now let's start everything up so maybe I'm just going to format this before

01:04:10 

shut in this down but let's code for my code wonderful and now let's get the global CSS and

01:04:25 

let's style everything to do with the card component so card component well of course we need to

01:04:34 

actually style the card itself so I'm going to go dot card we're going to display flex to initialize

01:04:41 

flex box and make sure everything goes from left to right I'm going to add a border on the bottom

01:04:46 

only and it's going to be solid it's going to be one pixel it's going to be RGB two one four two

01:04:54 

one four two one four let's give it a padding of 10 pixels all around so at the moment I mean

01:05:04 

it won't look like much it's carrying styling once again I'm going to get the card and see any

01:05:09 

peak element that lives inside of it I'm going to give it the font size of 13 just to make

01:05:15 

that little bit smaller so 13 pixels let's maybe also get the actual image itself so I'm actually

01:05:23 

say that any image container we can show this bullet exactly the same as here

01:05:29 

that lives inside the card element with a class of card I'm just going to say that I'm going to

01:05:36 

hard code the height of it to be 100 pixels and the width of it to be 150 pixels okay let's

01:05:43 

also round it off of it so I'm going to use border radius five pixels on it and I'm going to

01:05:47 

hide everything that's overflowing overflowing that 10150 I'm also going to give a margin of 10

01:05:55 

pixels all around just make sure that is a class name as well so that should do that of course

01:06:01 

it just cutting off our image right which means that the image that lives inside of it so this

01:06:06 

element right here I'm also going to change so I'm going to say that any image that lives inside

01:06:13 

that particular image container lives inside an element with a class of card I'm just going to

01:06:18 

make sure that the height of it's 130% so it's kind of a bit larger behind the scenes but just to

01:06:24 

make sure that there's no weird funky behavior happening if it's a square image and so on that's

01:06:28 

what I have done wonderful so this is looking pretty good let's carry on the next thing I'm actually

01:06:37 

going to do is just perhaps get rid of any kind of link looking stuff so I'm going to get the

01:06:49 

card links of element I gave the class of card link to and give it text equation none and I'm

01:06:56 

also going to change the color of the font to RGB242424 okay cool so that is looking much better

01:07:06 

there is a bunch more things to do however so this time I think I want to also get the description

01:07:15 

container so this right here and the text container just make sure that they are the same width so

01:07:24 

I'm going to just make sure that the text container lives inside so text container that lives inside

01:07:33 

the element the class of card as well as the description container so I'm going to give them both

01:07:38 

the same styling and I'm going to make sure that they both have a width of 200 pixels and

01:07:48 

a margin of 10 pixels okay so that's already looking a lot better next let's grab the info container

01:07:57 

so let's grab the info container and the info container I just want to make sure that everything

01:08:05 

is also from left to right so the info container holds the image and the text container I'm going

01:08:12 

to actually give it a width of 400 pixels and a border right it's time so a border right I'm going

01:08:19 

to get solid one pixel and then RGB this is a gray that I picked out I really that used it somewhere

01:08:26 

else already but it just means that this will look like that wonderful I think this is looking

01:08:33 

so much better already let's just get rid of this list item I'm actually going to make this

01:08:38 

generic because I don't want any list items to have this I'm going to go any list item it's going

01:08:45 

to have a list style type none so that's got rid of that dot great this is looking cool of course

01:08:51 

we click on it it won't do we'll just go back to the home page because we haven't defined a route

01:08:55 

for this to go to but I love this so far let's actually work on the search bar next so that we can

01:09:01 

filter these out okay I'm going to be filtering based on a query thanks to wicks so let's do it

01:09:08 

before we move on however I'm just going to actually get rid of any margin from the h3 element

01:09:14 

that lives inside the card as well as any margin that the p elements have so I'm just going to

01:09:20 

go and watch it zero and let's move on okay so we are now done with the card let's get rid of

01:09:27 

that console log this is what everything in here looks like I'm just going to make a tiny bit

01:09:32 

smaller for you so you can see everything right here okay and let's carry on so we've got the card

01:09:40 

let's do the search next so essentially the search bar so all I'm going to do is create a new

01:09:47 

component I'm going to create a new file I'm going to call this search bar dot j s and let's

01:09:54 

define it so const search bar equals let's write I'm going to get these syntax up for a search bar

01:10:03 

and let's return a div for now in fact I'm just going to make it an empty wrapping element

01:10:11 

and I'm going to do export default such part so the search bar let's actually create it right

01:10:21 

so what I'm going to do is create a in fact we can't make this a div sorry I'm being so indecisive

01:10:31 

I'm going to give this the class name of item container as this is going to be tackling an item

01:10:40 

in the nav bar which is why I'm going to do that and that's going to be reusable and now I'm

01:10:47 

going to create a div and this div is going to be the actual search plus I'm going to give

01:10:50 

this the class name of search bar container okay and let's create that search bar so it's going to be

01:11:00 

an input and this input well it's going to have a few things my input is first off let's

01:11:10 

give this the class name of search input the placeholder I'm going to give it is yoga

01:11:22 

the lattes massage and on a change I'm going to set the search time but the search I might

01:11:34 

actually want to be global which is why we're going to use context for this so e set search term

01:11:44 

e target value and then I'm just going to place the value as the eventual search term okay so

01:11:54 

a quick crash course in use context here hopefully you have used it let's actually save up here

01:12:01 

so search term set such and you state apart from instead of you state we're going to use context

01:12:09 

as we're going to be in this from the context of the app so we're going to save this as such

01:12:16 

context and let's actually import use context as well so import use context from react and we're

01:12:25 

also going to import port search context import search context from and I'm going to store it

01:12:34 

so we're going to go back out of here we're going to go into pages and we're going to go into app

01:12:41 

make sure that says pages and in app what I'm going to do I'm going to make this a little bit bigger

01:12:49 

for you or let's get create context right because here as well we're going to be creating that

01:12:54 

context we're going to use everywhere else you create context use state from react and now we're

01:13:04 

going to define such context that we imported into here right so we're going to have to export it

01:13:11 

as well export console you can use it in here and let's define it so I'm going to create context

01:13:19 

and I actually want the context to be no because I want to change the context from these such

01:13:24 

well so that's what I've done I've exported it and I've imported it in here so you can use it

01:13:30 

here and we can therefore use it here and change it here too so that's how that is all linked

01:13:35 

and the next thing I need to do is just use this search context and wrap the whole app in it

01:13:41 

so that you can use that context anywhere in the app so let's do it I'm going to use search context

01:13:46 

provider and the value I'm going to pass through is essentially this okay so that we go if this

01:13:57 

was really rushed please do check out my full-stack developer course where I go into this in a

01:14:03 

lot more detail of course I'm assuming you have the knowledge part use context already but I could

01:14:09 

not be accurate in thinking that cool and just yeah close that off so that is wrapped just going to

01:14:18 

be format this a little bit better and here is the whole code for that amazing the last thing we

01:14:25 

need to do is just save that up here as well so yeah that's right use state and use state starting

01:14:31 

off again now okay so now we should be able to use the search time anywhere in the app I'm just

01:14:38 

going to console up that search time is working of course we need to actually import this search

01:14:44 

for somewhere so we're exporting it let's import it in here from component search bar and I'm actually

01:14:52 

going to put it here right so in the header the second item in the header because this is the first

01:14:59 

this is the second item okay so there is and now if I search for something it's going to put console log

01:15:08 

I'm going to say SS the search time is indeed SS so that is looking good each child in a list

01:15:16 

should have a unique key okay so we also need to go back to the search and it's give each one of

01:15:26 

these a key so that is fine key I'm just going to go with service ID as that believe that exists

01:15:36 

on the service and they do have an ID so that gets rid of that error and also I'm going to use

01:15:42 

this slug so that we can now go to each one of these items too so just while we are here so let's

01:15:48 

go ahead and maybe go to forward slash services I'm going to use back six for this as we are

01:15:56 

going to have to put code in here because we're going to be looking for the slug so back tick

01:16:02 

forward slash services and then I'm going to use the dollar sign so we can put in some code

01:16:06 

so it's a little bit bigger for you so you can perhaps see I'm going to use encode URI component

01:16:14 

and pass through the service not main slug

01:16:23 

dot name okay because I'm just simply going into here getting the service getting the main slug

01:16:31 

name right so if we save that now so that is on the link itself if I click on here it goes to

01:16:40 

services and then the slug name of course we don't have a page for that yet but pretty cool

01:16:44 

that is going to that unique slug right amazing so cool the search bar is working the clicks are

01:16:52 

working I think let's carry on working on the search bar though because we want to be able to filter

01:16:57 

out and I want to style it up too so let's style it up a bit first this should say value as well

01:17:04 

make sure that says value and let's carry on one other thing I'm actually going to do

01:17:12 

is import and I'm going to import a search icon and this is a component I'm going to make so let's

01:17:20 

create a new file I'm going to go to search icon dot to s const search icon equals

01:17:37 

then export default search icon and I'm simply just going to turn an SVG that I found on the

01:17:44 

internet so here it is please feel free to take my code for this I'm just going to show you where

01:17:53 

I found this so here is one you can copy the path for it here okay and simply just paste it in

01:18:04 

like I have right here so that is the search icon that's all I've done yeah the code will be

01:18:12 

available to in the description and now I've imported it so import from search icon and I'm just

01:18:23 

going to put it right here so of course at the moment I just looks like here let's style all of

01:18:30 

this up and change is positioning to so let's get rid of that now let's go to the app.js file

01:18:37 

let's keep the search let's get the global CSS up and let's work on the search well okay great

01:18:47 

okay so first off maybe let's grab the search import itself

01:18:56 

so let's grab that I'm going to give up position of absolute and actually it lives in the

01:19:10 

search bar container and I want this to be its parent so I'm going to give this the position of

01:19:15 

relative so that it sticks to the search bar container okay so other moments over there somewhere

01:19:25 

let's maybe add another item in here so in the header so where's the app so that these

01:19:34 

things are spaced out evenly with the third item being in here and that third item is essentially

01:19:41 

going to be the login bar so I'm going to create a login bar which actually we already have

01:19:48 

created right we've just got some text so cool that should space all these three things

01:19:55 

are equally now wonderful and we can just see these search bar a little bit better so given that

01:20:02 

the position of relative so that search input is now positioned according to the search bar container

01:20:09 

next I'm also just going to give this a well actually maybe let's define the width of the

01:20:14 

parent with I'm going to go with 400 pixels height 40 pixels and then I'm going to give it a margin

01:20:24 

right of 400 pixels as well and then the search for itself I'm going to give it a 100% so it

01:20:32 

fills the parent I'm going to give it a padding 10 pixels on the top and bottom and 30 pixels

01:20:38 

on the left and right this round of so I'm going to do border radius 20 pixels

01:20:47 

outline I'm going to say none border I want to give it a solid border of maybe not this maybe

01:20:54 

292929 and finally I'm just going to give a box shadow of zero x axis 12 y axis 24 pixels

01:21:06 

blur and the color for this is going to be RGB a 0 0 0 0 0 0 6 okay so that's what it looks like

01:21:17 

at the moment next I'm going to also position this and also you know I don't know why it's like

01:21:21 

all the way up there it's in an item container which I think we will use now let's get the SVG

01:21:31 

that lives inside the search bar we'll look for the SVG so the search icon and again I'm going

01:21:37 

to give a position of absolute this time however I'm going to give it a z index of 1 so that it

01:21:45 

goes here and I'm going to position it from the top and from the left so all I'm going to do is go

01:21:50 

top 10 pixels left 10 pixels and there we go there it is this is looking great cool now I think

01:22:03 

we should perhaps style the item container so the item container I'm just going to stick that

01:22:10 

here and the item container what do I want that to be like well I just want you initialize

01:22:18 

flexbox and then I'm just going to align item so from top to bottom center okay so they look

01:22:25 

like this so that one right here I'm going to wrap this in an item container and this an item

01:22:29 

container too and finally I think let's just give it a margin so I'm going to give it a margin 0 from

01:22:35 

the top and bottom and 10 pixels from the left and right okay great so I'm loving how this is

01:22:43 

looking now let's hook up the search bar next so back on the search page is where we're going

01:22:49 

to do this logic I'm just going to minimize that let's import such context from pages app so once

01:23:00 

again we're just importing the context here and now let's get it so we're going to get this

01:23:07 

this let's go ahead and do that down here so const search time set such time we're going to use

01:23:20 

context and the context that we're going to use is such context so that's all I'm doing so that

01:23:26 

we're able to get the search time in this file or in this component or in this page to be more

01:23:33 

precise okay so there we have it so now the search time can be used in the search component and

01:23:43 

I'm going to say that if as such time exists well then we're going to want to search find the

01:23:52 

service list but also based on a query so I think what we should do is use if the search time exists

01:24:03 

we're going to do something else so if the search time exists we're going to do that and if it

01:24:10 

doesn't we're just going to find all the services whether if it does exist we're going to do query

01:24:17 

services starts with and then we're going to look for the services by the name and then we're

01:24:24 

going to decode URI component I'm going to pass through the search time and then we're going to

01:24:35 

find okay so that is a long one this should be starts with

01:24:40 

and then once we have it so we can't define the constant twice so I'm just going to

01:24:50 

set it up here but as nothing and then assign either that or that to it and then I'm going to

01:24:57 

just set these services so this just means that we're going to fetch the services each time the

01:25:02 

search time changes as well so add that as a dependency to the use effects and now I can search

01:25:10 

so how cool is that amazing we have linked up these such but let's move on okay so next I want

01:25:19 

to actually handle what we see when we visit one of these pages so let's do that next

01:25:24 

so let's just get rid of some of these again and now in pages I'm going to create a services

01:25:31 

directory make sure to name it services as this is the path we're creating services and then

01:25:36 

the slug so to create the slug all I'm going to do is create a new file and then I'm going

01:25:44 

to use square brackets right slug because that's what's going to be replaced j s so there we go

01:25:51 

now in the slug essentially it's going to be the service page right so I want to show the service page

01:25:57 

so just like that and we're going to do export default service page once again we're going

01:26:08 

to import a bunch of stuff into here this time I'm going to import use router from next router

01:26:17 

so next router I'm also going to import use effects from yaks as well as use state so let's get

01:26:26 

those two things in there let's also import create client and oh or strategy from wicks API

01:26:39 

client I'm going to import the availability calendar from wicks redirect so actually we need to

01:26:48 

actually import this as well because we don't have this as a dependency so let's get a

01:26:52 

terminal and pmi wicks redirects so that will do its thing but we've got the availability calendar

01:27:00 

we also need to get these services so this is all going to be for getting the right information

01:27:07 

from our wicks client I'm also going to import cookies so import cookies from j s cookie

01:27:18 

and I'll show you how these cookies work in a bit import and then I think we are also well we're

01:27:25 

going to have to create a few things I'm going to create like a mini card as well to actually show

01:27:30 

all the slots available for the service but let's get to building out the service page first

01:27:36 

so let's get the data in right so I'm going to define this as fetch service singular this time

01:27:43 

as we're going to be fetching one service and if a slug exists so we can find that out

01:27:50 

const router equals use router okay so we're just using router from next router if router

01:28:01 

query slug exists I'm going to await and then we need to define my wicks client again so

01:28:13 

in fact we can just get it from here so the search page I'm just going to copy this we should

01:28:24 

probably put this in another file I will do that in a bit and I'm just going to paste that up here

01:28:30 

and this time we need services we need availability calendar and we also need redirects from here

01:28:37 

okay so that's what we need redirects and we imported redirects oh no okay so we need this from

01:28:48 

bookings and then we're going to import redirects from wicks redirects we just literally

01:29:00 

installed so we've got those three that's the three that we want

01:29:09 

so let's await my wicks client services query services and then we're going to look in our

01:29:18 

services for something that equals and then we're going to find the main slug name

01:29:29 

let's make this smaller and do decode your i component and then we're going to pass through

01:29:36 

essentially the router query slug so we're going to literally pass through

01:29:42 

this and search for it in here by its slug because that's the unique identifier so that's the

01:29:48 

wisest thing too such by and then of course we're going to do finds and call it go so great and

01:29:56 

let's save this under something so I'm going to save this as service item singular because we

01:30:01 

can only expect one because the slug is unique and then I'm simply going to set service

01:30:13 

so we're going to save this in state service item so let's actually define that here const service

01:30:21 

set service use state I want to solve with the state being no go so hopefully that makes sense

01:30:28 

and it's passed through that service item so we can save it to the state great so that's how we

01:30:33 

would fetch a service I'm going to put this in a use effect so here we go use effect

01:30:42 

fetch service and every time I guess these slug changes we want to call that so let's just check

01:30:48 

this works right I'm going to console log service singular I'm just going to put the word service

01:30:54 

here in front in case we have any other console logs there now if I refresh this you should see

01:31:03 

the one service showing up here and in items that it is so we are indeed getting that service

01:31:12 

that is good I'm going to go into items however so let's go into items so all I'm going to do

01:31:21 

is go items and get that first item because we are just going to get one so there we go there is our

01:31:29 

one item nice and now from here we want to get the availability too so let's do it I'm going to

01:31:36 

write another function here so const fetch availability and we're going to have to search for

01:31:48 

availability essentially we can do it by the let's say last week let's see we only want to show

01:31:56 

the week so obviously in your dashboard you can have loads and loads of days but we just want to show

01:32:01 

for the week so one week I guess starting today so let's define today const today equals the new date

01:32:11 

object and const one week in the future it's going to be new date let's pass through today

01:32:25 

but then let's also grab one week or can we do it here set date

01:32:31 

one week dot get date plus seven so if we cancel log it's right one week I'm just going to

01:32:51 

put this in a use effect as well so to leave that use effect we're going to essentially if

01:33:03 

service exists we are going to fetch availability and then we're going to actually rerun this

01:33:13 

every time these service changes so let's check it out for now we should just be getting one

01:33:26 

week so one week from today is this date that is good so I just want to check if I just

01:33:31 

chain this on if this will work still now that does not seem to work I guess because we

01:33:39 

define it here so fair enough okay we'll just keep it like that cool so now once we already

01:33:49 

defined today and one week ahead we can pass through those dates so this time I'm going to await

01:33:58 

my wicks client services do we want services this time we want no we don't we want the availability

01:34:07 

calendar this time query availability

01:34:15 

the tea

01:34:19 

availability and then availability I'm going to not pass through this

01:34:29 

let's open this up and I'm going to pass through I'm going to filter right so I'm going to get

01:34:37 

the service ID and just pass through whatever the service ID is right because we got the service

01:34:51 

up here we're then going to filter availability by this service right so we're going to look

01:34:56 

for the ID so that we know which class we are looking for we're going to pass through the start

01:35:04 

date which is going to be today and we're going to do it to ISO string you will let's put this on

01:35:11 

separate lines and then we're also going to pass through the end date which is one week to ISO

01:35:18 

string and the other thing we need to pass through is the time zone I'm just going to do UTC

01:35:24 

so great that is looking good and once the all of that is done I'm going to set availability

01:35:33 

entries so let's actually maybe define that up here too so I'm going to do const

01:35:40 

available ability entries set availability entries I'm going to keep as an empty array and then

01:35:51 

we're going to override that so down here set availability entries and I'm going to get the availability

01:36:03 

if I can only spell it let's actually also define that up here so whatever comes back here will

01:36:09 

save us a very little ability so I'm going to grab that pass up through and get the availability

01:36:20 

entries cool so that should now give us the availability entries let's check it out I'm just going to

01:36:27 

do console log availability entries again I'm just going to make that a string so it's obvious

01:36:36 

and now down here today we get all the availability entries for the platform okay so however

01:36:42 

that makes sense we've got the service got the service essentially get the ID and then we're

01:36:46 

using the ID to get the availability entries for the platform so that we can now map our out

01:36:51 

little cards so let's get to styling this page next let's do it so what I'm going to do is just

01:36:59 

return and then I'm going to essentially let's make a empty wrapping container and

01:37:10 

if service exists I am going to then

01:37:16 

show an article let's give this the class name service singular container

01:37:30 

I'm going to make a div let's give this the class name info container

01:37:34 

this is going to have a main image which I'm going to actually make as a component this time

01:37:48 

so I'm just comment that out because we need to actually create that and then I'm going to just

01:37:52 

use the information that we have so the service name so once again the service name I'm going to

01:38:02 

create a p element that has the service tag line now the p element that has the service

01:38:15 

description so again we're just using stuff from that object then I'm going to make a hairline

01:38:21 

element for a line and then I'm going to put h3 and this is going to show these schedule right

01:38:27 

and the schedule we want to map that out we want to map out essentially the availability entries

01:38:33 

so available in G's map thank you very much and each availability let's go with entry

01:38:41 

I'm going to map out onto a card so in fact I'm going to create a let's put this on a new line

01:38:50 

schedule card component and we're going to pass through the availability entry entry into that

01:38:58 

right so we're going to get that we're just going to pass it through like so and then I'm also

01:39:04 

actually going to get the key from this so whereas the here's the availability entry I want to get

01:39:11 

this so there's zero and use that as a key and to do that I'm going to use object keys

01:39:19 

so key equals I'm going to get object keys availability entry and that should get me the object

01:39:27 

key and just assign it to the key so that's all I am going to do on the scheduled card in fact

01:39:34 

we should probably comment all of this out now until we get the scheduled card made

01:39:40 

and next actually after this whole info container I'm going to create a address container

01:39:47 

so I'm going to give this the class name of address container

01:39:58 

and I am also going to have a mini map here and she passed through the longitude and latitude

01:40:04 

so mini map again I will be creating this later and apart from that I'm going to just have a

01:40:11 

P element that is essentially going to show the location so we need to essentially

01:40:20 

let's get up the service again

01:40:27 

go into here go into locations and then get the business address

01:40:35 

formatted we'll get the city and the country too so let's go ahead and do that so what was it it

01:40:43 

was service okay chance go into the first item

01:40:58 

get business address for mattered

01:41:08 

so that is one I'm just going to put this cool font icon here too

01:41:11 

you can get it up from my code and then I'm going to let's just copy this because this is essentially

01:41:18 

the same we're just going to change this to be city and then do it again so in a P element

01:41:27 

and change this to be country okay good so it won't look like much now but we're getting all

01:41:35 

the information next it's style up let's put an image and let's also put in a map as well

01:41:41 

as map out all the things onto little cards so let's maybe create the cards first so in the

01:41:48 

components I'm going to create a new file this is going to be a schedule card j s

01:41:57 

const schedule card let's make it bigger

01:42:07 

export default schedule card and this is going to return a button essentially because if you

01:42:16 

click on it it should redirect you so it's going to be a button and in the button I'm going to have

01:42:23 

the start day so what do we want what are we passing through into the schedule card again

01:42:31 

passing through the whole availability entry okay

01:42:44 

so all of these we're going to use the start date

01:42:53 

so first off let's pass through the availability entry

01:43:02 

you can show that as well relatively correctly

01:43:07 

and now I'm actually going to use moment in order to format these a little bit better

01:43:11 

so I'm just going to NPMI moment moment is a great library for formatting dates and a more

01:43:17 

readable fashion so that's what I've chosen to do so now I'm just going to import moment from moment

01:43:26 

okay now let's actually go ahead and import everything else we need to import here so in fact

01:43:35 

we're going to have to import a few of these so I'm just going to get these paste them here

01:43:42 

and delete the ones we don't need so we don't need the actually we need all of these okay

01:43:49 

so let's just keep those we're passing through the availability entry we're also going to need

01:43:57 

my Wix client so let's just paste that in up here we need to get all these three things as well

01:44:03 

so that is fine and then let's use the availability entry start date and I'm going to

01:44:12 

essentially define a start date that is more readable so I'm going to use moment

01:44:19 

and pass through the availability entry slot start date because that's what it is it's slot

01:44:32 

start date and it looks like this and I'm going to change the format of it

01:44:37 

I'm just going to also pass through here for the time so h h m m s s okay so now I can

01:44:47 

essentially define the start day and I'm going to use the start date up here

01:44:56 

and reformat it so I'm going to format so that we get the day the first three letters of the day

01:45:03 

like mon choose words then we get the month and then we get the yeah okay so console so in fact

01:45:13 

let me just put it in here now I'm just going to do start date and you will see that we need

01:45:21 

to actually map that out first so I'll start day sorry so onto the schedule card I'm just going

01:45:30 

to uncomment this out now because we can officially map onto the scheduled card now let's just

01:45:36 

import it up here import schedule card from schedule card

01:45:45 

start date format is not a function let's go back in here

01:45:50 

ah that's because we don't format this sorry tab nine you trip to stop okay there we go that is

01:45:56 

what it should look like and that's how we reformat it to literally get the three letters of the day

01:46:04 

we get the month and then we get the yeah how about from month it doesn't really seem to be working

01:46:09 

why is that so that should be capital M maybe it's going to confuse with the minutes there

01:46:14 

but otherwise I think this is looking good I'm quite happy with that

01:46:21 

cool so those are our buttons let's add some more information here so we've got the start day

01:46:27 

the next thing I want to do is get the start time so let's define the start time of the class

01:46:32 

to start time and once again I'm going to get this start date format and then what do we want

01:46:42 

we do actually want that tab nine so let's keep that and let's get the end time to so const

01:46:50 

end time equals start date format and then we're going to pass through the availability

01:47:04 

slot end date from our data and let's pass through this again and this time I'm just going to format

01:47:15 

again yeah like that so that is looking good to me let's check out if it looks right so start time

01:47:30 

end time whoops make sure that is positive moment okay cool that is looking good okay that was

01:47:40 

oh amazing so we've done it we've created those three buttons let's start them up a little bit more

01:47:47 

well actually maybe let's get the yeah okay let's start this up and now let's work on the main

01:47:52 

image and the map I think we've done a lot let's take a quick break with some styling

01:47:58 

so in here let's work on the service individual service page

01:48:05 

so what do we need to get well let's work on the service container first that wraps everything

01:48:12 

I'm going to actually space it out from the top so that it's away from the header that is covering

01:48:17 

some information and also going to initialize flexbox right so that we can center everything so

01:48:25 

justify content center so at the moment it will kind of look like this and everything's from left

01:48:32 

to right so the two containers now I'm going to say that the info container that lives inside

01:48:38 

this service container so dot info container it's going to have a width of 700 pixels max and a

01:48:48 

padding of five pixels so there we go that's the info container and also let's get the address

01:48:56 

container this time so the thing on the right so dot address container and this one let's give

01:49:04 

it a width of 300 pixels and a padding of five pixels too next we're going to grab these service

01:49:12 

container and we will have a main image so maybe let's deal with that when we get to it though

01:49:21 

I think the other thing that we need to do is yeah maybe add a class to these buttons

01:49:33 

so let's give this the class name of schedule card button let's pick out the schedule card button

01:49:42 

and I'm going to do display flex justify content I'm going to do space between so that everything

01:49:54 

in these buttons is kind of spaced out but of course we need to also make the width 100% of the

01:49:59 

parent for that to kind of take a fact so core this is already looking so much better what else

01:50:05 

we want to do these buttons I think border none that's kind of cool right maybe let's add a

01:50:16 

pointer so cursor pointer just so we know that we can actually click on them and let's also

01:50:26 

give each one a border bottom solid one pixel RGB two three six two three six two three six

01:50:39 

and yeah let's meet the background color why actually I've changed my mind RGB two five five two

01:50:44 

five five two five five okay so already that is looking cool I quite like that I think it's obvious

01:50:53 

that you can select them right and it looks kind of neat let's carry on so we've got the address

01:51:00 

we've got the schedule now let's work on the redirect so if you click it it goes to the booking page

01:51:06 

so back and here on this slug

01:51:12 

well actually on the schedule card itself let's do it here I'm going to create a redirect

01:51:17 

so let's define const create redirect it's an async function

01:51:33 

and const yep that's correct const redirect await this is not quite so right not services just

01:51:40 

my works client redirects and I'm going to create redirect session

01:51:50 

and in here we're not going to pass through a URL we're going to create redirect session just make

01:51:57 

sure that spoke correctly we are going to get a bookings check out slot availability

01:52:09 

and pass through the time zone as UTC so to match what we did above coolbacks post flow URL

01:52:25 

window location h ref cool and then once that is done we don't want to return redirect we just

01:52:34 

want to get the window location and use redirect

01:52:45 

redirect session

01:52:48 

for URL so let's check it out so on click of the button

01:53:07 

we are going to create redirects and pass through the availability entry that we are working with

01:53:14 

right just make sure that says on click so now if I click on one of these slot availability not defined

01:53:24 

that's because we need to pass it through into here as the availability entry and now if we

01:53:30 

click on one of these it should take us to the login callback page so we need to create that

01:53:36 

so once again this time where the search is I'm going to create a new file and this is going to be

01:53:43 

login callback js let's import a bunch of stuff that we've been reporting everywhere and we

01:53:52 

really should clean up but I'm just going to roll with it for now let's import this let's import

01:54:04 

use state and use effect from react and import cookies from js cookie next I'm also going to

01:54:13 

just take the wicks client so let's grab that and put it in here this time what we need we don't

01:54:19 

need any modules actually so let's delete that and let's define a login callback so login

01:54:25 

callback and in here I'm just going to save some stuff to state so const next page

01:54:34 

set next page start off with it being null const error message set error message tab 9 is being

01:54:43 

really helpful here const verify login

01:54:50 

this is going to be an async function I'm going to use JSON parse because we're going to get the

01:54:54 

local storage this time so let's get local storage get item we're going to get the oh

01:55:07 

of redirect data and let's just save this as data and then I'm going to go to local storage

01:55:20 

remove item or the redirect data so cool that is looking good and then we're going to try

01:55:31 

again this part is going to be from the documentation when you use my wicks client I'm going to get

01:55:37 

auth parse from URL let's also get code and state from this so just like that let's call this

01:55:53 

and then let's get the tokens

01:55:55 

oh wait my wicks client auth get member tokens that is the method that we need we're going to

01:56:10 

get code state of we're going to post your data as well cool while there are no tokens

01:56:19 

so we're checking if tokens exist we're also going to check if refresh token exists we're going

01:56:29 

its values if the value does not exist we're going to overwrite tokens

01:56:40 

again so just in case that is kind of just a quick fix

01:56:51 

now I'm going to get the cookies and set the session

01:57:00 

to be the token right so JSON stringify tokens let's not have an expire you can add that if you want

01:57:10 

and then we're going to get the window location if data exists we're going to get the original

01:57:25 

URI or just go to the homepage

01:57:30 

and then we're going to catch any errors so catch error set next page to be essentially this

01:57:45 

or the homepage and then set error message to be the error to string

01:58:04 

amazing and then let's put this in a use effect just like so and then let's just return

01:58:11 

I'm going to return an article that if an error message exists

01:58:22 

then I'm going to yeah show the error message or if next page exists then we're going to show

01:58:34 

continue href next page otherwise if it doesn't we just display the word loading dot dot

01:58:56 

just like that just make sure use effect is spoke correctly there and now we click on

01:59:04 

one of these and you will see it go to any three nine four one this is the login callback

01:59:11 

that we wrote so essentially thanks to here so here we are on the headless settings

01:59:18 

and then the settings for the auth so the auth app thanks to this right here that is what is allowing

01:59:25 

us to essentially go to this page this is the login callback so just make sure to have your own URL

01:59:32 

here forward slash login callback cool so hopefully you're seeing this now and now you can

01:59:40 

literally make a booking okay you can give in your name your email your phone number and add

01:59:44 

message and pay now you can also personalize this further if you want that's totally up to you

01:59:50 

I'm just going to leave it as it is and then we can also choose to login as well so you can choose

01:59:56 

to login I'm just going to choose to login with Anya at code with Anya.com so I'm just going to

02:00:02 

create that login and then it will show my name we can also just go back so now I am back

02:00:17 

and we can also choose to display my name if we are logged in if you actually look at application

02:00:24 

you will see that here under cookies there is a session ID meaning that we are going logged in

02:00:31 

as Anya okay so maybe let's work on that next I wanted to show my name up here just so that we

02:00:38 

know we are logged in let's do that so I'm just going to delete this session token for now so I'm

02:00:46 

just going to delete it delete that token so we named it session and added a token and we've added

02:00:52 

it to the cookies these are our cookies thanks to essentially every time we set cookies

02:01:00 

so cookies set session and then the token ID that we just deleted okay great let's move on

02:01:09 

so on the app what we need to do is edit the login bar so this one right here which other

02:01:22 

moment just as login bar it's minimized this it's going to move this down I'm going to import a

02:01:28 

few things so in fact let's import this I'm also going to import members from at wicks members

02:01:46 

let's also import use effect and use state from react and import cookies from

02:02:04 

deus cookie cool once again we're going to need my wicks clients I'm just going to copy this

02:02:10 

I'm going to paste it in here we're just going to get members and passes through here

02:02:18 

and that's it so we just want to get the member name for when we are logged in and we want to

02:02:25 

also be able to log in and log out so maybe let's just get rid of everything here I'm going to put

02:02:32 

this in a div let's give this the class name I'm going to reuse the class name of item container

02:02:43 

so this is the same class name that essentially holds everything in our header I'm going to have

02:02:48 

a p tag that just says hello I'm going to pass through the user so we're going to actually set

02:02:53 

the user to state so let's do that up here const user set user we don't need that so that was

02:03:03 

added to me by tab nine but it's incorrect so I've just deleted that great so we have one item

02:03:10 

container next I'm also going to show a button essentially so let's create a button and in fact we

02:03:19 

need to put this in a wrapping div so I'm just going to put an empty element just like so for now

02:03:27 

or maybe let's make a nav because we're going to have one element of buttons what's kind of a

02:03:32 

navigation it's up to you you don't have to put a nav if you don't think it is and then I'm going

02:03:37 

to have a third element here just making sure that it's only same correct formatting so I'm

02:03:45 

going to do that and tab that out and this one also is going to have the class name of item

02:03:52 

container just like so this one this item container is going to hold a button

02:03:59 

and this button let's give it the class name of primary

02:04:06 

and the text try for free just going to space that out because I want to also add an on

02:04:18 

click to this and if we click on this I want to log in so I'm going to write a log in function

02:04:29 

uh in fact we don't need that we can just do log in like that and let's write that function so

02:04:37 

const log in it is going to be an async function so I'll accept that and then I'm just going to use

02:04:45 

my wicks client so my wicks client here and I'm going to get a method from it that method is

02:04:52 

auth and I'm going to generate auth data so that's correct and all I'm going to pass through

02:05:02 

is whatever location we are in so I'm going to pass through the window

02:05:08 

location origin forward slash log in

02:05:22 

cool back making sure to select exactly the same as we did

02:05:28 

so this is just from the documentation right and then I'm going to pass through the window

02:05:33 

location h ref next I'm going to set something in local storage so I'm going to get local storage

02:05:42 

I'm going to set item to be o auth redirect data and then JSON stringify data cool I'm also

02:06:01 

going to save the return of this as just data so that whatever comes back here we are passing

02:06:06 

through into here and saving it local storage under this property next we're again going to use

02:06:12 

my wicks client this time to get auth and then the method of get auth URL and again pass through

02:06:19 

the data and the return of this we're going to have to wait for this this is an async method

02:06:25 

and we're going to just get the auth URL from here so auth URL okay cool and once we have that

02:06:34 

auth URL I'm going to get the window location and just assign the auth URL to it so wicks auth will

02:06:43 

listen to send the user back to the callback page so log in dash callback thanks to this so that

02:06:50 

we can log in okay so that is our log in function let's also write a log out function so const log

02:06:58 

out again this is an async method and I'm going to use my wicks client I'm going to use auth but

02:07:04 

this time I'm going to get the log out method and then I'm going to pass through the window location

02:07:10 

h ref and then the return of this we're going to have to await this as it's an async method

02:07:17 

and we're going to get the log out URL this time from here and then we're going to go get the

02:07:25 

cookies and we're going to remove all the cookies right because you're going to remove the session

02:07:29 

so just like I deleted it manually we're now going to be deleting with code we're going to remove it

02:07:33 

so that removes that token so our authentication token and then I'm going to do window location log out

02:07:41 

URL go so that's how we log in and log out and now I'm just going to actually write another button

02:07:50 

so we've got a button to try for free this button however we only want to show the login button

02:07:59 

if there is no member right so first actually we have to define a member so let's fetch the member

02:08:06 

so up here I'm going to write const fetch number again this is an async function I'm going to use

02:08:16 

my wicks client auth logged in we're going to check we're going to call that and if this is true

02:08:24 

we're going to await my wicks client dot members get my member singular so just like that

02:08:38 

so if we're logged in we're going to get the member so since you want to get that member and

02:08:42 

member name and everything otherwise we just have an empty object and then we're going to use set

02:08:48 

member so in fact I'm going to define up here set member or sorry member set member use state

02:08:58 

null and then we're going to use set member to change it from being null to whatever comes back from

02:09:04 

here okay so let's actually get the member from this object so I'm going to go into that object

02:09:12 

and get the member from it and then we're going to set member with member or undefined

02:09:24 

okay cool so that's all we're going to do now I'm going to fetch the member and use effect

02:09:29 

so let's pass that through into a use effect use effect fetch members or fetch member singular

02:09:38 

let's make sure that is single as we're just fetching one and then pass you an empty dependency

02:09:45 

great the other thing we need to do is set the username right so depending on if we are logged in

02:09:53 

or logged out we want to either show the username or visitor and again I'm going to put this in a

02:09:58 

use effect so use effect and I'm just going to write if my works client

02:10:06 

off is logged in and that is true I'm going to set user to be well if member exists I'm going

02:10:15 

to go and find the profile of that member so this is just the object member and get the

02:10:21 

nickname that that member has set for it's him themselves or I can either use the member profile

02:10:34 

slug or just an empty string so we're literally getting the nickname of the member and if that

02:10:41 

doesn't just the slug and if that doesn't exist then we're just going to get the empty string

02:10:46 

else if we are not logged in I'm going to set user back to be visitor okay great and I want

02:10:55 

this to run essentially if this changes or if the user changes or if the member profile

02:11:05 

nickname changes or if the member profile slug changes cool

02:11:20 

this should be dot dot

02:11:22 

so once again I'm just going to delete this cool so we've got hello visitor here

02:11:38 

great just delete these as we don't need that and let's start off with the user being the string

02:11:47 

visitor and then let's style it up a little bit more so all I am going to do

02:11:57 

is on the globe we'll see us let's work on the nav I'm just going to comment that out and the nav

02:12:04 

itself I'm just going to use display flex to make sure that flexbox is initiated and everything

02:12:10 

kind of displays from left to right so there we go and then let's also finish off this button

02:12:18 

so on here this button right here I'm actually going to display certain things based on if we are

02:12:27 

logged in or not so I'm going to wrap this in some curly braces if member does not equal null

02:12:44 

then we show the button and then depending on so we'll get my works client off logged in and call it

02:12:54 

so if we are logged in we'll display the text log out otherwise let's display the text log in

02:13:04 

okay and then also the on click as well that's going to change depending on if we are logged

02:13:10 

in or not I'm going to format this a little bit better but for now here's the button so on click

02:13:17 

I'm going to say that if my works client is logged in so question mark then I want to log out

02:13:33 

otherwise I want to log in cool so it looks like this it's carrying on styling it up so back in here

02:13:42 

I'm just going to say that any p element that lives inside my nav is going to have the font size

02:13:48 

of 14 pixels

02:13:54 

let's grab the nav I'm going to get the button and if the button has the class of log in

02:14:01 

I'm going to say border non give a padding of 10 pixels give it a background color

02:14:11 

of transparent

02:14:16 

and now let's get the nav button log in on hover and just change that to be maybe a gray

02:14:25 

so I'm going to post a two for one two for one two for one cool and now also

02:14:33 

I'm going to grab each item containers everything with the class of item container

02:14:39 

I'm going to initialize flex box I'm going to align items in the center so we'll use a line item

02:14:46 

center from top to bottom and also add a margin of zero on the top and bottom and 10 pixels from

02:14:52 

the left and right so great

02:14:58 

we are nearly done we just need to make sure that this button also has the class name of log in

02:15:06 

that we just start so class name log in just make sure this is installed so just go up your

02:15:13 

terminal and do npm i wix members to make sure that is installed great so save that and that is

02:15:22 

looking much better okay cool and if we click on here it should take us to this login page so that

02:15:31 

we can log in and of course we if we are already logged in so log in with Google and because

02:15:39 

that session token is there we should see our name also make sure to export this so export

02:15:48 

default log in callback it should say hello and your kuber and I can log out this was simply

02:15:57 

just clearly cookie so in application here you are essentially going to clear this session

02:16:02 

so log out and there we go that is now deleted and it will say hello visitor again so that's

02:16:10 

what we have done amazing this is looking good let's carry on so we can now log in log out we can

02:16:19 

also actually purchase classes from here and that will be managed on the wix website the last thing

02:16:25 

what to do is just put in some maps i'm not going to be doing that thanks to map box so let's go

02:16:31 

ahead and do that i'm going to do that let's fast put in the little map into here so if you don't

02:16:38 

have an account with map box already please go ahead and head over to map box and just sign up

02:16:44 

and create a token so i'm just going to sign up with you i'm just going to click on sign up let's

02:16:50 

go with ania kuber ania at code with ania.com let's just go ahead and do ania kuber and use a strong

02:16:59 

password and just agree to this okay this is already taken so let's do one great wonderful and

02:17:07 

let's create our account fresh this page and then we'll just ask you what industries you're in

02:17:14 

so for this i guess i'm going to just put hobbyist primary goals add maps and i'll develop it

02:17:25 

myself and then i'm going to put web great and there we go so we need to create a token so let's go

02:17:35 

ahead and do tutorial i'm going to call it tutorial and it's going to delete all of those that is

02:17:41 

correct and i'm just going to create that token okay once again i'll just ask if we will password

02:17:48 

and we should be good to go with that token so yeah you can use your public D41 or you can use this

02:17:55 

one it's up to you just go ahead and copy one and then in the dot env file i'm just going to add

02:18:03 

it so i'm going to go next public map box equals and then just paste it like that go

02:18:18 

so now let's use it i'm actually going to create a mini map in components i'm going to create

02:18:22 

a new file i'm going to call it mini map dot j s and let's go ahead and just clear about which of

02:18:28 

this stuff up so we just have the mini map now let's actually export our component so const mini map

02:18:37 

equals and then we're going to do default export mini map and return

02:18:50 

for now i'm just going to create a div this should of course say export default

02:19:01 

and this div i'm going to give it the class name of

02:19:09 

mini map container okay so there you go

02:19:16 

now let's import a few things i'm going to import map box from and we're going to actually

02:19:24 

have to install map box gl so let's go ahead and do that let's go to our terminals

02:19:31 

and i'm just going to go in here and do empty in i map also yeah i'm making sure your next

02:19:36 

j s class bar so make sure that is the case and i'm also going to import a style sheet

02:19:43 

so i'm going to import in port map box gl this map box gl cs so that we have the styling for

02:19:51 

our map there's loads of sizes you can choose from that's just the generic one and i'm also

02:19:55 

going to import use effect and use ref from react okay now our mini map in order for this to work

02:20:06 

we're going to have to create div and give this a reference so this reference is going to be

02:20:13 

a map container and now let's use ref so i'm going to use ref to define the map container use ref

02:20:23 

and that's essentially going to go in here so we referenced that and we used ref up here from react

02:20:30 

next i'm just going to get map box that we have just got from map box gl and i'm going to

02:20:38 

assign it access token we're going to go into process in v and we're going to get our next

02:20:44 

next pub lick map box token okay so that's just what we called it in the dot envire the envire

02:21:02 

if you want to make sure that it's incorrect and you're just copy and paste that so it's really

02:21:06 

obvious great now let's use a use effect in order to actually get the map and

02:21:14 

assign it a longitude and latitude as well as the zoom so we're going to use use effect this is

02:21:19 

just from the documentation and we're essentially going to pass through a longitude and a latitude

02:21:27 

so for now i'm just going to hard code it so const long equals and then let's just pick

02:21:38 

something where we can just pick it from you know an existing service that we have so let's

02:21:45 

go to booking services

02:21:52 

let's go to the platform

02:22:01 

okay and this will come back with a longitude and latitude that we're going to take

02:22:06 

so in fact if we console log this out so on the service here you will see under the location

02:22:19 

we get a longitude latitude so i'm just going to steal that for now so we can hard code it like i said

02:22:24 

here we go there's a longitude and const lat equals

02:22:41 

let's just swap the round long lat and it just means that now this is the code we need this is just

02:22:53 

from the documentation every time long and lat change we're going to check if map current exists

02:23:03 

so if there is a map we just return out of this and map is we're going to have to define as well

02:23:08 

const map because use ref null and if a longitude exists we're just going to grab one of them

02:23:15 

i'm going to get them up we're going to assign the current map and create a new map box

02:23:24 

map and pass through some things so we're going to pass through the container which is just going

02:23:30 

to be the container where we want to show the map so map container current these style of this

02:23:41 

it's going to be sure we can have this one in fact i wouldn't change it to be 12 just because i

02:23:46 

like that style the center is going to be the longitude and lastitude and zoom let's put us 15

02:23:51 

cool so that's what we're going to do and i'm just going to start this up a little bit too

02:23:59 

so down here let's go with mini map let's grab the mini map container so the thing that's going

02:24:09 

to hold down map i'm going to assign a height of 300 pixels a width of 300 pixels let's round

02:24:16 

it off a bit i'm going to go border radius five pixels and then hide any overflow so overflow

02:24:26 

hidden which means that the div inside the mini map container

02:24:31 

so essentially this div right here i'm just going to give it a hundred percent a height

02:24:44 

a hundred percent so it takes up the whole thing so great so for now i'm just going to import that

02:24:51 

mini container onto the slug so let's import mini map from components in fact i'm just going

02:25:05 

you know write the path so components mini map and we're going to get that mini map

02:25:15 

and just use it there so great there we have it just going to hide this as well as i don't like

02:25:23 

it so to do that i'm just going to grab map box gl compact basically all i've done is inspect this

02:25:36 

actual map and figure out what this component is called right so map box gl compact and i'm just going

02:25:43 

to do display none so that's kind of a hack really okay so there we go there it is and i can also

02:25:51 

put a little marker on it if i wish so to do this i'm just going to do that down here

02:26:00 

let's define the marker so const marker equals new map box gl marker and it's also passed through

02:26:12 

so i'm going to pause through the color that i want the marker to be i'm going to pause through

02:26:15 

RGB it's just like the blue that we have in our theme and now i'm just going to set the long and

02:26:29 

let and pause through the long and let i'm going to add to the map current okay however we imported it

02:26:39 

up here this should probably be gl so change it to gl as well as here gl now let's have a look

02:26:52 

great and there we have it there's our marker this is looking fantastic the next thing i want

02:26:58 

to do is just put in a main image so let's do that i'm going to create that to be a component to

02:27:03 

for each individual slug so let's do it once more i'm going to create a new file i'm going to

02:27:10 

pull this main image dot j s and before moving on instead of hard coding the long and let i'm

02:27:16 

going to pause it through as props so l and g l a t which means that on the slug i need to

02:27:26 

pass them through as well so l and g equals i'm going to go into the services so i'll have this

02:27:33 

put this on a new line we'll check if the service exists we're actually already wrapping it in

02:27:39 

the service so it has to exist so we don't need to check if it exists which is going to get the

02:27:43 

service we'll go into locations and then get the first item from there and then get the

02:27:51 

business address location longer chute okay so just like we were doing previously this time we

02:28:00 

just getting the long and chute and the latitude so in fact i'm just going to copy that changes to be

02:28:06 

lat and then changes to be latitude just like that great so this is looking good and say that

02:28:18 

so now the map should be different for each slug and let's continue working on the main image

02:28:23 

so let's define main image cool let's do export default main image and let's return something

02:28:36 

right so i'm just going to create a div and inside is going to be an image and you guessed it that's

02:28:43 

actually going to show the main image perhaps as the alternative text yeah let's just have a main

02:28:48 

image for now and then i'm going to actually import media from wix api client so import media

02:28:58 

from at wix api client and now just like we did with the previous images let's define our image

02:29:10 

i'm going to use media that we just got from up there get image URL and i'm going to pass through

02:29:18 

we're going to pass through the service into here and then i'm going to get the media main media

02:29:27 

image okay so let's pass through the actual whole service and now i can just get the image

02:29:34 

and get its URL let's give this a class name to i'm going to give this a class name of main

02:29:43 

image container so we can style up a little bit but on here of course we also need to actually

02:29:49 

pass through that whole service into the main image so i'm just going to go serve this and pass

02:29:55 

through the whole service so just like that and of course let's import it so import main

02:30:04 

image from and then i'm just going to do the actual path components main image so great

02:30:12 

let's style up a little bit so let's find the service container and i'm just going to say that

02:30:20 

the element with a class name of main image container that lives inside of it it's going to

02:30:28 

have the following style and i'm going to make sure that each one is 750 pixels with a height

02:30:35 

of 500 pixels overflow hidden and let's round off a bit and do border radius five pixels okay

02:30:48 

good and of course we also need to do whatever the image inside is going to look like so

02:30:55 

the image inside i'm just going to give this a height of 90% great so now let's look at that

02:31:04 

this is looking wonderful if you want we can even go bigger so perhaps let's go bigger

02:31:08 

150% just to make sure that image always fits and actually we should probably make it

02:31:16 

the same size as the info container so where is the main image container let's make it 700

02:31:26 

okay so that is looking much better i'm happy with this final map is just on the home page so

02:31:33 

let's go here to where we can see all of these and let's put a map in here so let's do it

02:31:40 

so let's also create a component called map j s and i'm going to copy a bunch of stuff so in

02:31:47 

fact i am going to just copy all of this and paste it in like so and let's define our maps of

02:31:52 

const map equals like so and let's do export default map we are also going to take a bunch of

02:32:05 

stuff from here so let's grab these these things i'm just going to paste them in like so

02:32:11 

let's return a div give this the class name of map container so not mini map container and in

02:32:24 

here i'm going to have another div and let's give this the ref of map container that we defined up

02:32:31 

there i'm also just going to start this up now while we are at it so where all the map stuff is

02:32:36 

so here's our mini map i'm also just going to do map and play it out now so let's grab the map

02:32:45 

container i'm going to give this a height of 100 of the viewport height and a width of 50 of the

02:32:53 

viewport width okay and any div that lives inside of it i'm just going to again just give it a

02:33:01 

width of 100% and a height of 100% so let's carry on again we're going to have to write a use

02:33:12 

effect so let's go ahead and do that just pass through the dependencies and this time we're going

02:33:20 

to pass through some coordinates but we are also going to map a few so that's why i'm going to pass

02:33:27 

a lot of coordinates right for all of my services so let's do that's codes and let's define

02:33:34 

codes on the app page so let's get up this page so that's going to be on one of the pages it's

02:33:41 

actually the search page so we can get rid of that and now let's define our code so let's

02:33:48 

codes and i'm going to get the whole service list so service list this whole thing

02:33:55 

all my services and i'm going to use map and i'm going to get each service it's called item

02:34:08 

and for each service item it goes to locations get that first item back get the business get the

02:34:18 

address and get the location okay so that's all i'm doing and now into the map i'm just going

02:34:25 

to pass through those codes of codes equals codes okay and now let's import the map so import

02:34:34 

map from components so now on the actual map itself if i console log those codes we should be able

02:34:43 

to see see we're just getting two objects so those are the codes we want to essentially map onto

02:34:52 

the map so once again if or map already exists i just want to return out of this and if codes

02:35:02 

let's just go with first item exists longer chute and the latitude exists so latitude

02:35:20 

then you want to get the map current new map box let's create a new map let's create the container

02:35:27 

first i'm going to use map container current the style i'm going to change to 12 and the center

02:35:32 

is indeed going to be the codes longitude and the latitude and zoom i'm going to put that to

02:35:40 

so great and when are we going to change this i think we should change it every time the longitude

02:35:46 

or latitude changes for the first item so great there is our map we just need to position it to the

02:35:53 

right so what is the wrapping element for all of these so what's wrapping our map it's the such

02:36:03 

container so here we have the such container we do not just going to probably do so let's just do

02:36:11 

it up here you can do it whatever you want so let's just do it at the bottom actually so

02:36:31 

search for our container display flex so that will ensure that they are next together

02:36:37 

great now let's map some markers right so all i'm going to do is get those codes

02:36:46 

so after this finishes so here

02:36:50 

the code for each the code i'm going to create a marker so const marker new map box marker

02:37:05 

i'm just going to pass through what the color once more so the color i want to do is RGB

02:37:10 

two eighty six two five four you can show that is actually wrapped like so

02:37:21 

and then i'm going to set long and lat and get each of the longitude and latitude and then i'm

02:37:28 

going to add to my current okay cool so if we refresh this now those markers are added

02:37:38 

great so there is one and i'm sure you can find the other okay wonderful this is looking so

02:37:48 

so good i'm so happy with this of course we should probably make this 50% of the width as well

02:37:56 

so what is that it's the results container when we get that results container and we give it

02:38:04 

a width a 50 of the viewport width as well just so it's kind of like 50 50 this is looking great

02:38:11 

maybe we can't even make this 60 40 as i think that looks better wonderful

02:38:25 

one thing i'm going to do is just replace this log in it's just going to take me to the

02:38:31 

main page i think instead so i'm just going to swap that out so i think it should take me here

02:38:39 

and i'm just going to wrap both in a link

02:38:47 

and i'm just like that's just going to go to the such page

02:38:52 

just like so and i'm going to do the same for this one as well i'm just going to wrap it

02:39:02 

in the link element and format it a bit better okay so that will just take you to the home page

02:39:15 

now and let's maybe start this up so in fact maybe i'll give this link the class name of primary

02:39:23 

and this link the class name of secondary and get rid of that button element which means we also

02:39:32 

should probably free that class name so that it doesn't matter if it's on a button or not so i think

02:39:42 

i did that up here let's just go with anything with the class of primary and anything with

02:39:50 

the class of secondary and give them both a margin of five pixels okay great actually just change

02:40:03 

a few things around just because that's the way i prefer them so i'm just going to write the path to

02:40:09 

this and i'm also going to put this in a helper file so all i'm going to do is actually

02:40:19 

perhaps let's do it on the same level as the dot unv file i'm going to create a new file

02:40:29 

or let's help her as j s and i'm just going to literally add all of this

02:40:40 

and we're going to import a bunch of other stuff

02:40:48 

so that is the search page don't need a minimap don't need the main image on the slug

02:40:59 

we're also going to pass through all these three things into here not just the services which

02:41:07 

means we need to then import all of these things as well so that is already done for me let's do export

02:41:18 

const which means i can delete that and i'm just going to import my exclients from back

02:41:43 

help us check us great which means i think we can get rid of all that i'm just going to check

02:41:48 

everything works so on the card doesn't see we need to do much the login bar members so let's

02:42:04 

pass through members as well into here so members just getting everything

02:42:13 

and so let that out and import my exclients from helpers

02:42:31 

let's get these scheduled cards yeah i'm just going to comment these things out

02:42:46 

and import my exclients from helpers such but doesn't need it

02:43:01 

we search icon doesn't need need it and i feel you're now good nearly go

02:43:14 

import my exclients from helpers

02:43:20 

and on the search page two

02:43:30 

import my exclients from helpers and we just need to import cookies into that helper file as well

02:43:50 

okay great and everything seems to be working as it should

02:43:56 

okay so now i'm just going to clean up that code essentially remove everything that i have

02:44:00 

consulate out clean it up and share it with you as well so please check it out in the description

02:44:05 

below for the final code if you want to use it just a final thing i want to do is our text

02:44:11 

none to the by primary button as well as on the secondary button i also want to prevent scrolling

02:44:20 

on the y-axis here of the actual app itself meaning you can't scroll up and down and then it's

02:44:28 

at a scroll to this area once it has filled out so we can scroll through all the available services

02:44:36 

so i'm going to add overflow scroll on this element so go all the way down here overflow

02:44:46 

scroll and make it important as well as just a sina height as well so that knows what to scroll

02:44:53 

to great so there we have it there it is all filled out icon of course type four services

02:45:01 

let's go with transyoga this is looking wonderful and then we can actually see the class

02:45:09 

let's also add a scroll to this so let's inspect this what this this in it's in a service container

02:45:18 

so let's add this and find the service container

02:45:23 

so there we go and there's two classes this is all looking wonderful i'm really happy with this

02:45:38 

and that's it thank you so much for coding along with me i hope this was useful and i hope that

02:45:43 

you've enjoyed building out a fully functioning booking site please take this to the next level this

02:45:48 

of course like a very basic one there's so much styling you can do and there's so much more

02:45:52 

functionality you can add like this will fully work and please go ahead and deploy it as well

02:45:57 

i can't wait to hear what you think of it


Description

In this video, we're going to build a fully functional booking system using Next.js and Wix SDK. We'll start by creating a new project in Next.js and then learn how to use the Wix SDK to manage bookings. We'll cover how to create a landing page, browse classes, select time slots, make actual bookings, and more. Additionally, we'll be using the Map Box API to add new classes and schedules. By the end of this video, you'll have a fully functional booking system that you can deploy and use.