Today we are going to build a realtime team collaboration Microsoft Loop 2.0 application with the help of nextjs and react in this application we are also going to integrate an AI model so that you can also generate the document from the AI hey there and welcome back to tub guruji Channel this is a full stack application and it's build for the beginner as well let's walk through the application first and then we'll talk About the text tag which we are going to use to build this application if you see we have this beautiful landing page
and Simple and Clean and once you click get started it will ask you to authenticate to our application so with the help of clerk we added the authentication now you have option uh to sign up or login with the Facebook Google or you can even log in with the email let's log in with the Google select the account and then once you select it it it will redirect You to the dashboard on the dashboard you will see the all the workspace which you previously created also you have option to create a new workspace at the
top you will can switch from personal account to the organization account with the help of clerk we're going to learn how to integrate easily the organization feature now if I switch to the organization where you will see one workspace now this particular workspace can also share with with your Organization with other members so you have option to add number of members as if you are admin to this particular organization also if you want to create a new workspace just click on this one here you have option to change the cover as well here we going
to learn how to easily update the cover and how to add this complete feature then you also have option to choose the Emoji icons here you'll see bunch of different option to add the icons as well After this once you select the any of this icon let's say We'll select this icon and here you can add the workspace name let's say project idea for developers and simply click create once it create it will redir you to the documentation page over here you will see on the left hand side option for your documentation uh the notification
option as well as you can create the number of documents at the bottom section here you will see how many Documents in a free tire you can create on this side you can even update the cover image for your each of the document then you have option to update the Emoji and not only that as soon as I updated here automatically the workspace name also get update so here we'll say project ideas and as soon as I update H or enter it you will see it also change without refreshing the screen then here we added
this beautiful re text editor where you will see different Option to add now let's add a heading here we'll say list of ideas now you have option to add the list as well okay here you can add number of different plugin to your Rich Text Editor not only that but you have also option to remove any of this uh uh text or whatever then you have different kind of alert the L meter you also have option to add the tables as well okay and all the features that we are going to learn from the Basic
this is completely free re text editor and we are going to learn how can we modify according to our needs then not only that but each of the document has the own comment box where us you can share the comments with each other here if I write the comment and send it now this comment will be shared with your teammates you have option to add the Emoji or not only that but you can also tag to the other user here you will see the notification As well once the tag are commented in the comment box
for the given documents now you can also generate the template from the AI so you don't need to write everything from the scratch here you can just mention the template which you are looking for let's say you want a scrum or let's say project progress tracking in table okay and simply click generate now and boom if you see we have SIMPLE uh template for that not only that but if you want to generate a resume for your own let's say um generate resume template for full stack developer of 5 years of experience and then simply
click generate now and boom if you see we have this beautiful uh resume template for you okay so that's how guys you can also add or learn uh how to generate the template from the AI that also we are Going to cover in this particular course now as soon as I create a new document over here you will see the progress also get changed immediately and the new document get added here you have option to delete any of the document once you click delete it will automatically delete and it will you will also see the
change in real time now now let's see how in real time it works let's say you are typing something okay and on the right hand side for the other user see This is different user and immediately he will see the change whatever change you are making it will see on the other user immediately how cool right also if you want to comment anything in this particular uh chart you can add it so you can say add your comment and send this now if I go back to our application uh on the other user here you
will see the count is changed from to 2 to three and here you will see that user comment as well okay see and That's how the notification also going to work in real time without refreshing the uh your screen okay so this complete application we are going to build in this particular course now let's talk about the text tag which we are going to use to build this application so first is the nextjs which is the react framework then for styling we are going to use a telin CSS and the Shad C and UI library
now for the authentication and to add the Organization feature we are going to use my favorite clerk which is the authentication service provider then in order to integrate the AI model we are going to use a free gini a API AI model and it's very easy to integrate as well and for the real time comments and the uh notification we are going to use live block.io it also have a lot of different products to integrate with your application and it's a real-time collaboration uh product now and the Most important in order to add the document
editor we are going to use this editor. JS uh Library okay and to save the data into our database for back end we are going to use a Firebase database which is again a realtime database uh which we are going to use in inside our application in order to get a realtime update without refreshing the screen so guys uh if you did not subscribe to my Channel please do subscribe also go to The tub guru.com in order to get the source code access or you can join the membership to get uh all the source code
access for a free the membership is just starting is less than uh $9 so you can just join it and get exclusive access uh to the tub guru.com with all the exclusive courses as well as the source code also you can track your each of the chapter by chapter and you can track on your dashboard as well so guys uh without doing any further delay let's Begin to develop this Microsoft Loop 2.0 clone application in order to create a react application we are going to use a neck JS nijs is a react framework to develop
the web application it provide a lot of different feature and if you are new to this NJ don't worry because we are going to learn everything from the basic so first thing let's go to this next js. org which is official website for the nextjs and then here you will see the Command to create the application you you can go to this get started and installation step here you will find the command to create the next JS application then go to the folder where you want to create a project and open Terminal at that folder
here you just need to write or page the same command npx create next app at latest now at latest will install a uh create a next application with the latest version now click enter and then It will ask you to do you want to proceed say yes now here we need to add the project name here we'll add um microft Loop CL okay and click enter now will you like to use typescript so in in this tutorial we are not going to use a tip so you can say no then yes link say no the
tailin CSS obviously we want to use a TN CSS so say yes so when we install the nextjs right it also install the TN CSS for us so you don't need to install it again manually would you like To use Source directory say no and the app router we want it and it is it is a recommended so say yes and then import allies say no now here if you see it inst install some default and required dependency like react react Dom next and some Dev dependency for the telin SES now if you see our
project is created and it's ready to use it now open a vs code and then open the folder where you just created that particular project right and select that project folder and Then it will open inside your vs code now on the left hand side you will see the all the projects uh folders and file okay let's walk through one by one so very first folder which is app folder where we going to write and add our all the pages of the application inside this you will see global. CSS which include all the CSS styling
which is applied globally throughout the application then we have layout. Js which is the uh a layout for our application okay Which is called a root layout obviously U for the next JS application we need a root layout inside here you will see some metadata is applied a font is also get applied and over here all the pages is going to render this uh children through this children uh through this body tag okay then we have page. jss uh sorry page.js which is the default and the first page for our application now once we run
the application you will get to know next we have node modules uh so Whatever the packages or dependency we install right all the packages files which is inside this node module obviously we are not going to touch any time then the public folder which is again important folder uh which uh used to store all our images or fonts or whatever okay so whenever you put it inside this public folder and want to access your image you don't need to provide a complete path you just add the image name and that's all now obviously Once we
start developing our application you will get to know much better then we have this next. config.js file which is help us to add the configuration related to a nextjs application then we have package lock and package.json file which contain the name of the um application the version the script to run the application as well as dependency which we install and some Dev dependency so right now if you see these are the some of the default dependencies then we have Post CSS and T.C config.js F which is uh tailn CSS configuration okay so right now if
you see over here uh in that particular folder the T CS is applicable so if you want to create a new folder okay you created a new folder and you want to apply tvin CSS in that folder make sure that folder uh need to be here okay that means you need to provide the part of that folder if it's not come under this particular uh path now let's run the application so go to this Terminal and click new terminal so it will open the terminal inside your vs uh code only and just type npm run
da now it will run your application on the port local 3000 okay now let's open this port on your uh browser and if you see it's uh showing the default page of the nextjs let me bring this side by side so you will understand much better so let me close this one let me close this and over here if I go to this app And page.js right which is the default page and if you see everything whatever written here you will see on the screen okay now let's see uh let's clean everything okay so I
will just delete everything from here and then I will add a simple du tag over here I will say h2 tag and we'll say subscribe to tube grui now if you did not subscribe to my Channel please do subscribe and as soon as I save it right you will see this changes on the screen immediately okay Now obviously here we have some gradient background okay the lines so that's because inside this global. CSS inside this root we have this background start and background end color if I save this one and remove it and save it
you will see plain background with the text subscribe to to guruji okay so that's how you can run your application and as I say this is our default page when uh first time we when you run the application now next thing we want to do Is to install one telin CSS based Library called a Shad CN okay which is very powerful library and the most important thing is very easy to use okay obviously it's a free and in order to install this Shad CN Library first thing you need to go to this ui. shen.com and
then click get started here you will find the uh option called installation click on it and click neck JS because we are using nextjs but here if you see it uses for different different framework As well now as we already created this project the only thing we need to do is to run this uh Shad CN initialize command okay which is a CLI command to run it so that it will initialize the S inside our project so go to a terminal and over here uh click on this plus sign so it will add a new
terminal and just paste this line of code so let me copy this paste it here and it will ask you some of the Question so here we you can select the style which you want okay you have two different style one is default one is newor I will select this newor in this particular project and click enter now you option to select the base color let's select the neutral you can select any of them and the CSS variable for the color say yes and then it will write a component. Json and it will add couple
of folder as well let me show you so if I go over here and inside this you'll See two new folder get added one is the components so right now it's empty so whenever we install any shat CN component that component file will be added inside this component folder automatically then we we have leave folder obviously uh for this particular file we are not going to touch and and again we have component. Json which is a Shad CN related configuration okay now let's do one thing if you scroll down little bit right uh obviously this
is The information to add a font if you want to add a font but if you scroll little bit down over here you can add a button okay now if I go to this left hand side and you will see the component folder sorry component section where you have the button component okay go to this and here you will see the preview how it looks here you have code example but in order to use this component you need to install this first so copy this command and then go to your Project over here inside your
terminal paste it so it will install the button component now once it installed you will see the inside this component folder you will see the UI folder inside that we have button. jsx file file okay which is uh or which is created by the Shad here so obviously if you want to make some changes uh to the default button you can make some changes over here and here you will see the different different variant the size and lot of other things okay Now if I go to this page. jss and want to use that button
component just add it like this and if you see now it is importing from this component / ui/ button now here if you if I write subscribe and if I go back to our application over here you will see the text or button called subscribe see how beautiful right now it also have different different variant which you can explore from the documents so if I say variant as a outline and save it you Will see the button with the outline you can even change the size if I want to change the size to small you
can also uh do that if I go back you will see the button with a small size okay so uh if you want to explore more about each of the component you can always uh refer the shat and documentation now the last important thing that we we are going to do is to update the font globally okay so right now if I go to this layout. JS and here You will see this is the default font which is the inter from the next SL font /g gooogle okay so this is a Google font only so
if you want to know uh the different font let's go to this Google font okay by the Google only obviously and here you can search different different font whatever the font you like it okay let's say I like to use this outfit font okay and just go over here and just make sure that okay this is the currect font that you want to use And if you know the name of the font you can just replace it over here let's say outfit right and here make sure to update this um method as well you can
put the subset as it is you can change this name but right now this is just a constant name I will keep as it is and save it and now immediately you will see the change and now the font is Chang okay so obviously this font is applicable to all the text which we are going to add it inside our Application so that's how guys uh you can set up your um project and update your font I hope you understand everything until this point if you have any question while creating the project or adding the
shats in library or updating the font let me know in the comment section now let's say you want to create a new route called dashboard okay and if I click enter and put the part like this you'll see we got the 404 404 error it Means the page is not found okay the question is how to add this particular route and obviously after that we need to make sure this particular d dashboard page is only accessible to the user who log to our application and in this chapter we are going to add authentication part so
that we can restrict user to access certain pages okay so first thing let's create a new route so inside this app folder we'll create a new folder and we'll call it as A dashboard now inside the dashboard page sorry dashboard folder we want add page.js file okay and here we need to add a default template now in in order to add a template right you need to write the export function and you need to import some packages right now in order to avoid all of this thing and to write everything from the scratch we have
one vs code extension so click on this icon okay which is the extension icon and then search for the es7 plus React Redux react native uh snippet tool okay this is very powerful extension uh and if you see it's downloaded more than a lakh or million but the most important thing once you install this one it's very easy to add the templates also make sure to install this TN css. Intel sense so when you're writing the TN CSS classes is very helpful uh and it will give you suggestion now in order to add a default
uh template right to this page. jsx just write RFC which stand for The react functional export component and click enter and boom if you see the default template is ready now here I will just rename this to let's say dashboard okay and save it now your dashboard page is ready now if I go to the dashboard and click and refresh this page now in this case you will see the text dashboard and now we are not getting any 404 error because that's what the text is written inside this dashboard page okay so that's how you
Can create a route now to uh just to make sure that our folder structure is well organized right I'm going to create a new folder but but in this case I'm going to start the folder name with this square bracket sorry the circular bracket so uh next J will not consider this particular folder as a route and I will just drag this dashboard route inside this route folder so all the routes related to our application we will keep inside this folder okay and if You see nothing get changed see now let's move back and let's
understand how the authentication flow will work look like now once user start or come to our application we want to show a display loog login page okay now user on this particular page will enter the credential obviously here we are going to add the email uh uh password sign up as well as we are going to add a Google social authentication as well then once user enter the credential our uh uh Authentication Service will validate the credential and then once is validate it will log in as a successful and redirect to a dashboard but if
the valid the credential is not valid then we going to show the login fail and we display the error message now this is a very long process okay and in order to implement this particular complete sign up and signin page we are going to use the clerk authentication clerk is authentication Service provider and most important thing is very powerful it also provide their own UI kit as well as you don't need to add any configuration CL is taking care of everything another thing uh you can use it as a free as well so up to
10,000 monthly active user you can add it to your um application but along with that if you want to go beyond that you can obviously uh go to this Pro Plan as well now I use this clerk from in my many of the application and obviously um They updated many of the things and it's quite great when you want to use the clerk okay so the first important thing if you don't have an account create a new account with the clerk and then go to the dashboard once you come to the dashboard here you will
see uh option to create an application if you see in this case I already have a lot of application which I created with the clerk now click on this create application and you need to give the application name let's Say microft Loop uh we can say close for example and here you have option to select or enable the authentication you have email phone username Google Facebook and many of them right now in this case we'll enable Google we enable Facebook and the email now on the right hand side you will see how it actually look
once you integrate on this uh inside your application this is how your um uh signin page will look Like okay so beautiful now just click on this create application and then it will redirect you to the dashboard where you will see the different option to integrate uh this clerk inside your application now obviously we are going to use nextjs so these are these are some of the things we need to follow but on the left hand side you will see many of the option now once us are authenticated to our application right here it will
come Under this user section now obviously we also going to implement this organization section it's very cool feature so that you can create your own organization and you can give access to your documents to your file to the only to the organization and all the members which is inside the organization how cool it is right then you have option to add the authentication Service later on you have multiactor authentication you have option to customize it and there Are many other things okay anytime you can access your API key through this developers API key now uh
I will go back let's go to this uh get started and first thing you need to install this clerk NE CHS okay dependency so this is the SDK we need to install so copy it go to your project and inside the terminal I just clear this one and paste it here so it will install the clerk for our nextjs application next thing you need to add This env. loal uh you need to create a this env. local file and inside this you need to add this um environment variables okay so these are the API key
so first thing let's go to this root directory and then here we'll create env. loal file paste your keys and then save it next we need to add the middle .ts file okay so we need to create it first so here I will just copy this and inside the root directory we'll create a new file called mid. JS make Sure it's a JS and enter and inside this one we need to copy all of this code and then paste it here okay let's save it uh another thing um we need to wrap our application inside
this clug provider component so copy this clug provider and then let me close all of this tab for now and then go to this root layout okay inside this root layout I will just paste this clug provider and we'll wrap all of our application inside this cler Provider now make sure to import this cler provider as well so here we imported it and then save it and that's all now here uh click on this continue to the next JS guide so it will open the guide for us and the next process next step to uh
add the custom sign up and signin page but until this point whatever we did it right here you will see let me go to this home page nothing is happening okay don't worry because next step is to create create our own Sign up and signin page okay so first thing uh if you see these are the route we need to create it okay but obviously you need to type everything so best thing just copy until this point O sorry and then go to your app folder inside this app folder we'll create another folder we can
call it as a and then inside this create a new file and paste that route which you copied now make sure it's changed to jsx and click Enter and boom if you see it automatically create a folder and file for us right and then copy this content and simply paste it here and save it same thing you need to do it for the signin page as well so copy this then inside this o folder paste it here like this and select I change this TSX to jsx and then copy this content and simply paste it
here and save it okay and the last thing we need to update our environment Variable so copy this environment variable go to your env. looc file and simply paste it here and save it okay and now if I go back still you don't have any change but if now in this case if I go to this slash signin you will see the signin uh page where you have option to add the credential and everything how cool it is right also you have the sign up page as well see okay so that's how you can integrate
signin and sign up Page now another important thing in this one right if you want to update this sign in and sign up page that also you can do it but before that let's say you want to uh go to this dashboard page and you want to restrict uh or you want to add authentication to the dashboard page right so before accessing this dashboard page we have to make sure that user is log to our application the question is how to do it right so that's for that one right go to this clerk Documentation and
click on this uh option called clerk middleware okay I will also keep the link in the description now in this CL middleware right as you know that we already have this middleware DJs file now if I scroll little bit down over here you will see that you have option to create a route matcher okay now this route matcher will help us to add a to restrict some of the pages uh from the public access right so copy this uh line of code and just paste It here inside this middle wear so if you see this
is the is protect route okay so that route we will add it here make sure to import this create route matcher and in this case we want to restrict the dashboard we don't have Forum so I will remove it and we just want to restrick user to access from the dashboard next thing we need to protect this route so if you see here we need to add this line of code okay so I will copy this everything and I will replace This CL Pro middle here with the newly uh copied code okay like this and
simply save it now if I go back to our application right and refresh this dashboard page boom if you see it's redirect it to a signin page right because even though if you try to access this dashboard it will redirect you to sign in page because we we are telling to this middle wear or clerk that dashboard need to be protected same thing you can add it uh over here Whatever the route you want to protect right now but if I go to this local 3,000 you will see you don't need any sign in because
this page is public but anytime if you want to make this page as well as a protected one you can just add slash and now boom even though if you try to access local 3,000 it will ask you to sign in okay so that's how guys you can add the authentication for your application okay now next uh let's let's go to this dashboard page and click sign In with the Google so I will sign in with the Google select the account and then now it will redirect it to a dashboard page see now on the
dashboard page let's go to this dashboard page so inside this dashboard page here you can have option to add add one component from the clerk which is called user button from the nextjs right and if I add like this and save it you will see on the screen this user profile image and if I click on this one you will see This beautiful clerk UI kit to manage your your account it also give the user detail have option to manage your account and many of other things okay obviously you can have option to sign out
from this one as well and once you sign out it automatically redirect it to a signin page okay so that's how you can add the clerk and add this user button so that it's very it will be very easy to manage your account next we going to learn how to Customize our signin and sign up page let me log out from here and now if you see it's redirect it but here if you see this is just a simple page but the question is how we can modify uh this signin sign up page that's what
we are going to see now now let's Design This signin page for that one we are going to ask telin CSS styling but if you want to give a try to this clerk element that also give you the customized signin page currently It is in beta mode so you can um they recommended to use it in development mode and not in production mode so you can try it it's very easy to use first thing you need to just uh do is to install this clerk element and then you can just see this sign in example
and how they use it okay they have their own clerk elements but if you want to use a tell CSS based uh clerk UI sorry the signin UI you can go to this hyper ui. D and just search for this a They have this predefined component like this if you see on the screen right now you can select the one which you want let's say you want to use this one and on the left hand side you can use your clerk sign in and sign up component and on the right hand side you can uh
anytime you can update this um image as well so over here let's click on this jsx view the click on view and here you will find the source code right copy this jsx go to your project and over Here I will just paste it here inside the square circular brackets now I will remove this signin page from here and make sure uh to remove this comment as well and if I save this one and go back to our application you will see this signin page but as you know that on the left hand side we
need to replace with our signin component so simply I will just remove this Main uh component like this if I remove this and save it let me go back and Let's not remove the complete main but you can remove this particular D like this and save it and now if you see on the left hand side is a blank and simply inside this main you can add your sign in component and save it and boom if you see now we have this beautiful signin component now on the top you can add the logo and any
other things which you want to add and the most important thing it's a responsive okay on the smaller screen this is how it looks on The bigger screen you will see uh you will look like this okay so that's how you can uh redesign your signin and sign up page same thing you can do it for your signup page as well now we are going to implement the header for our dashboard if you see in this mockup we have the uh logo along with with the name in the middle we are going to add the
organization option that we will add it in the next chapter and on the right hand side we going to Show the user profile icon it's quite simple so let's go back to our application let me close all of this tab and go to this dashboard now inside this dashboard um we are going to create a new folder but the folder name will start with the underscore components so again uh the folder which start with this circular brackets or underscore will not consider as a routes and inside this folder we'll add header. jsx now let's add
a default template and Then save it now this header component we are going to add it in uh add inside this dashboard page so let me remove this user button for now and simply We'll add header from this component SL header and save it now on the screen you will see the text call header now let's go go back and uh let's add a new logo inside your public folder so I already added as a logo.png you can get it from the Google just type it uh Microsoft Loop logo and you can just save it
now In order to add the logo uh we also want to add the name of the logo like Loop right so what we can do we can create a new component for this logo so let's go back and this logo will be we needed in many of the places so what we can do inside this app folder let's create a new folder for all the component which we are going to share throughout the application and inside that we'll create a logo dot just logo do jsx Okay add a Default template and save it now inside
the header I will just simply add the logo over here and save it now you will see the text logo now let's inside this logo uh component let's add the image first and then we'll add a text as well so inside the DU We'll add the image tag from the next SL image next also has their own image uh tag and inside this we'll provide the source now You can just refer your image using the file name so we'll use slash slash / logo. SVG make sure it's SVG or it's a PNG only so make
it PNG and then here we'll give alt tag as a logo then we'll give a width of 30 and height is of 30 okay and if I save it you will see the logo on the screen next we'll give a text and we can call it as a loop here we'll give a class name we'll Make font bold and text Excel perfect now let's bring everything in one line so for this do we'll add a class name we'll make Flex item to be in the center and we'll give gap of four let's make it gap
of two only and your logo is ready okay and obviously this logo we already added inside this header okay next thing we need to add the user button so here we'll add a user button component and save so you will see the user button now we want this user button On the right hand side so first we'll make it uh we'll add a class name as a flex and we'll make justify between also we'll make item to be in the center and then save it now you will see the logo and the profile image on
the left and right side respectively next uh for this de We'll add a padding of three and then save it perfect also let's add little bit of Shadow so we'll add a shadow small so we you will see the line like this right Very light line but it it will just give you some uh uh header effect okay so that's how our header is ready it's quite easy and quite simple right next thing we going to learn how to add the organization and so that we can also attach that to our um header now we
are going to implement the organization part and it's quite easy to integrate it but before that let's understand two different workspace for our application the one for the user Profile where user can come to our application and create workspace under his profile only okay and that workspace is only available to the current user now when I say the workspace it nothing but an dashboard but whatever the documents come under uh to the dashboard we can call it as a workspace now there is another uh workspace for the organization where uh when user come to application
user have option to create an organization and he can also add a Member to the organization so that whatever the workspace um we create or user create right for the organization it is accessible to all the members belong to that organization now let's take an example let's say you are working for the development team and for the development team you created the organization as a development and you can add it you can add all the developers uh to that particular organization and whatever documents or Things you want to create it is accessible to the all
the developers which you added for the organization but now tester team let's say you have another team which is tester they cannot access your work uh workspace okay so for that uh you need to create another or organization called tester and then you can add a member and create a workspace in that one okay now in order to add a work organization it's quite complicated thing and so that we are Going to use a clerk clerk provide a very simple tool to add an organization so first thing let's go to the dashboard okay and inside
the application you will see the option called organization okay so currently we don't have any organization enabled but you can enable it through this enable organization currently it's disabled so just click on this um toggle icon called enable now over here you will see we have different different uh roles okay currently we are Only one role called admin and for the free tire we have the five members which you can add in organization and there are lot of other things and settings you can find it here then inside the role you can add a multiple
role so who whoever the organization is creating right the user is a admin user and other is a member user obviously you can add your own uh role as well but for now I will keep it as uh default one called admin and member Because that's what I wanted and then another is the permission so you can create your own permissions and that permission you can attach to this uh admin and member role now let's say you want to create a new role called uh read only member okay read only member you can just create
it here you can add the organization key let's say read only member and you can add a description So currently uh okay let's add a same thing Over here and the permission you can add the permission to manage domain read domain manage member and all of these things so here we'll say for example let's say read member and then create a role and if you see now new role is get created okay so that's how you can create the role now the question is how can we integrate it so uh in the documentation if you
go to this cler documentation and search for the organization okay so here we have choose Organization and on the left hand side you will see this organization part okay you can explore this documentation and it's uh quite good documented all of these things but let me uh integrate it inside our uh application so inside the header we're going to use that one so after this because we want this oration if I if you see this header right we want it in the middle so you we have one component from the clerk called organization switcher okay
integrate That one and then save it now if I go back to our application and refresh it you will see the personal account because currently the organization setting or organization is not created right and you will see your personal account you can anytime switch to a personal account if you don't want to uh work in organization space but if you want to create just click on this create organization it will give you this beautiful popup here You have option to upload and Logo as well let's say you want to upload any logo so I will
search uh some logo let's say this react logo open it and then you can give organization name here we'll say development developer tip okay here is a slug automatically created and then click create organization here you can invite the member as well let's say I want to invite this member okay you can add the member email as well you can even add the role only okay You can add admin member or a read only me member role as well here I will select the member and then click Send invitation and then simply click finish okay
now obviously it will react to the dashboard but here you can update that setting as well but right now if you see we have this developer team organization anytime you can switch to the personal account if you don't want to work on organization okay now let's say uh whether we got the email or not for the Invitation now here if you see we got that email called Microsoft Loop clone and over here we got a beautiful email to accept the invitation okay so that's how you'll get that email as well and once you accept it
you can log to our account and simply you can uh get access to the that organization okay so I hope you understand how we added this organization part and all next now in order to get the organization detail it's quite straightforward let's say uh You in page okay and let's let's try it in heer so over here you can get the organization ID using this constant or ID is equal to use o now here uh make sure to add the use client because um when you uh use any hooks right you need to make sure
you are on the client side and here I will just console this organization ID and save it and uh once you console it let's go over here go to the inspect panel go to the console and here you will see the Organization ID okay but if I change this to a personal account you will see now organization ID come as a null it means we will get to know whether the user is on uh user selected as a organization or user selected his personal account and depends on that one we going to uh create the
workspace in a respect to organization or personal account okay this is quite straightforward if you have any question uh to this particular part let me know In the comment section and that's the reason we are using clerk to implement this uh complicated feature very easily inside our application now whenever we create an organization right uh currently it's is the redirect into a uh homepage okay so to fix this issue just simply uh to this organization switcher you can add organization um after create organization URL and here click the SL dashboard okay so it will be
on the Dashboard only and save it also you can add after leave organization URL and here also you can add a dash code only and save it now if I go back back to our application and create a new or organization we can call it as a tube guruji create and then you can add the new members if you want I will skip for now and if you still see our um we are still on the dashboard page okay and on the deleting organization or you can even leave the organization if you don't Want to
stay longer okay and after deleting also you will be line on the dashboard page only now we are going to implement the dashboard where we are going to display the workspace uh list if you see on this mockup uh this particular uh mockup is for the new user if they don't have any workspace okay and once we have the workspace then we can show the list over here but currently at the very initial stage obviously every user or whoever Who joined right they don't have the workspace and then the screen will look like this we
have these two buttons uh the plus sign and the new workspace it will uh redirect it to a new screen called create workspace on there we are going giving option to uh add the name select the cover and all of these things but before that let's implement this particular part so let's go back to our application and inside this component I'm going to create a new file called Workspace list. jsx add the default template and save it now this particular workspace list we are going to add inside this page. jsx under this one so here
we'll call workspace list and then save it now if I go back to our application you will see the workspace list is showing on the screen now um inside this workspace list let's add a class name here we'll say margin y to 10 padding of 10 now on This medium screen will give padding X to 24 on large screen will give padding X to 36 and on Excel size will do padding X to 52 okay now whenever you h on this one you'll see the corresponding CSS um styling for that particular telin CSS class now
if I save it you will see that workspace now depends on the screen size right it it automatically added the padding and all now if I decrease the screen size you will see the padding is decreased Immediately now let's go back to our application again and over uh inside this particular D let's Implement some of the uh tags so let's add a du tag inside the D We'll add h2 tag and we say hello and we want to add the username okay so in order to get the username you can use it with the help
of use user hook okay so this you user Hook from the clerk next yes so it will return the uh the login user credential okay now make sure you'll convert this into a use Client this particular component and in order to get the username you can just use user do uh full name and save it if I go back you will see the full name of that user now let's apply some style so we'll add a class name and here we'll say font bold text is of 2 Xcel and save it perfect now on the
same line we want to add a button similar like this one okay so over here after this du We'll Add a button and for this button we'll just say We'll add this plus sign so something like this okay and let's bring in one line so for this D okay let's bring this inside this D only and we'll add a class name flex and justify between and save it perfect okay now another thing uh currently the default color of our Shad component is a neutral Right and we want to change that color to our own custom
color okay so in order to change it throughout the application right let's go back to a telin do config.js file and inside here you will see whenever we initialize the color uh sorry the shat component right when we set up it it also added this all the colors and respective uh color code as well the primary secondary all of this thing now we want to change the primary color so here uh inside this default Remove this one and you can add your own primary color X code so in this case I will add hash 823
0 FF and save it now as soon as I save you will see this color of the default shat component get change and it's kind of purple okay so that's how how I added so make sure you can also update this tail. config.js with your own color code after this uh let's add a new du tag and inside D We'll add another d let's add a h2 tag and here we'll Say workpace workspaces maybe and uh we'll add a class name so we'll add a class name font medium and we'll change this color to text
primary for this du I'm going to add a class name margin top to 10 and save it and let's see how it looks so this is how it will look like so we have this workspace and on the right hand side you can add this uh icon as Well now in order to add this icon right you can either use a different different uh icon Library as well so very popular which is the Lucid DOD okay uh it's very easy to use it and there are lot of Icon you will find inside this library and
in order to install this Library click on get started go to the installation and make sure to this react okay now we are using npm copy this npm command and inside your terminal just paste it so it will install the Lucid react library and In order to add a component it's quite easy so over here let's add a du and inside du let's add layout grid component and if you see this is the um icon component we just added we We'll add one more call Align left and save it now if I go back to
our application if you see this two compon uh two icon get added now let's bring in one line so here we'll say class name Flex gap of two and then here as well uh for Complete thing we made okay let's do one thing uh okay that's fine let's make it flex and justify between perfect okay something like this same and the last thing we need to add this image and the text with the button now I already added the image inside my public folder okay and this is the image I think I will just rename
this to Workspace and I change this to workspace PNG so that we can directly use it over here okay now one more important thing uh if you remember right under this workspace we also want to show the list if the there is some workspace uh uh documents are there right so what we can do we can Define one state here we'll say workspace list comma set workspace list is equal to use State now initially it will be empty and right now we don't Have any workspace documents created right so everything currently is empty only and
over here we are going to check so here I'm going to add a condition if workspace list. length is equal to equal to zero it means no workpace is created then we going to add a new D and inside this de we are going to show this workspace option okay so I currently I added the and and operation but let's add a question mark and let's add a tary operator otherwise we'll show The workspace list here I will just add workspace list as a simple text now inside this du let's add uh this particular code
so first thing we need to display the image from the next SL image let's add a source here I will say slw space.png here we'll add a width of 200 height of 200 okay you all tag as a workspace next uh I'm going to add a but uh h2 tag and here we'll simply say create New say create a new workspace and save it and if I go back so this is how it will look like quite good and the last uh we want to add a button so here we'll add a button and here
we'll add a new workspace now to this button if you see currently button is in the um purple color but you can give a variant so here we'll add a variant and we simply say Outline so it will be look like this um I will also add some class name and we give margin Y 2 three perfect now let's bring everything in one line so simply to this D we'll add a class name we'll make it Flex Flex column and we'll add justify Center and save it and we'll also add a item to be in
the center so it will be in Center like this Uh we also give margin y to 10 so space from bottom top and boom if you see we have this beautiful dashboard ready uh and obviously uh if the work space the list is there obviously this section will be hidden there and then we will show the actual list of the workspace but now on the click of this two button we want to navigate to the create new workspace um section okay so uh for that one we are we need to create a new route so
inside this route folder I'm going to Add a new route called create workpace and inside this we'll add page.js file add the default template here we'll rename this to create workspace and then save it okay now when we click on this button right we want to navigate it to the that new screen now there are two option either you can Define the router hook and programmatically you can redirect it or there is another option to use a link tag from the next / link to this link Tag you need to add the H reference and
then you need to wrap uh this button inside this link tag and here I will just simply add sorry the create workpace and save it okay so on the click of this button okay which is WRA inside this link tag when you click on it it will navigate to this create workspace uh route or page now if I click on this one if you see it jump to this create workspace page how cool Right same thing we need to implement for this new workspace I will just copy this link tag and for this button we
want to add right and here I will close the tag and then save it so even if I click from here if I click from this side it will jump to the same page if you think this new workspace outline is not attractive you can just remove this variant outline so it will be more pop up okay so now I Think this is look much better then this one okay so guys if you have any question any doubt let me know in the comment section this is just a UI thing that we did it there
are lot of things that we are going to learn in this particular video so stay tuned if you still did not subscribe to my Channel please do subscribe and uh one more thing I want to tell you before moving to the new chapter uh if you go to this tub guru.com here you will find an Exclusive sources courses and the source code for each of the courses also not only that but you can track each of the course chapter by chapter okay here you you will find all of these uh courses and there are many
of the free many of the paid and uh in order to get the source code access of the each of this project you can join the membership as well which is just eight $99 per month and then you will get an all the source code for free okay for each of These project so just join it and as I say uh you can track each of the chapter chapter by chapter here you have option to get the source code you can see the demo or you can also watch on the YouTube now we are going
to create the new screen called create workspace where user can enter the workspace name he has option to uh change the banner or cover of this particular workspace and not only that but he have option to change the Emoji as well once user click on This uh cover uh then we will show this dialogue box with different different images you can select any of them and one user click on this emoji icon we're going to show the Emoji picker as well so first thing let's implement this create workspace page and let's uh move from there
so obviously uh right now once you click on this new workspace right we are navigating to to this create workspace page so let's go back to this create workspace page and Inside here first thing uh let's add a class name and we'll give some padding margin so depends on the screen size uh the padding will applicable so first thing we'll add the padding to 10 on the medium screen We'll add padding X to 36 then on last screen we add padding X to 52 and uh on extra last screen we add padding X to 18
also We'll add padding y to 20 okay if I save this one you will see Let me refresh this screen once and This create workspace is showing like this let me remove okay next we'll add one D inside this du uh this is actual uh card okay so this is nothing but this particular uh card which we are going to add so at the top we have the image so let's add that du for that one and this will be the we'll say cover image okay now to this cover image we'll simply um add okay
so first thing we need to add a image okay so we'll add a image source and here we Need to provide the source now for the source in this case I'm going to add uh uh here we'll say cover image comma set cover image is equal to use State and here by default the default one I'm going to add which is the cover.png and this particular image I already uh stored inside this public folder called cover.png okay I don't know why it's not showing but yeah if you see this cover.png okay and this image we
are Going to add it over here so let me just replace it with the actual State called cover image and then over here we'll add width and height let's add width of 400 height of 400 but let's give some class name so here we'll see actual with full height I'm going to add the custom height okay so that's the reason I added with this square bracket and we'll call it as a 150 pixel then uh we'll make object to be covered and I want to Round the Corner only top corner to the Excel Okay so
if you see here the round uh the corner is rounded only on the top side okay not the bottom side so you can also do that using rounded here we'll say top only and we'll add as a uh rounded Excel size and save it now if I go back to our application so here we use the use state so we need to change this to use client okay and boom if you see we have this beautiful uh cover section okay now on a h on this one right Because right now or on the click of
this one we want to show some kind of effect or clickable effect right so in order to implement what we can do um can add the h2 tag over here and we can just simply say change cover okay so currently it will look like this but but we want this change cover in the middle of this particular image so you can um just add class name here we'll say position as a absolute so as soon as you make this absolute it will come on the Top of this image then uh we'll add padding of four
and we'll add width to be full height to be full okay uh we'll make item to be in the center let's make it Justified to be in the center and let's see how it looks so I don't think so it actually change anything let me bring this down and okay so I think we forgot to add the flex but if you see it is in the center but it is not correctly showing but Because it's going out top of this particular screen so for this particular du you can add a class name and Mark it
as a relative okay and save it now if you see it is in the center perfect um also I'm going to wrap this image inside One D like this okay and now whenever I hover on this one then only we want to change or show this change cover uh text as well as we want change the opacity of the image so Simply uh here for this class name you can mark it as a group okay and now uh we have H effect right so on this one let's say you want to uh here we will
hide this particular change cover initially so I will just simply say uh hidden and now if you see it's actually not showing on the screen but uh whenever I hover on this one so you need to add Group H then you can just mark it as a flex so when we say the group H right so whenever we h on The complete de it also change the the effect or it it will also apply the H effect to this uh particular text now if I go over here and H it see okay perfect same thing
we are going to do but in this case we are going to add a h effect for the opacity so here we'll say Group H and then we'll add opacity let's say 40 see perfect right we'll change this little bit let's say 20 oh let's add we want dark actually perfect okay so that's how you can change that opacity as well I'll make it 40 only and then uh over here I will add a cursor pointer okay so when I over on this one the pointer will change now on the click of this one we
want to open the uh dialogue okay so that we will add later on but I hope you understand this particular part next thing we want to add this particular uh section okay so simply After this one uh I'm going to write uh let's say input section and here I'm going to add a du inside this du uh let's add a class name and we'll add a padding of 12 first and then we'll add the H2 type we say create a new workspace to this h2 tag let's add a class name and we'll add a font
to be medium text to be Excel Perfect uh after this after this h2 tag we'll add another h2 tag and uh we'll just simply write like this is a shared space where you can collaborate with your team okay and also we can write uh you can always rename it later perfect right so this is just a simple text which we added here obviously I will add a class name we say text small and margin top to Two something like this uh let uh after this um I'm going to add a du okay so here we
added do and because we want to add the Emoji picker so which is kind of button so what we can do um we will add a button okay so this button will be uh we will add a variant as a outline and in this button I'm going to add the Emoji uh icon right so here we'll say uh smile plus so this it will Look like this right so that particular Smiley icon I will add see beautiful right and for this de We'll add a class name We'll add a margin top to it and save
it and then we'll add the input as well so now in order to add a input right let's go to this shat CN and if I scroll down you will see the input component okay because that's what we need it over here so in order to get that one copy this npx command first and then paste it here so it will install The input component and then you can directly use it so once it installed right here if you see if I type input you will get the suggestion to import this component for the from
the component folder now once you add this one here I will add a placeholder is equal to and here I will say workspace name and save it now if I go back uh and okay so if you see we have this Workspace name now let's bring everything in one line so for this du We'll add a flex We'll add a gap of two and we'll make item to be in the center perfect right and this is our uh input field now after that we have the simply two buttons let's add that two button as well
so let's add a d the first button will be uh create and other button will be the Cancel okay for this cancel button I will put the variant as outline and uh save it now if I go back we have this create and U cancel button okay now let's let's add a class name We'll add a margin top to seven and we want to make it justify at the end okay let's make it Flex first and we'll make justify end okay we'll also give gap between these two button something like this okay now um we
want to disable this button until And unless uh user did not input anything right so in order to save the user input we are going to say in one state so here we'll say workspace name comma set workspace name is equal to use State and uh save it now over here to this input we we input have on change uh method which will uh give us the event e and then we'll set the workspace name now inside the event e whatever the value user type right we can get it using this event Do target. value
and over here I will add a disabled method so if I just put disable it means disable is true in this case and you will see the button is disabled but uh we can write a condition now so you can only disable if the uh the workspace name is do length is not there okay now if I save it length and okay so we have error okay so here we need to add a question mark and save It now right now if you see it disable but if I type anything it enable immediately perfect it's
working fine next uh if you see it look it we give the card like effect right same thing we are going to add to this particular uh card so maybe for this du we can add it so here we'll add a class name We'll add a shadow of 2 XEL okay and obviously border is we are not adding but we'll make rounded to be Excel boom if you see how beautiful we have this particular card okay now obviously you can add uh now obviously this is depend on the screen size it automatically change the layout
and you think see how beautiful only thing that I think I will give more we go here as well I will add padding y to 28 little bit down and padding X here I will add something like 96 here I will also increase to 64 and save it perfect I think this is Good and if I decrease the screen size right it will change the padding and all perfect on smaller screen this is how it looks like perfect now next we going to learn how we can add this change cover uh um dialogue okay so
once user click on this change cover we are going to open this dialogue and we are going to add an option to select a different different images for the cover okay the default one which is this one but if you want to Use it to pick something else we are going to give option and later after this we also going to add the Emoji picker as well now on the click of this uh change cover we want to open this t dialog and we want to show these images okay so for that one let's go
back to our application and I added this new folder called underscore Shar and inside that I added the cover option now inside this cover option file I simply export the Default uh list of the uh this particular image URL object okay so we have this image URL fi this image URL I got it from this uh free.com so what you need to do just go to this free.com okay and then search the any any kind of images so in this case I search for the abstract and simply click on any of the images and copy
the image address once you copy this IM image address just paste it here okay and then you can add as much as images you want Okay so this cover option we are going to use to show all the images option now um to select this cover right we want to uh create a new component and this compon comp I will keep inside this appor component folder because uh this particular component we going to use it in later on as well so I will create a new file and here I will say cover picker. JS add
the default template so here is here is thing right you can make jsx you can add JS it doesn't matter but Just for the consistent purpose I added jsx over here okay to the component file and now to this cover picker right uh we are going to add uh the dialogue box so if you go to this shadan shadan has this dialogue component and this is the example right this when you click on button it will open this dialogue so in order to add this dialogue copy this npm command go to your project inside your
terminal just paste it here so it will Install the dialog component for us now this is a example use case so copy this import statement and simply paste it here and then you need to copy this dialog sorry this particular U code use case code and I will paste it here like this okay so currently we did not import this uh component anywhere okay so let's save it and then let's go to the uh workspace list now over here if you remember let me uh so let me go to this page.js file Where we have
this workspace list oh not here my bad so inside the create workspace we have the cover image right let's let's add this cover picker over here for now okay so I added this component save it and then if I go back to our application you will see this button right call open now if I click on this one you will see the dialogue is opening but we want to open the dialogue on the click of this one right so what we need To do we need to pass this particular line of code to this dialogue
okay because inside the cover picker our dialogue is opening on the trigger of this particular open text and we want to add our line of code over here okay so this line of code we need to pass it so simple way to uh do this one right is to pass this line of code as a children uh to the cover picker okay so what we can do we can uh wrap this inside the cover picker okay now now This is the child element of this cover picker and inside the cover picker we'll accept it as
a children okay and simply I will add the children I will render this children over here okay and now save this both the components now you will see the magic now if I go back to our application okay here if you see uh we need to um change the width Okay so simply go over here and for this dialog Trigger here I will add the WID to be full let's save everything and now if you see we have this option now if I click on this one you will see the dialogue is opening how cool
right perfect so that's what we wanted now simple uh simply we need to um iterate the image uh that we already store inside our uh cover options which is inside this shared folder okay so all these images we need to iterate it so let's go to this cover picker and uh for The dialogue title I will just write like this update cover okay and inside this description let me clean this out and here I will add a du inside the D we'll use cover option do map here we'll say cover comma index and the arrow
function now inside this one we'll add a uh let's add image or let's let's add a du okay and inside this D and we'll add a image tag from the next SL image okay now to this image tag let's add a source and we'll Just simply say cover. image URL here we'll give a width as let's say 200 and height of let's say 140 and save it now if I go back to our application and click on this one so we got the error now this error is saying that host name image. freep.com is not
configured under the images in your next. config.js file so whenever you use any third party uh image URL inside your application then uh you need to make sure that host name Okay so if you see this is the URL right and this host name need to be configured under this next. config.js for the security so simply copy this host name because that's where we are fing all me we added these images right and then go to your next. config MGS file okay to the root directory inside here we'll add images inside the images let's add
a domain and inside a domain let's add Your domain okay and just make sure it's WID listed and then make sure to restart your application and once you restart refresh your screen and if I click now let's click over here so maybe we got error I'm not sure okay so we got this one but if you see um the dialogue is open but it's quite weird right means it's not perfectly uh the the way we want so to fix this one let me go to this cover picker again and inside here we'll add a De
inside this oh sorry not here but inside this de We'll add a class name We'll add a grid we'll add grid column two when the screen size is smaller on the medium screen size we'll make grid column 3 and on the large we'll make grid column four okay so we'll show in short we on the large screen we will show four images in one row on the medium screen we'll show three images otherwise we'll show two images in one row also here we'll give a Gap of five and I will add margin top to three
let's save this one and boom if you see this is how beautifully it look lies OB L the image is not in a perfect size so for these images I will add a class name and over here we'll add height of 70 pixel we'll add width to be full and we'll make rounded to be let's say media and make object to be covered so it will not stretch and now if you see all the images in one size okay perfect Obviously you can add more images as I say you just go to this free P
copy the image URL and paste it next we need to add a button to update the cover image okay and also we want to add a cancel button as well so inside this Shaden dialogue if you go to over here right you will see the custom close button uh example right if you go to this code here you will see in order to add the custom close button you need to add the dialog footer inside the dialog footer We have this dialog close uh component and inside that we have the button okay so what I
will do just copy this line of code and after this dialog description sorry after this dialog header I will put it the dialog footer make sure to import this dialog footer the dialog close and the button as well okay now I will add one more button uh maybe I will add it after this and here we will say update now this button will be a primary so I will Remove this one and then save it so if I go back to our application click on this one okay so it's saying children only expected receive single
element okay so here we need to add this update outside of this one so this is the one dialog close button and then we need to add another one with the update the variant I will remove this one and save it if I click this one now if you see we have the close and update button now this button we want on the right hand Side here uh if you see we have this class name start justify start I will remove this one so it will be on the right hand side okay next whenever I
click something right and click on update we have to make sure this image get updated okay also whenever we click on any of this one we have to make sure it is rounded with some border okay means we are show we need to show some kind of selection so first thing let's define a constant here we say selected Cover comma set selected cover is equal to use State and then um on the click of this one so this is a du and for this de I will add on click method here we'll say set selected
cover will be the item comma image URL not item the cover do image URL okay and here I'm going to write a conditional styling so depends on the condition we are going to add a styling So uh you have to wrap in inside the curly braces then add this code and then simply we have to write a condition here if you want to write a condition write dollar sign curly braces and here I will just simply say if the selected cover okay if is equal to equal to cover do image URL if this matches then
I'm I just want to add a border to be a primary so here I will add border as a primary and I will also add border is of size two okay also uh outside of this Condition I will add a padding of one and we'll make rounded as a large okay or rounded as a med let's do it medium because that's what the our image of the Border corner is medium only so let me bring this down and save it now if I go back and open this one if I click on this one see
it is get selected if I select this one boom okay so that's how guys you can add this uh border uh to the selected cover image okay now once you Select this cover image uh uh on the click of this update button right we need to actual update uh the cover and we need to set the URL of that cover image to the parent component okay so what we'll do uh to this update button We'll add on click method and here we'll simply set new I will set the new cover as a new method and
here we'll just simply pass the selected cover URL okay so selected Because when we select any of the cover that that image URL we are storing inside the selected cover and then and simply uh so here we set the cover okay now once you set this cover um here this particular method we need to pass back to the parent component as a set new cover and save it now let's go back to our parent component and here if you remember we have this cover picker component simply here you need to add a Or get the
set u the call set new cover method here it will get the value as a V and we need to store this cover the new added cover inside one state okay not inside one state because we already defined the state so simply we'll set it inside this uh cover image State as a value V okay and save it now let's test this out so let's say Let me refresh the screen once so I will click on this change cover let's say you want to update with this cover and click Update and nothing okay boom if
you see the cover image change let's update this one and see okay so that's how guys you can update the cover image if you think this cover image the height is little we need a little bit more just change it over here I think now this is good okay perfect so that's how guys you can update your cover image with this beautiful dialogue now we are going to implement the Emoji picker and for that one we are going to use the emoji picker React Library which is very powerful library and most important thing it's easy
to integrate just you need to install it and then uh with this Emoji picker component you are going to uh integrate it or use it inside your application so first thing uh let's copy this install uh mpm command to install the uh Library go to your project and simply paste it here I will close all of the TP for now and now we want to integrate it inside our create workspace Right so when we click on this uh smile plus button right which is emoji button then we want to open that one so uh and
this Emoji pickup we need it in multiple places so I will going I'm going to create a new component inside this underscore component under the app folder and we can call it as a Emoji picker component okay. jsx and I'm just U changing this name because Emoji pick will be same uh the name will be same right because Library name is also same That's the reason and then add a default template and save it now inside this D okay let me undo this one so over here uh first thing this is the Emoji picker which
we want to add right so copy this component name go back to your application and save it now the import important thing is when you import this Emoji picker right it directly displayed on the screen let me show you how so copy this Emoji picker component and then uh Obviously we want to add it before this button so I will just add Emoji picker component and then save it now if I go back to our application Let me refresh the screen once okay so it's saying Emoji picker do did not Define so make sure to
import this Emoji picker okay so the import statement need to be need to add and then you will see this Emoji picker Let me refresh it again okay we have two error but we will uh we will Sol it in a Moment but this is how it will look like right and we don't want that one we just want to show this Emoji picker only when when user click on this button so for that one uh inside this Emoji picker component I'm going to add a du and uh whatever the button okay smile plus but
but we want to uh add it we can render it over here through the children so simply here I will wrap this inside this Emoji picker component and this will be The children of the Emoji picker and simply accept it here as a children okay the similar way which we did it for the cover okay and now this children you can render it uh like this okay let's save this one and this page as well now if I go back to replication you will see now we have the um button and along with that we
have the Emoji picker perfect now uh we need to make sure that everything in one line so what we can do uh I Will wrap this inside the DU okay and first thing as I told you that we need to open this Emoji picker when user click on this button so here I will add a uh constant We'll add open Emoji picker comma set open Emoji picker is equal to use State initially it will be the false okay now this de I'm going to show only when the open Emoji picker is true okay so I
will add uh open imoji picker is true and and then only open This du and uh on the click of this one so here I will add on click method set open Emoji picker as a true and then save it now if I go back to our application and click on this one you will see the Emoji picker is opening perfect but it's not aligned perfectly right so what you can do uh for this particular de let me bring this down you can add a class name and we'll make absolute uh position as absolute and
we'll add Z index let's add 10 and save It if I go back you will see now everything is aligned perfectly and then we have the Emoji picker because we we added the position absolute right it automatically align to the button also now when you click on any of this Emoji right we need to replace it over here so Emoji picker has a many different properties okay the one which is the on emoji click so on emoji click it will um emit the event e and if I console this event. Emoji it will return The
selected Emoji let me show you so let me go to this cons Ina panel because we just console it inside the console.log I will clean everything and if I click any of this one right see it's ch it's showing on the screen immediately perfect right now this particular Emoji we need to pass back to our parent component so I will remove this one and here we'll set the emoji icon and we'll add e. Emoji okay now this set emoji icon will pass back to Our parent component so inside here now I will accept it here
as a set IMO icon and simply we want to set that icon right so I'm going to add one state to hold the Emojis we just add Emoji comma set Emoji is equal to you state okay and initially is empty obviously but when we have the Emoji so here we'll say Emoji not Emoji let say value only and here we'll add set Emoji As a value okay now obviously we want to display that emoji as well so here I will add a condition if Emoji has some value then show the emoji icon otherwise show this
Smiley plus icon okay let's save this one now if I go back and let me c close this if I select this car see the car is showing on the screen okay so that's how you can update it but we have to make sure this dialogue is also getting closed so as soon as you select it you can just Simply set the uh open Emoji picker as a false and save it now if I close on this one see now it's closing immediately as soon as we select any of this icon okay another important thing
uh obviously you can uh go to this documentation and you will find a lot of other um features as well the one of the feature which I like it and um I want to use which is the Emoji Style okay now it has a different different Emoji Style one of them is a Facebook if I save it and go back to our Application you will see the Emoji Style is changed and it will look like some different one okay so that's how also you can update your emoji icon to like for like a Facebook or
like a Google or any or Android or iOS as well okay so that's how guys you can U update the Emoji uh or you can add the Emoji picker for your um inside your application so if you have any question let me know in the comment section uh if you face any issue uh while adding the Emoji picker Now next thing we need to do is to save our workspace once us click on create to our database now for that one we are going to use a Firebase database first thing the reason that we use
Firebase that come is a free to use then it also include the realtime database which we require inside our application to get a realtime update without refreshing the screen then it's easy to integrate and it has a very rich hdk so that is it is very easy to uh make some crude Operation on the data and record and most important it's well documented okay so uh let's go to this firebase.com and if you're are first time on this Firebase so you just need to create a new project or just sign up to the Firebase first
with the help of Gmail if you already use it then it's very easy for you but even though if if it's your first time don't worry we'll go uh stay by by step once you are here uh make sure to log in it and here you Will find the option called go to console just go go over here and if you don't have any projects I will definitely suggest to create a new project once you create the project you will see the screen like this now if you see I already have a couple of application
which is uh already there but if you want to create a new application click on this uh plus button and select the web okay here we'll give the name let's say Microsoft Loop clo uh then click Register App we are not using Firebase hosting if you want to deploy your application on the Firebase you can also do that then uh you will find this add Firebase hdk option now copy this command and it will install the Firebase uh inside our application so here I will clear this one and just install npm install Firebase so once
the Firebase is in install this is the Configuration for your Firebase so copy this one go to your project and simply okay let me get this down and we'll create a new folder outside of this app folder maybe inside the root directory and we can call it as a config okay so all the configuration related files we can keep in this folder and here we create a new file called Firebase config.js paste the code code which you just copied now if you see we have this API key I will just remove it From here and
then inside the. loal I will paste it so we'll start with the next public because whenever you want to use your variable on the client side you your variable name should start with the nextore public then the key so here we'll say Firebase API key and simply paste it okay I will uh copy this Co environment variable and I will just put it over here so here we will say process. EnV and then um your have high Bas API key variable name okay and save it now over here uh I will just export this app
if you need anything uh then we'll also add a export constant DB is equal to get fire store okay and here you need to provide the app reference okay now make sure to import this get fire store so let's save this one first and here I will go and let's import that one oh sorry get fire store from here we'll see Firebase SL fire Store okay and that's all and save it but make sure to it will you will export this one so that we can use it throughout the application now close all of this
typ for now and then uh go back to our application here sorry inside the Firebase console click go to uh continue to console and here you will find your app right Microsoft look CL now you can enable it uh maybe it's loading I'm not sure but anyway uh on the left hand side you will see the option called fire Store database if you don't see the option just expand this one and then you'll see it over here click on it and then once you click it will open this Cloud fire store now in this case
I already have some of the application which is using this fire store okay so just ignore this one these are some collection these are some documents inside this collection okay so don't worry we'll go one by one but for now make uh just ignore this thing but More important thing if you go to this uh rule section okay here make sure you will allow read and write okay so that you can able to uh create a new record or up delete made some operation as well okay now uh next thing let's go back to our
application and then now we are going to add a record to our Firebase fire store so go to the components oh sorry uh not component go to the app and where we have the create workspace page. jsx file now inside here We are going to create a new method called constant on create workspace and uh this in this method we want to write a code to uh create workspace for us now first thing we need a document ID so this document ID need to be in the string format so here we'll say uh doc ID
is equal to do sorry date do now like this uh so what we did we are just using the current time stamp and every time the time stamp will be Different so that we are using it as a document ID then we'll write constant result is equal to await set doc okay and if you see this set Doc is importing from the Firebase fire store then we need to provide the document reference and here we need to add a fire uh DB reference so will add DB from the config SL Firebase uh config which we
already find inside this um Firebase config folder right sorry this config folder we have we have this fire B config so this DB we are using and make sure to import this as well then we need to provide the collection name now collection name you can consider it as a table name okay so if you see we already have some some of the collection name but obviously we are going to create a new one and here we'll call call it as a workpace then we need to provide the document ID now this document ID need
to be in the string format so I will Convert it into a string so document ID ID do2 string then you need to add the field or column which you want to insert so obviously here we use aw I will make this as a sync and let's add some field let's say you want to add the workspace name so here we'll add name as a workspace name or here I will say work workspace name only then uh we'll add the Emoji which Emoji user select so that emoji icon as well uh then we'll add the
Current cover or cover or cover URL I will say and for this cover U URL we'll say cover image we add image only makees sense right then we'll add We'll add created by who created this okay that users's name we want to add it now let's get the username first so we'll add constant user is equal to use user so with the help of uh clerk U you user hook we can get the users email ID so here we'll add User. primary email address. email address in order to get the user email address uh then
we want to add ID of the document so I will add just ID as a document ID and most important thing the organization ID now here for the organization ID there are two way that we can do it first uh for the organization ID right whether if the user selected as the organization then obviously we'll put the organization ID okay like this so obviously we need to Get that first is equal to use Au okay but if the organization ID is not there then we'll simply put the users's email ID okay and obviously when we
F the data right we are fing depends on the organization ID so even though it's a email or it's a uh um what we say organization ID it doesn't matter but but only thing that first we'll check with the organization ID if it's there use that one otherwise you the users email ID okay and I think that's all okay that's all we needed for now you can add more details like date when it added and all of these things and once it's get added we just need to Route it to the new screen okay so
here we'll say constant log um data inserted just we'll write okay because we don't have new screen yet and also I'm going to add a new state so we'll call constant loading comma set loading is equal to use state So whenever we click on this create uh workspace right we'll set the loading as a true initially we'll make it as a false and then once it's created we'll set the loading as a false okay here I will write documentation like use to create new works space and save data in database okay to be very straightforward
now this on create workspace we need to call on the click of this create button So here we'll say on click and we can just call like this okay so on click method we'll call this on create workspace method also we want to disable this button when so here I will add a condition or or the loading is true okay and uh we can also add the loading indicator so here I will add if loading is true and and then I will just simply go going to add a loader so if you see we Have
different different icon right you can use any of them and for this one I will add the uh T CSS class called animate spin okay so it will actually spin your component okay so obviously this is icon so it will actually spin it and if your loading is false then it will not spin I think that's good enough here I will just give margin left to let's say two okay some space between this create and all I think we are good on this one now Let's test this out so let's go back to our application
refresh the screen and here let's change the cover so we'll select this cover click update then you can even select the emoji icon let's say this one and here we'll say project idea okay and then simply click uh create now if you see we have this beautiful indicator and it's now in inserted so that's is again uh come to the default state but if you go to the inspect panel and go to the console you Will see the text called sorry the inside console will have the console text called Data inserted let's go back to
application and search for the uh collection name called workspace see we have this new collection name called workspace inside this we have the new data and boom we have the cover image created by emoji and all of these things how cool it is right so that's how guys you can get this all the information and it is get inserted into your Database now obviously as soon as it get inserted we want to redirect it to a new screen okay so let's create that new screen and here we'll create a dynamic route now let me explain
that one so let's say uh once you navigate it right you want to go to this workspace slash and some ID let's say you want to the the you can say document ID right so this ID will be changing uh we going to change every time every time this ID will be different right like the first Thing is two then two three four and so on right every time it's different so it's called a dynamic route okay because it's not fixed so in order to create a dynamic route first thing let's go to this routes
then add a new folder here we'll say workspace then inside the workspace we want to add a d Dynamic route or dynamic folder and this folder will start with the square bracket here you can give the uh ID let's say document ID and then click enter and inside this one you'll simply uh add the page. jsx file okay now add the default template and here we'll say um workspace that's it I think that's so good enough and save it now whenever you create a document we are going to navigate to this uh workspace document ID
screen so here uh first thing we need to add a router so here we add constant router is equal to use router from the Next SL navigation okay and then we are programmatically going to rout it so simply we'll say router do replace when you can use push but when you push right and on the click of back button it will again jump to the create workspace page but we don't want that way we want we are going to use replace when we say replace it will actually replace your create workspace with a new page
and when you click back it will go back to the dashboard page and not on the create Workspace page and here simply We'll add the route called workspace slash and the document ID so here we have doc ID right and if you see how I added this one workspace and this doc ID we already have that one right so that one we just added over here now we don't need this console anymore so I will remove it and then save it now let's create another workspace so here I will go let's refresh the screen once
and let's change the Cover let's add emoji and here we'll say developers projects and click create now we have loading as soon as loading is done it will redirect it to workspace page and if you see now this time the routing will be workspace slash and the document ID how cool right so that's how guys you can uh navigate from one uh page to another but along with that you also learn how can we add the data inside of Firebase fire store okay Perfect if you have any question any doubt until this point let me
me know in the comment section now once we create this workspace right and obviously if you remember we are navigating uh to this ID as well okay and this is the obviously workspace ID but after that we want to uh navigate to a dynamic route again but in this case it will be the um document ID so here is thing once we have the workspace under the workspace you can Create a multiple document right so under the one workpace it can be a one document it can be a two or more than two three four
whatever right and obviously if you have two workspace again and second workspace as well you have multiple documents so the question is how can we uh Implement in in in the form of routing right so simply we going to add the workspace workspace ID as well as then we going to add the uh document ID okay each Document has a unique ID and that ID we're going to add it so this is nothing but an nested Dynamic route okay nested Dynamic route or it also called as a um multi-level Dynamic route okay so let's Implement
that one it's quite easy uh only thing that you need to do now if I go to this route we have this work page uh the document ID so here I think we can rename this to instead of document we can call it as a workspace ID and under This workspace ID I will remove this page. jsx file and then we'll create a new uh folder again and we can call it as a document ID okay and now inside this document ID we will have page. jsx file now let's add a default template here we'll
say workspace document okay and then save it now if I go back to our application right so in in this case if you see we have for faor but if you type some document ID then it Will redirect it to a workspace document and that's what we need because we need this workspace ID as well as we also need the document ID okay now the question is when we are going to create document when we create the workspace we also going to add one more uh C inside the work uh sorry workspace document collection so
we are going to create a new uh collection so as soon as we create the workpace which is the obviously default One here simply um before uh routing to the new screen right here we'll simply add that particular uh new documents inside the document collection so before that one I will just replace the document ID we'll call it as workspace ID okay just little bit meaningful and here I will I also replace it okay and then we'll create a new method we'll say await set document and inside this one we'll add a Doc We'll add
DB reference comma we'll say workspace documents comma and then we'll create a new document ID now in this case document ID little bit different so for that I'm going to use uh uu ID for uh Library okay so it will give you a unique uh ID so let me add it here so we'll say Doc ID is equal to UU id4 okay so this will give you uh some random ID and which is again in the form of string and this doc ID will add it here make Sure we'll convert it into a string and
then we'll add the uh all the information let's say first thing you need to add the workspace ID from which workspace is it belong to so this workspace ID we going to attached to it then who created it so I will just copy this created by then uh we'll add the cover image so cover image it will be a null initially and the imoji also it will be null initially okay so this is a uh uh Default document which we are going to add then we'll add ID as a doc ID after this um the
organization ID which is not required because it's come under the same workspace and the last is document output so here we say document output and initially it will be the empty okay kind of arop string and for now I think that's enough if you want to add more you can add it later on as well and I think we are good for now let's save it And now what I will I'm going to do I'm going to delete this collection for now just to I want everything to be clean so I will delete this collection
and let's create a newly workspace okay so let's go to the dashboard first then here we have create new workspace uh we'll change the cover let me select this one and then we'll add the workspace name here we'll say uh developer team Okay here you can select the Emoji which you want so I will select this home emoji and then simply click create now if you see we have this beautiful uh loading indicator but if you see we got the 404 error because uh this is not a route okay the route is something like this
correct so obviously we forgot to add the uh newly document ID so here we say Doc ID and then save it I think now this case it will work let's create a new Workspace we'll say developer team one add Emoji change cover and click create and boom if you see now we redirect to a workspace document where we have workspace we have the workspace ID and then we have this document ID obviously this information is also you will find inside this Firebase fire store and if I refresh it you will see inside the workspace document
we have this document created Okay so with are some basic information and then we have workspace which is newly created workspace as well and each workspace uh document you will find it here so when you want to fetch the all the documents belong to that workspace ID you can just fetch it with the help of this workspace ID as well how cool right so that's how you can uh add the workspace document routing that's the reason I created this particular section now as soon as we create this Workspace document right and we have this information
now we also need to import or we we also need to create one more document in a new collection called document output in that one will save the actual um document information okay so let's go back to our application and inside this um create workspace once we create this document uh we'll also create one more document so here we'll say await set doc because this is this Particular document when uh we are creating only when we are creating a new new document here we'll say Doc um inside that we'll provide the debr reference then we'll
say document output comma and the document uh ID will be the same ID we are going to keep it so I will copy this document ID as the document ID make sure it is the string and then we'll add the information so here we'll add the doc ID As a doc ID and then I think uh we can add the document output is equal to empty okay so this much information I think for now we are good if you need any more information we can add it here okay but make sure you'll add the document
output uh or we'll just say output okay instead of uh put everything because document output we already have the collection name and I think we are good to go let's Save this one and let's go back to our application go to the workspace here we'll create a new okay so we need to go to the dashboard here we create a new workspace uh add some uh Emoji we'll say new workspace with Doc and change some and click create as soon as it create it will redirect it now just make sure you will uh uh see
new collection called document output with this document ID and the output Okay perfect so that's the thing we need to add now as we know that we are on the workspace uh workspace um screen where we have this workspace ID and then we have this document ID which we all saving now uh on this page we are going to add two section one is the side navigation bar on which we are going to add logo uh then we have this notification Bell icon obviously we are going to implement the notification uh Feature as well then
we have this workspace name and the button so this button uh will help us to create a new document to the database and then it will also update this document list without refreshing the screen so we going to learn how can we update the list in a real time okay that's the reason we are going to use a Firebase real time database then at the bottom we going to show how many file user created and the For free tire we are going to only I mean we are allow user to create only five file okay
and then on the right hand side we are going to add the uh Rich Text Editor which is a very modern one uh similar like the Microsoft Loop okay but first thing first uh we need to First create this side navigation bar and then we need to create a right side right side space for the documentation now here the first thing we need to do is to uh display this Information and then we need to F this information okay so let's go back to our application and let's display the uh some UI Elements which you
want to show on the side navigation bar but obviously uh we need to add the space for the side navigation bar as well so over here um I will add a so this de we're going to add it for the side now and another de we're going to add it for the Document okay now for the side navigation bar uh let's create a new component so under the workspace I'm going to create a compon uh the folder called underscore components and inside this we add s now. jsx add the default template and save it now
let's import this side name over here so I'll put a side navigation and save so you can uh directly mention the uh width and height For the side navigation bar uh over here only so I will give the uh I will put the width when the screen size is medium so we'll put the width of uh 72 okay otherwise I will hide this side navigation bar and for the document uh I will add class name and here when the screen size is medium I will put the margin left to 72 here I will just write
document and then save it now if I go back to our application you will see this particular space for the side Navigation bar now let's go to this side navigation bar and inside here I will add a class name here I will make height to be uh screen I will make it fix okay and uh let's save this one let's see how it looks Let me refresh this ones I don't know side Now is not showing on the screen make sure it is imported okay so maybe uh let's do one thing either you can Define
this information over here oh sorry over here or let me remove this One completely and I will Define directly into this side navigation bar so I will put the height of the screen I will put um the width of 7 to for the medium screen uh when it is small I will hide it but when it's a medium I will just show it as a block let's save this one and see the side navigation bar uh make it fixed okay so it will be fixed and then you will also see the see the documents okay
uh then we going to add the background to be blue maybe We'll add a background of 50 perfect and if you see on the left hand side you will see this light blue color perfect uh next we need to add the logo and now we know that we already have the logo component which we created inside this uh underscore component so we can directly use that one so here I will add a du inside that we'll add a logo and save it and now you will see the logo uh showing on the screen after this
we want to add the note Bell icon So here I will add a bail icon from the Lucid react simply and save it and now we have this beautiful bell icon as well let's bring everything in one line also for this Bell icon I will add the height of five width of five and text is of gray color and for this de we add a class name make it flex and we'll make justify between and item to be in the center uh also we are going to add some uh padding so I'll add the padding
to This complete de as a padding to let's say five okay and we'll add a shadow Medium as well perfect uh below this I'm going to add a border so we'll add a horizontal line and to this horizontal line I will add a class name margin y to let's say five okay so if you see we have this light color border that's I think enough uh next uh as I uh as per the Mockup right we need to show this workspace name and this plus icon so simply I'm going to add a du inside D
We'll add a h2 tag and we'll simply say Works workspace name um after this I will add a button so we'll add a button and we'll add a plus icon to this one um for this h2 tag we add a class name we make font medium up and save it for this button I Will add a class name I think it's already small let's see how it looks on the screen I think this is good I will just try to make it small so I will add provide the size as a small and let's bring
everything in one line so uh let me put it inside one de again like this so I can apply class name Flex justify between and then item to be in the Center perfect okay after this as I told you that we need to show the list of document now first we need to get this list of document right now in order to get the list of document we need to fetch the uh all the document from the Firebase but if you know uh we are going to fetch all the document which belong to uh selected
or uh given workspace ID right so if you see we have this workspace ID for uh each of these documents so let's go back and over here If you see uh we have this workspace ID inside this URL as well as we also have this document ID now the question is how to get this information so react uh sorry the nextjs is Prov providing us uh one hook called use params so simply we are going to use that uh use param hook so here first we need to make this component as a client side and
then here uh you will write constant parm or not here actually uh actually we don't need to use any hook here we just use The parents something like this okay you have to dest structurize this params and then you will directly use it let me consol it for you first and let me show you what is included this inside this params okay let's save this one and go back to our application so right now uh let me go to the inspect panel and inside the console so right now we are getting undefined because we are
inside the component let me remove this from here and let me try it inside the use Effect maybe it might help so here we say params and let console this parents value maybe it's uh yeah if you see it's not working inside the component so maybe we need to Define this parameter inside the actual page. jsx so go to this page. jsx and I will add this use effect over here and I will add the params as well and let me just console this one Okay so if I console this and refresh it I'm not
sure why still it not showing so I added this use effect now and make sure to add it as a use client because you have we are using this use effect and let's import this use effect as well okay so this is just for the uh to display purpose okay I'm just showing this uh parameter value if I save this one and Let me refresh this screen and now if you see we got this this information now inside this information You will see the document ID which is the what we pass over here okay and
then the workspace ID which is nothing but this one now this particular field name is nothing but the one which we give the folder name okay so that's how you can access uh the document ID and workspace ID through this parameter now if I remove this one that doesn't matter but to this side navigation bar you can just pass this parameter value as a params that's all and now if I go to the side Navigation bar and here I will accept it as a params okay let's save this one and let's save this one as
well now once we have that uh parameter value here we are going to write on methods we'll call it as a constant get document list and here we'll add Arrow function like this now inside this one we need to get the document list but not only we are getting document list but we have to make sure that whenever we add a new Document uh to our document uh list we have to get it automatically without refreshing the data okay and obviously uh depends on the workspace ID we need to fetch all the documents so first
thing we'll add constant here uh we'll add a query because we need to write query on that one so here we'll say query from the fire store Firebase then we'll add we need to provide the collection name inside that we need to Provide the DB reference from the Firebase uh config then we need to provide the uh collection name which is the workspace document just make sure it's documents with the S and then we have to write a condition so here we'll give comma and we'll simply write where uh on which field so The Works
Space ID make sure the field name is correct so it's a s with capit small only ID is capital okay then comma then You have to provide the operator so we need is equal to equal to operator because uh depends on the workspace ID we need to fish right and here we'll simply add parameters dot workpace ID okay so this is the value uh is nothing but the this particular value okay once we have this query ready now here we need to write constant Unsubscribe if you want to unscribe subscribe this particular snapshot here we
have the method called on Snapshot okay so this on Snapshot will give you or get it the all the latest data whenever the your document get updated okay it will just call automatically and here we need to pass the query and then it will just simply return the query snapshot so I will just write query snapshot the arrow function and simply we'll write quy snapshot dot for Each document and we'll iterate this each of the document So currently I will just console this doc. data okay and we'll see whether we are getting the document or
not now this get document list we need to call inside the use effect so we'll call the use effect and we'll simply add this get document list make sure we'll call this get document list whenever the parameter is available okay then only we will call it and I think we are good here I will Just write a documentation use to get document list okay now let's save it and inside the console we'll see whether we are getting a document or not so if you see we did not get any document so okay so here is
thing uh if I go back to our application the workspace ID is of type number okay and the one which we are passing is of type uh string so what you need to do uh you just need to convert this into a Number like this and let's save it and let's see whether we got it or not and if you see wow we got the document ID and if you see we got the two document I think we have these two documents though that's the reason we got the two documents okay and um if you
see the workspace ID is same and I think that's good let me check the workspace ID of both the okay so right now if you see workspace ID of this one is only one document so that's the reason it's Showing only one document this is just a duplicate data if you see this ID okay okay that's because um this get document list called two times okay and we can avoid this one uh so in order to avoid because when what happen in next sometimes the user effect we get called uh two times so in order
to avoid it go to this next. config.js file and here just pass react mode as a true and then save it and restart your application and run it again so uh it makes sure it is False okay and not a true so make sure that one and now if you see we only got the one document because that's only one document is belong to that workspace ID that's pretty good right now let's go back to side navigation and now we need to display the list of the documents okay so either uh you can just write
your code over here or you can uh create a new document a new component for it to display the list of documents so first thing uh we need to save this document List so here I will say document list comma set document list is equal to use State and we need to append this each of the document list because we are inside the for Loop so here we'll simply add set document list which is equal to previous document here we add document list of document inside the bracket we add document list comma dot sorry so
this need to be a dot dot dot because this is the spread operator and then We'll add doc. data okay so we are just it's kind of pushing the uh each element into the array right so this kind of thing and I think we are good to we are good over here okay I will remove this console and then save it now let's itate each of these document list so here we we are going to show the document list L and for this one I'm going to create a new component so I will create a
component called document list. jsx add a default Template and save it now simply we'll import this document list component over here it's just to um make sure our application is much uh smoother and the code we don't want to put all the code in one file right so it's it's always better if you can't uh and divide your application in smaller smaller component now to this document list we need to pass the document list as a document list go to document list make sure to uh get the D structurize your uh document List it need
to be D with a cap small and save both the files now let's display each uh or iterate our document list so over here I will use document list. map so here we I doc comma index the arrow function and inside this I will add a du now inside D We'll add one more du now first thing uh we need to add a docu uh document name so here I will add the h2 tag and we'll simply show Doc dot Document name okay and save it make sure it's we are passing the document name if
you see that currently we don't have the field called document name so whenever we create a document right so if I go to the create workspace where we have logic uh to add a document right here I will also add document name and I will provide as a Untitled document so this particular field I'm going to pass and this is a default field when we create the Document very first time okay so currently in our database we don't have that field for this particular record so I will just add over here and default I will
add Untitled document okay so this is the field obviously we are going to add it from the next time because we already updated our code now if I save it and go back to our application and refresh it you will see the T called Untitled document and this Error is because we did not provide the key property so for this du We'll add a key as a index and now we also have document uh name uh over here I'm going to add an image okay and we provide the source now over here I already have
one image called Loop document. SVG this is the SVG file you can get it from the source code as well and I will keep the link of the source code in the description now over here you just I will just add The file called Loop document. SVG for that one I'm going to add a width of 20 and height is of 20 and save it now if you see we have this Loop document icon or logo whatever you say let me close this tab and now let's bring everything in one line so here I will
add a class name make it flex and gap of two item to be in the center and save it perfect uh next uh if that document has an emoji because we also have the field Called Emoji if the document have the field emoji that also we are going to show okay so doc. Emoji if is there just show it and here I will add a class name make it Flex gap of Two And if the Emoji is there then we don't want to show this Loop document image so here we'll say document. emoji and and
if it's not there then don't show this one okay if Emoji is not there then show the image otherwise uh uh it will show the IMO as well okay and let Me go back and if you see we have this document now let's add some styling to this one so for this du I'm going to add a class name um here we'll add a margin top to three then we'll add a padding of two and on over or also we are adding padding x23 then on how we are going to add a background is of
gray color of 200 okay and we'll make a corner to be large then we'll make a cursor pointer and save it so if I hover on this one see how the effect is coming okay also If I uh we need to check which file is selected from this uh it okay from the ID we can just show that uh this particular do document is selected so for that one we need to add a conditional styling so simply wrap this CL whole class name inside the curly braces with this particular tag or code and remove this
single code and then simply write a condition so I will add a dollar sign here we say item do ID if it matches with the parents do Document ID that's all and then we'll add a styling to this one so here we say background to be white so simply uh because each of the document has their own ID and that ID is matches with the uh document ID which is active one then we are going to show background as a white and we have one error okay so we don't have item this need to be
a doc and if you so okay I don't know why p okay so we need to pass the params as Well so make sure from the side navigation bar we also pass the parms as a params okay so because we need to pass the parameter value and let's see and now if you see this one is selected that's why the background is showing as a white how cool right so that's how uh you can show this document now next thing uh whenever user click on this plus sign we need to uh add a new document
with the default credential Okay so we already have the code for that one so if I go to this uh create workspace where we are adding this default document right copy this everything as it is I will also copy this routing and everything and let's go back to the create document logic so inside the side navigation bar we have this button right plus button so over here I will add this new method we say create New document and I will paste this code okay so it use await make sure it is a sync now it's
quite simple make sure uh you have all the fill and all the dependencies imported so we'll generate the document ID then make sure to import this set doc this particular doc and the DV reference which is already have then the collection name we have to make sure that document ID is in the form of string then we'll pass this workspace ID Which is the number so make sure it is a number then created by then user information we need it so we'll get this user information from the clerk hook call use user and then once
we have this email ID the cover image emoji and everything is as it is the ID is nothing but this document ID and obviously I I'm not going to put the document output over here but for now I will keep as it is now this Method create new document okay now this create new document method we are going to call it when user click on this plus icon so here we'll say on click and we'll simply call this method now uh we'll set the loading State as well so here we'll say constant loading comma set
loading is equal to use State and we'll make it false initially now when user click on this set create new document we'll set the loading as a true and when the document is created we'll Set the loading as a false as soon as new document is created we'll just route it to the workspace then here will be the parms do workspace ID so this need to be a params actually params do workpace ID and same thing because we are getting the workspace ID from the parameter right and then the document ID uh I think we
need to import the router as well so simply add the router is equal to use router from the next slash Navigation and I think we are good place and now only last thing we need to do uh we need to show the loading indicator if the loading is true so here I will add the loader icon I will add a class name here I will add height of four width of four and then it will put animate to be spin otherwise I'm going to show plus icon I will remove this plus sign because if the
loading is false then it will show Plus uh text Let's save this one let's go back to our application and if you see right now we only have one document now if I click on this plus icon you will see this loading indicator and boom if you see now we have the second document if I click again see we have the third document right how cool uh this particular if you see that we have that uh effect right when we add it it's showing multiple files that's because when we get the documents we have to
make sure The document list is empty okay and then save it and now if I try to create a new one see it immediately create a new one as well and if I click on any of this one right we have to make sure that it will also uh clickable and it is selectable and also we will change this path as well so it's quite easy if I go to the document list component and here we'll add onclick method okay to this on click method uh we can add a route to the new Screen so
simply you can add the constant router is equal to use router from the next SL navigation and here I will add the router dot push and here we'll say slash workspace slash the workspace ID which is we can get it from the par. workspace ID plus slash and document ID right so that is also from the uh doc. ID because we need to navigate to the current uh selected document right something like this let's save it And let's teste this out now if I click on this second document if you see the second document is
selected and not only that it's route to the second document point to to the second document and same way you can select any of this document okay okay perfect so that's how you can uh add the U or face the documents as well as you can um select the document which you want to work on now next thing we are going to add an icon so that we can get something like this so if you See this icon and we are going to show some option to that one as well so for that one I
will add a new component we say document options. jsx add a default template and save it now to this document option first let's go over here and I will just import it over here we say document options component and save it now let's go to this document option and over here I'm going to add the more vertical icon this particular icon and Then save it now if I go back to our application you will see this three dot icon let's add some height and width for that one so here I will add a class name
we add a height of four width of four and uh from this document list I will make this as a flex for this du and we'll just make justify between and item to be in the center so that icon uh will be on the right hand side perfect now on the click of this one we need to show the option menu okay so let go to this Shat CN UI and inside that we have this drop- down menu component now if I click on this button if you see we have this beautiful drop down similar
kind of dropdown we need to implement so first thing you need to import this or install this component so that we can use it so inside the terminal just paste this command so it will install the drop down menu and go to this drop down option copy this um import statement first let's add it here And then copy this uh example code and simply paste it here now if you see in order to open the dialogue sorry the drop down menu this is the trigger right the open text now our we want on the click
of this menu we want to open this so I will just paste it here so if I save it now if I go back to our application you will see on the click of this one now it will open this menu and if you see how beautiful it's looking right now let's edit this one so we Don't want this label and separator we'll remove this here the first option will be uh share link then here we'll say rename and I will add delete you can add more option if you want okay let's remove this one
and save it make sure everything is looking good see you can even add the icon for example if you say you want to add icon so here I will add a link I don't how link two icon will look like let's see now if you see we Have this link two icon obviously um I'm going to change the height and width so I will add a height of four width of four and for this item I will add a class name we'll make it Flex gap of two same thing let me bring this down I
will just copy everything as it is so that I will add it for the rename and I will add it for the delete as well only thing uh okay so here I will change this to a trash Icon trash true and I don't know for okay so for trash to need to be to this one and here I will add pin box maybe and save it and let's see how it looks so if I click on this one if you see we have this three icon rename delete and share link even though you can also
change the color of this uh text as well okay now if I just write text to be in the red for the trash icon right you are just showing that this is a warning message if I click on this one you will See the delete option now in in the form of red color it's a red color right perfect so this is how we can show the documents and quite easy obviously this all functionality we are going to implement later on now next thing we are going to add the progress bar at the bottom so
in order to add a progress bar um we can directly add it into the side navigation let me go back yeah let's add it here only so let's like progress Bar and we going to add a du and now in order to add a progress bar we are going to use a Shaden progress bar component so if I scroll down you will see the progress and this is how it looks in order to use it just first install this uh progress bar component and this is just a simple use case so it's quite easy to
use and inside this du I will paste this progress bar and import this progress also uh this is just a value how much Progress is completed right that value we are providing let's save it and go back to applic ation and boom if you see we have this beautiful progress bar showing on the screen now we want this progress bar at the bottom so simply add a class name here we'll make it as absolute okay and we want add the bottom so we'll add a bottom maybe on 10 and we'll add the width of maybe
let's say 95% and save it 95 is going out of screen let's add 85 I think this this is good see and that's how our progress bar will look like okay now uh to this progress bar uh I'm going to add some more uh text so here I'm going to add h2 tag and we'll simply say five out of five files us uh for this five I will add a strong tag and here as well I will add a strong tag and save it now um this particular value is nothing but the document list name
sorry length so here I will add document list do Length and save it now if I go back you will see we created the four files and it's showing four out of file five files Ed okay uh here I will add a class name we make text smaller and we'll make text Reg uh we'll add font we'll change the font light perfect this look good to me right and U we'll add a margin y to2 also I'm going to add one more text I will just copy the existing one and here I will Replace everything
and we'll just say up upgr your plan for unlimited access and save it see perfect right even though if you did not give margin over here that's completely fine perfect now depends on number of files we need to calculate how much progress uh or we need to calculate the value for this uh progress bar okay now over here inside this uh document creation so inside the side Navigation we also have to make sure we are going to create a new document with the document output okay so if you remember we already added this inside the
create workspace so this particular logic we'll just paste it over here okay so nothing we need to change because we already have the document ID and all of this information okay so here uh first we create the actual document and then we also create the document output let's save it and Let's test this out so just For the uh sake uh I'm going to delete all of this uh workspace document delete it and let's create a newly okay so if I click create on this one you will see a new document is get created not
only that but if I refresh this screen now you will see the document output and here we have the new document with this document ID that document ID you will find it over here okay so if you see this is a 6 C9d Let's see we have the 6 C90 okay and inside that we going keep actual reach text editor or information whatever the output which we are going to add or whatever document we write it will store in that particular folder so next we'll see how can we Implement that Rich Text Editor and how
can we save that uh whatever the user add the input or write something on a document that we are going to store inside our document output uh collection now depends on uh To calculate this particular progress depends on the number of file created it's quite simple first thing you need to write a logic so document list. length is the kind of formula divided by the maximum file okay so if you they have three file divid five file into 100 because we want to calculate the percentage and then save it that's all if I go back
now and if you see I created the five files and that's the reason it show full but if I delete any Of the file let's go to this uh let's refresh this screen and we have the workspace documents let's delete some of the documents let's say we delete this document and if I go back to the screen if you see now we have the four document right now if I add new one see automatically it's added new document as well as it also updated our progress bar now once we reach to the maximum file uh
creation right we need to avoid User to create a new file and we want to show some kind of alert dialogue that you cannot create a new file you need to upgrade it right so in order to write a condition let's go to this create document and here we'll add a condition if uh document list. length is greater than equal to maximum file so here we have maximum file which we Define that constant then we'll return nothing and now if I try to create new one see nothing is happening right but In the same time
we need to show some kind of alert box so let's save it so for that one let's go to this shatan and search for this sonar so sonar is act like a toast message if you see this example like this same thing we are going to implement so first thing we need to import this sonar component into your project and then once it install inside the root layout we need to add this toaster component and make sure it is Importing from this components / ui/ sonar so let's go to this uh root layout and inside
this root layout um inside this body tag let's add about the children and paste it here like this make sure to import this and then save it now wherever you want to use you can just use this toast message so let me close this and let me close uh and go to this side now where we are creating this document and here we want to show the toast Message so make sure to import this toast message from the sonar only and here we will see say uh upgrade to add new file and save it let
me go back to our application and if I try to create it now if you see on the bottom side we got this to mes saying upgrade uh to add a new file okay you can even add the buttons as well if you see this example in this example they added the button and if you want to know how uh the code you can just go Over here and you will see this information now let's implement this one as well so copy this line of code and simply paste it here okay so you have the
description here you can say you reach Max file please upgrade for unlimited file creation so label you can hear say upgrade and on the click you can even Navigate to the upgrade page right now we don't have the that page so we'll keep as as it is and save it now if I go back to our application and try to create a new one see we have this beautiful toast matches saying upgrade to add a new file perfect okay so that's how guys you can limit user to create any more new file obviously later on
later on in this course we going to learn how to delete this particular file or let's let's Implement this delete operation right now only so in order to implement this delete operation first you need to know how to delete it so just search for on the Google Firebase delete document and you can see this Firebase documentation in order to delete the document and if you see this is a on line code to delete the document okay so copy this one go back to your application and where you have that document list let's go to this
document List and inside here you can implement this uh method so here we'll say constant delete document and the arrow function here you just paste this await uh Delete doc make sure to import this delete doc the document and the DB reference here we need to provide the collection name so our collection name is workspace documents and here we need to provide the document ID so that document ID we can get it when user Click on the document okay so here we'll pass as a doc ID then as we are using await make sure we'll
change this to a sync and if you scroll down so on the click of this uh document option right so here we need to I think we can add on document option but if I go to this document option here you can add on click event so here I will add on click event to this menu item and here we'll Say delete document also we need to know which document we we are deleting right so to this document option we are going to pass each document information okay so from this document list we just pass
the document information as a doc because we are retting that information right and let's save it go to this document option now we have the document information just simply pass document ID to that one and we'll uh pass delete document to the Parent component from here okay don't be confused I if I'm fast let me know in the comment section so from the next video I will be slow but let's see from the one user click on this delete document we are just simply calling delete document this particular method we are passing back to the
parent component which is the document list and here I will accept that delete document here we pass the doc ID and then we'll call this delete Document method and to this delete document method I will pass the document ID like this and simply it will delete the document okay and automatically it will refresh the data as well now over here you can you um uh show the alert or some kind kind of dialogue before deleting the record and once the document deleted you can even write a toast message saying document deleted okay as I told
you that you can also add the uh alert dialogue before Confirming it okay and save everything let's go back to our application and let's test this out if I go over here click delete and boom if you you see the document deleted immediately okay if I want to delete it document deleted I'll prog is updated okay so uh not only that but obviously in the Firebase as well now you will see only three documents so until this point if you have any question any doubt let me know In the comment section because there are a
lot of things that we are going to implement in this particular application now now in this section we are going to implement the text editor or document editor where on the top uh uh section we are going to show this header along with the user profile icon on the left side then the share button and the organization switcher option okay so and uh below that we have the cover image uh where user can update the Cover image for the uh given documents then the Emoji picker and then the file name as well so user can
edit the file name as soon as you edit this file name we have to make sure all of these three uh elements get updated into the database as well so let's go back to our application let me close all of this tab first and inside this page. jsx under the workspace we have this document section right now for this document section I'm going to create a new Component under under this workspace undor components and and we can call it as a uh document editor section. jsx add the default template and save it now this particular
document will add over here so we say document editor section and save it now inside this document editor section as uh I explain already right as per the mockup at the Top we are going to show header then after this we are going to show cover image then uh Emoji picker then we have the file name and then last the reach text editor or document editor okay so let's create an component for the header so inside this underscore component we are going to create a new component we can call it as a uh document header.
jsx and then add the Default template let's save this one and simply add this component over here so we can call it as a document header and save it now inside this document header the three things we need to show one is the organization in the middle then share button and the user profile on the left side we don't have anything if you want to show something you can but right now we'll keep it as Empty um then we want to show organization switcher from the clerk nextjs this particular component we imported then we want
to show the share button so I will add a button component and here we'll say share and then we also want to show the user profile image with the help of the clerk user button now for this one I will add a class name make it Flex gap of two and for all of these item we add a class name make it flex and simply say justify between I Will also to make item to be in the center if I go back to our application Let me refresh this once and then you will see this
header section now let's give some padding so simply I'm going to add a padding of let's say five and let's add a three and we'll add padding X to 7 okay uh we'll simply add some Shadow effect let's see how it looks I think this is much better now here obviously currently we are not in the organization Mode it's a personal mode but anytime if you switch to the organization mode right you have option to switch it from here as well then this share button actually help us to share the document and this user profile
icon um where you can manage your account and all next uh we want to show this cover now for this cover component we already have that component uh ready right and in order to show this all of these three Item uh we can create a new component and we can keep all of these three component into that one and we can call it as a document uh info. jsx add the default template let's save this one and simply I will copy this three things and we'll paste it over here and then make sure to import
this document info this particular component and save now inside this document info first Thing we need to show the cover now for the cover it's simply the cover picker which we already have right this component so that component we are going to use now inside this cover picker we need to Simply show the uh image and we need to give option to select the image if you remember we already have that particular uh component so if you go to this create workspace where we have this cover picker I will just copy the middle part Of
this C picker okay and then make sure to import this image component then in order to uh provide this cover image let's define the state called cover image comma set cover image is equal to use State and by default we will show the uh local image okay so which is the abstract. PNG which is similar way that we already Define okay so so it's just a cover.png I will just paste it here as a Cover.png and I think we already imported the image as well and let's save this one now if I go back to
our application you will see this cover image and you have option to uh change the image as well if you see we already have that component ready so we just use it in our um uh application because we don't need to write any code right because we already have that component ready made uh next um we have to make sure we will implement this set new Cover method so here we just set the cover image as a cover perfect and save it now if I go over here change the cover if I replace and select
this one and immediately it will update you can uh here change the height let's say 220 or 200 I think this is good next uh as per the mockup we want to show this emoji icon which is on the half on the cover side and half on the below of the cover so let's add that one too so under this Emoji picker We'll add Emoji picker and inside this uh I will just copy the code which we already have inside this create workspace where we already added this Emoji picker right um we'll copy this line
of code like this okay and uh let's change this to a du and we don't want any variant here I will add a class name and we can put some transparent background so in this case I want to give my own color code so I will add the custom color code so here this is the color code I'm going to add it and we'll add a padding of four to this one and we'll make rounded as medium okay and make sure to define the Emoji so constant Emoji comma set Emoji is equal to use State
and uh we already install okay make sure to import this smile plus and for this one as well I'm going to uh change the height and width and will make the text is of gray Color let's save this one and let's see how it looks so okay so it's just showing the Emoji picker directly and okay so so here make sure this is Emoji picker component and not the Emoji picker so I will just update that one accordingly so we don't want this Emoji picker because we are using our own custom component and if you
see we have this Emoji picker and if I click on it it will give us this effect okay obviously we are we are getting error one because we click on this any emoji icon because we did not set the Emoji yet but before that uh I will just wrap this Emoji picker component inside the DU and then we'll add class name as absolute so we'll make absolute position and we'll add margin left to 10 so let's go okay then also we are going to add margin top to minus 20 pixel Because we want to on
the top of this one see let's add 40 I think this much better uh let's make it cursor pointer and save it for this Emoji I will add a span tag and here I will change the class name and we change the font size let's say or text size to 5 XEL okay now if I okay so also we forgot to add the set emoji icon so here we'll Say emoji and we'll set the Emoji value the selected Emoji value as a Emoji Let's test this out so if I click on it and select any
of this so it's showing the text as a Emoji so this need to be Emoji like this okay make sure it inside the curly braces let's try it again perfect and if you see we are getting this beautiful emoji icon obviously you can change depends on your selection you can change This cover and the imagej icon as well perfect the last thing we need to do is to add the uh uh file input okay so user can have option to edit the input so over here I will add a d then we add a simple
input is of type text uh then here I will add a placeholder as a Untitled file our Untitled document and we also need to provide a default value okay so whatever the value user set so here we'll say default value And this default value we can get it from the uh document information for now I will just add untitle document and save it if I go back you will see that text let's give some styling so for this du I will add a class name let's say margin top to 10 and padding is of 10
also for this input let add a class name we'll say font bold text is of 4 Exel and we don't want outline or that Input and if you see now we have this beautiful um file name if I delete it you will see the placeholder as well now as soon as you type something right we have to make sure it will get updated to the uh to our documents okay and this particular file name we need to update to the workspace document because we already have this uh IDE and depends on that one we need
to update the document name now in order to get the document Information right we need to face document info so for that one let's go to the parent component of this particular document info which is the uh document editor inside here now to this document editor we need to get the parameters so here we'll say params and this params we need to pass from this document editor section so here we say params and parent so in so from this page. jsx which is the Parent component which is the workspace document and where we got this
params right this params we pass to this document editor section and from this document editor section we'll get it and then we'll simply pass to this document info like this now inside the document info we'll accept as a params and then we'll f the document information so here we'll say constant get document Info and here we will say await okay so first we need to write document reference so here we say Doc reference is equal to um document then the DB reference comma The Collection name which is workpace documents and then the document ID so
document ID we can get it from here so we say parms dot document ID once we have the reference we'll say Constant doc snap is equal to await get doc so we are fing just only one document and then here we'll say uh document we'll pass the document reference here we'll pass as a async and simply we can write document snap. exist then we'll console the doc snap. de now this get document info we need to call inside the use effect now whenever we have the params information right so this information Whenever is available then
only we'll call our get document info method so we need to make this as a used client so here we'll mark it as a used client because we are using the uh react hop call use effect and here I will write use to call or used to get document info and save it now if I go back to our application and go to the inspect panel inside the console you will see that object with that document Information right now the document ID is Untitled document right now this information will store in one state so here
we'll say constant document info comma set document info is equal to use step and here we'll say set document info as doc snap dot data now once we have the document information uh for this input we will provide the we already provide the default value but here we'll replace with the actual document name so Document info do document name and save it now if I go back so right now the document info uh document name is a Untitled documents so that's the reason he showing as Untitled document also we'll replace with this actual Emoji if
it Emoji is there so for the Emoji or we can set the Emoji here as well so we'll set the Emoji as doc snap. data dot Emoji and save it let's see so we don't have Emoji so that's the Des string as it is and the same with the cover image okay so we'll also change the cover image so here only we can set the cover image so Set uh cover image as a doc snap data dot cover image and save it so okay so we have one error uh let's see what's the issue so
to fix this issue um here we'll Check first whether we have the cover image or not okay if the cover image is there then only set the cover image otherwise don't set it and and let's see now we don't have that error now as soon as we have the all these changes right we have to make sure that we'll update the uh our documents information right if I update the change uh the cover we have to make sure inside our document the cover is set with that appropriate value same with the input And the Emoji
as well so let's Implement that one so here I'm going to add a constant and let me bring this down so here we'll say update document info and to this document info we pass key and value okay so you don't need to uh write each different method for each of these three elements uh here we'll say await update Document and uh here we'll pass the DB reference then the collection name now if you want to know how can we get this uh information right how to write the code so if you see over here inside
the document you will find all of this information now in this case if you want to uh add a data or update a data you will see inside this documentation just search for the update uh document and here you will find the information so in order to update it right you can update This document with the document reference and then you can set the value or you can directly Define it here like this so let's do that one similar the way which mention in the um document so first we'll create the document reference is equal
to document then DB reference then collection name which is the uh workpace document comma and the document ID so in this case our document ID is the parms Do document ID then we write await update doc here we'll put provide the document reference and then we'll just simply set the value so similar like this one now whatever the value we want to set is nothing but a key and the value now we are using await let's make this as a sync and here we can write the toast message uh saying uh document updated and save
it now this update Document info we going to call whenever uh there is change in the code so for example if you user updated the cover we'll call this method so here along with the set cover image I will also call this update document info okay so I will bring this down and if you want to call multiple uh methods right you have to U put it inside the curly braces and then you can call the update document info so the key is cover Image and the value is uh the cover and then save it
let's test this out so if I go over here click on this change cover select the any images any cover you want and click update so uh we updated but we got one error so no document to update so it's saying the document is not present so the problem over here the collection name is incorrect this need to be a documents so if you see we have this documents so Make sure the collection name is correct okay and also make sure the we are we need to use key right so we have to wrap it
inside this square bracket okay because this is the field name now let's save this one and let's test this out so if I go back and change this cover to something else let's say this one and click update if you see we C the toast message saying document updated if I go back to our application you will see now uh the cover image is showing with the Proper URL cool right now let's refresh this screen and let's see whether we are getting the updated information and even after the refresh you will see that change same
thing we are going to do with the Emoji so let's go back copy this update document info and whenever the Emoji is selected so over here let me bring this down we need to call two methods so I will wrap inside this uh curly braces and here I will call the second method called update document Info the key here is emoji and then we will simply pass the uh Emoji like this and then save it now let's test this this one as well so here I will click it I will use this emoji and it's
saying updated document if I go back to our application you will see this emoji icon get updated and just refresh the screen and let's see we got the Emoji cool right second we need to update this uh of document name so let's update that One as well now we are going to update this uh input when user click outside user type something and uh if you click outside then only we are going to update not on every uh input uh keyboard input right so in order to do that we are going to use on blur
effect okay so this will uh emit the event uh and then we'll just call the update document info but before that let me console for you and inside the event we have the target do value in order to get user entered Value now if I go to this inspect panel and inside the console and if I type something let's say uh new file okay right now if you see nothing is happening but if I click outside you will see the new file text is updated so let's uh Now call the update document info here the
key will be the document name and then we have the value let's update it now so here we'll say uh text file and click outside you will see The text file updated not only here but it's on real time it's updating the file name as well along with the Emoji if I updated the Emoji with something else you will see it's a real time updating along with the file name as well okay so new file 2.0 as soon as I click outside here you will see the change so that's how in real time you can
also update your information with the help of Firebase so guys uh until this point if you have any question any Doubt let me know in the comment section now it's time to display the reach text editor if you see uh as per the mockup we have the reach text editor below to this document information so for that one we are going to use this editor. JS Library which is very powerful editor Rich Text uh editor library and it is free to use it's open source but the most important thing they have a lot of different
plugin if you see this is the example where uh you can Add different different uh elements to your document so in order to uh integrate this editor. JS let's click on this get started make sure you will go to this editor js. here inside the documentation you will find the installation step the first thing we need to do is to install this editor uh JS so copy this command go to your project and I will close all of this tab For now and inside the terminal just paste it here so it will install the editor
JS make sure it is installed and then wherever you want to use you need to import this editor JS and then you can use it but uh there are some of the things did not mention I think but don't worry I'm going to tell you so if you see this is the script tag where they are using this uh Source editor. JS but let's do one thing so first thing we Want to show this editor JS under this document editor section so click on this document editor section component and inside here we are going to
add the reach text editor so first thing we need to create a new component so here I will create a new component and we can call it as a reach text a document editor we can say reach document editor. jsx now add the default template and then save it now make sure to import this component over here so Here we'll say reach document editor and save it now inside the application you will see this reach document editor let's give some um marging and padding so here I will add a class name We'll add padding X
to 10 and we'll also add margin left to 10 or maybe a 20 so it will be in one line now inside this one we are going to add our reach text editor so here we need to write du ID is equal To editor JS and just close the tag now obviously you need to provide the reference but before that make sure to import this editor JS so I will copy this one go to a project and simply I will paste it here okay now next thing you need to define the reference okay so over
here I will add constant reference is equal to use reference uh obviously you have to make Sure it is uh it's supposed to be imported from this react and also I will Define the variable called editor now here I will Define constant here we'll say initialize or init uh editor and in this method we will actually initialize uh the editor so first thing here we'll say if editor because we already defined this one right so editor do current is not defined it means editor is not initialized then we can initialize here Okay and for that
one if I go scroll down little bit you will see this particular method just copy it as it is and paste it here now make sure to import this editor which we already imported and this is just a holder for the editor JS okay um next uh we are going to re uh refer this Editor to the okay we actually we don't need this constant because we already defined this editor over here so here we'll say Reference do current is equal to editor okay so we are just referring to that current editor and I think
that's all okay and this is the ID I don't know whether we need to provide the reference to that ID Let's test this out first and we'll sa so I will save this one and go back to your application and here nothing is displayed on the screen yet actually we forgot to uh call this init editor inside the use effect Whenever we load the component right so make sure to uh add that one so I will just make sure to call this inish editor like this and then save it and here make sure to add
question mark and then go back and if you see we got this plus sign where currently we only have the default uh tool called text where you can type anything you want okay you can even move this you have option to uh bold it or italic it or link it right now obviously there are lot of option we Are going to add in this particular um options okay where you can have heading paragraph code block tables list and so much but right now let's align this in proper way because right now there are so much
space on the left hand side so uh let's go to the editor section so we have this reach document editor and inside here uh let's remove this and save it and let's see how it looks so now we'll give some margin from the LI so here we say margin left to 20 we added a minus one okay so it will come on the left hand side let's add more I think this is good enough okay so here user can start writing see perfect now the question is how can we add all of this plug-in right
because right now only text is available and you can add more options so for that one uh if I go to this editor JS site here you will see an option called Awesomes plug-in now click on this aome plug-in and here you Will see all of this plugin like text list table code uh and there are lot of other things here okay and you can integrate each of them I'm going to tell you how to do it but uh if I go to this documentation and and if you scroll down little bit here as well
you will see that option so here we have this all the option the only thing that you need to do you have to make sure to import this particular plugin and simply add that inside this tool section Okay so if I go Over here I added this uh inside this uh editor JS where you can initialize this tool option okay now you can add as many as tool you want this is nothing but the plugin okay so obviously I'm going to tell you how to use it so if I go to this aesome plugin that
I open over here now you can uh select the one which you want you want to add text list and everything if I go to this uh text and typography you will see different type of text let's open this heer I will open In a new tab and in order to use this heer first thing you need to import this one so obviously we are not using Yan but we'll use this npm so I will clear this one then put npm and paste this command which uh add the header for us now click enter and
then this is the simple way that you can add it first you need to import it I will import it here and then you just need to add this header inside the Tool so I will add over here and then save it now if I go back to our application and click add you will see the new Option called heading now if I click on this one here you can type The Heading okay and here right now if you see we have different option for the heading okay but even though if I select any of
this option nothing is happening right because for this uh headings tag right you need to provide a custom CSS so let's Implement that one so in order To apply this custom heading uh option right let's go to This Global CSS and simply we can uh add it here so here I will just say H1 tag and this is the class name for the uh editor and inside that one we'll apply the text is of 3 Exel now you can add anything you want okay it doesn't matter and the font bold now I will copy this
for other heading tag so here I will add H2 H3 H4 H5 and the last is H6 here I Will say uh 2 XEL and we'll make the semi bold font then here I will add Excel with a semi bold font then for H4 We'll add add a large text and we'll also add the semi bold font over here for all of them we can add semi bold and here we'll add medium and small or we can add base as well and save it okay so that's how here you can add medium and small and
save it now if I go back to our application so Here we have an error called at apply so let's see why so it's saying the text MD class does not exist okay so here we need to provide as a base so base was correct and now let's refresh it I think we are good now if I click on this heading with t title heading and now if I click on this option again now you have option to change it and boom if you see it's changing immediately okay now this Heading tag is working perfectly
fine also you can convert this text or you can move this up and down right so for example if I want to move this up and down you can easily move it okay how cool it is correct perfect so that's how you can add the plugin let's add some few more plugin plugin so here uh you can add a Cod you can add warning delimeter let's add delimeter that is good one then I I also add alert box and here you will see you have the list uh Media means you can add images you can
you also add the tables okay so let's add daily meter so this is how the daily meter will look like uh here I will add the npm and once you add this one you need to import this so inside this re text editor I will import it here and then simply you can use this one as a daily met o inside the tool only okay and save it now if I go back to our application and Click here you have option called theery how the three dot coming okay also uh one more thing I want
to show to you that you can even add the custom configuration okay let's say you want to add this alert right and for this alert as well you can add the custom configuration where you can have alert type primary secondary and all let me show you how let's import this particular plug-in call alert and then import this Statement now this is the process where you can add one by one okay there's no other option but you can get it from my source code if you want to save the time and then add this tool called
alert now once you add it make sure the alert is getting added so if I click on this add and if you see we have option called alert uh box right now here if you see we have the option called secondary primary and all of these things you have different different option over here Also if you restrict that option to certain uh uh certain uh alert type you can also do that you can add this class with an uh configuration you can add this shortcut as well okay it's quite easy so if I copy this
custom configuration and you can replace it with this alert where you have class alert you can add the inline toolbar as a true the shortcut and the config as well let's save it and let's see how it Looks so I don't know why this error is coming okay we need one more curly braces and then save it now if I add this alert you will see the alert box right now to this alert box you will see different different option as well okay where you can have left centralized and something like this wow that's pretty
good right right so that's how you can add the different alert option as well if I did not put anything right you will see the Placeholder as well because this is the placeholder we added and that's the string whatever you update you can see that also not only that but if I try to add the alert you will see this uh shortcut key right that also you can add it and with the shortcut key you can just uh add the alert second important thing if you type if I type the slash right you will see
you you are getting this option as well so on the click op slash as well you'll get that option so Now guys uh I will pause the video over here and in the meantime I'm going to add um some of the plugins into our application like tables or the list or the code as well okay and you can also try your own if you face any issue in that while implementing any of the plugin let me know in the comment section but I will pause the video and I will add it so that I can
show you uh the all the plugins which I'm going to add in our uh List now once um you add all of these plugin so in this case I added a lot of plugin like delimer heading text tag then I also have the table list checklist image code okay added many of this uh uh plugins to this text editor now the question is how can we save this one because uh we want to save this document into our Firebase fire store so in order to store this information let's go back to our application and first
thing we need to fetch it and then we Want to store it so let's go to this R document editor and inside this editor we have one option called on change okay so this on change uh has event API and event and then inside this we'll just console it okay or we don't need to console actually but inside the onchange so whenever you make a some change it will uh trigger this on change call back event okay so I will call new method so here we'll say uh save Document and this save document I will
call it here constant save document oops like this and for now I just console it okay just to make sure that save document method is getting called okay so on the change of this document I will give comma and then save it now let's go back to your application Let me refresh this once and if I go to this inspect panel go to the console clean everything and here let's try to type Something okay so here I will say hell team how are you as soon as I stop it you will see the save document
is getting trigger right it's working fine and if you see as soon as type the save document is uh getting called okay so that means the save this particular method is working as expected now inside this one you need to call refer do current means we are referring to the current editor this current method has a method called save okay and We have uh this is a promise so it will call then and let's put the output okay so here we need to just put the output data and then we'll console this output data so
here we say output data okay so whenever we write something we'll conso it let's see what we are getting from the document so let's clean everything here I write hello team how are you okay and inside the console if you see We have this uh console output inside that we have time and version and most important thing we have this block information this block information is very important so whatever you we write right inside this you will see we have the data and is of type text so showing as a text and is of type
paragraph So default is a paragraph right but let's say uh so something is not working so if you see it's going Beyond This uh side on the on the top of this sidebar but we can fix this in a moment but if you add a heading let's say uh title right and then you will see that change as well so if you see now we have the two blocks one the for paragraph one for the heading and for the second we have the type heading with the text and the level as well how cool right
now this all of this Json we need to save inside our database so so uh once we have this output right we can directly Uh save this into the Firebase fire store so that we can see in the next chapter but until this point if you have any question any doubt let me know in the comment section and here I will just put use to save document and save it and here uh this margin left I'm going to give it only when it's a large screen so that issue that is going on the top of
this bar it will get removed and I think for now we are Good now as you know that we already have this save document method which we implemented now inside this one we are going to update the existing document because uh if you remember we already uh have this document output collection and this collection we are creating whenever we create the workspace document right and each of this collection uh sorry each of this document has the document ID and inside this we have the field called output simply we are going to Update the output every
time when there is a any change so let's go back over here and first Define the document uh reference is equal to Doc then we need to provide the DB reference comma collection name so in this case is document output so make sure the collection name will match with the uh collection name which you entered and then the document ID now in this case the document ID we need to get from the parameters so Simply we'll get the param from the parent component so if I go to this parent of this reach document editor so
over here if you see similar way that we send these param to this document info we are also going to send it to this re document editor and then simply inside this document oh so we already here let's go to this re document editor and now we can just simply access Parms do document ID okay and obviously it is a string I close all of the tab and now I think we are good now next thing here we'll say await update Doc and then here we need to pass the documentary reference and the field which
you want to update so in this case we'll just update the output field with this output data as it is and make sure this output data is in Json so we are just passing the Json and Firebase is support the Json uh uh what will say Json data type okay so you don't need to worry about that one to convert it into a string or anything oh so here I need to convert this as a sync and perfect okay okay let's save it and let's test this out now if I go back to our application
I will refresh this document and if you see this is a new file 2.0 document let's update something so here uh I'm going to add let's say let's add a checklist so here we'll say idea 1 idea 2 idea 3 okay now obviously Nothing is happening because we are not showing that user that okay your file is updated or about but let's say inside this document and if you you see this document ID called 933c now it has that output right if you see inside the output we have this block inside the block we have
just the new item which we added right idea one idea two and idea three and all of these things how cool right let's add couple of more things so here I'm going to add delimeter then I'm Going to add the alert box and we'll say uh add new idea in about list I'm just adding something okay and and uh here obviously you can even change this uh color and all okay now even though you don't need to save anything or any that automatically with that particular method our data is getting updated into our database and
if you see the output inside this uh Firebase fire store how cool right now everything until this point is good right but if I refresh This one see we are not getting the data obviously we need to F the data as well so let's go back to our application and here I'm going to create a new method called constant get document here we say get document output that will be a good and inside this get document output we are going to fet the um document output information right but in this case we are going to
fish uh the uh the document update with the real Time okay so for that one I'm going to use constant unsubscribe is equal to on Snapshot okay and then here we'll provide the document reference inside this we'll provide the DB reference comma The Collection name so here the collection name is the uh docu document output then the document ID so in this case document ID is similar which is this params do document ID which we can get from the params obviously and Then it will return the document like this okay now let's console this document
first so here I will say doc. data and that's all now this get document output we need to call inside the use effect so here I'm going to create a use effect and I will just simply call this get document output so get document output now this get document output I I'm going To call whenever there is a change in the params and then save it now if I go back to our application and the file which is selected is a new file 2.0 let's go to the console and here you will see on the
line 47 make sure the line 47 is correct which is this one now we got the output outut say document ID along with the output if you type something let's say type here right and as soon as I type it you will see on the line 47 47 without Doing anything we got the real updated information perfect right now simply we going to store this in a one state so here we'll say constant document output comma set document output is equal to use state and then over here we are getting data right but we just
want the field called output we don't want document ID we will just C use this Output field okay so here we'll say set document output as document. data do output and then save it now obviously we need to add it into our editor so simply inside this init editor you can after this code right you can just add data as a uh document output if there's document output right we can say add the document output data otherwise don't add anything okay we just put empty value let's save It and let's check it out so somehow
um our data is not getting updated to this uh document output so I will remove this one and simply what you can do uh over here you can call render Dot and uh not render my bad uh first we need to call a editor which we already defined do render and then inside here you can uh provide your output data okay so this information will keep it so here we'll say document data. output okay So I'm not sure I think maybe like this we can okay let Define like this and we'll see whether we are
getting output or not now if I go back to your application so we got an error saying editor. render is not a function let's see so here um we'll also make sure that if the document. data and output is available then only uh render the document I think we don't need this uh set document data so I will remove it and the console as well and let's save It now if I go back to our application you will see the change okay let me clear all of this thing let me add something else so new
so here we'll say oh so every time is getting rendered so for that one um I think we need to so here we need to only make it a render first time and afterwards for that current user we have to make sure that is not getting every time okay so we have to add a condition but before that we have to inform to our Firebase file Store that uh who is the editor of this particular file the last editor okay so first thing what you need to do uh here I will use the user okay
so make sure to add the constant user is equal to use user and then we have to make sure if user is Ender then only uh initialize this uh editor okay once you done with this one here we'll add edited by as a new field and over here I'm going to add the users email ID okay so here we'll say primary do I don't know why It's not getting okay make sure to import this user first and then you will get primary email address do email address okay now let's save this one and right now
I will just not execute this gate document output for now but if you rendered this one and let's add new text okay now for this particular document let's see what we get it so I will just go back okay so go to this data and our document output okay so this document and if you see the text New text is showing and along with that we are getting the new field called edited by Perfect now after this one once we have this edited by right I will just uncommon this one to get the document and
along with that I'm going to add the one variable called L and we'll say uh is it or is uh is f okay and I will make it false so first time I'm going to write a Condition if is f is true uh is is false or user or here we say not user but document. data do edited by is equal to equal to user do primary email address. email address if it's not there so you have to condition not not okay if uh this condition does not match then you can go to this if
uh the document do data edited by is equal to this primary email address then go don't go to this if Condition and along with that I will set is f to be true okay if the data is already F say don't F the data I will just format this document so it's little bit complicated that to understand but the it's very easy actually by in the in the implementation wise okay so let's save this one and let's test this out if I go back to our application now so we have one error let's say uh
the editor. render cannot read a property of undefined okay so What we can do uh because the get document output is getting called before rendering this editor so we can call this get output instead of not here I will un commment this code and we can call this get output to one of the method called on ready okay so let's try to add it here so whenever this editor is ready we can call this get output uh document and let's save this one and test this out now and now if you See we got the
text now even without rendering you will see that you can able to uh type it okay and now it's not rendering for that particular user we are we are fetching data but we are not rending every time because the it's simply checking the condition is already fet and it is uh edited by that particular user okay and that's the reason it's not going inside but if you see inside our database is type or is uh updating our record perfect right now Before moving forward I want to also inform you that um we use this real
time uh document update now over here if I update something let's say uh you updated something right and immediately on the left hand side you will see the changes affected on the screen okay cool right and as soon as I type it without refreshing it it also reflected on the other screen so that's how guys uh this is a real time update you will see it without refreshing your Screen before uh implementing any other feat we are going to implement the workspace page currently if you remember we are just showing the empty space because uh
for the first time user right and then we are giving option to add a new workspace now user already have the lot of workspace created or maybe one even user created one workspace that's final and then we are going to show that workspace list and on the click of that one we are going to open the workspace Uh with the documents and all okay so let's go back to our application and let me close all of the tab first and then open the dashboard section so where we have let me close all of this go
to the routes where we have the dashboard inside the page. jsx where we have this workspace list now under this workspace list section I'm going to add a new component so let's create a component first so we already call it as a workspace list okay That's find so here we'll say workspace item list. jsx and then add a default template now here I will just replace this with the workspace item list and then Simply Save this one uh now here inside the workspace list I'm going to write a method called get workspace list with the
capital w and then uh here we'll write a constant query is equal to Query then collection here we need to provide the collection name so in this case is workspace comma um I think we need to provide the let me get back so if you see this is how we need to provide uh uh to pH all the documents okay and um from the workspace so we W which is capital and then we have this all the documents so depends on the workspace uh ID okay so yeah so if you see uh all the Workspace
depends on the organization ID we need to F it so here we'll say workspace obviously I think we need to also provide the DB reference just make sure yeah so we have to provide the DB reference as well and then collection name after this we need to provide the we Clause inside this we Clause we'll pass the organization ID so here we say our ID is equal to equal to and then we need to get the organization ID along with the users email so here we'll say Or ID is equal to use authentication and we'll
check first if organization ID is there then we pass the organization ID otherwise we'll pass the users email ID okay because we are setting organization ID uh this fill for the both the prime email address and organization ID as well now once we have this query here we'll say constant um query snapshot is equal to Await get docs okay because we are ping multiple documents and then pass the query here we'll make this as a sync and simply we'll say query snapshot. for each where we have the uh document and here we'll say console.log document.
data now we'll call inside the use effect so let's define the use over here so we need to Define when the organization ID is there and if the user information is there and here we'll Simply add user and and get workspace list and save it now let's go back to our application and let me go to this dashboard page and inside the inspect panel because we are just consoling for now and if you see on line 26 we got this three uh workspace perfect now let's uh save this in one state so we already defined
this state in this state we want to Define it sorry save it so here we Say set workspace list which is equal to previous information then spread operator because we are appending with the existing one right because this is a for each Loop and here we'll say Doc do data so each of these document data we are just pushing to this uh State and save it now this workspace list we are going to pass workspace list is equal to workspace list to this workspace list component now let's go to this workspace List component here I
will get it as a workpace list and over here let's save it now before that I think we are good for now but if you see now that particular new uh add new workspace uh default um component is not showing anymore because we have the workspace list now perfect now inside this item list we'll just iterate this workplace list do map we say item comma index and the arrow function here I will add a class name We'll make a grid grid column uh two on the smaller screen on large screen we'll make grid column three
sorry medium screen grid column 3 and large we make grid column 4 and save it now first thing uh if I go to this inspect panel console I need this information so first let's let's display the workspace name and just make sure it's working so I will Define a du inside D like Define h2 tag and here we'll say Uh item dot or here we can write workspace okay that is more meaningful dot uh workspace name let's save it and let's say whether on the screen we are getting that workspace name or not so if
you see we don't get that one so we'll copy this one and simply paste it here make sure the workspace list is rendered only when we have the workspace List information so here um make sure the arrow function um brackets is correct so This need to be a circular brackets let's save it and let's try it now now if you see we have this three uh work space name perfect now before that let's show the image The Source here we are going to show a workpace cover and here let add question mark then we'll provide
the width let's say 400 the height let's say 200 and Al tag I will say cover and save It wow so something is not right so this need to be I think cover image also I'll provide the key as a index save it let's go back to our application and if you see now it's showing this uh images okay it's weird but yeah we'll fix this one now uh to this image We'll add a class name We'll add width of 200 not width let's add height of 170 pixel then we'll add a uh object to
be cover and uh we'll add the Rounded top okay so here we'll say rounded top to Excel and save it perfect okay uh I think this is the height I will little bit decrease it let's make it 150 and this is pretty good now below that one I'm going to show the name so along with the Emoji definitely so here we'll say Emoji so workspace do Emoji I we add a class name and we'll give a flex gap of Two Perfect also uh let's wrap this text inside one de and here I will add a
class name we add a padding of four and we'll add a rounded bottom so let's add rounded bottom to be Excel and save it so if you see we have this workspace name perfect that's look pretty good uh next um for this deal let's add a class name here I'm going to add a border then we'll add a shadow Excel let's see how it Looks so we have the beautiful shadow also we'll make a rounded Excel and for this grid I'm going to add a gap of let's say six okay and now we have this
workspace ready uh also uh let's give some margin top to six so we have some space between this one perfect we have this four ready okay and obviously on this depends on the screen size right it will change the layout say cool right uh if you think Let me check on mobile view how it looks I think that's pretty good right on mobile view this is how it will look like great uh next let's go back to our application and over here I'm putting the how effect so uh on Hover we'll just kill it to
let's say 105 and we'll make Transition all for a smooth animation so if I H on this one you you will see the change perfect also uh we'll make Cursor pointer whenever I H on this any of the item now when user click on this workspace uh let's say in this case project ideas workspace we should navigate to the workspace but currently if I try to go to this workspace and let's say this is our document okay uh and click enter then we are not able to uh get the page and it's showing 40 error
because in under this workspace and under this workspace ID we don't have the page. jsx now if I uh let me go To this workspace so inside this workspace folder you will see we have this uh workspace ID and then under the document ID we have the page. jsx right now let's do one thing in go to this workspace ID and simply create page. jsx file add the default template and I will just rename this to workspace and save it now if I go back to our application and now you will see the text workspace
is showing on the screen now another important thing here once we have this One right we can show the side navigation bar because we already have that component and in that component we are showing the document list right so let's Implement that one so go to this workspace and simply I'm going to add the side now like this okay and inside this side now we have to pass the parameter because it needs a parameter value so simply from this workpace I will get the parents first and then I'm going to pass over Here like this
and save it now if I go back to application and boom you will see this beautiful side navigation with all of this information now obviously this uh workpace ID is no longer uh available but if I go to the dashboard now and on the click of this one we should navigate it so let's Implement that one so let's go to this um dashboard under the components where we have this workspace item list now on the click of this one we want to add an uh Or we want to Route it so this is the actual
item okay so this is nothing but this particular item so let's add an onclick event and here we'll say on click on click item we'll say only will say on click workspace item and for this one I'm going to pass the workspace do ID because we have this workspace and from there we can get the ID now we'll create this method we a Constant on workspace item and here uh we'll get the workspace ID now simply uh we'll Define the router here because we are programmatically routing it from one screen to other and we'll add
the use router make sure to import it from this next SL navigation and here I will say router. push and here we say slash workspace slash and the workspace ID okay and save it perfect now if I go back to our application and if I click On this one now you will see it's redirected to this uh particular workspace and in that workspace now you will see this two document if I click any of these document boom you will see the details okay so that's how guys you can redirect it now uh if I go
to this workspace right and this empty space you can just Define here the or you can show some kind of message okay select this workspace or start creating a new document something like this it's up to You how you want to display okay if you don't want to show a blank page so give a try and let me know in the comment section if you face any issue and one more important thing that um you can try and send me the uh complete project link so I can review it on my YouTube channel as well
now here if I switch to uh the developer organization right and refresh it here you will see the workspace okay which I already have but We have to make sure when we call this get work list uh very initially I have to set the workpace workpace list as empty okay so if you see right now I'm getting this uh duplicate value right so we can also avoid that one too and even though if I switch to the personal account right now I'm getting the personal only so that's how guys you can just switch from one
workspace to other and even though if if I click on this you will see the uh document now One more important thing you can try on your own is the delete option here you can add an option and here from here you can add a delete document option the similar like which we implemented over here here if I click delete it will delete the document now it's time to add a two big feature to our application one is the comment and other is a notification we are going to add a real time comments to our
application and then whenever user Add any comment or tag to the any user inside the comment then user will also get notified with the help of this notification another important thing that each of the document has their own comment section so you can just add it your comments to the each of the documents now before adding comment to our application we have to make sure that we are saving the user information so so inside the uh database we we are need to create a new collection name Called users and inside this one we are going
to store all the users information whenever they log in so simply we can Implement that on uh on a dashboard page whenever user come to the dashboard right we have to make sure that that users information will be inside our database so let's go to this uh dashboard page and maybe you can add it on a heer component or maybe you can add in document list component it doesn't doesn't matter because anyway uh it is On the uh dashboard page right so I will go to this dashboard and here we have the components folder inside
that we have the header. jsx and let's Implement over here so here I will write constant save user data like this okay and inside this save user data we'll simply set a set document and inside this we need to provide a collection name uh so first we'll Define the reference and then we need to provide the Collection name so in this case we'll say uh loop users so Microsoft Loop users and then uh the document ID so you can generate one document ID so we'll say constant doc ID is equal to um we can generate
from the current time time and we'll make sure it is in the string format and then just provide that document ID okay also uh this need to be wrapped inside the document first like this and then you can add the uh field which you want To add so in this case let's say name of the user so I will keep um you need to get the users name over here constant user is equal to use user and then from this clerk who user hook we can get user do full name or let's add a full
name then outar so for outar I will add which is the user image so here we will say image URL and the last we can also add the email which is user dot uh primary email address dot email address okay and we Are using await so here we'll make this as async I will just wrap this in a TR cach block okay and let's format this document as well now this save user data we need to call it inside the use effect so whenever uh this particular header launch we can call inside this use effect
so here we'll say user whenever the user information is available then only call this save user data method okay here we say use to save user data As simple as that and save it and instead of this document ID I will just keep users email ID okay so or you can just even write it here that will be easy and this document ID will keep as a user ID so it will not insert a duplicate record okay let's save it and tast this out so over here if you see in the dashboard uh so obviously
is get refreshed but if I go back to the uh fire store you will see the new collection name name called Loop user we Have we have this document and inside that we have the information perfect that's what we want right so now it's time to implement the comment feature so for that one we are going to use the live blocks doio the live blocks provide a realtime collaboration to your application they have different different products the one which you are going to implement which is the comments it's a realtime comments and they have their
own UI it so you don't need to add Your um UI as well but if you want to add you can do that as well then the second is notification that also we are going to add it and then we have the realtime text editor also realtime API and many more now most important thing these live blocks is very easy to integrate and secondly uh is free to use as well the now let's go to this uh live block.io and if you don't have an account create a new account and then jump to this dashboard
you will land on This quick start guide here on the left hand side you will see all of this information along with the API key and the your usage as well okay now first thing that we are going to add the comments uh to our application so click on this comment section okay then you can select the framework so in this case we'll select the nextjs so click on it and after that you will see some of the step to follow in order order to add a comments so first thing let's copy this Command line
and then go to your project and simply install this so once you paste in inside the terminal it will install this uh live block uh for you then uh we have to initialize the live blocks. config.log doc config dots file will generate for for you make sure to say yes over here and then we'll wait to make sure that the file is get created and if you see this live blocks. config file is created okay Now this file is required in order to make some customized configuration or some other configuration related to the live blocks
next if you scroll down little bit now we have to create a new page or new file called room. TSX um so let's go back to our application and inside this root directory inside this app folder we'll create room. jsx obviously we are using JavaScript so we are using jsx and copy the all the content as it is and save it now here You you will see you have the production mode or D mode okay so you can select the either one so I will select this time uh D mode and make sure to remove
this uh type so we don't need it also here you will see the publisher key right so I will just cut it from here and we'll paste it or we keep it inside this EnV file or env. loal file here I will add next public uncore and here we'll say Li block primary key is equal to and paste This key now copy this environment variable save this file and and then here we can access it using process. env. environment key now over here you will see the room provider currently the default they provided as a
ID as my room okay but we'll come on this point in a moment now save this one and let's go back to our application and the first step is uh to add the live live block room to your page okay so wherever you Want to uh add this a comment section you can just add it like this you have to wrap it your component inside this room and you can use it so first thing let's create a component and so what I will do I will go to the routes inside this we have the workspace
and under this workspace components we'll create a comment box. jsx file add the default template now this will this will be our uh comment uh component where we will keep the uh Command code okay so if you see this particular line of code we'll keep it in that one so I will just copy this use threads now inside this use thread it it's a hooks only okay live block hook but it actually help us uh to get all the commments okay uh next we have to copy this line of code and simply paste it here
okay so whatever the threads I means whatever the comments we are we are getting we will um render it through this thread component and this composer Help us to write the comment now uh make sure to import all of this one and this is the client component so mark it as a use client so I will just cut it from here and I will paste over here okay and save it now the thing is where we want to use it okay so this fourth step is so we are going to use it uh over here
on the right hand side where we are going to add a button and on the click of button we are going To pop up that um what we call comment box okay so let's go back so over here in workspace only where we have this document editor section now to this one let's add a du and for this do will'll add a button uh to this button we'll add a chart bubble icon I'm not sure not this one but let's add let's add message Circle and not show how it looks But let's add this one
and save it make sure that button is showing on the screen so let me refresh this once now if you see this button is showing on the on the bottom side now let's bring it on the right hand side so what we can do we can um make it as a fix so for this class we'll mark it as a fix then we'll make right uh let's WR to five and then we'll add a bottom to five okay and save it now even though you scroll the screen your button will be Constant at this position
now inside this one uh I'm going to add our what we can call it as a let me go back to a documentation and this collaborative app means inside the room we have to wrap it right now obviously we also want to add the notification uh component again it will be inside the room component only okay so better we can wrap uh the room not wrap but we can wrap our page. jsx Which is document ID inside that room so simply I'm going to to use room over here okay like this if you see and
I will wrap inside this particular page okay and simply now you can Define the comment box okay oh my bad uh comment box and save it now if I go back to our application um so here we saying the thread is not defined okay cannot read property thread so we have to make sure Inside the commment Box make it as optional for now and save it and now if you see we have this right comment and this obviously uh is very complicated but we'll fix this issue in a moment now what we need to do
on the click of this commment uh box button right on this button then only we want to open this command box so in order to do that we will Define one state we can call it as a open comment comma set open comment is equal to use State and initially I will make it as a false now whenever the comment box or open comment is true then only we want to show this commment box and when and on the button click we'll simply set the comment or we can say set open comment as opposite of
the open comment okay and let me bring this and save it now if I go back to our application if I click on this one okay so nothing is happening wow so so over here um make the J index Let's say 50 okay because we want the on the top of this one and now if I click it you'll see that U um option to write the comment right but it's little bit weird so let me go back to the comment box and here we'll define specific width and height so here inside this we'll say
a width let's say uh 300 pixel also we'll give height of uh 350 pixel and then we'll add a little bit Shadow large and we'll make rounded large okay also we make sure to add the Overflow ATO so that you can scroll in that one now if I click on this one you will see that uh comment section okay but it's the if you see this not perfectly style so if I go back to the documentation and scroll down little bit on the six point that you need to add import this particular style CSS so
copy this and then add it inside this layout. TSX file so inside the root layout let's go to this root layout file and simply paste it here and save it now if I go Back again to our application and click on this one now you will see a proper styling to your commment box okay now whenever we open this commment box we want to make sure this button has the cross symbol so to this document editor here we are showing this icon right here also I will add a condition open comment is if it's true
then we want to add a cross icon otherwise we will show this circle and save it now you'll see that Change now if I open it so we have to make sure to import this X from this Lucid icon this is icon actually the cross icon and if I click on it you'll see the X if you want to close it just close it like this okay and even though you scroll it your commment box will be constant at that location perfect now let's write some comments so here we'll say my first comment okay and
click Send now as Soon as send it you will see that you received the comment how cool right but currently it's showing the uh profile as with the placeholder and the username as a Anonymous okay but here you will have all the options also not only that but you can even reply to the thread as well now this comments is a a real time means uh on this particular document any user can see it okay now let me go back to our application and I let me switch it to the developer team where we have
The developers uh means organization document as well and I will open any of the document if you see we have a lot of things here and now click over here you will see that same comment as well the reason is because we have the room ID which is the my room so if I go to the uh let me go to this room. jsx file where we provide the ID as a my room and that's why everywhere is showing the that particular commment because it's checking with the room ID right room ID Is nothing but
some uh let's say you are we have 10 rooms and each room has their number of people so they can chitchat right but obviously whatever the chat chat you are doing in that first room that will not visible or not hearable to the second or not seeable to the second room so that's kind of thing it's there right now the question is how can we update it so if you scroll down and obviously if I go to this documentation where the seven point is to add user to The commments that also we need to check
that how can we add the user to the command here you will see how to add it and all of this information okay but uh along with that one uh if I go if I go to this authentication part right somewhere so if you see this authentication guide and inside here you will see how to authenticate and everything okay with the access token and all and uh for the room right you can Define or you can Write any room ID whatever you want okay now we are going to follow some standard in order to write
a room name I will just go back so I will not confuse you guys and I will keep on this particular uh document okay uh at this step and let me go back now to this room uh room provider right we are we need to provide some room ID so for that one let me go to this uh workspace document page. jsx where we Define this room right and to this room I'm going to pass this Parameter and simply we are going to uh we are going to add the workspace ID colon document ID okay
and this will be our complete document uh sorry the room ID okay so this is a combination that we are going to follow so to this room I'm going to pass a parameter so it will help us to get the workspace and document ID so go to this room and simply to this room provider I'm going to write Parms parm do workspace workspace ID then the colon plus params dot document ID like this okay so this will be our complete uh room ID now obviously uh you can also keep the document ID only uh it's
up to you how you want to do it or let's let's try only with a document ID because that will be the unique only and then save it okay now once you are uh defined this Document ID right now every time whenever uh you write a comment that will only applicable to that particular document let's save it and test this out so if I go back to our application so it's saying parameter is not defined obviously here we need to accept that as a params because uh from the page we pass this uh parameter and
here we'll accept it so let's go back to our application so we have to error it's saying failed to get document because Client is offline Let me refresh it now we are good now if I click on this particular uh uh icon now you'll see that previous comment is no longer here but now if I put new comment here and click Send it you will see the comment is get sent obviously it's an anonomous but we can change it in a moment now if I go to this new document and try to open it here
you will see that particular commment is no no longer inside the document now that is only Available to this document where we left the comment see because this is the document ID which we pass it as a room ID and only to that particular document you will see the comments how cool right and as we are in uh in the organization mode right you can collaborate your comments with along with the documents in a real time okay now the next and important thing that we need to implement is the users profile and name so when
you when you send uh the Comments we have to make sure the username and comments need to be there now it's time to display the user and if you see this is the option called authenticate and add your user so as you know that currently it's showing Anonymous and then we need to show the users's name and the users uh profile pck and if I click on that one you will see that how to add user to your live block comments and if you see these are the users right where you'll get the Profile image
and name and the comments whatever the comment they added so if you scroll down uh these are the thing that we are going to implement it but before that they specifically mentioned that you need to authenticate your application the first step is to find an authentication guide for your framework and then we need to implement this particular feature so first thing let's click on this authentication guide for your framework okay and then Obviously uh you'll get to know how to add that one so simply click on on that you will jump on this authentication page
guys don't worry it's quite easy okay so we we are going that's why we are going step by step then um they mention two type of authentication method One is using access token and other using ID token and you can choose either one so access token is quite simple and flexible for the go permission so we'll select that one uh Below that one if you scroll down little bit uh this is the authentication and how to do it and everything they mention it but uh here you can select the framework which you want so in
this case is a nextjs so click on that one and this are some of the step now we need to follow so once you land on the this particular page where it written setup access token permission with a neck JS so first thing you need to install this dependency so copy that dependency and Just paste it here so it will get installed next you need to set up the Authentication Endo right inside our nextjs so we are on D environment so copy this uh complete path from this API to route. TS go back to your
application inside this root directory I'm going to create a new file and paste this so it will also create the folder for API live blocks or and then it will create a route. JS make sure it's a JS and click Enter now if you see it's created the folder along with the file and simply copy everything as it is and paste it here now here this is the uh secret key so I will just cut it from here and I will paste inside this env. loal now this environment key we want it only on the
server side so we don't need to put a nextore public we just put Li block uh secret key is equal to and paste this key and save it now we'll simply use over here we'll say Process. EnV and the key the we don't need a type I will remove it next thing here we need to get a user from the database so uh the current user okay so current user we will get it but uh we we're going to use it uh the uh clerk hook for that one so simply we'll update over here so
here we'll say inside this post we'll say constant um or here only we can add let me remove this constant First and here we'll say await current user and this current user we are importing from the nextjs uh make sure to update this to nextjs SL server and then you'll get the current user okay now here we need to uh prepare the session first okay this is very important so this is optional feed providing user info so I will remove this one and instead of this user ID we need to provide the email address so
the email address is primary user. primary Email address dot email address okay so this uh users current user email address we provided now uh live block I have give a complete control on what the what are the permission that you want to provide uh to the given uh room right so right now if you see these are some of the way that you can provide but if you want to provide the access to the all the rooms right you can just simply say session. allo and then here you need to provide The room ID okay
so let me go back for now and if you see I don't see any room ID over here but we'll get that room ID using constant room is equal to await request do Json okay and obviously we destructure it so we'll get the room information from here and then we'll say session. Alo and we'll need to pass a room ID and here we'll say session do full access okay so we are giving full access to That particular room and that's all now once we have the session information uh we'll authorize this one and then we'll
simply return the response but here we have to make sure that we'll get the uh room ID as well okay now there are many many of the times um you might not get a room ID okay and if you remember inside our room. jsx uh so I think we oh yeah we are passing this room ID as well okay but for now Let's keep as it is and save it next let's go back to our uh documentation and scroll down little bit now inside we have to set up the client side so inside this live
block provider we need to add this Au end point and then you need to replace this publisher API key so I will copy this one go back to your application and then simply replace your publisher API key so I will remove it from here and paste it with a new new API endpoint okay and save it now let's go back and I think we are good for now so this particular step is optional so it's not mandatory and I think we are good for now okay make sure your comments is still working so if I
go to this comment and if you see the comments part is still there but it's still showing Anonymous don't worry because we have to uh follow some more step now let's go back to the Document mentation and simply I will go back to the previous page which is the how to add user right now we implemented this authentication part right so you will you can just skip this particular part now and then scroll down now this is the very important thing which is a resolving users now in this particular section you need to implement this
resolve user uh function inside your Li provider okay and you can uh just return the users list depends on The user ID which they are going to send it it's quite easy first thing copy this resolve user function then this is your live block provider I will just paste it over here like this okay now let's see what are the user ID we are getting over here okay so and obviously this will return something so right now I will put it empty and then save it now if I go back to our application and open
the comments okay so here uh in the inspect panel you will See at line room uh 15 we are getting this particular ID which is obviously not belong to what we are uh we want right let's type something let's say new comment again and let's enter it and now you will see the users email because uh we updated our logic right and that's the reason uh now it's showing the actual user ID right now obviously if another user is try type something on this commment right you will get that user ID over here as well
now this is Nothing but is wring the array of the user ID which is uh commented on that particular document now your task is to get the all the user list from our Firebase Firebase to uh database uh with this user ID right so so if we have the three email ID inside this user ID we have to get details of that particular users information from the Firebase so simply inside this one we going to write the um method to get the Firebase uh sorry to Get the users detail from the Firebase so here I'm
going to write let me remove this one here we'll simply say constant query here inside that we call collection the DB reference then we'll say uh loop users make sure the uh collection name is correct so it's a loop users that's good then comma here we'll say where and then we'll get email now obviously here you can pass in operator Now in operator we'll find all the matching value okay and then you have to pass the array so here we'll say user IDs we'll pass this user ID as a array okay next we'll do the
uh query oh so let Define constant query snapshot is equal to get docs because it will return a multiple documents and then we have to pass a query reference as a que now uh we'll iterate this query snapshot using for each and uh oops for Each my bad I don't know why it's showing okay so here we need to add a weight so that's the reason it showing us to use a weight over here so we'll use now query snapshot. for each and inside this we'll Define a doc like this right now let's console this
document. data and let's see whether we are getting the user information or not okay so here I will save it and let's test that Out and once I open this one right you will see that we got the user detail okay because we have this uh comment which is posted by this particular user and that's why we got the name email and outar cool right perfect now we need to save this one state and then we need we need to return that one so I will Define the let let's Define constant uh users list oh
sorry user list is equal to empty and then we'll just push this user L user list. Push and doc. data okay so each of the document we push inside this user list and simply we'll return the user list and save it okay now let's go back to our application and now if you here see it's showing the users's email sorry user name along with the user P right make sure uh uh you will create a new room because uh if you try to use old one right it will still showing Anonymous but let's try that
one and anytime you Can go to the um live black dashboard okay let me go to this dashboard and here you can also see all the information if you go to this project let's say we are working on development and right you will see how many active user how many rooms are created how many connection has made and all of these details inside the room anytime if you think you want to delete something you can go over here and just delete that particular comments as well okay now Even different if different user is typing something
and he uh put the comment then he uh you can see his profile image and name as well okay perfect now before uh moving forward we also going to uh Implement one more feature inside this comments so let me go back to our application and it's quite easy because we already have everything now here uh we already implemented this resolving user and obviously you are able to see this uh Users uh image and name as well but if you scroll down little bit now we have to implement this resolving mention suggestion now if you put
at the rate you will get the suggestion from the L of the users how cool right let me I'll show you how to implement that one so first thing again inside this live block provider under this resolve user you need to add a new function called resolve mention suggestion copy this one go back to Application and inside this live Brock provider we already added this uh resolve user right now we'll add one more so simply We'll add this resolve M suggestion okay now text will include the whatever the user write some text that particular text
and room ID is nothing but the simple room ID okay and it will return the email ID so in order to implement that one too here is the logic okay uh so it will check if the text is there and then it will filter Out out the result and then it will just simply return the result okay so let's Implement that one so I will clean this out and I will just copy uh everything as it is and we'll paste it here okay only change I'm going to do over here that I will say is
not equal to because I want to fetch all the user right so it will check if email is not equal to null and then we are passing everything obviously We are getting the user list and uh once we have the user list we are going to use this particular condition if text and all right so let's add that one so after this we'll add if text then uh make sure this is uh this user list is late okay not a constant because we are going to update this user list and here we'll say user list
of user and user.name include text then uh you'll get the user list okay and the last part is uh you just need to Map that one okay so I will just copy this and I will return this the all the result directly okay make sure here is a user list okay and then um not user list actually okay let me here is a user list only and save it okay let's T this out so if I go back to application go to the chart and if I type let's say here I will type the add
the rate oh so if you see we got the error that is say cannot Read property of stream so let me go back and somewhere we are not so so we are not getting the uh the user list because it is showing but inside this document editor section if you remember we provide this J Index right if I remove this J index and then you are able to say but you are not able to click it because it's going um behind this particular um re text editor okay so another option to this one if I
go to This reach text editor here you can give some margin from the left so here we'll say uh margin left to let's say 20 oh sorry we need to give from the right let's say margin right to 20 and let's say now if you see it is clickable and now if I try to uh add this okay so some again still we have that error let me go back to the inspect panel and still we are not able to scroll this one so margin is also not working as expected so let's do one Thing
uh we'll add a du okay and we'll put inside the grid okay so here we'll put a grid here we say grid grid column uh four okay and out of four column we assign three column to this document editor okay so simply we'll say class name column span three and save it now let's test that out if I go back to the here and now I can able to add it and as soon as I put add the rate right you will see that I also added this new user okay from this another tab now
I'm able To get the suggestion and now once you put the suggestion hey how are you you some message over here and send it and boom if you see your profile image is showing not only that but you can even reply to the thread okay you have this beautiful um emoji icon as well and you can just reply to the thread as well now once um the user add the com to our uh a room right or we can call it as a inside the document com in box we are Going to send notification to
all other user so in order to send a notification we are going to use live blocks again so live block has one more feature called notifications now we pretty much set up the live block along with the user information and all of these things only thing that we need to integrate the notification so select the uh notification from the quick start guide then select the framework as a nextjs and simp simply uh you need to Install this uh live block npm command so we already have pretty much but I will just make sure that we
are not missing so I will just install it again and you don't need to initialize again because we already initialized this live block config file then we have to uh create notification provider but if you remember we already have the room created okay uh for the live block provider so if you go inside the room. JX so let me go over here so we Already have the room provider and the uh live block provider as well so you don't need to create again newly second uh you need to wrap your application obviously we already did
it so inside our uh workspace document page. jsx we already W our application and now inside this side navigation if I go to this our application you will see this notification Bell icon right that's where we are going to add the notification so simply in order to add The notification if I go over here you will see this line of code you need to add it so I will create a new component inside this workspace component and we can call it as a notification box. jsx and first let's add a default template and save it
now before adding this line of code we need to make sure to make it some placeholder in order to display the uh drop down right so obviously you can create your own R if I go to this Shad C Right that's where we have the popover so that this popover we can select it okay so if I click on this one this is popover will come out so I will use this popover and simply uh first we need to install this popover so copy this npm command and open a terminal I don't know why it's
not opening yeah and simply paste it here next we'll copy this import statement and inside This notification box I will paste it okay oh not here this is a import statement let's paste it here and then the sample code if you remember this is our pop over trigger right and obviously uh we want to add notification Bell icon so simply I will uh add a children here and I will render this children inside this pop over trigger and now I will use this notification box I got inside the side navigation where we have this Bell
icon Okay so over here okay so I will just import this notification box and inside this this I'm going to render the Bell okay and save it now what will happen when you click on this Bell icon Let me refresh the screen once and you will see the beautiful popover cool right now inside this popover content we are going to Simply paste this inbox notification list so let's go to this notification Box and simply inside this popover content I will paste okay now make sure to uh use this notification uh we have to use this
hook make sure to add that one and along with that we'll use this import statement okay and save it I think that's all we need to do and let's go back to our application also we already added this uh styling so you don't need to add we already have the users uh add User to notification that is already implemented so you don't need to again uh update it but if I go back to our application you are seeing this uh loading uh indicator right now if I go to the inspect panel uh let me bring
this at the right hand side and go to the console you will see that you are getting this Local Host authentication error that's because inside our API route so let's go to this API routes okay where we have Have this room now let's console this room whether we are getting this room information or not okay now obviously this is on the server side so you can uh check the console inside your terminal so if I go to this terminal where our app is running okay and now if I refresh the screen you will see the
room is no longer there okay I don't know why it's not displaying okay but if I search room see the room Is coming as a undefined okay now what is the solution for that one because this problem I face it when I I'm implementing this particular feature but in order to um remove this particular error we have one um solution and you will not find anywhere on the internet so go to the room. jsx where we have this authentication endpoint right right now to this authentication endpoint we are going to pass the room ID okay
so here inside parameter we'll pass the Room ID we'll say room we'll say room ID that uh room ID is equal to and then if you remember we have this format okay as our document ID as our room ID so we'll just simply add over here here okay so first let's bring it in the curly bra and because we are passing Dynamic value right and now we have the room ID now inside the route. JS file we need to accept that parameter so here I'm going to write Constant um here we'll say inside bracket search
params is equal to new URL and we'll say request do URL okay and uh then we'll get the we'll get the room ID so here we'll say room ID is equal to search params doget and inside that we need to pass the fill name which we pass which is this room ID okay now we'll get the room ID now if I print this room ID over here and save it let's observe the input okay so let me bring this down okay and if I go back to our application okay let me refresh this screen once
because I don't think so we pass the room ID yet but if I search it here and now you'll see the room ID okay so let's go go back and now this room ID we need to pass to this session like this okay and then Simply Save it now if you don't want to you can remove this uh room as well and now if you see we don't have any more error okay and just make sure that you are not getting that uh authentication error anymore inside the console okay now if I click on this
uh notification right now if you see we don't have any not ification okay but if I uh if I um refresh this and try to add some comment let's add a comment so here I will say add the rate game play how are You and send it okay and now if I go back to this section and if I open this one and boom if you see we have the uh user notif ification and it's saying game play mention you uh in this this this rul s up how are you right cool correct now only
thing that you can increase this uh size okay if you don't want because this is I think little complicated but you can even replace it here you have option uh to edit it as well but before that I am going to just Uh inside the command box let's give some width so or not command box inside the notification box we'll give some width and height for this popover so simply here inside the popover container I will add the class name as a width find and if I save this one now and go back to our
application here if I click on this notification you will see the notification as well cool correct perfect now if I add more you you will get it right but the problem is here let Me add some comment okay if I add just a simple commment let's say simple commment and send it right that time I will not get that notification see I'm not getting notification I'm getting notification only when someone is tagged to me right so if you want to add notification to each of the uh comment right you just need to add one hook
so here you need to Define one hook called constant update room Notification setting is equal to use update notification setting okay and this particular Hook is importing from the live block now inside the use effect so here I'm going to define the use effect and here we'll Define the value update notification settings and inside that we'll will provide the thread as all okay now here you have different option all none or replies and mention okay perfect now let's save it and let's Go back to our application and from other user I will just add some
comment okay let's add some comment okay and send it now over here if I click on this one see you got a new comment let's say let's add some comment cool right perfect so that's how guys you can send the notification and get the notification now uh if I go to the notification where we have the uh the inside the sorry live block Uh documentation they have the notification uh API as well so inside this uh ra API okay so you'll find it here and go to this notification here you have option to get the
notification and all of these thing right they also have their own API uh to do it also um in the live block node and go to the notification you will find the different different option now if I go to this uh live block block SL react API reference and go to this notification Right here you will find more information they defined some of the hooks regarding to notification now over here you can even count the uh number of not notification okay uh in order to display it on this particular notification um icon okay so for
example let's uh go over here and copy this and simply use it here make sure to import this uh hook and then you can just get the count so for example let's say we'll get The count okay whenever the count is ready now if I go back to our application go to the inspect panel and inside the console you will see the count okay which is two because we have the two notifications right perfect now we can show this count as well to this uh so let's let's cut it from here okay and we going
to go to this okay we already have the children over Here so let's let's do it here only because we have the notification Bell icon and here let's add a du inside de I will put this children which is the Bell icon and then I'm also going to add account okay and save it let's see whether it's displaying or not so near the notification ion see okay here uh I'm going to add a class name as a flex gap of one and for this one I'm going to add a class name padding of One rounded
full background primary text wipe see how weird it's looking right so obviously we'll uh change the size so here we'll say text of 3 pixel and I added some of the styling here okay some padding and some text size and now if you have see we have this beautiful notification where if I click on it you will see the notification okay perfect so guys that's how you can add the notification if you Have any question any doubt until this point let me know in the comment section also if you face any issue related to the
live block I will also keep the uh Discord link of the live uh block developers in the description now there is a one quick fix that I want to uh show you so over here if you add a table okay where we have this table option and when you write something let's say you want to write something okay but here you will see we CAU one Error and it's simply saying that function update do update doc call with invalid data nested array are not supported inside our Firebase fire store so right now the uh very
nested array means uh array inside array array inside array right this is not supported by Firebase so there is one solution for that one let's go back to our re document editor where we are have save document method now inside this save document method currently we are saving The output in the Json format now if I go back to our uh database and here you will see the document output and each of the document you will see we save it as as a Json right now here we can change this to convert this Json into
a string F so here we we'll just add json. stringify and we simply convert this Json into a string format now when we save this particular document it will save it as a string but when we are going to get that uh particular output And then that time we are going to convert this into the Json okay so inside this editor. render we'll just add Json do pass and whatever the data output we are getting we will convert that into the Json from the string okay and now let's save it now let's go back to
our application now if I add something let's say you want to add table okay and now if you see we can easily add the table information okay and we don't have any Error now if I refresh this one then you will see the table it gets Sav now we don't have that any more issue regarding the nested and now here you can add anything regardless of whether you a nested or not so on our document screen where we have the workspace here we are going to add the very important feature called generate the template from
AI so on the screen here we are going to add an option or button where uh we we going to Give an option to the user to add the template depends on his requirements so user will add his uh requirement in the input field and then once we have that one we'll add that and we will pass that particular uh requirement or prompt to the AI model obviously we are going to use uh free AI model to generate the response and then once we have the response in the Json format we will just simp simply
add it to the document so throughout this particular uh chapter we Going to learn step by step how can we generate the AI response how can we integrate the AI model to our application and for that one we are going to use the very popular Google AI model so it's a jinii AI model okay and most important thing is free to use so if you go to this ai. google.de and here you will find the AI uh model and how to use it okay it support very different different uh languages as well so just click
on this Learn more about the gini API and you will land on this bill with the jini API uh page where you will find all of the detail now talking about the pricing so jini 1.5 flash okay it's a free of chart if you see over here it's a free of chart you can make 15 request per minute I think that is more than enough and 1 million toer minute okay obviously it will update every time and most important thing it's a free of charge okay and you don't need to pay anything But if you
want to go with the higher model or pay as you go they also have that option and it's quite cheap okay now if you don't have an account create a new account so I will just sign in with a Google and then once you uh login you will find oh let's simply go to to the dashboard so here you will see try it now in studio and you will land on their own Studio so over here you have option to get the API key so once you click on that one you will find the option
to generate the API key now I already have one so we'll use this one but before that let's learn how to create or generate the uh model first okay so it's quite easy it's like a u uh if you use the chat DP right you enter some prompt and you'll get the output same thing that we are going to use it over here but before that uh in order to get the Prompt in a specific format because we want the format in the uh re for the re text editor right and if you go to
this editor JS right and go to this documentation here you will find if you go to the saving data right you will see this is the output data format that how we want right where we have the time block and version and this block is very important if you scroll down little bit here you will find the sample how it works right we have the some random ID The type the data and all of these things we have paragraph then we have list header and lot of other thing okay same format we required so in
order to do it what you need to do first uh just follow this step okay this is the simplest St that I'm going to tell you first I will copy this output format and I will go to this AI studio and here I will say reference to okay it's reference to and I will simply paste this Jon format then After that I will write generate template for editor. JS in Json for and here you can write any thing for for example let's say you want to generate the template for grocery too list document okay now
this is just a simple example I'm telling and then simply click run and boom if you see it's generating the all the format for us not only that but here we mention that we want in a Json format and that's why they give us Inside the Json format where we have the type paragraph different list and lot of other thing cool right perfect and that's all we need to do obviously if you want to add some more information you can add in this prompt okay but now what you need to do go to this right
top hand side and here you have option called get code click on it and here you will find some code now obviously we are using JavaScript click on JavaScript and this is the code that we need to add Into our application but before that we need to install the generated to a hdk and it's quite simple copy this npm command and then go to to your vs code I will close this tab and all of these things and inside here I don't know why it's not yeah I will just open new tab and paste it
here okay so it will install the Google generative Ai and then simply copy everything go back to our application and inside here if you remember we already have this config Folder we created right inside that I'm going to add a new file and here we'll say Google AI model okay dot jsx and then simply paste your code which you copied that's all now here obviously we are making some update I will remove this comment then next thing and very important that we need to add the API key okay so simply go to this.l file over
here I will add nextcore public here we'll say Jinii API key okay and now this key you will get it from this get API key model okay so let me okay we already have this code we don't need anything now but go to this get API key and simply copy this API key okay then go back to our application and paste it here now copy this jmin API key and simply I I will put it here as the environment variable name okay then if you scroll down little bit uh we don't want this function anymore
so I will Remove this function along with that I will remove this function call Okay then if you see this is the history this is the uh what we entered the prompt and this is the model output okay we are keeping this history because whenever we ask something right it will take a reference of this history and then it will give you the exact output okay then we don't want it here so I will command this out as well now one more important thing right now it will give you the Response in the text format
and we don't want that one so I will just replace this with the application SL Json so it will give us a Json format output and save it okay now you are 80% done only thing you need to do is to uh use this one okay now for that one let's go back to our uh routes under the workspace components where we have the reach document editor okay so inside uh inside here right we are going to uh create one button okay and this button Will help us to uh enter the user input okay so
here I will add a du okay so this du I will make it I will add a class name we'll make it fix at the bottom let's add a 10 and when the screen size is medium I will put a margin left to 80 okay I will put the left zero and will put the J index as well and inside here I will add a new component for the AI model not model but AI component to generate and add all the information so here inside This underscore component I will add generate from AI or we'll
say generate AI template AI template so here we'll say t with capital do jsx now add a default template okay and save it now this particular component will simply add it here okay and save now let's go back to our application to see that changes so over here you will see the test called General AI template now inside the generate AI template I'm going to add a Button from the shats here and here we simply say generate from AI or we'll say generate AI templates that will be more meaningful okay perfect and here if you
want to add a icon here you can add a icon so I will add layout grid and save it now if I go back this is how it looks you can just add some styling so first thing I will add a variant as outline then I will add a class name Oops as a flex gap of two and for this icon I will add a height of four width of four okay so it will matches like this see now we have beautiful option now on the click of this one we are going to open a
dialogue box and then on that one we are going to add an input field so let's go back to the uh shadan in order to add a dialogue as we already uh imported a dialogue so we don't need to import it again just I will use this import Statement over here okay and then we'll use the sample code over here okay now this is the actual trigger to open the dialogue okay but we want to open the dialogue on the click of this button so I will remove this dialogue trigger okay this is the different
way I'm doing and I'm going to add one state so here we'll say constant open comma set open is equal to use State now initially I will make it false now that this dialogue has one property Called open okay and to this open I'm going to pass this our open State now whenever I click this button so over here I will add on click method I will set oh I will set open as a true okay so when button is Click I will set the open as true and this dialogue will open now let's go
back and test this out so if I click on this generate AI template see how the dialogue is opening okay now to this dialogue we are going to add some Couple of things so first thing I will here write generate AI template inside here uh I will simply write some kind of label so here we'll say label and here we'll say what you want to write in document okay you can write any uh text and then after that I will simply add the input field from the Shaden component to this input field I'm going to
add a placeholder we'll add some Example let's say project idea or something like this okay uh I think that's all and then after this we'll add a two button one for Generate AI model which called the our AI model and another is to cancel the uh dialogue so first button cancel it now to this button I will add variant as a ghost okay and we'll add a second button we'll say Generate and we don't add any variant let's save this one and let's see how it looks see so if I click on this one this
is how it looks let's add some styling so first thing for this du I will add a class name we'll say margin top to five then we'll make it Flex We'll add gap of two we'll add justify to end We'll add Gap to let's say five okay and now if I go back so if you see now we have this Perfect thing okay um for this label I'm not sure but let's say let's add some margin top to five just I don't think because this is a label right so I don't think so label will
apply that one but if you change this to h2 tag it might help us to add that padding see perfect okay now here once user enter the input right and on the click of generate we are going to call that method so let's add couple of more things so first thing uh we need to add A state to accept the user input so here we'll say constant user input Comm set user input is equal to use State and uh we'll also add a loading State as well set loading is equal to use State and we'll
make it false initially okay and we'll call one method called generate from AI okay um also on the click of this cancel button so we'll add on click method We are going to set the open as a false okay and on the click of this generate button we are going to call the generate a not generate uh generate from AI um method okay which we already written over here now first thing whenever user click on this button right uh we have to first make sure that user has some input so here we'll make it disabled
if user did not enter anything or or loading is true okay and uh now over here we'll add set loading As a true because obviously we want to show that indicator then we are going to if I close this and go to this a model if you remember we added we commented this code right just cut it from here and paste it inside our generate from Air okay now what this method will do this method actually call the chart session okay which is inside this method see this chart session okay now in order to use
this chart session inside this or inside Throughout the application right or inside any component you have to make sure you will export this chart session okay so that you can use it over here so simply import this do control space and import this chart session from add at theate config Google AI model okay as we are using AIT make sure you'll make this as asynchronized and you have here you need to add a prompt okay what user wanted so what I Will do I get one constant here will say prompt is equal to and I
will add my own prompt so here we'll say generate template for or will say for editor editor. JS in Json for and the user input okay so whatever user enter for that input generate the editor. JS uh one more important thing if you go to this Google AI model and for the user right we here we write reference to then we paste all the D on format and if you Scroll to the right uh not all the right but over here um so yeah remove this particular line okay generate template for editor and blah blah
blah until this to-do list right because this is just EX for the example we wrote it so make sure to remove that one and now save it now over here because that's the that's the prompt that we are going to pass and then copy this prompt and just simply send into this send message okay perfect Now this response we'll get in the text format obviously we'll convert it into a Json but the response that AI is rning is in the Json only okay so right now if you see we click on this generate from Ai
and it will just consoling it on the console also when the loading is true means when we are fetching data right we set the loading as a uh true and once it's finished we'll set the loading as a false okay and here also uh we are going to set the open as a false means it Automatically uh cancel the dialogue as well also here I'm going to add one condition if loading is true I'm going to show loading indicator so loading icon I can show otherwise I will show The Taste call generate and for this
icon you can add the animate spin class from the telin CSS so it actually spin uh your icon now let's go back and let's test this out so I will open the Inspect panel just to make sure that we are getting some information oh one more important thing I just uh got it set for the input right we already defined this input state but we forgot to add the user input so for this input component we have to add onchange method this onch change method will emit the event and then we'll simply set the user
input as event dot um target. value okay so it will actually Get us whatever the user right and now save it now let's T this out if I go over here and click on generate a AI model here if I write something let's say project idea okay and make sure to open inspect panel so we can just observe the all the changes and then click generate now if you see we have this beautiful indicator showing okay it's generating from the AI so we'll wait and inside the console we will observe the response and boom if
you see We got the response okay obviously it's is a currently a string but here you will see this is the exact output that we wanted okay perfect now this output we need to put it or we need to render it inside our uh editor. JS uh re text editor right and it's quite easy because we already did it so let's go back now and over here first thing we need to convert this into a Json so here we'll say constant output is equal to json. pass and then we'll just simply pass This okay and
uh I think that's the what we wanted here I will add a try cach block just if you have any error so it will just catch over here okay and I will put this output inside this track and catch block here also I will put the set loading inside the catch and then once you define this output we'll say uh that uh set generate AI output and then we'll set this output Okay now this method we Define but we did not initialize this me we did not Define anywhere we just call this one right now
because we want to send this back to the parent component so here I will just send back to the parent component through this uh params and inside the re document editor where we use this generate AI template here I'm going to call this okay and here we'll say output and simply we need to render to Our document and if you remember we have already have this method over here right editor do render and then we'll simply need to render the output now our output is already into the Json format okay if you remember because here
uh before sending to the parent component we already R uh converted from string to the Json okay we already pass that one so you don't need to pass it again perfect now let's try this so here I will say generate AI model and here you Can add anything let's say you want to add uh grocery too list okay and click generate and boom within a minute it generate the document for us how cool right it added some dummy data as well let's try something else so here we if you want to add uh let's say
uh project progress tracking okay and simply click generate now this is this kind of uh a temporary is quite helpful when you want to uh you are working with the team collaboration and something like that Right and boom if you see we have the project XYZ progress tracking where you can add the planning phase word one 2 3 and lot of other thing okay now not only that one but you can even uh add some more extra things right let's create a new document so here I will add a new document and once you add
the document here I will say uh my resume okay you can even build the resume as well now simply uh I will generate the AI template here I will just add uh Generate um full stack resume for 3 years experience and uh expert in react development okay okay and then simply click generate now it will also give you the format of your resume okay so we'll wait and boom if you see we have the beautiful format with the name obviously you can change whatever you want you have experience information Here you can update on your
own the skill education and so much right how cool so guys there are lot of thing that you can do with this so guys if you have any question any doubt until this point let me know in the comment section this generate AI template is one of the key feature of this application along with the uh chart and the notification okay how cool so guys if you have any question as I told you comment in the comment section if you really like this Video press like button and don't forget to subscribe to my channel now
we are on the final stage of the course where we are going to deploy our application on a cloud so that your friends and family can also see your application so so that you can also share with them and if you see on the screen I added this beautiful landing page quite simple and easy nothing else on this particular screen where uh we have this get started button and it will Redirect me to the dashboard okay if it's not log in obviously it will redirect me to the signin page as well also one more important
thing if you go back to our application and then go to the uh middleware DJs and then make sure you will also add one more endpoint here or matching route called workspace okay so that it also uh restricted from the other user to access it now uh once you are on this page let me go to this local 3,000 okay and let's deploy this Application so first thing you need to do is to create the GitHub account and then we are going to push it to the GitHub and then finally we are going to deploy
it on overself so if you don't know about the veral so veral is a free platform where you can deploy your nextjs application and also nextjs is developed by versal okay this is the kind of uh interesting thing so uh if you don't have an account with the veral so Just create that one as well but firstly uh let's go to the github.com or you can go to the gitlab or bitbucket and then create a new repo here I'm going to add the repo name so here we'll say Microsoft uh loop CL okay or we
can say Microsoft Loop 2.0 then you can select the uh repo public or private it's up to you and then simply create repo once you create the rep repository you need to uh add this remot origin to your uh application Okay so just paste this command over here so it will sa the origin uh then you just need to add this all the change change file so I will just add get add dot then I will commit these changes so you need to write some commit message here we say initial commit and simply click or
I think you are pushing first time then push with this push origin main okay so here I will add G push origin main perfect and if you see all our code are now pushed now if I refresh This particular repo you'll see all the changes all the files are here and just now we push it right perfect now next thing go to the worel and once you log in you will find the dashboard here you will see I already uploaded a lot of or deploy a lot of projects uh here click on this add new
and we have the option called project inside the project make sure to connect your repo so in this case I connected with the GitHub but you also have the option like Gitlab or bit bucket as well once you connected you will see your project name because we just now pushed so it's saying just now and simply click import once you click import you can give whatever the name you want uh I will just make Microsoft loop I will make it just Loop okay then it automatically detect the framework next uh don't touch to this one
because it already depends on the which framework you are using it Automatically set the build and output setting but most important we need to add the environment variable now if I go to this env. loal file right this file did not push to the bit bucket or sorry GitHub so just copy all this environment variable and then simply paste it here do crl c crl v and boom you will see all the environment variable automatically get added along with the name and the value okay and now simply click deploy now it will say take some
time First it will check the deployment then it will build the build log then it will actually start your deployment and and if there is any error it will notify us so we'll make that change and then once we again push it and that's all so one more important thing with the connecting with the GitHub and veral so whenever you make some changes to our application and push it to the GitHub it automatically trigger the deployment with the latest changes so you don't Need to manually deploy it again except the first time first time you
need to deploy it with the all the configuration like environment variable and all and then next time it's just push the push to the GitHub and that's all and boom if you see our application is now live it's ready and this is the domain for our application now if I open this particular domain on the new tab here you will see this beautiful landing page On the click of this get started I already log into this application so I'm able to authenticate directly to this application and everything is working as expected cool right perfect so
guys that's how you can deploy your application uh on veral if you have any question uh related to the deployment let me know in the comment boxs so that's all for this particular course guys I hope you really enjoy this uh complete Tutorial uh if you have any question you can definitely reach out to me and uh if you did not subscribe to my Channel please do subscribe uh press like button and press notification Bell icon so you will not miss any update from me so guys see you in the next video keep coding keep
smiling