Overview
This tutorial guides you through building a full-stack Learning Management System (LMS) using MongoDB, Express, React, and Node.js (MERN stack). The platform enables educators to upload course content and students to browse, purchase, and watch courses online.
Key Features
- User Authentication: Implemented using Clerk, providing seamless sign-in, sign-up, and user profile management with ready-to-use React UI components.
- Course Management: Educators can create courses, add chapters and lectures with video URLs, and set pricing and discounts.
- Course Browsing & Search: Students can view course lists, filtering by keywords with a responsive search interface.
- Course Enrollment & Payment: Integration with Stripe for secure online payments, including a test mode for easy development.
- Course Player: Students watch course videos with features like free previews, marking lectures as complete, and progress tracking.
- Dashboard: Separate dashboards for educators (course stats, earnings, student enrollments) and students (enrolled courses, progress).
- Rating System: Users rate courses with interactive star ratings that update dynamically.
Technical Highlights
Frontend
- Uses React with routing handled by React Router.
- Styling with Tailwind CSS and Google Fonts for a modern UI.
- Rich text editor for course descriptions implemented with Quill.js.
- State management and context API maintain app-wide state and helper functions.
- Authentication state and user data are synced with Clerk.
Backend
- Express server with RESTful API endpoints for courses, users, enrollments, and educator functions.
- MongoDB schemas/models for users, courses (including nested chapters and lectures), purchases, and progress.
- File uploads (course thumbnails) handled with multer, stored on Cloudinary.
- User role management enables users to become educators with specific API routes protected by middleware.
- Stripe payment integration creates checkout sessions; webhooks validate payment success and update purchase status.
Deployment
- Backend and frontend deployed separately on Vercel with environment variables securely managed.
- GitHub used for version control and continuous deployment integration.
Getting Started
- Initialize Frontend: Create React app, install dependencies (React Router, Quill, Star Rating, Tailwind, Axios, React Toastify). See Maîtrisez React : JSX, ReactDOM et création de composants for foundational React concepts.
- Setup Backend: Create Express app with necessary packages (Mongoose, Cloudinary, Stripe, Clerk middleware).
- Implement Authentication: Integrate Clerk for user signin/signout and restrict routes.
- Create Models: Define MongoDB schemas for users, courses, lectures, purchases, and progress.
- Build APIs: Develop controller functions and routes for course management, user data, enrollment, progress, and payments.
- Handle Payments: Configure Stripe API keys, implement checkout sessions, and webhook handlers. For deeper insights, refer to Build and Deploy a Responsive GPT-3 Landing Page with React.js which covers payment integrations.
- Connect Frontend with Backend: Use Axios calls in context API to fetch and update data.
- Deploy: Push code to GitHub, connect repositories with Vercel for frontend and backend deployment. Get deployment best practices from Build a Modern Frontend Developer Portfolio Using Next.js, Tailwind CSS, and Sentry.
User Flow
- Students browse courses, use the search box, and view detailed course pages.
- Users register/sign in via Clerk; profile pictures and user states update dynamically.
- Upon purchasing courses, payment sessions are handled via Stripe, with webhooks confirming payment and updating database.
- Students watch courses, mark lessons complete, and submit course ratings.
- Educators manage courses via dashboards, publishing new courses, viewing enrollments, and earnings.
Conclusion
This tutorial delivers a practical, complete LMS solution leveraging popular modern technologies, focusing on user authentication, secure payments, course management, and smooth user experience. The project is finely tuned with responsive design and robust backend architecture.
Additional Resources
- React Beginner Tutorials (recommended before starting)
- Clerk Documentation for Authentication
- Stripe API & Webhooks Guide
- Tailwind CSS Setup Guide
- MongoDB Atlas for Database Hosting
Feel free to explore, customize, and extend the LMS project for your needs.
hello and welcome to another exciting tutorial of great stack in this tutorial we are going to learn how to create a
full stack learning management system using mongodb Express react and nodejs this is a LMS website where Educators
can upload the courses and students can enroll and watch the courses online in this project we will create the user
login and registration feature using Clerk clerk is a user authentication and user management platform it also
provides beautiful and ready to use UI components like sign in sign up and profile component for react application
we will also add the stripe payment gway in this LMS project so that students can buy the courses online so let's start by
taking a quick look at the project demo that we will be building in this tutorial so this is the homepage of our
lmsb we site where you can see the navigation bar then title and search box then we have the trusted companies logo
then we have some course card after that we have the testimonials and one call to action section then we have this
footer now if I open this course so here you can see this is the course description page where you can see the
course title description and average rating number of our students enrolled in this course then we have the
instructor name and then we have the course structure and we can display the course chapter and lectures title then
we have the free preview option also after that you can see here we have the detailed description of this course and
in the right side we have this card where you can see the course image then we have the offer price actual price and
discount then we have some other data of this course and enroll Now button now if I come back and click on this one
if I click on this button so it will open this course list page where you can see all the courses available on this
LMS website and here we can search for any course by adding any keyword so let me add the keyword JavaScript and click
on this search button now you can see the course related to this search term and here we have the option to remove
this search filter we will click on this cross icon so again we can see all courses now to enroll into any course we
have to create an account on this one so here we have the create account button if I click here it will open a signin
component that is built using Clerk and if you are new on this website you can use this link sign up to create an
account and I already have the account so I'll click on this sign in and sign in using my Google account after sign in
you will find your profile picture here and after that you will see the my enrollments and here you will see the
option to become educator and once you are educator you will see this option educated dashboard so now if I click on
this my enrollments so it will open a list of courses where you have enrolled and if I click on this button it will
open the course player page where you can watch the courses right and you can also rate this course and to play this
course here we have this watch link if if I click here it will start playing the video in right side like this let me
just come back and we will open this course click on this button and here we have this chapters if I click on this
watch button so you can see this course will play in the right side and here we have the chapter number and lecture
number then we have the lecture title and we can also Mark this lesson as completed by using this Mark complete
link now if I go to educator dashboard so here we have the dashboard for educator where educator can see the
status like number of enrollments then total courses and total earning after that here we have this add
course page from where educator can add any new course so here we have the option to add the course title like this
then we can add the course description here after that that here you can enter the course price then you can add the
discount and here we have the option to add the chapters so in the courses we will add the chapters and in each
chapter we can add multiple lectures so let's click on this add chapter button so here we have to add the chapter name
so just add chapter one click on okay so now in this chapter we can add the lectures so just add this lecture here
we will add the lecture title then total duration of this lecture then we have to provide the URL that is the video URL of
this lecture right and if I check this checkbox then it will be available for free preview and after adding all the
detail just click on the add button so this lecture will be added and finally you have to click on this add button so
it will publish your course after that you can see the published courses here in my courses section so in this my
courses you can see I have published one course right and this is the course price and
this is the publish date and here we have the number of students enrolled in this course after that you can go to
this section where you can see the number of enrolled students and the student name right so this is the
educator dashboard now let's try to purchase any course so I'll select this course and click on this enroll Now
button so it will open this a stripe payment Gateway and here we have to add any email ID and click on this card and
here we have to add the card details so right now we are in The Taste mode of this stripe so here we can use the test
card number so the test card number is this one and here we have to add any future date then add any 3digit number
and here we have to add the name then click on pay button so now you can see we have successfully enrolled in this
course also that is cloud computing Essentials and now we can start watching this course so this was the overview of
our LMS project after we finished building this LMS project using marus tag we will deploy it on versal before
we dive into the code if you are completely new to react I highly recommend watching my react beginners
tutorial first it is available for free on my YouTube channel and I will include the link in the description below now
let's get started now we will start creating our LMS project so right now I'm on my desktop
screen and here we will create a folder with the name LMS which is learning management system
now we will open this folder in vs code and our LMS folder is open in this vs code now we will open the terminal so
we'll click here select new terminal so in this terminal you can see we are at this directory LMS so here we have to
create a react project to create the react project we will use wheat package so let's write
npm create we at latest now press enter here we will press y for
yes now it is asking for for the project name so in this project we will create the front end and back end so for the
front end we will write the project name client then press enter after that we will select the
framework react then select JavaScript now our basic react project
has been created next we have to move to this CL client folder so in this terminal we will write CD
client so in the left side bar you can see we have the client folder and in this one we have these files right now
you can see in this terminal we are at the client folder so here we have to install the dependencies
so let's write npm install so it will install all the depend dep is required for the DC
project after executing this command you will see a new folder in the left side that is nodecore
modules in this folder it will install the dependencies after installing it we can
run our project to run the project we will write npm run Dev we have added npm run Dev press
enter so it will run our project so our project is running at this URL Local Host Port
5173 now we will open this link in web browser so this is our basic whe plus react project it is successfully running
in the web browser next we have to clear this project so just come
back and in the left side word you can see here we have this index.html file and in this
one we have this title so in this title we will add our own title so here I'm going to add our website name that is ID
me this is the project name then we will add our channel name great a stack after that we will open this SRC folder
and in this SRC folder you can see we have app. CSS just delete this one then we have this
app.jsx so we will clear all the code from this file and here we will use RF C snip it so it will create this component
structure if this RFC e snippet is not coming for you then you need to install one extension so here in this extensions
you need to search es7 react Redux just install this extension then you can use the RFC
snippet to create the component structure after that here we have this index. CSS file so we will open this and
here we will clear all the codes in this index. CSS next we have to insert the assets
that we will be using on this website so let me just come back to the desktop screen and here we have one folder
called assets and in this one I have all the images and icons that we are going to use on this website so let me just
copy all the images and icons and here we have one assets. JS file file also just copy everything and come back to
the project folder then go to client then go to SRC and in this one you will find this assets folder so in this one
we have to paste all the images and icons so let's paste it here after that in this one you will
find one file called favicon SVG so just copy this favicon . SVG file and come back to the project folder and here you
will find this public folder so in this public folder paste this favicon do SVG file and we can delete this we.
SVG now just come back to the vs code and in the left side you can see we have the assets and in this assets we
have all the images and icons and one assets. JS file and here in this public folder we have this favicon do SVG so we
are going to use this favicon do SVG as a favicon icon for our website so here we will open this index.html file and in
this one you will find this link tag where you will find re icon and here we have this hdf v.svg so
instead of this wheat. SVG we will write favicon do SVG save the changes and come back to
the web page now you can see the icon in this browser tab so it has been updated so we
have added our own favicon icon and you can see the title also it me cre a stack correct now let's come back and here we
have two add some other packages also so to install other packages we have to come to this terminal and first we have
to stop this project for that let's write contrl C press y now we will install some packages so
just write npm install and write the package name so first we will install the react router
Dom using that we can add the routing on our react project after that we will add the
another package that is react YouTube using this react YouTube package we will add the YouTube videos on our
website after that we will add the another package that is unique ID using this unique ID
package we will generate the unique hexad decimal ID for our courses after that we will add the quill package using
this quill package we will generate the rich text for our course description and after that we will add the next package
that is humanized duration so this package will help us to convert the video
duration in hours minutes and seconds so next we will install the RC progress package so this RC progress package will
help us to design a progress bar or circular progress next we will install one more
package that is react simple star rating so the simple react rating package will help us
to display a star ratings for our courses so we have added npm install react router Dom react YouTube then
unique ID quill humaniz duration RC progress react Simple Start rating now press enter so it will install all these
packages after that in the left side bar you will find this package.json file just open
it and in this one you can see we have dependencies and in this dependencies you will find all the packages that we
have installed so we have all the packages right after that we can start our
project to start our project again we will use npm run Dev press [Music]
enter so it will again start the project and if I come back to the web page refresh it so it is
working next we have to add the support of telin CSS in our project so let's open a new tab and search
for V tnd and open this
website and here we have the steps to install telin CSS in our we plus react project so the first step is to create
react project that we have already created then we have the Second Step so we have to use these commands so just
copy this one and come back here and let me again stop this project using contrl
C then paste the command now just come back to the documentation again and copy the second
command and paste it here now let's see the next step so the next step is to configure the tnd config
JS file so just copy everything from here and come back to the vs code and after that in the left side you will
find this telvent config.js file so here we have this file and in this one we will replace these contents so just
remove everything and paste the code that we have just copied that's it after that again come back here and here you
can see the next step we have to add these lines in the index. CSS file so just copy this and come back here and
open SRC index. CSS and paste it like this after that just come back
here and you can see the next step is to start our project that's it so we have configured the telin CSS to start the
project again write this npm run Dev now we can use the tent classes in our react project next we have to add
the Google font on our website to add the Google font let's search for Google
font open this website fonts. goole.com and in this one we have this search box so in this
one we will search for Google font that is outfit select this one now just click on
this get font and here you will see this button get embed code just click here and here we have
this import button we'll click here and just copy this import statement and come back to the vs
code and here before these three lines we will pay the import statement like this after that we have to add the font
family for the entire web page so here we will add a start and font family and we will provide font name
that is outfit so now we have the support of Google font on our complete react
application next we have to create create the folder structure for our project so let me just hide this
terminal and in this left sideb bar we will create the folder structure so in this SRC let's create a folder called
components and in this components folder we will create the components for the educator and also for the students so in
this one we will create another folder called educator and in this components folder
let's create another folder called students so we have the components folder then we have educator and
students now in this SRC let's create another folder called pages so in this Pages folder we have to
create the pages so in this Pages folder again we will create two other folders for
educator and students so create a new folder in this pages and write the folder
name a students or let me write a student and in this Pages let's add
another folder with the name educator and here also I will update the name it will
be a student like this now in this SRC we have to add one more folder that is
context in this context folder we will create the context file of our application where we will store the
state and functions that we will use in the entire application so now let's create the files in all
these folders so first let's open this a student folder in this components so we will create the components for a student
so here we will create a new file in the a student folder and write the file name never.
jsx here we will use ra Ace and let's write the text never we will add it in H1 tag like
this now let's create another file and it will be hero. jsx for hero
component again write RF C snippit and here we will add the title hero now let's add another
component that will be call to action do jsx let's create another component that is
companies here we will add our a fce and write the text companies now let's create a new
component course card do jsx let's add one more
component course section so let me write courses section do
jsx after that we will add the another component in this student that is loading
now let's add next component that is [Music]
rating now we will add the next component that is search bar after that we will add the next
component that is testimonial sections now let's add next component that is
footer do jsx so we have created these components for a student section now we will create
the components for educator so in this educator folder we will create a new file and write the file name nvar we
will display different nvard for educator so we are adding the component nard
dot jsx here we will add the text edu that is Educator
never now in this educator folder we will create a new file and it will be sidebar here we will add the
text sideward and in this educated we will create one more file that is another component called
footer so for the educator we will add different footer here we will add the text a do
footer so we have created the components for educator and students now we have this pages so we will create the pages
so in this one let's create the pages for a student so in this a student we will create a new file and write the
file name home. jsx here we will add the
text homepage now let's add another file that will be course Details page so we will add
course details. jsx now let's write new page so we will
add courses [Music] list after that let's create a new page
that is my enrollments now let's write what more page that
is player where a students can watch the courses so we will add player.
jsx so we have created the pages for a student now we will create the pages for educator so educator will have the add
course page dashboard then educator page then my courses page where educator can see their courses and there will be one
more page called a student enrolled where educator can see who has enrolled to their courses so in this educated
folder let's create a new file and write the file name add course do jsx
add codes now let's create a new file that is dashboard educator dashboard now we will
create a new page that is Educator now we will create a new page called my
courses and we will create one more page that is students enrolled so we have created all pages
and components for our project next we have to create a context file where we will store the common
Logics and we will store the state and functions so in this context folder we will create a new file called add
contact add app context.
jsx in this app context. jsx file we have to create the context so first we have to use the create context hook so
let's write import create context from
react after that using this create context we will create the app context so let's add
const app context equal to create context now we have to export this app
context so just add export like this after that we have to add the app context provider so here we will add
export const app context provider and create this function
so we have created app context provider function and in this one we will get the props
and here we have to return one component so just add return
and we are going to return this app context dot provider component like this and in this one we have to use
this props do children like this next we have to provide
the value in this component so here we will add the value and in this value we have to
provide one object so first let's define one object here so just write con value is equal
to empty object and we will provide it here now whatever States or function we will declare in this value object that
will be passed in this app context. provider right next we have to provide this support of app context in the
complete application for that let's open this main. jsx file and in this one you can see here we
have this a strict mode so let me remove it and here we will use app context
provider like this and just use the same tag for this closing so we will add it
here so we have added opening Tag app context provider and here we have this app context provider closing tag and in
this one we have this app tag then we have this app context provider that is imported from this
context folder app context. jsx file like this now save the changes and now we have the support of app context on
our complete application next we have have to set up the routes so to set up the react router
first in this file we have to import the browser router so we will write import and in this one we will
add browser router from react router Dom correct and after that we have to wrap this one using the browser router so
here let's write browser router tag and close it
here like this so first we have the browser router tag then we have this app context
provider then we have the app component like this so we have wrapped the app context provider using browser router
tag now we have the support of react router in our project next we we have to set up the routes and router for that
let's open this app.jsx file and here in this
one we have this return div so in this div we are going to set up the routes so here let's
write routes tag just select it from suggestion so you can see routes tag has been imported from react router Dom
close this tag here like this now in this routes tag we have to use the route so just write
route select it from here so this route has been imported now just close this tag for
self closing now in this route we have to provide the path so we will add the path
of homepage that is slash so when we will hit this path we have to display the homepage so here we will add element
and in this one we have to provide the page component so here we will add curly bres and provide the home page component
so just add home and select it from here so you can see this home has been imported from Pages a student SL
home like this now now we have to close this tag correct now whenever we will open
this slash then it will open this homepage component if I come back to the web page here you can see the message
homepage that is coming from this page as you can see here we have the pages and in this Pages we have the
student and here we have this home and here you can see the message homepage so the same thing is coming on this website
so it is coming using the react router now again come back to the app.jsx file and we will create the route for other
pages so after that we have to create the route for course list page so just add route or let me just duplicate it
and here we will change the path it will be course list and in this element we will write
course list so you can see this course list has been imported from Pages a student and
course list after that duplicate this one and here we have to add the path for course page so here we will write
path name course and it will be a dynamic route so here we have to display
different courses so here we will add course SL colon ID and we will provide the dynamic ID and
based on this ID we will display different courses so here we have to display the course Details page so just
write course details you can see this course details
has been imported from Pages student now let's duplicate it and here we will add the another page
that is my enrollments and here we will provide
component called my enrollments so it has been
imported here you can see we have added course list component so we have to add one more route for this one course list
and here we have to provide the dynamic input so after this course list we have to provide SL colon
input so based on the different keywords we will display different courses so let me just collect it it will be
input and here also we will Mount the same course list component So based on this input keyword we will display the
filtered course list after that we have added this my enrollments and just duplicate it and
here we have to display the player where user can watch the course so let's write the path player
and this route will be dynamic so we have to display different courses So based on the ID we will display course
on this page so here we will add/ colon course ID and here we have to display the player
component select it from here so this player has been imported after this player we have to
import the loading component so here just duplicate it and let's
write loading SL colon path so so it is also a dynamic route and here we will add the
loading component after adding it let's check all the routes so just copy this path
and come back to the web page and here if I provide Local Host Port 5173
SL course list so you can see here we have the message course list page correct now if I change the route if I
add course and after that we have to add any ID so just come back and here we will write SL course SL in the ID we
will write 10 like this now you can see course Details page so this route is working
now let's check this my enrollments just copy this one paste it here so now you can see my enrollments page so this
route is also working now just copy this player and after that we have to provide the course ID so here we will write
player and write any ID like 10 so you can see player page so it will display the player page now just come back and
here we have this loading and after that we have to add the path so let's write loading and then we will add then we
will add any path so you can see the text loading so these routes are working next we have to add the route for
educators so here after this route we will create one more route and this will be route open and
Route closing tag like this and in this one we have to provide the
path and here let's add educator like this and in this one we have to provide
one element so we will add the element and we will add educator element so you can see this
educator has been imported from Pages educator folder and educator file now just close this tag like
this now in in this one we have to add the nested routes within this educator so here let's write within this opening
and closing route tag we will write another route tag and this will be self closing like this and here we have to
add the path and we will add the path called educator and here we will add the
element and in this element we have to provide the
dashboard so just add dashboard now just duplicate this one
and here we will add the path add course we can remove this Slash from here and here we will
write component that is ADD course and here we will write the path that is my courses and here we will add the
element my courses now just duplicate it and here we will write the path called a student
enrolled and here also so we will add the element that is a student
enrolled so you can see so you can see a student enrolled my courses add course dashboard all pages has been imported
correct now we will test these routes so first we have to use the path educated and after that we will add these path
name so just come back and here let's write SL educator so here you can see educator page and if
I again write SL educator so it is displaying blank page
so we have to display the Nate component here like dashboard so just come back and we will open this Pages educator and
go to educator. jss correct so in this one let's write one div and in this div we have to
provide the outlet so first we have to import the outlet so just write import outlet from react router Dom and
within this D we will write cly bres Outlet we have to use this Outlet tag
and close this tag here now save the changes and come back here now you can see it still it is
blank so we will just come back here and you can see here we have added these nested routes so from this one we will
remove this slash that's it after removing it if I come back here you can see we have the educator page and in
this one we have this dashboard now if I change this path if I write my
courses so here you can see educat page and in this one we have this my courses page if I come back and let's see the
other routes so here we have the add course and a student enrolled so just copy this
one and here we will write SL educator SL add course so here you can see educator page then we have the add
course so all these routes are perfectly working after setting up the route next we have to create the component and we
will Design the component so first we will start with the navigation bar so let's see our figma design file for the
navigation bar design as you can see in this figma design this is the navigation bar and in
this navigation bar we have the logo some links and one button so we will create this navigation bar for the
homepage and in other page let's go to course list page so in this page you can see the background color of this
navigation bar is white and all the contents are same as the homepage and this course Details page
but the background color is white that's it now if I go to other page like this one so this is for the educator
dashboard page where educator can add a new course so in this one you can see the navigation bar looks different so we
will create the different navigation bar for educators so let's start creating the
navigation bar for the homepage for a student so just come back and we will
open this component folder then go to a student then open navb bar. jsx so here we have added this text we
will remove this text from here and we have this div and in this one first we have to add the logo so we will add the
image tag and in this one we have to provide the logo so we will use the logo from assets so if I open this
Assets in in this one we have the assets. JS file and if I open this assets. JS in this one we have imported
all the images using this file path and import a statement and we have provided these
name for import and after that we have exported all the images in this assets object so we can
simply use this assets object and use any image like logo search icon any other image also using this assets
object and after that you can see we have added some other data so here we have the dummy educated data B that we
will display on our website this is an object after that we have this dummy testimonial data so it
is an aray and in this aray we have multiple object that represent individual testimonial data after that
we have the dummy dashboard data then we have this dummy a student enrolled data then we have dummy
courses so we are going to use these dummy data and we will display these data on our
website so right now we are going to use the logo from assets so simply add curly press say then write assets selected
from here so you can see this assets has been imported from assets folder assets file and from this one we will find the
image so from this assets object we will use the logo that's it after that we have to add the alt
property so in this one we will add logo and here we have to provide the classes so we will add the class name property
and we will provide the width and after that we will change the width for different screen size so just
add LG and width 32 after that we will add cursor pointer so in this navigation bar we
have added the image that is the logo after that we have to add different content in desktop view and mobile view
for that we will create two div this is the first div just duplicate it this is for the mobile view so in this one we
are going to add the content that will be displayed on laptop view or desktop view so here in this one we will add the
class name hidden so by default it will be hidden on mobile phones and here we'll add the
screen size medium and above screen so for this one we will add Flex so again it will be visual on medium and larger
screen after that we will add item Center then we will provide the Gap and here we will
add text color so the text color will be gray 500 in the St we have to add some links
so we will add two links so just add a div and within this div we will add two links so here we are going to use button
tag and in this one we will add the button text called become
educator and after that we will use this line and after that we are going to use the link tag so here let's write
link we we will use the link tag from react router Dom so you can
see this link has been imported from react router Dom package now in this
link we can add two property so first let me close this link tag and here we will add the two property and in this
one we will provide the path so simply add SL my
enrollments and here we will use this link and closing link tag like this so within
this link tag we have to add the link text so the link text will be my enrollments like
this so in this navigation bar we have added the logo then we have have added the div for desktop screen and this is
the another div for Mobile screen in this one we have added one div that contains two links we have used one
button tag and one link tag and after this link and button we have to display
one button that will be create account so here let's
add button tag and we will add the button text create account now in this button we will add
classes so just add the class name property and here we will provide the Tailwind classes so let's write
background blue 600 then text white padding X padding Y and rounded full so that the corners will be
round after that here we have the first div so in this one also we will add some classes so here I'm going to add the
class name and in this one we will provide Flex item Center justify between padding X and we will add different
padding X for different screen size then we have added the Border bottom then border color and padding
from y AIS after that we have to add the background color as you can see in the figma design we
have different background color in the navigation bar when we move to course list page and for other page we have
this background color in the navigation bar to do that here before this return a statement
we will add some space and here we will check so just add con is
course list page equal to location
dot path name dot includes so if the URL path name includes this text that is course list
it means we are on the course list page so this variable will be true so whenever it is true we have to add the
background color white and if it is false we have to add another background color so we are going to use the turn
operator so here we have this class name so we have to wrap all these classes in curly
bres to use the template literal here we will add the back tick so remove this single quat and replace it with
backtick and after that here we will use dollar sign curly bres and here we are going to use this
is course list page variable we will check if it is true then what will happen we have to display
the white color in the background so we will add background white and then we will add the colum and it means when it
is false then we will add another color so here we are going to use background
Canan 100/70 now save the changes and next we have to mount this Navar component on
app.jsx file so we will open this app.jsx and in this Navar component and this Navar component will be displayed
on all pages so we will mount it before this routes so before this routes here we will
Mount Navar so we will select this Navar from this components student nabar so you can
see this nabar has been imported from components student naar now this now just close this tag
and here we have this div so in this one also we will add some classes so here let's
provide text default mean height green and background white for entire application after adding it let's come
back and open our website so here you can see we have this navigation bar correct so right now we have added this
navigation bar here in this return in this D so this navigation bar will be displayed on all
the pages including educator dashboard so we have to provide different navigation bar for educator so
we have to hide this one and when we will on the educator page we will hide it so for that here we will
write cons is Educator route so when we are on the educator
route then we have to hide it so here we are using use match from from react router
Dom so here you can see use match has been imported from react router Dom and in this one we have to provide the
path this one so if the path matches SL educator slash anything else right so in that
case this is Educator will be true and whenever this e educated route is true then we have to hide this navigation bar
so here let's write curly presses and in this one we will write not of is Educator
route so whenever it is false then only we have to display the navigation bar so here we will write and operator and we
will move this Navar here that's it save the changes and still you will see the navigation bar on
the homepage so it is hidden it is hidden because we are on the educated path and
if I go to homepage here we have this navigation bar and if I go to any other page that includes the educator in the
URL so you can see when we go to/ educator SL add course then n then the na bar is hidden and if I remove this
path this navigation bar is visible on a student page so this is the home page for a student now we will Design This
navigation bar so just come back we will come back to the nav bar. jsx file and in this one you can see
here we have added the class name for this div and after that we have this div that includes one button and one link so
in this one also we will add the class name and here we will provide the tnd classes so here I'm going to provide
Flex item Center Gap five save the changes just come back to the web
page here we are getting some space in the right side this is because here we have added this another div right so in
this div we will add the class name and we will add medium and above a screen it will be
hidden so it will be hidden on medium and above screen size now you can see we have this navigation bar till this
point so this navigation bar for desktop view is looking nice now we will add the navigation bar for mobile view so just
come back and for now let me reduce the screen size so you can see if I reduce the screen size it is hidden on the
small screen so we have to add the navigation bar for smaller screen so just come back and here
this is for the smaller screen so here let me add one comment for phone screens and here in this
div let's write some classes so we will write Flex item Center Gap two then Gap five and text Gray
500 after that here also we will add two links so we will add the div and in this div
first we will add the button so we will copy this one only paste it here so in this button we have
added we come educated and then we have this link tag that is my enrollments right and after that here we will add
one button and in this button we will add one image so we will add the image
tag then we will use the cly addes assets dot user
icon and after adding it we will come back to the web page now you can see here we have this links become educator
my enrollments and then we have this user icon so instead of button we are displaying one user icon for the smaller
screens like this after that we have to add the Coler authentication on our web page and using
the Coler we will add the functionality in this create account button so that user can click on this button to create
an account and after creating the account we will display the users profile picture here and we will replace
these links according to the US users login estate if the user is logged in then we will display different links and
if the user is not logged in then we will display different links here for that first we have to create the account
on cler to create the user authentication in our project just click on the link given in the description
that will directly take you to this page that is color.com so this clerk is a user
authentication and user manage platform using clerk we can easily integrate the user signin sign up feature in our
website and we can manage the users profile so to integrate the clerk authentication first we have to create
an account on this website I'll click on this link sign in I already have an account so I'll
choose this Google signin then you will find this screen here you have to select create
application and in this one we will write our application name so let's write great a stack
LMS and here we will choose the email signup option and Google sign up option then click on the create application
button after that we have to choose this react and here we have the steps to
integrate the color authentication in our project so the first step is to create a react application using V and
after that you can see the next step so the next step is to install cler so here we have the command that we will execute
in the terminal so just copy this one and and come back to the vs code editor and we will open the
terminal first we have to stop the project using control C press Y and here we will paste this command that will
install the color package after executing this command if I come back to the side word and
open package.json file so in this one you can see we have the dependencies object and in this one we have this
Coler react so the Coler has been installed after that we have to do some setup so you can see the next step we
have to use this color API keys so just copy this key from here and we have to add it in our environment
variable so just come back and here in this client folder we will create a new file with the name
EnV where we will store all the environment variables so in this one we will paste this color publishable
key and we have to start our project so in this terminal we will write npm run Dev so it will start our
project after adding it just come back to the Color website again again and you can see the next step so
we have to import the color publishable key in main. TSX or jsx file so just copy this statement from
here import your publishable key just copy this one and come back to the vs code and we will open main. jsx file and
in this one here we will write this a statement that will import the
publishable key from environment variable right and here we have added it before this create
root correct next we have to add the color provider component for that first we have to import it so here let's write
import curly Braes color provider and we will import it
from single code at Coler SL Coler SL color react we can remove this line from here a strict mode is not
required so we have added this import statement color provider now we will wrap these components using the color
provider so after this browser router here we will write color provider like
this now let's move this app context within this color provider so now you can see first we have the browser router
in this browser router we have the color provider and closing it here then we have the app context provider then we
have the app in this color provider we have to provide our publishable key so we will add the publishable key and
provide this key from here so write this cly bres and provide publishable
key after that in this one we will add one more thing that is after sign out URL we have added this after sign out
URL and in this one we have to provide the path that is SL like this now we have the support of
color authentication in our project now we can simply use the color reusable component to create our login
or signup component so just come back to the navigation bar so in this student we
have this na. jsx so in this one we are going to use
the color component to create the login or sign up form so first we have to import it so here we will write the
import statement in this na. jsx file we will import use
Coler from Coler slash color Crea after that we will import user
button then we will import use user
from color react now we have to add the functionality on the button that will
open the login form for that here we will write const we will get the open sign
in from use cler we are going to use this open
signin when we click on the button so it will open a sign up form after that we have to get the user
from this use user so here let's add const user equal to use
user like this now you can see here we have added this
button create account right so on this button we have to add the onclick property so here we will write on click
and in this on click we will provide the add function and here we will use this open sign
in that's it save the changes and come back to the web page if I click on this create account
button it is opening this login form you can see sign in to Great stack LMS so we can sign in using this Google account or
we can use the email address and if you are new on this website you can create an account using this link we will click
on this one sign up so it will open this sign up form where we can sign up using the Google account or we can use the
email ID and password to create an account but before creating any account we'll just come back to the vs
code and here you can see we have added this button so this is the create account button so whenever we will sign
in or sign up then we have to hide this button and instead of this button we will display the users profile icon for
that here we will wrap this one in a curly Braes and here in this curly bres we
will use this user it means whenever the user is available if the user is already signed up in that case we will display a
user button component so just add user button select this
one and we will add colon so whenever the user is available it means the user has already signed up then we will
display this user button and else we will display this create account button like
this so this is the user button from Coler if I scroll up you can see we have already imported this user button from
cler act right after adding this just come back to the web page and click on this create account button then click on
sign up and I will use this continue with Google option I'll choose this email
ID then click on continue now you can see we are successfully logged in on this website
and here we have the profile icon and instead of this create button we are displaying the profile
icon and if I click on this one here we have the option to manage the account and we have the option to sign out from
this website if I click on this manage account it will open this window where
we can update the profile and we can add another email ID and if I click on this link we can
update the profile image we can click on this button to upload any
image now let's close it we will replace these links according to the user estate if the user is logged
in then we will display different links and if the user is not logged in then we will display different links so just
come back and here you can see we have added become educator and my enrollments
so let's wrap it inside a curly bres like this in this curly bres we have added
this button and this link correct and here we will use user then we will write and operator
then we will use this fragment and close it here after this closing link tag so you
can see whenever the user is logged in then only it will display this become educator and my enrollments
link and if the user is not logged in then we will hide it right so after adding it if I come
back to the web page here we have the option to become educator and go to my enrollments and if I log
out here we have this create account button only because first we have to create account then only we can go to my
enrollments or we can become a educator and if I click on this one it will open this sign in or sign up form
now let's add the same thing for the smaller screen so just come back to the vs code
and here we have this code for phone screen so in this one also you can see we have
this link called my enrollments and this become educator so we will copy the same thing
just copy this Curly bres from here and and we will paste it here within this
div and in this div we have missed the classes so just add the class name
property and here we have to provide Flex item Center Gap then gap for different screen then we'll add the
text extra small and here we are using user if the user is logged in then only will display
this become educator and my enrollments and after that here we have to display
the user icon so if the user is logged out then only we will display this user icon and if the user is already logged
in then we will display the user's profile image from cler so here let's write the curly bres and here we will
write a user and if the user is available then what will happen we have to provide the user
button like this and colon and if the user is not available then we will provide this
button now it is clear now save the changes and come back to the web page so if I change the screen size so
here you can see we have this user icon in a smaller screen and if I click here so it should open the login form so
just come back and here in this button we have to add the onclick property so just
add on click and in this one we will add the Aro
function and in this addo function we will call op signin function that's it now again come back and click on this
user icon so it is opening this signin form and let me sign in using the Google account so now after sign in you can see
we have these links become educator my enrollments and then we have the profile image so now we have completed the
navigation bar for our website after creating this navigation bar let's come back to the figma
design and on this homepage you can see we have to create this section where we will display the welcome message a small
text and one search bar for that let's come back to the vs code editor here we will open this
sidebar and in this one we will go to components a student and open hero. jsx file
now in this one we have to add the welcome text that will be displayed on the hero section so you can see in this
figma design we have this text then a small description and one search bar so just come
back and here let me remove this text
and here we will write H1 tag and we will add the text this
one Empower your future with the courses designed to fit your choice after that we have to
add this text in a span tag so here we will add the as span and uh close it here at this point
and after this asan tag we have to add one image so we will add the image tag and in this SRC we will add the curly
presses select this assets then write dot sketch and here we will add the alt
property a sketch after that we have to add some classes so just add the class name and
in this one we will medium block then hidden so it will be hidden
for small screen and for medium and above screen it will be block then we'll add absolute then bottom minus 7 and
right zero so we have added the position for this a sketch image after that we have
added the asan tag so in this asan tag we will add the classes so here let's write the class
name for this text we have to change the color so here we will use text blue 600 after that here we have the H1 tag
so in this one we will add the class name and here we have to add the classes so for medium and above screen
we will add text home heading large then text home heading small then relative font bold text Gray then maximum width 3
XEL and margin X Auto after that in this first div we will add the class name and here we will
provide the classes like Flex Flex column item Center justify Center then width full for medium screen
we will add the padding top and for smaller screen we will add padding top 20 then padding
X then padding x0 for different size a space y text Center then background gradient so we will add this color in
the background gradient color then we have added the title and in this title we have added the a sketch
image after that we have to add add the a small description so we will use the P tag and in this one we will add this
description text now in this one we will add the class name and here we will
write medium block and hidden so it will be hidden and for medium and above screen it will be displayed then we have
added text Gray and maximum width to XEL and margin X Auto after that we will add another text that will be displayed on
Mobile screen so here we will add this a small description text and here we will add
the class name in this class name we will write medium hidden so for medium and our screen it will be hidden then we
have added text color then maximum width and margin X auto save the changes and next we have to mount this hero. jsx on
the homepage so let's open sidebar and from here we will go to Pages student home.
jsx and in this one you can see we have added the text home so just remove it and here we will Mount our hero
component click here so you can see hero component has been imported from component folder a student folder then
hero close this tag after that here we have this div so in this div we will add some classes so
just add the class name and we will provide Flex Flex column item Center space y then text Center save the
changes and come back to the web page so here you can see we have this title text then small
description and here we have the sketch image so right now this text is looking very small so let me colnect it we will
come back to the vs code and let's come back to the hero. jsx
file in this one you can see we have used the custom class name home heading large and home heading a small right but
we have not declared these classes so let me just come back in the left side bar and we will open this telin
config.js and first we have to create our custom classes in this theme so here in this theme extend
object we have this extend object so in this one we will add font size where we will Define the custom font size so
let's add font size colum then add the the object in this
one we will Define multiple font size so first let's add course details heading a
small and here we will add the column then we will provide 26 pixel
comma 36 pixel now duplicate it and here we will add course details heading
large here we will add the value 36 pixel and 44
pixel we have to add a comma here so now we will duplicate this one and in this one we will add the font
size name that is home heading a small and here we'll add the font size 28 pixel and 34 Pixel duplicate
it here we will add home heading large we will add the font size 48 pixel and 56
pixel and we will add one more custom font size that is default and in this
one let's add 15 pixel and 21 pixel save the changes and come back to the web page now you can see this font
size is looking perfect for this screen correct and if I change the screen size
you can see on a smaller screen it is looking perfect and we have to remove the sketch image from a
smaller screen and then we have the a small description in a smaller screen and here we have the large
description now it is looking beautiful now just come back and we will
open this hero. jsx in this one you can see we have added edit this paragraph text after this paragraph text we have
to add one search bar so we will create a search bar in this search bar component so just open
search bar. jsx file and in this one we have added this text so remove this text and here we will add a form
tag like this now in this form tag we have to add one image and in this image we will
add assets dot search icon and in this alt property we will
add search icon and after that we have to add some classes so here we will add the class
name and in this one we will add width for the medium and above a screen we will add
MD width Auto and after that we will add width 10 for Mobile screen then we will add the
padding from x-axis after that we have to add the input field in this form so we will add
the input type will be text and in the one we will add the placeholder so in this placeholder we will add the text
called search for courses after that we have to add the class name property and in this one we
have to provide some classes like width it will be full height full then outline none text Gray 500/80
after that we have to add one button so we will add the button tag and in this button type we will write
submit then we will add the button text that is search then in this button we will add
the class name and in this one we will provide background blue rounded text white and padding X
then padding x 7 then we will add the padding y for different screen and margin
X1 after adding it here we have this form tag and before that we have this div so we will remove this div we will
simply return the form tag in this component now in this form tag also we will add one class name and let's write
maximum width that is Excel and after that we will add the width full and for different screen we will add
different height 14 and 12 then we will add the flex item center background white border border color and
rounded after adding it we have to use this form component in this home component so just
open this home. jsx and after this P tag we will Mount our search bar so here let's
add search bar so you can see this search bar has been imported and let's close this tag now
just come back and here you can see we have this search bar in this one we have the search icon and search button
correct now if I enter anything in this input field that is the search boox input
field and click on the button it should open the course list page and it should display the courses related to the
search keyword to create that functionality we will come back to the vs code and we will open search bar. jsx
file and in this file before this return statement we will write
const navigate equal to use navigate
hook so we are using this use navigate from react router Dom and now we can use this navigate
function to navigate the users on other page after that we have to add some State variable where we will store the
the input field data so here just add const and the state variable name is
input and the seter function name is set input equal to use a
state use state has been imported from react now here we will initialize this state variable so first we will add the
data and if the data is available then we will add data else we will initialize it with empty
string after that here we have to add form Handler function so let's add one function const
the function name is on search Handler equal to create this Aro
function here we will get the form event and here we will add e do prevent default so whenever we will submit this
form so it will prevent the website from reloading after that we have to navigate the users on
course list page so we will add navigate and in this one we have to provide the path so we will provide the path slash
course list and in this path we will add the input field data so we will add plus and
provide this input like this next we have to link this on submit Handler function with this form tag so we will
add on submit and provide this on submit Handler function in this form tag after
that we have to link this input field with this input state so here in this input
field we will add on change here we will add the arrow
function with this event in the parameter so we have created this Arrow function
and it will call this set input Setter function and here we will set the value using the event do Target dot
value after that we have to add the value property also so just add the value and here we will add input State
that's it so we have added the on change and provided this Setter functions set input so whenever we will add any data
in the input field that will be stored in this input State and when we submit the form then this input keyword will be
added in this path and user will be redirected to the course list page with this input text so just come
back and open the website here we have some issues so just check it we will open the console
tab here you can see we have some error in this search bar. GSX data is not defined right so just come
back and uh here in this search bar we have to get the data from parameter so just add data so if the data is
available in this parameter in this props then we will use this data here and if the data is not available then we
will use empty string to initialize this input State now save the changes and come back to the website again now you
can see we don't have any error and if I type anything in this input field like react and click on this search button so
now you can see we are redirected to this course list page and then we have the/ react so here we have this course
list page correct now on this course list page page we can display the courses
based on this keyword that is react now just come back to the homepage so we have created this
functionality for this search box after that if I open the figma design you can see we have to create
this section that is companies right so to create this just come back to the vs code open open this sidebar and from
here we will open this components a student and open this companies. jsx file right in
this one we have to remove this text so remove this title text and here we will use the text in P tag and here we
will add the text trusted by Learners from and after that we have to add one div
and in this div we will add multiple images so just add the image tag and here we have to add the image so simply
add assets dot then we will add the image name that is Microsoft logo and here we will add
the alt text Microsoft after that here we have to to add the class name so just add the class
name property and we will provide the width 20 and for medium and above a screen size we will add the width 28
that's it now we have to display multiple logo of companies so just duplicate this
line and replace the images so in the second one we will write Walmart logo then we will write
essential logo then we will add Adobe logo and after that we will write P
logo then we will update the alt text also so here we will provide different uh text in the alt property like this
after that here we have this div so in this div we will add some padding from top so we will add the class name and
provide padding top 16 then we have this text in P tag so here we will add the class name and in
this one we have to provide text base text Gray
500 then we have this div that includes all the images so here we will write class name and we will provide Flex Flex
WP item Center justify Center Gap six and for medium and above a screen we will add Gap 16 then for medium and
above screen we will add margin top and then we will add margin top five that's it after adding it we will
Mount this component on home. jsx so just open pages then a student then home. jsx
and in this one you can see we have added this hero component so after this hero component we have to
add company's component so you can see this company's component has been imported from component folder a student
folder and companies now just close this tag and save the changes now just come back to the web
page now you can see here we have all the company logo it looks nice after that if I come back to the
figma design you can see we have to create our next section that is the course section right so to create this
course section first we have to create a course card and in the course section we will display the four course card right
so to create this section we will come back to the vs code we will open
this course section component and in this one we have added added this title in H1 so just remove it and here we have
to add a title in h2 tag so let's write S2 and provide this text after that we have to add some
description in P tag so we will add the P tag and provide this small description right next we have to add
the course components that will be individual course card then we will display one button so here
we will add the space for course card then we will add the button so here we will add the link tag
we will use this link from react router Dom and just add this closing link tag and
we will add the link text that is so all course says and in this one we have to add the two property so just add
path that is/ course list so when we click on this link it will display all courses and it will red us to the course
list page and after that we have to scroll the web page to the top so here we will
add the on click property and in this one we will provide the arrow function and here we will add
a scroll to property and in this one just provide zero and zero so it will scroll the we
page to the top correct now in this one we have to add some classes also so here we will add the class name property and
in this one we will add text Gray 500 that will be the text color then border border color gr
500/30 then padding X padding Y and rounded so we have added the CSS properties for this button now we will
add the CSS properties for this title and description so in this title we have to add the text size so just add the
class name here and provide text 3 XEL font medium and text Gray 800 after that we will add the class name in this
description so here we will provide text a small so the default size will be text a small and then we'll add the medium
for medium and above a screen we have to add the text base then we will add the text color and
margin from the top now we will add the CSS properties in this div so in this div we will add
the class name and here we will provide the padding from y AIS then padding X8 and for medium and above screen size we
will add padding x40 like this save the changes and come back to the web page but before that we have to mount
this courses section so just open home. jsx file and after this companies we will
add courses section component so this courses section has been imported now if I open the homepage
here we have this title learn from the best then we have the description and then we have this button so all courses
and if I click on this button it will open this course list page and if I come back to the homepage here we have this
text so below this description we have to display the course list right so just come back
and we will come to this file that is course card. jsx right and in this one we will create
the course card to create this course card let me just come back to the figma design
again and in this design you can see we have four courses in this course section so in this first course you can
see we have the course thumbnail then we have the course title then educator name then we have the
ratings and price so we have to create this card so to create this one we need the course data
also so if I come back to the vs code and go to this assets and open assets. JS file so in this file you can see we
have already added the dummy course data so let me scroll up here here you can see we have one array with
the name dummy courses and in this one we have multiple object and each object is representing a single course so in
this course we have the course ID course title then we have course description after that we have the course
price then we have is published data then discount so we can also add discount on the course after that we
have the course content so this course content is also an aray and in this aray we have multiple object so for this
course content we have this chapter ID then chapter order chapter title and chapter content and in this chapter
content you can see we have added two lectures so we have the lecture ID and this is the second lecture of the first
chapter so in the first chapter we have added two lecture with the lecture ID lecture one and lecture
two right so right now we will focus on this one this dummy course data where we have the course price course title
course ID discount and if I scroll down here we we have this educator details then we have the enrolled
students and we have this course rating so in this first course I have added only one rating where user has given
five star right so we are going to use these data to create our course card now let me just come back to the course card
and here in this one we will get the course detail in this props so here just add
course so after adding it here we have added this title in H1 so I'm going to remove this one and in this one first we
need the course thumbnail so we are using the image tag and in this image SRC we will add
the image so just add curly say and we will get the image from this props that is
course Dot course thumbnail after that in this one we have
to add the course details like course title then educator name then we will display the ratings so here I'm going to
add a div and in this div we will add the course title in S3
tag and to get the course title we will use curly bres course Dot and the property name that is
course title I'm using this property name from this assets you can see in this asset file we have the course data
and here we have the course title right here you can see we have the course thumbnail
also now just come back here after this course title we will add the instructor name or educator name so we will add it
in the P tag so let me just copy this paste it here and here I'm going to add the property that is educator.
name so it will display the educator name after that we have to display the course rating where we will display the
average rating then we will display the start icons and then we will display total number of ratings so we are going
to group all these things in a div like this and in this div we have to display the average rating that we will display
in P tag suppose we have the average rating of 4.5 I'm adding it manually we will add
the dynamic value here after that we have to display the star ratings so here we will add a div
and in this div we will add the curly presses and here we will add one aray we will
add spread operator aray and provide five now on this one we will use the map
method and in this map method we will add the parameters and create create the arrow
function so in this parameter let's addcore comma I for the index and here we will return one image
tag so write IMG tag in this image tag we will add the key
property so in this key we will add the index I let me close this tag like this in this one we will add the SRC so
let's add SRC
CES I'll move this image tag within this bracket like this now in this SRC for now I'll add the
same icon so let's add assets dot star so it will add the a star icon
for five times after that we will add the alt property
and next we have to add the total number of ratings so we will add it here after this div so we will add a B tag and in
this one we have to add the total number of ratings so let me add any fixed value right now so I'll add
22 after this course rating we have to display the course price so after closing of this div here we will display
the course price in P tag so we have already added the course price in the assets file in the dummy data so we are
going to use that data so we will add CES then we will
use course dot course price but in the assets dummy data you will find we have
added the discount also so we are going to display the final price here after applying the discount so here we will
reduce the discount amount so we have added the discount like this one you can see we have this dummy data and uh in
this dummy data you can see we have this discount that is the 20 it means we have added 20% discount so we are going to
reduce that 20% value so we will add course dot
discount multiplied by course price divide by 100 so we will get the final
price and we are going to display the course price up to two decimal point so we will wrap this one in this
bracket and here we will add dot to fixed and provide the value
two like this and before this course we have to display the currency also so we will get the currency from involement
variable so that we can update the currency at one point and it will update the currency on entire application so to
get the currency from environment variable here we will open EnV
file and here we will declare a new envirment variable that is currency so we will declare it as
Vore currency equal to and here let's add dollar
sign now we will store this currency in a variable in our context file so you can see here
we have app context do jsx file so in this one we are going to declare a very table so in this provider
function let's add a space and here I'll add con currency equal
to import do meta do EnV and Dot we will provide the envirment with variable name that
is V currency now we have this currency variable here to access this currency
variable in entire application we have to pass it through this value object so in this value object we will just add
this currency now we will get this currency in our course card component so where it
is let me open it this one and here we have to get get the currency from our context
so here before this return statement let's
add const cly bres
currency and uh we will get it from Context file so we will use this use context hook so this use context has
been imported now in this one we have to provide our context that is app context so this app context has
been imported now we have this currency so we can use this currency here before this price so here let's add curly
Braes and provide this currency variable that's it save the changes so in this course card you
can see we have added the course thumbnail then course title educator name and then we have
added the rating and this rating is a fixed value this is not Dynamics so we will update
it later and right now here we are displaying the actual price of this course next we are going to display this
course card in the course section so this is the courses section do jsx file in this one we have added these title
description and this button so before this link that is a button we will display the four course card so
first we have to get all courses data from our asset file so again we will open this app context. jsx and in this
one we will get all courses data in a state variable so in this one here we will
create a state variable so just add
const and the variable name is all courses and we will add the setter function set all
courses equal to and we will initialize it with empty aray so we have added one empty aray for
this all courses now whenever we will run this application we have to store the course data from our assets file in
this all courses state for that we will create a function so here only we will create a function let me add the comment
first so we will add the comment pitch all courses and here let's add the function
const pitch all coures is it will be a synchronous function and we will create the Aro function now
in this one we have to store the data from our assets file in this estate so we will use this Setter
function and in this Setter function simply add dummy courses just click on this
suggestion so this dummy courses has been imported from this assets file right
so now we have added the course data in this all courses next we have to pass this all courses through this value
object like this so that we can access it in any other component now let's come back to the courses section and here we
have to get all courses that we have just created in the context file so before this return a
statement let's add const and we will provide this all
courses and we will get it from use context and provide the app
context correct now we have this all courses data that we will display here before this link so before this link we
will add a div and in this D we will add the cly addes and provide all courses and on
this one we will add the slice method here we will add 0a 4 so we will display only four courses so this will
be one array so we can use the map method so we will add the map and in this map we have to add one Aro
function so in this function parameter we will get individual course and we will get the index
number like this after that in this Aro function we will return the component that we have just created that is course
card component so here let's add opening Arrow course card so you can see this course card has
been imported and let's close this tag now in in this course card component we have to provide the
key so in this key we will provide index and uh after that in this one we have to provide the props so we will add
course and just provide course like this so in this course card component we have provided the course data as props
correct now after adding it if I come back to the website here we are not getting the
course data so let me just come back to the vs code and we will open the app context. jsx file so in this one
you can see we have created this function that will fetch the course data from the assets file but we have not
executed this function so we will execute this function using the use effect so before this value object here
we will add use effect and in this one we will create
one Arrow function and here we will add the dependency array that will be impt aray
and in this one simply call this pitch all courses function so now whenever we will run the application
then it will execute this function and this function will find the data from the assets file that is the dummy code
courses and it will store it in this all courses state after that we will display this data on the web page
so now if I come back here you can see we have the course thumbnail then we have the
course title then rating and this is the course price so we have total four course data here right so next we have
to apply the CSS properties for the course card so just come back and we will open course card. jsx file
so first in this one let's add the CSS properties for this div and here you can see we have added this div so instead of
this div we will use the link tag so that we can click on this one so we will use this link from react
router Dom so this link has been imported and you can see we have to change the is closing tag also so it
will be link now in this link tag we have to add the two
property so that when we click on this one it will open any other URL or path so here we have to provide the path it
will be/ course slash then we have to add the
course ID so we will add plus course doore ID so when we will click on this course
thumbnail or course card so it will open a new URL that will be course SL course ID that will be the individual course
page after that here we have to add the on click using that we will scroll the web
page to the top so in this on click we will add one add function and here we will
add scroll two and provide 0 comma 0 so it will scroll the web page to the top after that in this one we will add
some CSS properties so here let's add the class name let me move it in the new line so in this class name we will add
the CSS properties that is border then we'll add the Border color that is
gray then we'll add padding bottom overflow hidden and rounded large after that we have this image so for this
image let's add class name and here we will provide width full next we have this div so for this
div let's add the class name and in this one we have to provide the pad heading and text left after that we have the
course title in this S3 tag so for this course title we will add the class name and provide text base font semi bold now
for the course educator name we will add class name we will add the class name property and provide text Gray 500 so we
will change the text color after that we have the course ratings that is added in this div
so here let's add the class name and for this one we have to add Flex item Center and a space
X2 then we have this div where we have added the star icons so for this div we will add the class name and in this one
we will provide Flex that's it next we have the star
icons here in this image tag so in this one also we will add the classes so just add class name and for this one we have
to provide the width and height so we will add the width and height 3.5 correct next we have the text
in P tag so here let's add the class name and here we are displaying the the total number of rating or review so for
this one we will add the text color that is gray 500 correct next we are displaying the
course price in this P tag so here also we will add the class name and in this one we are going to add the classes text
base font semi bold then text Gray 800 after adding it if I come back to the
page here you can see we have changes in this course title then start ratings and reviews then we have the price it is
looking good now let's come back to the vs code and we will open this courses se. jsx file and in this one we have
added this div so in this one we will add some CSS properties so first We'll add the class name and for this one
we will add grid then we will add
grid call for so it will display four cards in one row after that we'll add the padding from
x-axis then we have to add different padding for different screen so we will add medium screen px0 then we'll add
medium screen margin y then margin Y and GAP four after adding it save the changes
and come back to the web page now you can see all cards are aligned in the same row correct this
text is looking very long so let me add the line break here so in this one here we will add br
now it is looking good but right now we have one issue if I open this web page in a smaller screen you can see this
card becomes very small right so we have to fix it we have to make it
responsive to make that we will add some custom classes so let's come back we will open this telin config.js file
so in this one you can see we have already added the custom CSS for the font size now we will add the custom
classes for grid template so here let's add a comma and we will add the grid template
columns let's add the object in this object let's add the property name that is auto so the
template name is Auto and here we will add the value for this Auto template so in this one we are going to add
repeat autoit min max 200 and one fraction so it will make the responsive layout where it will display number of
cards that will be Auto fit and it will be minimum of 200 pixel and maximum one fraction now we can use this custom
class name here so if I come back here in the courses section do jsx
file and instead of this GRE calls for we will add GRE calls Auto that's it save the changes and come
back to the web page now you can see it is looking same but if I reduce the screen size you can see this layout is
perfectly responsive now we have two cards in a row now we have one card for mobile view
and if I increase the size we have two cards and now we have three cards and if I make it full screen we have total four
cards in a row so this section is responsive and if I click here it will
open uh new path that is SLC course SLC course ID where we will display the individual course detail so let me just
come back here again and instead of coming back like this we have to add the click
functionality on this logo so that when we click on this logo it will take us to the homepage to do that just come
back and in this context file we have to create the navigate function F
so here after this currency let's add const navigate equal
to use navigate from react router Dom now we have to export it so that we can use it in other components so we
will provide it here in this value of object after that we will come back to the Navar file that is Navar do
jsx and here we have to get the navigate function so here let's add
con navigate equal to use
context and here we will add app context now let's use this navigate here
on this image so on this image tag we will add the on click and provide the arrow
function and here just provide this navigate and provide our path that is the
slash so whenever we will click on the logo it will take us to the homepage after that just come back
here and if I click on this card it will open another page and if I click on this logo it will take us to the home page so
it is working now instead of displaying this fixed value in all the course we have to
display the actual data from our dummy data that is provided in the asset file so to do that we have to create a
function that will calculate the course rating that is average rating for the course so to create that just come back
here in this app context here we have to create that
function so here let's add the comment we will add the comment function
to Cal calculate average rating of course now just create a function using const then function
name calculate rating it will be one Aro function and in this one we have to
provide the parameter so we will provide the course now from this course it will calculate the average rating so here
here we will check if this
course dot course rating dot
length is zero it means there is no rating or review on this course then simply we
will return zero it means the average setting of this course is
zero if the course rating length is not equal to zero then we will calculate the average rating so to calculate the
average rating first we have to declare the initial value so just add let total rating is
zero after that we will add the rating for each Dev viws for that we we will add course
dot course ratings dot for each so for each we will get rating and uh here we will use the addo
function and in this one we will return the total rating plus equal
to rating dot rating so it will add all the ratings of each Dev
viws suppose anyone has given five and other person has given four so it will give the output 4 + 5 that is nine now
we have to divide it with total number of rating so here we will
return total rating divide by course dot course rating do
length that's it so now we will get the aage rating of this particular course so now we have to provide this
function here in this value object like this so that we can access
it in any other component after adding it again we will come back here in this course card and in this course
card we have to get the function so here we are getting the currency from this app context so with that we will
get calculate rating function also right now scroll down and here instead of adding this value 4.5 here we will
provide curly bres provide this function calculate rating and here we have to provide the
course that's it so we will get the average rating of this course here in this P tag after that based on this
rating we have to display the start icons we have to display either five 4 4.5 3 3.5 like that
so here we are simply displaying a five star icons right so instead of displaying all the full star icons here
here we will add the tary operator so just remove it and here first we will add I less
than math. Flo and in this one we will provide this calculate rating
course now if the I is less than this one then what will happen we have to display the full start icon so just
add assets do start and if it is false then we will display assets Dot
a start blank like this save the changes and now just come
back here so here you can see we have total five rating and here we have total five stars in first and second one in
the next one we have zero stars and in the fourth one also we have the zero Stars right so this is the average
rating 5 and five and the average rating is 0 and0 now we will replace this value also that is the fixed number of reviews
so just come back and instead of adding this 22 here we will add CES course
dot course ratings. length save the change es now you can see in this one we have one rating in the second one also
we have the one rating and in other two cards we have zero ratings right so the average rating is five and here also we
have the average rating five and here we have Z and zero so now we have created the course card and then we have this
all courses button after completing this courses section if I come back here in this
navigation bar you can see here we have the the link called become educator so if anyone is already educator then we
have to display the educator dashboard instead of this become educator link for that just come
back and let's open this context file that is app context. jsx and in this one we will create one state variable so let
me just duplicate it and here we will add the name is Educator and then we'll add the
setter function set is Educator and we will initialize it with
Boolean data true so it means the user is already educator and if we make it false then the user is not signed up for
the educator after declaring this state variable we have to pass it through this
object so here just add comma and provide this is Educator and set function set is
Educator like this now we can use it in the navigation bar so just open nav bar.
jsx and here you can see we have this button called become educator right so in this
one here let's add erary operator so let me remove it and here we will add the C bres and here we will get the is
Educator seter functions so we have to get it from the app context so in this one with this navigate let's add is
Educator and after that here we are going to check is educated if it is true then what will
happen we have to display the text called educator dashboard and if it is false then we'll
display the text become educator like this and here we have to add the click functionality
also so that if I click here it will open the educator dashboard right so just add on click feature here and
provide the add function and here we will add the navigate in this navigate simply provide
the path that is/ educator like
this now just copy this one and paste it here for the mobile menu here also you can see we have this wecome educator
button so just replace this one after adding it just come back to the web page now you can see here we
have the educated dashboard instead of become educator here we have the educator dashboard and if I click here
it will open this Local Host SL educator and you can see the text educator page now just come back so after creating
this section now just come back here in this figma design and you can see next we have to create this testimonial
section correct to create that we will come back to the vs code we will open this testimonial
section. jsx file and from here let me remove this title and here we will add one text in S2 tag so we will add
the text testimonials after that we have to add the description in P tag so here we will
add the description and in this one we have added this BR tag to add a line break
and uh after adding it we have to mount this component on homepage so let me just go to homepage
home. jsx and in this one you can see we have already added this courses section right so after this
courses section let's add testimonial section and close this
tag now just come back to the web page here you can see we have this title testimonials and this description
so next we have to add the CSS properties for this one and we will display the testimonial data from our
asset so if I go to sidebar go to assets assets. JS file so in this one we have
this dummy a student enrolled and uh before that we have this dummy dashboard and here we have the dummy testimonial
so in this one we have this aray and in this aray we have have multiple object that have the name role image
rating and feedback text so we will display this in the testimonial section using this dummy testimonials data so
let me come back to the testimonials section. jsx file and first we will add the CSS
properties so first in this div we will add the class name and let's provide classes padding bottom padding X and for
medium and above a screen we will add padding x0 after that we will add the CSS properties for the main title so
just add the class name and provide the CSS properties text 3 XL font medium text Gray and 800 after that for this
small description we will provide the class name and here we will provide the text base
for medium and above a screen size then text Gray 500 and margin top after that we have to display the
testimonial data in a div so in this div we will display the testimonial data so just add the curly Braes and we will
use dummy testimonials so you can see dummy testimonials has been imported from Assets Now this is an array so we
will use the map method and on this map method we will add the arrow
function here we will add the parameter that is individual testimonial and index number so just add testimonial and index
and here we will return uh div now in this div first we have to add the key
property and in this key we will add index after that in this div we will add another
div and here we will add the image tag for the users image so let's add the IMG tag
and in this SRC we will provide testimonial dot
image and uh here we will add the alt property so in this alt property let's add
CES testimonial. name after that here we will add another div within this div we will add
the users name in H1 tag so here let's add the users name using this testimonial. name
and after that we will add the small text in P tag and here we will display the users's role so we will add
testimonial. rooll after closing of this div here we will create another div and in this one
we have to display the star rating so here let's add one da
in this one we will add the curly bres then we will add aray and we will add spread operator
array and we will add five here we will use map method and here let's add underscore
comma I we will add it in this parameter of an arrow
function in this Arrow function we will return the image tag and in this image we will add the
key property where we will add I after that we will add the image SRC
so here also we will add the same thing that we have added added in the course card so just add car bres and
provide this one I less than math. flow testimonial. rating assets star and assets star
blank and here we will add a star after that for this image we will add some classes so just add the class
name and here we will add the height five after this start rating we have to
display the review text so just add the P tag and in this one we will add
the testimonial feedback like this and here also we will add the class name so in this one we will add
the text color gray 500 and margin top here you can see we have this div in this one we have added all the start
icons so here just add the class name and we will provide the the flex and we will provide Gap and in the parent div
we will add the class name and in this one we will add the padding and then padding from
bottom next we will add the CSS properties in this text where we have added the role so just add the class
name and we will add the text Gray 880 then we will add the CSS properties in the text where we have added the name
so just add the the class name and provide text large font medium and text Gray
800 after that here we have added the image tag so in this image also we will add some classes so just add the class
name and in this one we will provide the height and width then rounded full so it will be a
circle after that in this parent div we will add some CSS properties so here let's add the class
name we will provide the flex item Center Gap then padding X padding y background gray
510 now in this div where we have added the key property we will add some classes so let's add the class name and
in this one let's add text a small text left border border
gray 530 padding bottom rounded large then background white after that we have to
add the shadow so here we will add Shadow and in this one we will add the
custom value for the shadow so we will add 0 pixelcore 4 pixel
underscore 15 pixel underscore 0 pixel after that we'll add overflow
hidden here we have to add the shadow color also so here just add Shadow
black/ 5 now save the changes and come back to the web page
scroll down so here you can see we have these reviews in the testimonial section
right we have to add the CSS properties here to align it in same horizontal line so just come
back so in this div we will add the class name and we will provide grid then grd columns Auto that we have
already used in the courses section then we have added gap eight and margin top 14 save the changes
and come back here so now you can see it is looking good but we have some white space here and it is aligned in the
right side so let me just correct it and if I come back here in this design you can see we have to align it like
this to do that just come back here in this file we have added everything in this div so so we have to
move this part outside of this div so let me just cut it and we will paste it after
closing of this div like this now save the changes and come back
here now it is looking good right but the icons are not displayed that is the review icon so just come
back here we have added this assets. a star but we have not imported this assets so let me add assets click here
so now this assets has been imported from assets file now save the changes and come
back it should display the start icon now but it is not displaying let's come back
here we have closed this areay here so let me just remove it and we will close it here after
this five bracket like this update this one save the changes and come back here so now we have these start
icons and after this feedback text we have to display one link so just come back and uh here we have
this review description then we have this closing div tag and after that here let's add one a tag
and we will add the hashtag here and in this one we will display the link text that is read
mode like this now here we will add some CSS properties so we will add the class name and in this one we have to add the
text blue 500 underline and padding X save the changes and come back here so now we have completed this testimonial
section also after completing it we will come back to the figma design and scroll down so here
you can see we have to create this call to ation section to create that we will come
back and from this left side word we will open this call to a. jsx
file and in this one here we have this text just remove it and instead of this one we will add the H1
text and here we will add this title learn anything anytime anywhere after that we have to add a small
description in P tag so we will add the P text and write this a small description after that we have to
display two buttons so we will add one div and in this div we will create two
buttons so so let's add one button tag and in this one we will add the button text get
started after that we'll add one more button so just duplicate it and in this one we'll add the button text learn
Moree but with this second button we will add the icon also so after this learn mode we will add the image
tag and in this image we will add the SRC that is asset dot Arrow icon after that in this alt
property we will add Arrow icon after adding it we will come back
here in the home do jsx file we have to mount this component so we will open home. jsx and after this testimonials we
will add call to X and close this one so this call to
action has been imported after adding it just come back here so at the bottom you can see this a
small title description and this get started and learn more text so we have to add the CSS properties for this one
so just come back and we will open
this call to action. jsx file and here we add some CSS properties for the first div so in this first one we'll add the
class name and here we have to provide Flex Flex column item Center Gap four padding top padding bottom padding X and
for medium and above a screen We'll add padding x z after that for this title that is in the H1 tag we will add the
class name so for this one we'll add the text Excel and for medium and above screen we will add the text for XEL
after that we have to change the text color and font weight next we'll add the CSS properties for this description that
is with the P tag here we will add text colored and then for the smaller screen we will add text
small after that we have to align these buttons so for this parent we will add the class name and here just add
Flex item Center font medium Gap six and margin top next we will add the CSS properties
for the buttons so in the first button we will add the class name and here we will provide padding X then padding y
then rounded medium text white then background blue 600 now for the second button just
add class name and here we will add the flex item Center Gap two that's it after adding it save the changes and come back
to the web page now you can see this call to action section is looking good and if I come
back to figma design you can see it is exactly same correct so after creating it next we have to create the footer of
our application so in the footer you can see we have to add the background color then we'll add three columns and in the
first one we'll add the logo and a small description then in the next one we'll add some menu items then in the last one
we'll add this text and this email subscription form and at the bottom we will add this copyright message so to
create this footer we will come back to vs code and from this left side bar we will
open footer. jsx file in this footer. jsx file let me remove this text and here we have this div so let me convert
it in footer tag and here we have this closing footer tag now in this one we have to create a
div where we will create three columns and after this D we will add the copyright text so here we will use the P
tag to add the copyright message so here I'm going to add the copyright message copyright 2025 at greatest tag
all right reserved and within this div we have to create three columns so let's create the div for the First
Column so in this div we will create First Column let me duplicate it so we have total three div tag now in the
first one we have to add One logo so here we will add the IMG tag and to add the logo we will add gly
bres assets assets is not coming in the recommendation so let me open this and after that we will come back to
the footer and if I write assets so we are getting these suggestions so this assets has been
imported after that here we will add the name of the image file that is logo dark then we will add the alt tag so in
the alt we will add the text logo after that below this logo we have to add one small description so I'm going to add
this description here so this is the content for the First Column so let's save the changes and we
will add the CSS properties for this footer so in this footer we will add the class name and and for this footer we
have to add the background color so we will add background gray 900 then we will add the
padding X text left and width full and margin top now here we have this div where we
are adding different columns so for this div we will add some CSS properties so in this one I'm going to add
Flex then Flex column for medium and above a screen we'll add Flex row then we have added items to
start padding X justify Center Gap 10 then Gap 32 for medium and above screen then we have padding y border bottom and
Border color white sl30 that's it now here we have this div for the First Column right where we have
added the image and text so in the first one we will add class
name Flex Flex column and for medium and above a screen we will add items a start then items Center and width full that's
it save the changes now we have to mount this component on homepage so we will open home. jsx
file and after this call to action let's add add footer select it so this footer has been
imported now close this tag save the changes and come back to the web page and now you will see this footer on this
web page so you can see here we have this logo image and we have this text in black color then we have this copyright
message also correct now let's come back and uh we will come to footer. jsx file so here you can see we have this text in
P tag so in this text also we will add the class name so here we will add the margin from Top then text Center then
for medium and above a screen We'll add text left text size will be a small and text color is white
sl80 now save the changes and now you can see this text clearly because it is in the white color
correct after that we have to change the color of this copyright message also so just come back and in this P tag we will
add the class name and here we will add some padding from y AIS after that we will add text Center then text size will
be extra small and for medium and above screen We'll add the text size a small and the text color is white/
60 now if I come back you can see this copyright text is also looking good and it is in the
center correct now we will come back and we'll add the content in other columns so here we have the div for the second
column and the second column will contain the list of menu items right so here in this div we will add one text in
S2 tag so the text is company after that we will add the UL tag and in this UL we will add the LI
tag and in this lii we will add the a tag and here we will add the hdf hashtag and here we have to add the link text
that is home now we will duplicate it and we will update the link text so the second one will be about us then in
the next one we will write contact us and then we will add privacy policy let me remove the extra Li
tag correct after adding it if I come back here you can see we have these content in the right
side it is in the black color so we have to change the color correct so just come back and here we will add the CSS
properties for this div so for this one we will add the class name and in this one also we will add
Flex Flex column and for medium and above we will add items to start then item Center width
full now for this title that is in the S2 tag we will add the class name and we have to add
the font weight that is semi bold then text will be white and margin bottom after that in this UL tag we will add
the CSS properties so in this UL we will add the class name and provide Flex for medium and above the screen we'll add
Flex column then width full justify between text will be small then text will be white then for the medium and
above screen we will add a space Y2 after adding it save the changes and come back to the web page now you can
see this second column is looking good with this title and these link text correct now we will add
the content for the third column and the third column will be hidden in a smaller screen it means it
will be hidden on Mobile screen and it will be visible on medium and above screen size so just come back and here
we have this div for the third column so here in this div we will add the class name and here we will add hidden
so by default it will be hidden then we'll add medium flex so on the medium and above a screen it will be
displayed with display property Flex after that we'll add Flex column items to start and width will be full now in
this one we have to add one title in h2 tag so in this title we will add the text called subscribe to our newsletter
and here we will add the class name so in this one we have to add the font weight semi bold then text white and
margin bottom after this text let's add the description in P tag so here we will add
this description and with this we will add the class name also for this P tag so in this one we have to add the text
size that will be small and then text color white 80 correct if I come back here so you
can can see this title and a small description in the third column after that we have to add one form where user
can enter the email ID and there will be one button called subscribe so just come back and after
this description that is in the P tag here we will add one div and in this div we will add the input field and the
input type will be email then we will add the placeholder and in this placeholder we
will add the text called enter your email like this after that we have to add one button also and in this button
we will add the button text subscribe like this if I come back here you can see here we have the input field
and here we have the Subscribe link now just come back and we will add the CSS properties so first we will add
the CSS for for this div so we'll add the class name and provide Flex item Center Gap two and padding from Top
after that we'll add the CSS properties in the input field so here we have this input field so in this one we will add
the class name so let me come to next line and provide the class name and here we will provide border border gray
500/80 then background color will be gray 800 then text color will be gray 500 then placeholder gray 500 then we'll
add outline none width height and rounded so that the corners will be round then we will add the padding X and
text size will be small next we have to add the CSS properties for the Subscribe button so
in this button we will add the class name and provide background blue 600 then width and height then text color
will be white and and Corners will be rounded save the changes and come back to the web
page now you can see this email subscription form is looking good with this input field and subscribe button so
now we have completed this footer and with that we have completed our homepage of our this LMS website correct after
that we'll create the other page so if I come here and click on this so all courses so you can see it will open this
course list page so now we will Design this course list page for that let's come back to the figma design and if I
move this this is the course description page and here we have this course list page
so we are going to design this page where we will add the navigation bar it is already
there then we will add this text and this search box and then we have this course card right so we will create this
page for that let's come back to the vs code and from this left side bar let's open
pages and in this Pages we will go to student and from here we will open courses
list this one in in this courses list page we will remove this div and here we will use
this fragment right now in this one let's add one div and
here we have to add another div so in this one we have to add one title so we will add one title in H1 tag
and and the title will be course list and after that we will add one small text in P tag so here we will add
the P tag and in this one we will add home and with that if I come back to the figma design you can
see so here we have this course list and after this course list we have this home/ course list so so it is looking
like a bread crumbs so just come back and here in this P tag where we have added home so after this home we have to
add slash and after this slash we will add course list
again like this now we have to change the color of this home text so here we will add the
span tag so let me move it in the new line and here we will use span and close it here after this
home let's wrap this course list also in the span tag so we will add this opening tag here and closing
tag here now in this P we will add the class name to change the text color so we will
add text Gray f 500 like this after that here we have this a span tag for home text so in this
one we'll add the class name and here we will add the blue color of text so we will add text blue 600 and cursor
pointer now when we click on this home text it will redirect us to the homepage for that we have to add the on click
property and we need the navigate function so we have already created the navigate function in the context file so
we will import it from Context right so here before this return statement we will add
const C asss navigate and use this use context
hook so use context has been imported from react now in this one we have to provide the app context
so app context has been imported now we can use this navigate here when we click on this home so in this asan tag let's
add on click and here let's provide the Aro function and provide this navigate and
in this one simply we will provide the path so let's add slash so it will take us to the homepage if I come back to the
web page here you can see we have the this course list then we have home and course
list and if I click on this home we are back to the homepage and if I click here we are back to the course list page
correct now in the right side we have to add one search box like this correct so we have to group this one in a div and
in the right side we have to display this search box so just come back and we will group this one inside a
div so here let's add div tag and move it inside this one and after closing of this
div here we have to add the search box so we have already created the component for the search bar so we will use that
component so just add search bar select from this suggestion so this search bar has been
imported right and close this tag now if I come back here we have this search bar also right now suppose we add
some keyword in this URL like this like JavaScript here in this URL then we have to pass this keyword in this search box
as a props so here we will add data equal to and here in this one we
have to provide the input data so we will get the input data from the URL for that here let's
add const then we will use input and we will use this use padm
hook and that's it so we will get the input from the URL parameter and we will pass it here in this search bar that's
it after adding it next we'll add the CSS properties for these div so let's start
with the first one and here in this first one we will add the class name and in this one we will
provide the position that is relative then we will add the padding X then padding top then text left now
for the second div we will add the class name and here we will add the Flex box CSS so just add Flex for medium
and above screen we will add Flex row and then Flex column Gap six items start justify between and width
full now for this title also will add the classes so just add the class name and in this one we have to increase the
font size so just add text for Exel font will be semi bold then text color will be gray 800
now we have this text in P tag so here we have added the class name and then we have this as span tag so
now we have added the CSS properties for this now just come back to the web page and you can see we have this text in the
left side and in the right side we have the search bar correct after that we have to display
the course card right so to display that just come back and uh here we have this search bar so after closing of this
div here let's add another div in this one we have to display the course so first we need all courses so
we will get all courses from our app context right so here just add the comma and write all courses that we have
already created in context file now we can use this all courses to display the course here using the the course card so
in this one let's add curly bres provide all courses and on this one we will add the map
method and here we will add the arrow function and it will return the course card that we have already created the
course card component so just add course card so this component has been imported
right now in this one we have to provide some props so just add the key property and in this key we have to add the index
number that we will get from this parameter so in this parameter we will add course that will give the individual
course then we will add the index and in this key we will provide Index
right after that we will add the course and here we will provide this course that's it now save the changes and come
back to the web page so here you can see we have all these courses on this course list page correct next we have to add
the CSS properties for this one so just come back and here in this div we will add the grid layout right so here let's
add the class name and provide grid GD column 1 then for small and above screen we will add GD column 2 then then for
medium and above screen we'll add grd column 3 then for large and above screen We'll add grd columns 4 then we have
margin y Gap three then padding X and padding zero for medium and above screen save the changes come back to the web
page so you can see all the course cards are aligned like this correct so right now we are
displaying all the courses now suppose we add any keyword in this field and click on the search button or we have
the search keyword in this URL right so in that case we have to display the filtered course right so we have to get
the filtered course data so just come back and here we will create a function that will filter the course and we'll
create one state variable also that will store the filtered course list so just add con and here we are creating the
estate variable so write the name filtered course and here we will add the setter
function set filtered course and here we will initialize it so just add user
state so it will be a state variable and initialize it with UT array like this after that we have to add the
course data in this filtered course so here let's add use
effect right and in this use effect we will add the Aro function and with that we will add the
dependency aray and in this dependency aray we will add this all courses so whenever all courses will
be changed then it will execute this function in this one we will add one more data that is input so whenever the
input will change then also it will execute this Arrow function right now in this Arrow function we will add the
logic to store the filtered data in this state variable so here first we'll check if we have all
courses and with that we have all courses do length greater than zero so just add all coures do length greater
than zero so in that case what will happen we have to create a
temporary variable so just add const and write the variable name temp courses and in this one we will add this
all courses dot slice like this after that we will check so just
add the turn operator and we are checking if we have the input right if we have the input then we
have to filter the data using this input keyword and if we don't have the input then we will simply store this temporary
courses in filtered course so here we'll add the logic for the filter and uh after that we will add this column so if
we don't have the input in that case we will simply use this Setter function set filtered
course and in this one just provide this temporary courses right and between this question mark and colum we will add
the logic to filter the data using this input field so here let's add this Setter
function set filtered course in this one we are going to use this temp course that is the temporary
courses list right so in this one we'll add the filter method now in this filter we have to add
the item as a parameter and uh here we'll add item do course
title then we have to convert the course title in lower case so we'll add two lower
case and then we'll add dot includes so if the title includes our
input keyword so just add includes and in this one we'll add input and we will convert the input field in lower case so
here also we will add two lowercase so if the course title contains the input keyword then that
course list will be filtered and it will be stored in this filtered course State using this seter
function right so now we have this filtered course so we will use this one here so instead of adding this all
courses we will use filtered course now if I save the changes and come back to the web
page still you can see we have same courses right but if I add some keyword in this search box so we will add
python click on search so now you can see we have only two courses that have the python keyword in the title correct
so this filter is working fine but right now here we have to add one text that will display the search
keyword and we will add the cross icon also that will remove the filter for that just come
back and before this do here we will add the space and here we will add curly brushes and here we will add one
condition if we have the input so just add input so when we have this input then
only we will display this div now in this div we have to display the
text that we have added in the input field so just add the B tag and here we will add the input value right after
that we'll add the cross icon so we will add the IMG tag and in this one we have to add the
file path so just add assets dot cross icon and uh in this one we'll add the
class name also so just add cursor pointer and when we click on this cross icon it
should redirect us to the course list page that is the same page right so here we'll add the on click also so just add
on click and in this one we will add the Aro function and in this addo function we
will return the navigate function and in this navigate we have to provide the path so just provide the
path called course list now here we have this div so in
this div we will add some CSS properties so just add the class name and in this one we will
provide inline Flex item Center Gap 4 padding X padding y border margin top then margin bottom minus 8 then text
Gray 600 that's it save the changes and open the web
page so here you can see we have the keyword that we have searched so we have this python here and then we have this
cross icon and if I click on this cross icon now we have all the courses right after that if I add another term
in this search box so let's add Cloud click on search so now we have the course that contains the cloud text in
the title and if I click on this cross icon again we have the all courses and if I add this here in
this search bar if I add JavaScript pressenter now you can see we
have this JavaScript course on this filtered result and here we have the cross icon to display all courses again
correct so after adding all the course card on this course list we have to display the footer also right so to add
the footer we will just come back here and uh before this closing fragment we have to add the footer component so
here just add footer we will click here so this footer has been imported right after
that just close this tag save the changes and come back to the web page so now you can see here we have this footer
also so we have completed our course list page also it is looking good and if I click
on any course like let me click on the first one so it is opening this course Details page so next we have to design
this course Details page and if I come back to the figma design and move here so this is the course details or Course
Des deson page so we will Design this page for that we will come back to the vs code to create the course Details
page we will come to left side bar and from here we will open this course details. jsx file and in this one we
will display the details about the particular course so let me just come back to the website again and when we go
to this course Details page you can see in this URL we have this path SL course and then we have the course ID
right so we have to find the individual course using this course ID so just come back to the vs code and here before this
return a statement let's add const ID and we will get this ID
from use patterns so this use patterns has been imported from react router Dom so now we have this course ID after
getting the ID here we will add one state variable where we will store the course data so just add
con and write the state variable name that is course data then we will add this Setter
function set course data equal to user
State and we will initialize it with null like this after that we have to get all
courses data that we have already stored in the context file so let's add
con all courses we have all courses in context file so just add equal to use
context and in this one we will provide app context so now we have all courses then we have the ID and using this ID we
will find the particular course from this all courses here we will create the function
to fetch the individual course data so just add const and the function name is fetch course
data equal to as sync it will be a synchronous function and we will create this Arrow function now in this one we
are going to use the all courses and here we will add the find method and here just add the arrow
function with the parameter course and on this course we will find find the ID so just add course doore ID
and we will check if this ID is equal to the ID that we have added here so if this ID is matching then we will get the
individual course so here we will store it in a variable so here let's add const find
course equal to this one now we will set this variable in the state variable that is the course data for that we will use
this Setter function so here we will add set course data and provide this one now we have to execute this function
whenever this component gets mounted for that here we will add the use effect hook in this one we will add
the Aro function and with that we will add the dependency areay that is an empty areay and in this one simply
execute this function fch course data so now we have the course data and now we can display the course data on our
website so to display the course data on this website here we have this div so let me remove the text from this div and
in this one we have to create two columns so here let's add the comment left
column duplicate it and it will be right column like this
now in the left column we will add one div and in the right column we will add another div like
this correct now in this first div we have to add the CSS properties that will align the child div in left and right
column so here we will use the flex box so let's add the CSS properties Flex then Flex column Reserve then Flex
column reverse then for medium and above a screen we will add Flex row then Gap relative item start justify between and
padding X padding top and text left after adding it we have to add the gradient color below the navigation bar
for that here we will create a div and in this one we'll add the CSS properties that will add the gradient color so here
let's add absolute top left width full height section height then Min - Z minus 1 then
background gradient to bottom and this color code like this after that if I come back
here that color is not displayed here because here we have added our custom class name that is section height
so we have to add the custom class name in our telin config file so let's open this telin config.js file and here we'll
add one more CSS property that will be spacing so after this gr column let's
add comma and here we will add spacing right column and create one object so in this object we will add
the custom name that is section height and here we will add the height of 500 pixel save the changes and come back to
the web page now you can see below this navigation bar we have the gradient color now it is looking good so again
come back here and uh just come in this file that is course details do
jsx so now we will add the content in the left column that is here in this div so in this div we have
to add the course title so we will add the title in H1 tag and to add the course title simply we will use this
course State here we have course data State let's add it here and from this course data we have
to find the course title so just add course title like this if I again come back
here go to assets open assets. JS file so here you can see we have dummy courses and in
this one we have this course title right then we have this course description and in this description we have this h2 tag
P so this is the rich text then we have the course price discount then course content and in this
course content we have the chapters and within this chapter we have the lectures so we have to display all these data so
again come back here and here we are displaying the course title right after that we have to
display the course description also so just add the P tag and uh in this one if I simply add this
course data then course description and come back to the web
page it is not working we have some issues so just come back and first we have to add the terity
operator in this return right because it will take some time to fish the course data right right
so until the course data is not loaded till then we will display a loading screen so here let's
add this course data after
this return and then add the question mark So if we have the course data then
only this will be displayed and uh here we will wrap it in a fragment let's close this fragment
here correct now at the end here we have the closing bracket right so after that let's add colon and here we will Mount
our loading component you can see in the left side bar we have created this loading. jsx so we will Mount this
component it is not giving the suggestion so we will open this file and come back
here now if I type loading so we have the suggestion and we have mounted this loading component now if I come back
here you can see we have this loading text but still it is not displaying the course details so let me just come back
to the homepage and click on this one let's click on the first course card so yes now we have this course title
introduction to JavaScript then we have this course description but in this course description you can see it is
displaying all the HTML tags like H2 P UL Li right so we have to hide these tags we will just display the text and
we will display the text up to 200 character for that just come back and
here we have added this P tag so from this P tag we will remove this
and here in this P tag we will add the dangerously set inner HTML here we will add another curly
Braes and then write double uncore HTML colum and then we will provide the course
data dot course description so it will hide all the HTML tags after that we have to display only
200 characters so just add slice method and here we will provide 0 comma 200 that that's it now just come back to
the web page and here you can see we have this course title and small course description right next we have to add
the CSS properties for this one so just come back and let's add the CSS properties for the left column so in
this left column we will add class name and we will provide Max width Xcel Z10 text Gray 500
after that we will add the CSS properties in the title so here just add the class name and provide this class
name text course details heading large then we will add text code details heading a small then we will add font
semi bold and text Gray 800 so right now you can see we have added the custom classes that is course details heading
large course details heading a small right this course details hitting a small will
be applied for the smaller screen and for medium and above a screen this class name will be applied so we have to
Define these custom classes in the telin config file for that let's open the telin config file
again and uh in this one we will add one new property that is font size so you can see we have already declared
that font size and here we have added course details heading a small heading large so we don't have to add again we
have already added so just come back now you can see this course title and description is looking
good now again come back and for this description we will add some CSS properties so here we have this course
details. jsx file so in this P tag we will add the class name so let me move it in the new line and add the class
name so here we will provide padding from Top then text base and text
small so here we have this description after this description we have to display the course rating right so just
come back and uh here after this P tag we have to display the course rating so let
me add the comment here review and rating so to display the course rating
we will just come back to the course card component so let's open this course card where it is it
is in the company comp course card right so in this course card you can see we have already created this
component to display the ratings right so here we have this component and in this one you can see we have added this
course. educated. name but right now we don't have this educated name details in the asset file so we will add the manual
data here so let's add one hardcore data we will add Greatest Tag if I save the changes and come back
to the homepage now we have this instructor name greatest tag so we have added the
same instructor name for all the CES we will update the instructor name when we will connect it with the database so now
just come back and here we have this course rating so just copy this one and we will come back here in this
course details. jsx file and paste it here after adding it you can see here we are using this calculate rating so we
have to import this calculate rating from the use context
so just copy this one and in this use context we will provide this calculate rating after that you can see
here we are using this course so instead of this course we will use our state variable that is course data so just add
course data then here also we have this course so we will add course
data then here also we will update course data after updating it we will come back
to the web page open any course so we have some issues let me check or just come back here and you can
see here we are using this assets so we have to import this assets also so just
add assets and you can see this assets has been imported right now if I come here and open any course you can see
here we have the average rating five then we have the starts then we have total number of rating so with this
total number of rating we have to display the text also like one rating two ratings five ratings for that just
come back and uh let's see where we have added here it is so here it is displaying the total
number of ratings right so after that we have to add the text called rating or ratings for that here after this closing
curly bres we will add another curly bres and in this one we will check if this length is greater than
1 then what will happen we will add the text so if it is greater than one then we will display
the text called ratings if it is not greater than one then we will display rating like this and if I come back here
you can see we have this message five then stars then one rating it looks
good after that we have to display the total number of students who has enrolled in this course so to display
the total number of uh students enrolled in this course here we will add another P tag so after this P we will add one
more P tag and uh in this P tag we have to display the total number of enrolled
students so we will add cly Braes course data enrolled a students. length so we will get the total number after that we
have to display the text called a student or a students so again add this one and here we will check if it is
greater than one then add question mark and colum and here we will display the
text so if it is greater than one then we will add a students and if it is not then we will add a student like
this and uh here we will update the text color so it will be blue
600 after after that here we have this course data and ratings so we will add it in one bracket so just add this small
bracket we will wrap everything in this small bracket now save the changes and uh come
back here so here you can see we have this one rating three students it looks
good now after that we have to add one text where we will display the instructor name so we will come back and
after this div so you can see this div is for this one where we have added Flex item Center so after closing of this
div we will add one P tag and in this P tag we will add the text called course by and then we have to display the
instructor name in different colors so we will add the span tag and in this one we will add the hardcoded name for the
instructor that is great tag right and for this text we will add different color so just add the class name and
here we will add the text blue 600 and underline after that in this P we will add the class name to decrease the text
size so we will add text a small like this and we have to add some a space also
so here you can see we have this D so in this T we will add some padding from Top then padding from
bottom and text a small save the changes and come back here so now you can see we have this ratings and course by greatest
stack and it is looking good correct next we have to display the
course structure like we have to display the course chapters and course lectures if I come back to the
figma design you can see here we have this course structure in this one we have to display the number of sections
number of lectures and total dation then we have to display this type of accordians where we will display
the chapter name and in this chapter name we will display these lectures name and in front of that we will display the
total number of lectures in this chapter then total duration for this individual lectures for that we have to create some
function that will calculate the total time duration and total number of lectures then we will display that on
the website so to display these data we have to create the function for that we will come to app context
from this left sideward we will open app context. jsx file and in this one let's scroll down and after completing this
function we will create another function so we'll add one comment let's write function to
calculate course chapter time so here let's add one function name const
calculate chapter time and create one AR of function so in this parameter we need
the chapter right so just provide the chapter here as parameter now we will add
let time time equal to Z after this let time Z here we will
add chapter dot chapter content in the dummy data we have added the chapter content and on
this chapter content we can use the map method and in this chapter we will get the individual lectures so let's
add lecture in this parameter and here we will return the time plus equal to and here just add
this lecture dot lecture
duration like this so now we will get the time and this time will be in the minutes so we have to convert it into
hours and minutes format for that we will use the humanized duration that we have already
installed so first we have to import it so a scroll up and here we will add import we will import the humanized
duration from and provide the package name humanized duration after importing we can use it
here so here let's write return so it will return the humanized duration and here we have to provide this
time right and in this one we will multiply by 60 and again multiply by 1,000 then in this one we have to
provide the second parameter so in this one we will add units and in this units we will add one
array and this array will contains hours and minutes so just add H
and M that's it so this function will return us the chapter time when we pass the chapter in this function after that
we'll create one more function so here let's write the comment function to calculate the course
duration so it will give the total duration of the course that will include the duration of each chapter right so
here we will add that function so we will add const and write the function
name calculate course duration and we will create this function and in this one we need the
particular course for which we want to calculate the total course duration now we will add the times so just add let
time equal to Zer and after that we will add this course and in this course we have the
course content right so just add course content. map method so it will give the individual
chapter so here let's add the Aro function and here in this one we'll add the chapter
now each chapter has multiple lectures so here we will add this chapter and in this chapter we have the
chapter content and on this chapter content we will use the map
method so in this map method again add the Aro function so let's add this one and
here we will add the lectures because each chapter contains multiple lectures right so just add lecture in this
parameter and here it will return the time plus equal to this lecture dot lecture
duration after that here we will return the total dation using this humanized dation
right so we will just copy this one let's copy it and paste it
here so here also we will get the total time in hours and minutes after that we will create one
more function that will calculate the total number of lectures available in the course so just add the comment
function to calculate number of lectures in the course after that let's add the function
name const calculate number of lectures and uh here we will provide the arrow
function and in this parameter we need the particular course right so just add the course here and
uh in this function we will add let let total lectures is zero suppose the total lecture is zero
so we have iniz the variable with zero after that we will add the lectures in this variable so just add course
dot course content and here we will add the for each in this one we will add the
chapter and create the arrow function now here we will add if and then we will add the
array dot is are [Music]
a then we will add the chapter dot chapter content then we will add the total lectures
here and it will be plus equal to the chapter dot chapter conent do
length so what will happen it will add the length that is the chapter length of this chapter so in this chapter suppose
we have two lectures so the first chapter length will be true so like that it will add all the chapters length
after that here we will add return so it will return this variable
that is total lectures that's it so we have created the function to calculate total number
of lectures then a function to calculate total course duration and one function to calculate
the individual chapter time right now we will pass all these using this value object so that we can
access it in any other component so we will copy this and paste it here let's copy the second
one paste it here and uh let's copy this one calculate chapter
time and paste it in this value object so here we have added this calculate number of lectures calculate
course duration and calculate chapter time now we can access it in our component that is course Details page
right so just open the course Details page again and here we need all these data
from the context so in this context we are getting this all courses and calculate rating so with that we will
get this data also so here let's add the comma and provide this calculate number of lectures calculate course duration
and calculate chapter time so we have this data now we can use it in our course structure
here after this P tag we will create one div so let's add one div and in this D we will add the space
from top and we will change the text color so just add class name and padding top and text Gray
800 after that we have to add the text in S2 tag so we will add the text called course
structure then we will add the class name for this text so in this one we have to increase the font size and font
weight so we will add text Excel font semi bold after that save the changes and
come back to the web page so here you can see this text course structure now just come back and after
this H2 we will add one div in this div we will add the space
from the top so we will add the class name padding top five now in this one we have to display
the course structure so just add the curly bres and here we will add the course data and in this course data we
have the course content and on this course content we will add the map
method in this course content we have multiple chapters so here we will get the individual chapter in this
parameter so let's add the chapter and with that we will add index and here in this one we will
return one div so let add the div and in this div first we have to add the key property and here we will add
this Index right now here we have to add one
div and in this one we will add another div here we will add the image tag and in this image we have to add the
icon so let's add CES assets dot down arrow icon after that we will
add the alt property and the alt text will be Arrow icon next we have to add one text so we
will add the P tag and in this one we have to add the title of the chapter so just add chapter do chapter title in the
curly Braes after adding it save the changes and come back here so you can see here
we have the get started with JavaScript that is the chapter name and here we have this
variables and data types this is also chapter name now in this chapter we have multiple lectures right so we will
display the lectures also and uh after closing of this div here we will add the time of this chapter so just add P tag
and in this one we have to display the chapter time so we will add the curly reses and here let's add
chapter dot chapter content and in this chapter contain we
will add length so so here let's add the text lectures after that we will add the Das
and here we have to display the time for that just add the curlys and we will use the function that we have just created
in the context file so let's add the function name calculate chapter time and in this one we have to provide the
chapter like this after adding it save the changes and come back to the web page so here
you can see with this chapter name we have the number of lectures it has two lecture and it has 35 minutes
duration right so in the second chapter we have two lectures and the duration is 30 minutes correct now we will add the
CSS properties for this one so just come back and let's start with this one here we have this div with the key property
so if in this one we will add the class name and here we will add the border and Border color then background white and
margin bottom and rounded after that here we have this div so here also we will add the class name
and uh in this one we will add the flex box so just add Flex item Center justify between padding X padding y cursor
pointer and select after that here we have this another D where we have added the image and
chapter title so in this one we'll add the class name and here also we need the flex so just add Flex item Center and
GAP two after adding the classes for this div here we have this P tag so in this P
tag We'll add the class name and in this one we have to change the font weight text size
and text size for medium and above screen after that here we have this P tag so in this one we'll add the class
name and in this one let's add text small and for medium and above screen we add text default save the
changes and come back to the web page so now you can see these chapter's name are looking good that is the chapter title
and we have the total number of lectures and and time duration and here we have the drop down
icon correct now within this chapter we have to display the lectures also right so
just come back and uh here we have this B tag then this closing div so after closing of
this div here we will add another div in this div we will add the UL tag and in this UL we will add the cly
presses and here let's add chapter and on this chapter we have the chapter content right so just add
chapter content and here we will use the map method in this one we will get the
individual lectures so just add lecture and with this lecture we will get the index number and create create this Aro
function now this function will return the LI tag that is list
item and in this Li tag we have to add the key property so here we will add key and provide the index
I after that here we have to add the image so just add the image tag and here let's add the file that is assets do
play icon after that in the alt property we will add play
icon after that here we will add some classes also so just add the class name and we will provide the width height and
margin from Top after this image we will add one div so in this div we have to display
the lecture title so we will add the P tag and in this one we will add lecture. lecture title in curly
Braes then we will add another div in this div we have to add one link that is preview if that lecture is
available for free preview for that here we will add the curly bres and we will add lecture
dot is preview free so when it is true in that case we will add the P
tag and in this P tag we will add the text called preview and uh after that here we will
add another P tag and in this one we have to display the total duration of this particular lecture so to get the
duration we will add the curly Braes and here we will get the duration using this lecture do
lecture duration but we have to convert this lecture duration in the hours and minute
format for that we will use the humanized duration so just add humanized
duration and in this one we will provide this lecture duration and then we will multiply it
with 60 and th000 after that let's add comma and provide the second parameter where we will add
the units and in this units we will add the aray and then we will add the H
and M for hours and minutes after adding it save the changes and come back to the web
page so now you can see here we have the chapter title then we have the lecture title that is what is Javascript
and then we have the second lecture setting up your environment and for this one you can see we have the preview
option and we have duration 16 minutes and for this one we have the duration 19 minutes so now we have to add the CSS
properties for these lectures so just come back and let's start with this
du so in this D We'll add the class name and here we will add overflow
hidden transition all then dation 3,000 after that we will
add Max height 96 next we have this UL tag so in this UL tag we will add the class name and
here we will provide the list dis then padding left then padding right
padding y- axis and then text color then we will add the Border top and Border
color after that we have this Li tag right so in this Li tag we will add the class name and here let's provide flex
and uh items start Gap two and padding y1 after that here we have this D right
so in this div we will add the class name and here let's provide Flex item Center justify between withd full text
color gray 800 then text small and for medium and over screen we will add text size that is
default after that here we have this div so in this div we will add the class name so in this one
we will add flex and we will provide the gap of two
right next we have this text in P tag where we are displaying the preview text so here
let's add the class name and in this one we will add the class name that
is text blue 500 and cursor pointer correct after adding it save the
changes and come back to the web page so now you can see these lectures title and duration are aligned in same
horizontal line and it is looking very nice and here we have this preview option
correct next we have to add the click functionality on these chapter title so that when we click here
it will collapse the description area that will hide this lectures and if I click again it
will again display these lectures for that let's come back a scroll up and before this return
a statement here we will create one a state variable so let me create it here
so just duplicate this one and here we will add the state variable name open section and the set function name is set
open section so using this state we will either open or close the chapter section
and here we will initialize it with empty object like this so we have added this a
state variable open section and set open sections and after that we have to
create a toggle function using that we can either close or open this one so here let's add one function
const the function name is toggle section and create the add function now in this one we need the
index and after that here we will use the setter function so just add set open sections and here let's add the Aro
function and in this one we will return one object and in this parameter we will get
the previous value so just add previous and here we will return this object and in this object we will add spread
operator previous comma and then we will add the index and colon we will provide not
of previous and index after adding it just come back to the section where we have created
this course title that is chapter title so here we have this chapter title
right here we have this div where we have added Flex item Center and then we have the cursor pointer select none
right so in this one we have to add the on click property so after this class name we will add the on click and here
we will use the arrow function and in this Arrow function we will provide our toggle function so we
will add toggle section and in this one just add this index like this so it will toggle the
section either open or close so to open and close the section we have to add the feature in
this chapter content where you can see we have added the minimum
height here it is we have this div with minimum height right so in this one we will add the
tary operator to apply the classes so let's add everything in the curly bres just add all classes in this curly bres
and instead of this single quote we will use the backx so that we can add the template literal so here we will add
this backx and uh here we will add back Tex like this now in this
one we have these classes and uh instead of adding this Max height 96 directly here we will use the template little so
just add dollar sign curly bres and here just add open sections and provide the index
and if we will add the question mark So if it is true then we have to display this
class name that is Max height 96 so we have to provide this class name if it is false then
we'll add this colum and here we'll add the height zero that is the maximum height zero so just add Max H and it
will be zero like this now save the changes and come back
to the web page you can see if I click here it should hide this but it is not working
so just come back here we have added this closing curly bres so just move it here after
this height zero now save the changes and come back to the web
page you can see these chapters are hidden and if I click on this chapter title then it will display
the lectures and if I click again it will hide the lecture if I click again it is displaying these lectures and if I
click again it will hide it let me click on the second one so you can see it is also working now when we hide or display
the lecture we have to rotate this drop- down arrow icon right so to rotate this icon we will come back
and let's see where we have added the icon so here we have this image tag right so
in this image we have to add the classes using the turn operator so in this image here let's add
the space and we'll add the class name in this class name let's add C bres and then add the back Tex and here we
will add the classes that is transform transition transform then we will add dollar sign cardly Braes and
here let's add the turn operator so here also we will add this open section index and if it is
true then we will add some classes and if it is false then we will add another class so when it is true we will add
rotate by 180 and if it is false we will simply provide the empty
string that's it after adding it save the changes and come back to the web page if I click
here you can see it will rotate this icon upward and if I click again it will rotate it downwards so you can see the
icon is rotating correct now after displaying this course
structure let's come back to the figma design and here you can see see we have to display the course description right
so to display the course description we will come back to the vs code and uh let's see where we are
closing this div here it is so here let's add another div where we will display the course
description so just add one div and in this one we have to add one text in S3 tag so just add S3 and here
let's add the text called course description right after that we will add the description in P tag so here if I
scroll up you can see we have already used the description here here it is so let me just copy this P from
here and paste it here so in this one we will update the class name so let's
add padding top three and remove this one and in this one here we are using slice 0 to 200 so
we are going to remove it because here we will display the complete description so just add this course description
correct after that we'll add the class name in this S3 tag so just add the class name and here let's provide text
that is Excel then font weight and text color after that in this div we will add the class name and here we will provide
the padding and text size a small and default right after adding it save the changes and come back to the web page so
you can see here we have the course description and then we have the complete description but right now it is
not formatted right so we have to add the format for these text for that we have to apply the custom classes so just
come back and here you can see we have this ptag so in this one we'll add one custom class name that is Rich Text for
this Rich Text we have to add the custom classes for that we will open in the index. CSS file so here we have this
index. CSS file and in this one we will add some custom CSS properties for that rich text
class name so let me paste these CSS properties you will find this
CSS properties in the asset file that you will download from the video description so just copy
these CSS properties and paste it here from the asset file right now in this one we'll add some extra properties so
here let's add atate layer
base and for this one we will provide the HTML SC scroll we have here smooth so the SC scroll will be smooth and
after that we'll add colon web kit scroll bar and for this
one we have to add display none so that the scroll bar will be hidden after adding it we will come back
to the web page and now you can see this course description is looking beautiful with this formatted data where we have
this heading then small paragraphs then we have the list items right so this course description is looking
good after that let's come back to the figma design and here you can see we have to create this right section
correct so to create this right section we will come back to the vs code and uh let's open course details.
jsx files so here you can see we have already added the comment right column and here we have this div so now we will
add the content in this div so in this div first we have to add one image that is the course thumbnail
image so just add image image and in this SRC let's add the curly braces and provide the course data dot course
thumbnail after that we have to add one div and in this div we will display other details of this particular course
so here we will add some space in the top so just add the class name padding top
five right now in this this one we have to add one D and here let's add the image in this
image let's add the SRC so just add assets dot time left clock
icon and uh in the alt text we will add time lift clock icon after that here we have to add the
width also so just add the class name and we will provide the width 3.5 after this image we will add the
text in P tag so in this one we'll add the 5 days
left at this price and we have to change the font weight of this text that is 5 days so we
will wrap it in the span tags so just add span and uh move it
here correct now in this aspan tag we will add the class name and provide the font
medium now for this P tag we will add the class name and here we will add the text color that is red
500 like this if I save the changes and come back to the web page so here in the right side you can see we
have the course thumbnail then we have this clock icon and this text five days left at this price so now we'll add the
CSS properties for the parent div so just come back and here we have this div so in this one let's add class
name and here we will provide Max width course card then Z index then
Shadow custom card we have to create this custom CSS in the telin config file to add the custom Shadow then we have
added the rounded then overflow hidden background white then minimum width right save the changes and if I come
back here here you can see the width of this course card that is the right side word is large so we have to add the
width so just come back here and you can see here also we have the custom class name that is width course card and then
we have this custom class name for this Shadow so we will add these classes in the telin config file so just open telin
config.js and here after this spacing object let's add the comma and here we will add the max
width in this one let's add column and create cre the object here we will add the class name course card and then
we'll add the value that is 424 pixel after that we'll add the shadow so
just add comma and here we'll add the Box Shadow column and then create the object and in this object We'll add
the custom class name that is custom card and here we will add the
value that is 0 4 15 2 and this color correct after adding this value
now just come back to the web page let's go to homepage open any course so you can see the perfect width
for this card and here we have the shadow also right after that let's come back and we have to add the padding here
so just come back here and open the course details. jsx file so here you can see we have added this padding top so
instead of this padding top we will simply add the padding five so you can see we have some space here correct now
just come back and here we have this div so in this one we will add the class name and here let's provide the flex
item Center and GAP two save the changes and now you can see it is aligned in same line
correct after that we have to display the codes price so just come back and uh here we have this div where we are
displaying the message that is 5 days left at this price so after closing of this D here we will create another
d right and in this one we will add the P tag and in this P tag we have to display the course price with the
currency so first we need the currency from the context file so here we have this app context right so in this one
let's add currency so we can use this currency
here so let's add CES currency and and after this currency
we have to display the course price so just add cly bres and in this one we will add course
data dot course price but in the course price we have to display the
final price after applying the discount so here let's add the course discount that is this one and in this one we will
multiply by course price and then divide it with 100 so just add slash 100 so now we will get the actual price and after
that here we will add it in the small bracket and then we will add dot to fixed and provide two after
adding it come back to the web page so here you can see the final price right next we have to display
the general price that is the normal price without discount so just come back and uh here let's add another P tag and
in this one we have to display the normal price so just add this currency and after this currency let's add the
curly Braes and here we have to display the course regular price that is course data doour price right next we have to
display the discount so just add P tag and in this P tag we will add cly bres course data discount
percent off save the changes and come back to the web page and now you can see here we have
this final price then regular price then we have the discount percentage next we have to add
the CSS properties for this one so just come back and let's add the CSS properties for this parent div so in
this one we will provide the flex then Gap and after that we will provide item Center and padding top now in this first
P tag we will add the class name and here let's add the text color then text size and font weight after that in this
second P tag we will add the class name and here we have to provide the text large then text color and line throw now
in this last P tag we will add the class name and here also we will add the text large and text color gray 500 save the
changes and now you can see this price area is looking good after that we have to add some
other information of this course like total number of lectures and total duration right so to display that just
come back and after closing of this div here we will create another div and in this div let's
add class name and here we will add Flex item Center then text small
then text default after that we will add the Gap and padding from top and then text color gray 500 in this one we will
add multiple divs so just add the first div and here we have to add one start icon so just
add image tag and then write assets dot star and in this alt tag we'll add start
icon after this we will add the course average rating so we will add the P tag so in this P tag We'll add
the function that is is calculate course rating so it will provide the average rating of this
course so in this one we have to provide the course data like this next we have to align these things in the same
horizontal line so here we have to add the classes so just add the class name and provide Flex item Center Gap
one correct after adding it if I come back here so here you can see we have the start and
the value five correct now just come back and here we will add one vertical line after this div so here let's add
the div in this div we will add the properties that will create a vertical
line so here just add the class name let me add the space here and here let's add the height
then width pixel then background gray 500/40 after adding it you can see here we have this vertical line correct so
after this vertical line again we have to display some data so again use this content just copy and paste it
here and here we will update the icon so it will be time clock icon and write the alt
text clock icon and here we will add the function that
is calculate course duration so it will display the total duration of this particular
course after that again we have to add the vertical line so just add this div and after that again we have to display
the data so just copy this div here and paste it here and in this one we have to add the total number of lectures so
first we will update the icon it will be time clock icon Let It Be and here we will add the function that will display
the total number of lectures so just add calculate number of lectures and here we will provide this course data and with
that here we will add the text called lessons save the changes and come back to the web
page so now you can see here we have this data that is average rating then we have the total duration of this course
and total number of lessons right and if I come back to this design file here you can see we have
these data here we have to update this icon also so let me just come
back and uh here we will update the icon here we will add assets dot lesson icon save the changes so you can see here we
have updated this icon right after that we have to display these details and we have to display
this button that is enroll now so if the user is already enrolled then we will display another message that is already
enrolled so for that we have to create one state variable so let me just come back to the vs
code and scroll up here we will create one state variable
so here let's write let me duplicate this line only and here we'll add the variable name or a state variable name
that is is already enrolled and this set function name is set is already enrolled and here we will make it
false so we will initialize it with value false now we will use this
data this a state to display different message in the button correct so now just scroll down where we have to add
the button [Music] so here
after this lesson we have this lesson in this div and uh then we have this div that contains all the details right so
after closing of this div here we have to add the button so just add the button tag and in this button tag we have to
add the text that will be based on the a state so just add the curly bres and we will add
is enrolled and if it is true then what we will display we will display the message that is already
enrolled and if it is false then we have to display the button text that is enroll
now correct now in this button we have to add some CSS properties so just add the
class name and here let's add the margin then width padding rounded then background color then text
white and font medium after adding it if I come back here you can see here we have this message enroll now and if I
come back and we will make it true and come back so you can see here we have already enrolled and if I make
it false so then we have this enroll now it works now just come back and scroll down
here after this button we will display some other description that will be displayed in all the courses right so
after this button tag here we will add one div and in this div let's add the text in P tag that
is what's in the course after that we have to display the content in list items so just add the UL
tag then Li tag in this Li tag we will add this text similarly we will add multiple
text in lii tag so let's add these text in Li tag after that we have to add the CSS properties for this one so first
We'll add the CSS properties for this div we will add the class name and padding top after that in the text we
will add the class name and we will add the text large and text Excel then font
medium and text color gray 800 after that we have the UL tag so for this UL tag We'll add the class name and
we will provide the margin from the left padding top and text a small then text default and list disk and text Gray
500 that's it after adding it if I come back here you can see this right side bar is
looking good Cod correct now we have to add the footer on this course description page right so just come back
and here we have this closing fragment right so before that here we will add the
footer select it from the S so the footer will be imported now save the changes and here
you can see at the bottom we have this footer it looks looks good so now we have completed this
course description page where we will display the individual course description and it display the course
structure also like chapter and lectures next we have to add the click feature on this preview link so it will
preview the video here at this place where we are displaying the thumbnail to display the review video at
this place we will come back to the vs code and here in this course details. jsx file here we will create one new
state variable so let me duplicate it and we'll write the variable name or a state variable
name player data and the setter function name is set player data and initialize it
with null so initially player data will be null right after that scroll down and uh
here we have added the preview link so here it is correct so in this P tag you can see we have added the preview so in
this P tag we have to add the on click property so that it will set the preview data so here
in this P tag let's add a space and in this P tag we will add the onli property and in this on click let's add
the Aro function now here we will add the setter function that is set preview data or set
player data let me come back here so you can see here we have added player data and
set player data so the state variable name is set player data so we will use this one here
set player data and here in this one we will add the object and in this object we have to add the property called video
ID and here we will add the value so it will be lecture dot lecture URL so just add lecture
URL we have this data in our assets if I open this assets so here we have this dummy course
data so in this course data you will find this lecture URL right so you can see in
each lecture we have this lecture URL so using that we'll display the video so in this video ID property we are providing
lecture URL and in this one we have to split after this slash so you can see here we have this U and in this one we
have this slash right so after this slash we will get the video ID so here let's
add lecture URL dot split and in this split just add slash
and after that we will add pop method that's it so when we click on this preview link it will set the
a state variable that is player data and in that one it will provide this video ID using this code right so after
getting the video ID we have to display the video in the right side so let's scroll down and here you can see we have
added this right column and in this right column we have this image correct so we have to replace this image with
the video so here we will add the space and here let's add the cly
addes and in this one we will check player data so if we have the player data then we will display the
YouTube video right and after that if we don't have the player data then we will provide this
image like this and before this colum and after this question mark we have to display the YouTube video for that that
we will use the YouTube tag that we will get from the package that we have already
installed that is react YouTube so let's import that we will add import YouTube
from the package name react YouTube Correct now we can use this to
display a video so here let's add the this YouTube
tag it will be self closing like this now in this YouTube tag we have to provide the video ID so just add video
ID and here let's add cly addes and we will get the video ID from player data
dot video ID right then we will add the options and here let's add curly
bres and in this one let's add clear variables so in this one we'll add the object and in this object we
will add the autop playay one so it will play the video automatically and uh after
that here we will add the iframe class name and in this if frame class name we have
to provide width and aspect ratio so the width will be full aspect video that's it so when we have the player data then
it will display this video and it will be autop playay and if we don't have the player data then it will display this
image now save the changes and come back here and now you can see this image here and if I open this chapter and click on
this preview link so now you can see it will start playing this video here but uh it is not removing this image so just
come back you can see we have added it at this place where we have added this
clock icon so by mistake we have added it here we have to add it here instead of this thumbnail image so here let's
add curly brushes and in this one we will paste this code like this and if we have this
player data then this YouTube tag will be displayed and
else we will display this thumbnail using this IMG tag correct now let me change it and here we will remove
this remove this curly bres remove this colum and that's it so in this div we have
this image that is the clock icon and after this clock icon we have this text and here we have this course
thumbnail right so either it will display the YouTube video or course thumbnail save the changes now come back
to the web page so you can see here it is displaying this video and if I go to homepage and open any other course
and click on this one then click on preview so you can see it will replace the thumbnail image and start playing
this video here so this preview is also working after that we have to create the
loaded screen right so just come back and if I open this course and refresh it you can see here we have this loading
text so we have to create a loading animation so just come back and from this left side bar we will open
this loading. jsx file right now in this one we have to create a loading animation so here let's add one
div now in this div we will add some classes so just add class name and we will provide width then width for a
small and above screen then aspect Square then border four then border color then border bottom and Border
top then we will add the Border full and animate a spin in this div we have added the class
name width 16 then width 20 aspect a square border four then border color gray 300 then border top then border top
color that is blue 400 then rounded full and animate spin after that we'll add the CSS properties in
this pent div so here we will add the class name and in this one we will add the minimum height that is a screen and
after that we will add the flex item Center justify Center that's it so we have created this animation effect after
adding this let's come back to the web page and here if I refresh this web page you can see we have this load animation
right but here we have one issue if I reload this web page you can see it is displaying loading animation but after
loading it should display the course Details page so that is not working so just come back
here and we will open course details. jsx file and in this one you can see here we have created this use effect so
in this dependency areay we will add all courses so whenever all courses will be changed then it will execute this fetch
course data save the changes and come back here so now you can see we have the course details and if I reload this
still it is displaying this course details so it is working fine so after creating this course
Details page we have to create this my enrollments page if I click here it will open this my enrollments so here we will
display the courses that any student has enrolled in right so to create that just come
back and from this left side part we will open a student folder and here we have
my enrollments do jsx correct and if I come back here you can see the same message my enrollments
page and here also you can see my enrollments page now now in this one we will create one title so the
title will be my enrollments that's it in H1 tag and after that we have to create one
table so let's add the table tag and in this one we will add the table head so just add T
head and in this this T head we have to add the table row so we will add the TR and in this TR we will add the table
headings so just add th tag so in the first one we'll add the course after that in this one we will
add some CSS properties so here let's add the class name and uh we will provide padding X padding y font we semi
Bol and truncate after that we will duplicate this one and uh in the next one we will add
the dation that will display the course duration after that we will add completed and in the next one we will
add the a status so first we'll display the course title and image then duration then
completed and after that we will add a status after that we have to add the data for this table
and after adding it if I come here you can see here we have these table headings right so for now
let me add the CSS properties for this one so just come back and let's start with the first div so let me wrap this
div inside a fragment so here let's add fragment and uh we will move it here
after closing of this div like this now in the first du we will add the class name so just add the class
name property and here we will provide the padding X then padding top after that we have to add the CSS
properties for the title so in this title we will add text to Excel and font semi bold next we will add the CSS
properties for the table so here we will add table Auto table fixed width will be
full overflow hidden and Border then margin from Top after that we have the table head right so in this T head we
will add the class name and provide text color border bottom then border colored and text small then text alignment left
and for Mobile screen it will be hidden after adding it if I come back here you can see this my enrollments
text and this table heading is looking good correct next we have to display the data of enrolled courses so first we
have to get the enrolled courses data for that we will create one state variable so we will create it in the
context file so just open app context and in this one here we have some State variables so
let me just duplicate this one and here let's add the state variable name enrolled coures and the seter
function name is set enrolled courses correct now in this state we have to add the enrolled courses data
but before that here we will add the initial values so we will initialize it with empty
aray now we will create a function that will add the data in this state so so here let's add one
comment we will add the comment fetch user enrolled courses and we will create the function
using const and the function name is fetch user enrolled courses and it will be asynchronous
function and in this one simply use the set function set enrolled courses and let me provide dummy course or dummy
courses so we have provided the data in this state right next we have to call this function whenever the component
gets loaded so in this use effect we will add this fetch user enrolled courses like this now we have to pass
this estate using this value object right so let me just copy this
one enrolled courses and set enrolled courses let me just copy this one only enrolled
courses and uh we will paste it here in this value object after that we will pass this
function also fch user enrolled courses in this value object so that we can access it in any other components so now
we have this enrolled courses data so we will get it in the my enrollments component or page so let's come back
here in this my enrollments and here we will get this data from the context so just add const here we will write
enrolled courses and we will get it from use context and in this use context we will
provide the app context so this use context and app context has been imported correct after that let's scroll
down and uh here after this T head we have to create the table body so we will use T body tag and in this T body tag we
will add the data so we will add cly bres let's write enrolled courses dot map
in this one we will get the Aro function and in the AR function parameter we will get
the individual course and with that we will get the index right now in this function we will
return the table row and in this table row let's add the key property so in this
key we will provide the index correct after that here we have to display the
table data so just add TD tag and in this TD we will add the image that will be course thumbnail
so here let's add IMG tag and we will provide the course thumbnail
so just add the curly blesses and write course dot course thumbnail after that here we will add
the CSS properties so just add the class name and provide the width for different
screen size after this image we have to display the course title and then we will
display the progress array so we will group it in a div so just add one div and in this div first we will display
the course title so let's write clys and here we will provide course. course title title
correct and after that we have to display the progress line that we will display after few minutes but before
that here let's add another TD tag so here we have this closing TD tag and after that let's
add another TD that is the table data and here we have to display the time that will be
the course duration correct so we have already created the function for course duration so we will import that from the
context so we will add calculate course duration and we will get it from the app context and we can use it here in this
TD so here in this TD let's add cly bres provide this function and here we have to provide the
course so it will return the course duration time correct after that here we will add another TD tag
that is table data and uh in this TD tag we will display how many lectures are completed out of total lecture so let me
write the manual value right now then we will make it Dynamic so here let me dite 4 out of 10 and in the span tag we will
write lectures like this and after that that we will create one more TD tag and in
this one we will add one button and in this button we will either add the text completed or ongoing if all the lectures
are completed then we will display the text completed and if some lectures are left and we have just started then we
will add ongoing so for now let me write ongoing after adding it if I come back here so so here you can see we have this
course thumbnail course title then we have the total duration 1 hour 5 minutes then we have
this completed lectures that is four out of 10 that we have added manually we have added the same thing and in this
status we have this ongoing so now we will add the CSS properties for this one so just come back and let's start with
this table body right so in this table body we will add the class name and we will
add the color then we will add the CSS
properties in the table row right so in this TR tag we will add the class name and provide border bottom then border
color then we have this table data right so in this one just add the class name and
provide padding X padding left then padding left for different screen then ping y then Flex item Center and a space
X3 next we will add the CSS properties for this div right so here in this div we will add the class name and
provide Flex one then we have this P tag where we are displaying the course title so in
this P we will add the class name and provide margin from the bottom and then we'll add the text a small all for phone
screen right after that we will add the CSS properties for this 3D tag where we have
displayed the course duration right so in this one we will add class name property and
write padding X padding Y and it will be hidden for Mobile screen after that we will add the CSS properties for the
table data where we have added the number of lectures completed right so in this one we will add the same CSS
properties that is padding X padding Y and Max SM hidden correct now we have this button in this table data so here
also we will add the class name and in this one we will add padding X padding Y and for Mobile screen it will be text
right that's it save the changes and come back here so you can see here we have
this thumbnail and course title aligned side by side and these contents are also looking good and this will be hidden in
phone screen and uh after that just come back and here we have this button tag so in this button also we will add some
classes so let's add the class name for this button and provide this padding then we will add the background blue 600
then we will add the text size and text color will be white so you can see this button is looking good correct after
that we have to add the progress bar in this one and with that we will add the value here in this completed section
right for that we will create one dummy data so we will come back here scroll up and uh here let's add con
and we will create the estate variable with the name progress array and the seter function name is set progress
array in this one we will add user State and uh we will initialize it with one aray and in this aray we will add some
dummy data right so let's add a space in this aray so initially we will add some dummy data and later we will
add the data from our database then we will build our back end so here let's add the data like this one we will add
multiple objects so let me add the first object and in this one here we will add lecture completed
and total lectures so suppose we have added the lecture two and total lecture is four then the progress were will move
to 50% right so like this we we have to add multiple object so let me add these
object in this progress are we have added the number of objects same as the number of courses that user has enrolled
right now after that we have to use this data here in this one where we are displaying
four out of 10 lectures right so instead of this manual value here we will add the data from that state
so let me remove it and here we will add cly Braes we will
add progress array and in this one we will add the index now we'll add the and
operator and here we will add back Tex and in this one we'll add the CES with dollar sign
now in this one we have to add progress array
index dot lecture completed correct after that we have to
add the forward slash and after this slash we will add the same thing so let me just copy
this and paste it here and instead of this lecture completed we will add total lectures like this after adding it if I
come back here that numbers are not displayed here so just come back here we have added
this square bracket let me remove it from here and we will remove it from end also like this so just connect this one
now save the changes and come back here so now you can see two out of four lectures here we have 1 out of five
lectures then three out of six lectures right here we have four out of four lectures correct now based on this data
we can update the button text suppose we have completed all four lectures then we'll display completed in this button
for that just come back and here we have this button text right so in this button text we will add
the data dynamically so here let's add a space and we will add
craes here also we will add this one Progress areay Index and operator then we will
add progress array index dot lecture completed divide by
Progress aray Index do total lectures and if it is equal to one right then what we will display we will
display the text completed and if it is not equal to one then we'll display ongoing so in this one we'll
add completed and remove this ongoing from here and add it here now save the changes and come back
to the web page so here you can see we have this ongoing ongoing ongoing and in this one where we have completed all
four lectures we have completed a status in this button correct now in this button we have to add the click
functionality so that when we click on this button it will open the player page where user can play that course right so
just come back and uh in this button we have to add the on click cck and in this on click we will add the navigate so
first we have to import the navigate from the context so here just add the comma and we will add
navigate so now we have this navigate from the context file and after that in this button we will add the onclick
property so here we have this button tag so here we will add on click and provide this Arrow
function and this function will execute this navigate function and in this navigate we have to provide the path of
our player page where user can watch the course so we will add slash
player and then slash and in this one we have to provide
the course ID so we will add course do code ID like this we have added this on click property after that save the
changes and come back to the web page if I click on this one you can see it is opening this player page correct and
click on this my enrollments so it will open this my enrollments page now we have to display one progress bar correct
to display the progress bar let's come back and uh if I open our package.json file here you can see we
have already installed the package RC progress right so using this progress package we will display a
progress bar so let me just come back here and in this one first we have to import it so here we will add
import and we will import line tag from from the package name that is RC progress so we have imported this
line tag now we will use this line tag to create our progress bar right so scroll
down and where we have this course title right so here it is after this course title that is in
the P tag here we will add one line tag now in this line tag we have to add
the a stroke width it will be two and then we have to add the percentage so let's add percent and in
this one for now let me add 50 and after that we will add some CSS properties so here we will add the class name and here
let's provide background that is gray 300 and rounded full after adding it if I come back here
here you can see all the progress bar is moving till 50% right because we have added the manual data 50% right but
instead of adding it manually we have to add it using our data that is displayed here right so
we will calculate the percentage according to the completed lecture and total number of lectures to calculate
that here in this percent let's write Progress aray Index and here we add if we have this
progress add index then in that case we will add bracket progress array index dot lecture completed then multiply by
100 then we have to divide it with progress array index dot total lectures so now we'll get the percentage
and if it is not available then we'll display zero or we have to move it
here like this so suppose we have this progress are a index then we will display the
percentage according to this data and if we don't have this progress add a index then we will display zero so it will
display 0% in the progress bar right after adding it let's come back to the web
page and here you can see this progress bar is looking good and it is displaying the actual value according to this
number of lectures correct so here we have completed all lectures so you can see
this progress part is moving till 100% right now in this page we have to add the footer also so just come
back and uh here before this closing fragment here we will add the footer so let's
add footer tag save the changes and now you can see on this page we have this putter also
correct so now we have completed this my enrollments page correct after that if I click on
this one so it will open this course page where user can watch the course so we have to design this page for that
let's come back and from this left side bar we will open this player. jsx that is the player
page here also you can see player page if I go to any code course click here so it will open this player page where user
can play that course so we will Design this page here in this player. jsx file in this page we have to create two
columns so in this div let's add one div that will be for the left column so let me write the comment
here this is for the left column now we'll create one copy of it and here we'll
write right column like this now we will wrap this entire div in a fragment so here we will
add this fragment and close it here so first we have this fragment then we have this div and in this one we have
left column and right column now for this D we will add some CSS properties so just add the class
name and here we will provide the padding for different screen size then we will add the flex Flex column reverse
then grid then grid columns two then Gap 10 and padding from xaxis after that we will come to the
left column so in this left column we have to add one text so let's add one text in h2 tag and here we will add the
text course structure right now for this one also we will add the class name and we will add the text size and font
weight now for the left column we will add the class name and here we have to change the text color that is text Gray
800 right now if I come back to the web page here you can see we have this text course structure so in this left side we
will display the course structure and in the right side user can play the video so just come back and in this left side
we have to display the course structure that we have already created in the previous page that is course Details
page so if I open this course details and here you can see we have created this course
structure right and after this title we have this div where we have added all the course structur code so we will copy
this entire div from here so just scroll down and it is closing here so from here we will copy this div and paste it in
our player. jsx file after this title so let's paste it
and from here we have to update some data so let me move it in the left side like this so let's check one by one here
we have added course data do course content so we will display this once we have the course data so first we need
the course data so here we will create one estate variable so before this return here we
need enrolled courses so we will get the enrolled courses from the context and with that let me import
the chapter time so we have created the function calculate chapter time and we will get it from use
context and in this one we will add the app context after that for this course we
need the course ID so if I come back here and in this URL you can see after this player path we have this ID so this
is the course ID so we will get it from the use padams so we will add const course ID and we will get it from
use padams so use pams has been imported from react router Dom after that we need the course data
so just add one state variable con course data and here we will add the setter function that
is set course data and we will create the user State variable and here we will add the
initial value null like this so we have to get the
individual course data so that we can play that course so to get the individual course data here we'll create
one function so here let's add const get course data equal to one addo
function and here we will use this estate enrolled courses and here we will add the map
method so in this one we'll create the arrow function and in this one we will get the individual course so let's add
course and we'll check with each course so here we'll add if statement and in this one let's write if the course
doore ID is same as this course ID it means we need the data of this particular course right so we
will set that course in this state so here we will use the set function set course data and provide this course now
we have to execute this function whenever the component gets loaded so here let's add the use
effect provide the arrow function and provide this function now here we will add the dependency areay
save the changes so now we have this course data right so here let's write this one in this curly reses we will add
course data and then we'll add the end operators so whenever we have the course data then only we will execute this one
so it will map the chapters right after that let's scroll down and uh here you can see we have this toggle section
right so it will open the chapter and display the lectures so we have to create this toggle section
function right for that here we need one state so just duplicate it and create the
state open sections and the seter function name is set open sections and here we will initialize it with empty
object like this and uh next we have to create that toggle function so we have already created it here so we will copy
from the course Details page and and just copy this one toggle sections and paste it
here like this next we need the one more state so here we will duplicate this one and we
will add the state variable name player data and the seter function name is set player data so using this we will play
the video in the right side so we will initialize it with null right after that let's check the
code again so here you can see we have this on click featured and we are adding toggle
section so now it is correct and if I scroll down here we have this calculate chapter
time so we have already imported it and after that here we have this chapter and chapter
content right so we are mapping the chapter that will display all the chapters so in this one we are
displaying this image that is the play icon so whenever the user played the video and completed this lecture then we
will display one check mark icon or tick icon so that we will get to know whether this chapter is completed or not so here
we will use the terity operator so here in this image
SRC let me remove this one and here for now let me add false right now I'm adding this false and later we will
update it when we will make the back end of our application so that we will get the actual data whether this lecture is
completed or not so here we will add question mark if it is false then we will
display assets dot Bluetick ion and here we will add assets
dot play icon after that we will come back to the web
page so you can see that course content is not displayed here so just come back and let's update other things here so
here we will scroll down and here you can see we have this lecture do is preview free right so
whenever the user enrolled to the course then they can watch all the lectures right so here instead of this preview we
will add watch and we will remove this one and instead of this is preview free we will
add lecture do lecture URL so when the lecture URL is available then user can watch that video
now in this we have this Setter function set player data right so we will update the data here so let me remove this
object and here we will add another object in this set player data and here we will update the
lecture then we'll add chapter and in this chapter we will add index +
1 then add comma and we'll update the lecture and in this lecture property we will
add I plus one now everything will be same and here you can see we are using this humanized
duration right so we have to import it for that we will scroll up and here let's
write import humanized duration and we will import it from the
package so let's write the package name humanized duration save the changes and if I come here still the course
structure is not displayed here so we will go to console and let's see we will open the
enrollments open this one yes now we have this course structure and if I open it
here we have this link watch right if I open this one here also we have this watch
link now let me go to my enrollments and open any other course so let's open the first one introduction to
JavaScript click on this button so now we have this course structure for this course and here we have this time and
this link watch right so we have created the left side of this player page now we'll add the right side but before that
if I refresh this web page you can see that a structure is hidden right so to fix it just come back here scroll up and
in this dependency array we will add enrolled courses after adding it you can see if I
refresh it still it is working right it works now let's add the content in the right side so just come
back here scroll down and here we have added the div for the right column so in this one we have to
add the course thumbnail so just add image SRC and in this one let's add CS we will add course data so when we have
this course data then we will add course data dot then course thumbnail and if we don't have the
course data in that case we will add empty string correct so after that you can see
we have this thumbnail in the right side but when we click on this watch link it should play the video instead of
displaying this thumbnail for that just come back and here in this div we will add
the curly bres and here we will add turn operator we will add player data so when we have the player data then we have to
display the video right so to display the video we will use this tag and uh after that we will add colum
and here we will move this after this image tag so what is happening here when we have this player data then we will
display one div like this and when we don't have the player data then we will display the
thumbnail correct so if I come back here and if I click on this one it should update the player
data and it should display the video here so just come back and here we have to use the YouTube tag so to use the
YouTube tag first we have to import it so here let's add import and let's add the cly addes here we will add import
and then we'll add YouTube and and we will import YouTube
from react YouTube Correct now we can use this tag so scroll down and uh within this div we will use
the YouTube tag and in this you T we have to add the same things that we have added in the
course details so in this course Details page we will come here here you can see we have added this
YouTube tag so just copy this one and paste it here in this player. jsx so in this we have added this video
ID and the video ID is player data dot lecture URL and then we'll add the
split and in this one just add the Slash and after that we'll add
dot pop method so in this one we have provided the video
URL and from this video URL we will extract the video ID and after that let me remove this
options and here we have to provide this iframe class name and in this iframe class name we have added width full
aspect video that's it and after that we have to display Place some other data also
below this video so we will add one div and in this div we have to add one P tag and in this P tag we will
display play data. Chapter do play dat. lecture and then we will display player data. lecture
title right after that we will display one button also so let's add the button and in this button we have to display
the button text either completed or Mark as complete so let me add the text here Mark as complete so just come back here
and if I click on this watch you can see it is playing this video here and below that we have this chapter name and then
we have the number right and then we have this link Mark complete so we will add the CSS properties for this one so
just come back and let's start with this div so in this one we will add the class name property
and we'll add the margin top for medium and above a screen size then we will add the CSS properties for this div so here
just add the class name and provide Flex justify between item Center and margin top after that we will add the CSS
properties in the button so in this button we will add the class name and provide text blue 600 right and in this
one also we have to add different text so for now we will add the false
here later we will update this logic when we will build the back end so here we will add if it is false then we will
add the text completed else we will add Mark
complete like this and uh after updating it if I come back here here you can see we have this chapter name or lecture
name in the left side and in the right side we have this text Mark complete and here we can play the video correct if I
click on the second one now we have this second video here if I click on this one now you can
see another video here and you you can see it is updating the numbers also so this is the second chapter and first
lecture if I click on the last one now you can see this is for the second chapter and second lecture
2.2 then we have the lecture title and Mark complete now in this page we have to add
the footer right so to add the footer we will come back here and scroll down and before closing
of this fragment we will add the footer component so just add footer like this so now you can see here
we have this footer so now on this player page that is the course play page we have to add the ratings also so that
user can rate this course right so we will add that rating in the left side so to add the rating just come back and uh
here we have the closing div for the left column right so before that here we will add one
div and in this one we will add one title in H1 so the title is rate this course and uh for this one we have to
add the CSS properties also so we will increase the text size so just add the class name and text Excel and font bold
now in this one we will add the class last name and here we will add the flex item Center Gap two and padding Y
and margin top if I come back here so you can see here we have this text rate this course
now to create the rating feature we will create a separate component so we have already created the file for that if I
come back to the sidebar and here you can see we have this rating. jsx so in this one we we will create our rating
component so in this rating component let me remove this title and here we have to create one aray so let's write
curly brushes and we'll add the aray Dot from now in this one we will add one object and in this object we
will add the length that is five after that we have to add one Arrow function so so let's
add the arrow function and in this parameter we will get underscore
comma Index right now in this function we will add one variable so just add const and
the variable name is a star value and it will be index + 1 like this after after that here we
will add return statement and we will return this bracket and in this one we will return
the asan tag now in this asan tag we have to add the key property so the key will be
index and within this asan we will add this HTML icon
code right right now for this a span tag we'll add some CSS properties also so we will add it in curly
bres and we will use the back tick so that we can insert the dynamic classes also so here let's
add text Excel then text 2 Xcel for a small and above a screen then cursor pointer
then transition colors and after that here we will add the dynamic class for
that we will use template literal so just add dollar sign curly bres and we will use this a value so if the value is
less than equal to what here we will add rating and for that we have to create one rating state right so before this
return statement let's write con rating and set rating equal to user
State and here we will add the initial rating or we will add the initial value
zero right so we will use this rating here so if the a start value is less than rating then what will happen we
have to display the icon in yellow color so here let's add question mark and we will add the class name text yellow
500 then we'll add the else condition and here we'll add gray color so just add text Gray
400 like this now we'll add one function that will handle the rating so to create that
function here let's write const and write the function name handle
rating and here we'll add the value and create this Arrow function here we will use this Setter
function set rating and here we have to provide value that we will pass in this function as parameter right and after
that we'll add if in this if we have to provide the rating value that user will rate on the
course so we will get it from the props so we will D structure it here so just add the cures and here we will D
structure the initial rating when we will call this component we have to provide the initial rating and with that
we will add the rating that user will provide so we will add that using this name on
rate so we will use it here if on rate is available then we will add on rate and
here we will add the value so we have created this function now we have to execute this function so just add use
effect hook and here we will add the Aro function and with that we will add the
dependency array now in this one we will add the if
statement and we will check if we have this initial rating so in that case here we will
add set rating and in this one just provide initial rating and in this dependency are also
we will add initial rating so that when the initial rating gets changed it will execute this
function and it will set the estate using the setter function this rating estate right now we have to link this
handle rating here on this aspan tag so in this aspan
tag let's write on click property and provide the arrow
function and just provide this function handle rating and in this one we'll add a start
value that's it so we have created this rating component now we will Mount this component on our player page so we will
open player. jsx and here after this title we have to mount the rating component so just
add rating and close this tag and in this one we have to provide the initial
rating so just add the props initial rating and the initial rating will
be zero like this save the changes and come back to the web
page so you can see here we have this rate this course and then we have this five stars in gray color and if I click
on the first one you can see it becomes yellow if I click on fourth one so up to four stars becomes yellow so this is how
we can enable this rating feature we will make it functional when we will create
our back end right so we have created this rating feature ourselves so we have not used the package that we have
already installed while creating the react application so you can see if I go to this package.json and here we have
installed this react Simple Start rating package right so we don't need this anymore we have not used it so we can
also remove it so we will come to this terminal press crl C then we will add npm
uninstall and provide the package name react Simple Start rating press
enter so now you can see that package has been removed from this dependencies right now let's run our project again
using npm run Dev so now project is running and you can see this course play page is working
fine here we can play the course and now we have this enrolled courses page then we have this homepage then we have this
all courses right and in this one we can search the individual course using any
keyword right so now we have completed the front end of our application where we have created all pages for the
students after creating all pages of a student now we will create the pages of educator dashboard so let's open the
figma design and here you can see these are the pages for educators this is the add course page and this one is students
enrolled page then we have this my courses and dashboard right so these are the pages for educator now on these
Pages you you can see we have to create the same navigation word then same left side word and at the bottom we have to
create same footer for all the pages right so we will create the component for footer navigation bar and this left
side bar so let's start with this navigation bar to create this navigation bar let me just come
back and in this left side bar we will go to this components in this components we
will go to educator then open navb bar. jsx and here we will add the elements for
educator Navar so in this one first we need some data from our assets so here let's add
import and we will import the dummy educator data and we will get it
from asset folder and and asset file after importing it next we need the user data and user button from Coler so
we will import it from color react using this import statement right now here we will add const and we will create one
variable called educator data and in this one we will store the imported data that is dummy educator data right after
that we have to get the user from this you use user right so here we'll add const user and we will get the user from
use user right now in this div we have to return the navigation bar so in this navigation bar we have to add one image
so for adding the image we will add the IMG tag and here we'll add the assets. logo right and then we'll add the alt
text and we'll add some CSS properties now we have to wrap this logo using the link tag so that we can click on this
logo so here we'll add the link tag and it will be imported from react router Dom now just close this link tag and uh
we will place this closing tag after this image and in this link We'll add the two property and here we have to
provide the path so when we click on the logo it should redirect us to homepage so we will add slash like this after
that here we have to display the users's name and profile icon and if the user is not logged in then we will display the
one user icon so here we'll add one div and in this div we have to add the user's name so here we'll add High then
we'll use this user data right so if we have the user we will display the user full name and if we don't have this user
we will simply display developers correct after that we have to display either profile icon or user icon so
again we will use this user suppose we have this user then we will display the user button component from cler so we
will display this one so it will add the users profile icon and if it is not available then we will simply provide
one image and in this image we will provide the profile
IMG like this save the changes after adding it we have to add some CSS properties in this div so here in this
div we will add class name and provide these classes corre after that here we have this pent
D so in this one also we will add some classes so here just add the class name and we will provide this class name
after adding it we have to mount this Navar component in the educator page right so from this left side bar we will
open this pages and go to educated and open this educated. jsx file correct now in this educated. jsx we have to place
our never so this never will be displayed in all pages of educat dashboard so we have
to place it here instead of this Title Here we will provide navbar and we will import this
naar from components educator naar correct don't import the student naar here we are importing the educator naar
after that we have to add some classes in the parent div so here we have this div in this one we will add these
classes after adding it if I come back here and go to educ app passw so here you can see we have this navigation bar
and in this navigation bar you can see this logo and in the right side we have the name and profile icon like this and
if I log out from here and now if I try to open this
educator here you can see we have one default profile icon and the name is high developer right and when we will
log in so go to educated dashboard now we have the name from the color data right
and then we have the profile icon and we can manage the profile right now we have to create the sidebar for the educator
dashboard so just come back and from this components we will open this sidebar. jsx now in this sidebar we have
to create some links so that we can click on that link to navigate to different pages like dashboard add
course my courses and a student enrolled right so just come back in this one we have to create some menu
so let's create one array and then we will map this array to create all menus right so here before this return let's
add one aray with the name menu items so you can see in this menu items we have added one are and in this are we have
multiple object and in each object we have the name path and icon so to create one menu we need the menu name then path
so that when we click on that menu we will be directed to this path after that we have to add the icon in each menu so
we have added total four object to create the four menu after that here we need one more
data that is stored in the context file so here we will use this is Educator data and we will import
it from use context and provide the app context correct after that we have to return the
sidebar and we will return the sidebar whenever this e educator is available so here after this return we will add is
Educator and and operator so whenever the is Educator is through then only we will return this div correct and in this
one we will add some CSS properties so here in this div we will provide this class name and add the CSS properties
after that we have to display the menu so we will use the curlys and here we will provide this menu items and on this
one we can use the map method correct and here we will add the arrow function and in this parameter we will get the
individual item right now here we have to provide the menu links that will be clickable so
here we will add the nav link tag we will get the naving tag from react router Dom and when we
are using the navlink tag we can use the two property and in this one we can get the active link also so
here let me close this tag like this so we have the nav link opening and closing tag and in this one we have to display
the menu item name and menu item icon so here we will add the icon using the IMG tag and after that we have to display
the name so here we'll display the name in P tag and here we have added some CSS properties so here we have added item.
name and item do icon correct after that we have to mount this one on this educated. jsx file correct so in
this educated. jsx file after this nav we have this div right so in this D we will add some classes and here we will
provide flex and in this one you can see we have added
this Outlet so before this Outlet we will Mount this sidebar so you can see this sidebar has been imported now just
close this tag and then we have this Outlet right so let me wrap this Outlet also in a div so here we will add one
div and uh close it after this outlet and here we will add the class name and we will provide Flex
one so in the left side we will get the sidebar and in the right side we will get the other component and it will use
the entire space available in the row because we have added the flex one correct now just come
back and here if iess it we have some is so just check it and if I go to console you can see we have the is assets is not
defined so just come back and here we have to import the assets also because in this sidebar you can see we are using
this assets right so we have to import the assets from assets folder and asset file so we have imported the assets save
the changes and come back so now you can see here we have this left side bar but that menu items are not visible
so we will come back and here in this nav link tag we have to add some properties so here
first we will add the two then key and then we will add the end so here we will add two item. path then key item. name
then we will add the end that is item. path equal to educator we are adding the end property for dashboard link here you
can see in this addo function we are returning this C so instead of this one we'll add a small
braet and here also we will update small braet that's it after adding it if I save the changes and come back to the
web page now you can see we have all these icons and menu links correct and we can click on this one to
navigate to different pages if I click on ADD course you can see in this URL we are at the/ educator / add course and
here you can see the text add course correct if I click on dashboard now we are on the
educator right and if I come back to the homepage and click here it will open this educator page now we will add the
CSS properties for this menu links so just come back and uh here in this nav link we will add some CS properties so
here let's add the class name and we will add the cly Braes and here we will add one Aro
function and in this one we will get the parameter and here we will add this is
active so whenever we will click on any menu link then that menu link will be active right so whenever the active is
present we will add different class name and when the active is not available then we will provide different class
name so here we'll add the common class name first so we'll add the back Tex and in this back Tex let's add these classes
so here we have provided this delant classes after adding it save the changes and come back here so you
can see these alignments are looking good and if I click on anyone you can see we have no changes in the navigation
menu in the left side bar right so we have to add some changes when we open any particular page so just come back
and here we'll add this is active so here we'll add the template little we will add dollar and calies is
active correct so when this is active is true then we will provide these classes this one after that we'll add
the column and here we have to provide another class name when is active is false so we have provided this class
name so you can see here we have used this tary operator after adding it if I save the changes and here you can see
when we click on my courses it becomes blue in background if I click on this one you can see the background color is
changing if I click on dashboard now you can see the background color here and in the right side we have this color so you
can see the difference in active and inactive pages right so you will come to know which page is open now we have to
add the footer in the educator dashboard so we will come back here and we will open this
educator then footer. jsx and here we will create the footer for the educator dasboard so here we will use the footer
component in of this T so we will add footer and in this one we'll add some
CSS properties so we will add the class name and provide this Telvin classes now in this one we have to add the left
column and right column correct so in the left column we will add one div and here we
will add one image using this IMG tag and we will provide the logo using assets. logo after that we have added
one div and using this we are adding the background color and after that we have this P tag
and in this P tag we have added this copyright message so this is for the left side of
the footer after that we'll add the content in the right side so here we'll add another D and in this one we have to
add some menu links so we will add the a tag so here we have added total three a tag and
in this one we have added the images right so here we have provided the assets. Facebook icon Twitter icon and
Instagram icon correct after that we have to add the CSS properties for the left column and right column so here in
this right d we will add the class name this one and in the first div that is the left div we
will add the class name Flex item Center and GAP four like this now save the changes and come
back to the web page but before that we have to mount this footer component in the educator. jsx so in this educated.
jsx here you can see we have this closing div tag so before that here we will
provide footer and we will import the footer from educator you can see the footer has been imported from components
educator footer close this tag and come back to the web page this page is not responding so let me just come back
here we have added capital F so let me make it small footer and here also small
footer save the changes refresh again now if I scroll down here you can see we have this footer at the bottom so now in
the educator section we have added the navigation bar sidebar and this footer after that if I come back to the figma
design so here you can see this is the dashboard page of educator where educator can see the total earnings
total courses and total earning then they can see the latest students enrolled data so to create this
dashboard page we will come back to the vs code and from here we will open this pages and go to educator then
open dashboard. jsx correct now in this one we need the state variable where we will store
the dashboard data so here before this return statement we will add one State variable with the name dashboard data
and the set function name is set dashboard data and we will initialize the user State value with null and we
have to import this user state so user state has been imported from react correct now in this one we need the
currency also and we have declared the currency in context file so here we will import the currency from use context so
import this use context and provide the app context so now we have the currency and we have
the estate to store the dashboard data now in this state we have to store the data right so to store the data we will
create one function so here we will create one function with the name f dashbo data it will be asynchronous
function and in this one we will just call this Setter function set dashboard data and in this one we will provide
this dummy data that is available in the assets so we will import this dummy data from assets folder and asset file
correct next we have to execute this function whenever this component gets loaded so here we will add the use
effect so here just add the use effect and provide this function and in this one simply call this PCH dashboard data
and we will import this use effect also so use effect has been imported here correct after that here we have the
return statement correct so in this return first we will check when we have this dashboard data
avev then we will return this bracket and in this one we will return this div correct
and if it is not available here we will add colum and simply we will provide loading component so just add
loading the loading suggestion is not coming so we will open this loading component
here from this students and loading now just come back here and if I type loading so now we are getting this s for
Lo loading component so close this tag and you can see this loading component has been imported correct so what is
happening here if the dashboard data is available then it will return this div and if it is not available then it will
return this loading component right after that in this one here we have this div so let me remove this text from here
and in this div we will add some classes and provide the CSS properties so in this we will provide this class name and
provided this tement class after that we will add another D and in this one we have to add the
space so just add the class name and provide a space y5 like this now in this one we have to
create the row for the dashboard data as you can see here we have three columns so we will create one div that will be
row and in that one we will create three columns so here we will create one div and for this one we will provide the
classes so it will align the child div in columns right after that let's create the First Column so we will create one
div and in this one we will add these data so you can see in this div we have added one image and here we have added
the patients icon so first we will import this assets right so in this D we have added the image tag and provided
the patient icon after that we have one div and in this one we are getting the dashboard data and from this dashboard
data we will add the enrolled student data and find the length so we will get the total number of enrolled
student and here we will display the text total enrollments like this we will create two other columns also so we will
duplicate this one for two times and we will change the content so in the second one you can see
we have added assets. appointments icon then dashboard data do total courses and here we have the text total courses
after that in the third column we will provide the content so here I have provided assets. earning icon then
currency that we have already imported after that we have the dashboard data then total earnings and here we have the
text total earnings correct after adding it now we will come back to the web page so here you can see the dashboard data
is not displaying so to fix it we will come back here and from this left side but we will open app.jsx and in this
nested routes you can see we have added route path educator so here we have to provide slash just add it save the
changes and come back to the web page now you can see when we go to Local Host 5173 educator it is
displaying the Educator's data right and if I click here it will open this add course and if I click on dashboard it
will open this educator data page right so just come back and now we will add the other details in this dashboard so
again we'll open the dashboard. jsx file so in this dashboard. jsx file you can see here we have
added this div for the row and after that here we will add the space correct and here we will add the data that will
display the enrolled students for that here we will create another div in this one we have to add the title
so we will add the title latest enrollments and we have added the classes in this title that is written in
the h2 tag after that we have to display the data in a table so we will create One D and here we will add the CSS
properties so we will provide the class name and provide these tement classes after that we will use the table tag to
create the table so let me create one table here so here we have added one table tag
and provided these classes then we have the table head where we will display the table heading text so in the heading we
will display hashtag then a student name and course title and provided the CSS properties after that we will add the
table body and in this table body we have to display the data like number that will be displayed in hashtag column
then we will display the students name and course title so to get the data here we are using
this dashboard data right so we will use it here dasboard data and in this one we will find the enrolled students data and
this is an array so we can use the map method and in this map method we have provided one Arrow function where we are
getting the items in getting the index then we will display the data in table row so we have
added the TR tag and in this table row we will add the table data using the TD tag so in the first one we have to
display the number so we will use this index and the index start from zero so we will use index + 1 so it will start
the number from 1 2 3 like that and after that we have added the table data where we will display the student image
right so here we have added item a student. image and after that we have to display the a student's name so we have
used the aspan tag and in this aspan tag we have displayed the user's name that is the student name after that in the
third data of the table we will display the course title after adding it if I come back to the web page again so here
you can see we have these data in the educator dashboard correct so after completing this educator dashboard page
we will create this my courses page right so here we will display the all courses published by this particular
educator to create that we will come back to the vs code here we will open this left side
bar and from here we will open pages educator and my courses now in this one we have to
display all courses of particular educator so we have to get the courses from our context file so here before
this return we will add const and we will get the currency from the context and we will also get all
courses from Context file so here we have the currency and all courses and we will get it from Context so just add the
use context and app context after that we will create one state variable where we will store the coures so here we have
created one coures state and the set function name is set courses and we have initialized it with value
null after that we will create one function that will Fitch all the courses right so here we have created this
function with the name Fitch educator courses and in this one we have provided all courses that we are getting from the
app context using this Setter function correct so next we have to execute this function whenever the component gets
loaded for that we'll add the use effect hook and and in this one we will add the F educator courses function so this
function will be executed whenever our component gets loaded after that we have to display the
data through this return statement right so here we will return the div whenever we have the ches right
so here we will use the trary operator and write ches so when we have the course state that is here right when we
have this course say State then we will return this div and if it is not available then we will simply return the
loading component so here we'll add loading like
this after that we have to display the courses data within this div so first we'll display one title in a div so here
let's add one div and in this one we will display one title called my courses so we will add the title in h2
tag and here we have added these CSS properties right and for this D we will add the class name and provide width
full after that here we have just c d so in this one we'll add the class name and we will provide the
classes this one after adding it if I come back to the web page here we have added this use effect
so we have to import this use effect from react so just click here so you can see use effect has been imported save
the changes and come back to the web page so now you can see in the left side we have these menu items and here we
have the title my courses that we have added here right after that we have to display
the table so we will display the table in a div and in this div we will add the table like this and in this table we
will add the table head right so here we will add this table head and in this one we have added these table row and table
heading text that is all course say earnings students and published on correct now we'll add the CSS properties
for these div so in this one we have added this class name and after that in this table we will
add this class name correct after adding it if I come back here you can see here we have the
table headings with all courses earning students and published on now we have to display the course data so in the first
one we will display the course thumbnail and name then we will display the earning then students and published on
data right so just come back and here after this table head we have to display the table
body in this table body we will display the table data using this courses right so here we have added the table body and
provided this class name and then we have this coures state and this will be one are so we have used the map method
and in this one we will get individual ual course right so from this individual course we will get the ID that will be
added in this table row and then we have the table data so in the first one we have to display the thumbnail so we are
getting the thumbnail using course. course thumbnail then we have to display the course title so here we are using
course. course title and we have provided these relevant classes after that in the second one you can see we
are displaying the currency that we have already imported from Context after that we have to display the earning so here
we have we have added the number of our students then we have added the price and we have multiplied it correct after
that we have to display the enrolled students so here we have added enrolled students. length so it will display
total number of enrolled student for the individual course after that we have added the date so it will display the
date when the course was published so after adding it if I come back here you can see here we have all the data like
thumbnail course title earning total number of student enrolled and course published date so we have created this
my courses page after that we will create another page that is enrolled students where educator can see all the
enrolled students for their courses so to create this let's come back to the figma design and here you can
see this is my courses that we have already created and after that here we have a student enrolled
page so here also we have to display one table where we will add the table heading hashtag a student name course
title and date then we will display the data so to create this one we will come back and from this left side word we
will open a student a students enroll. jsx file and in this one first we have to
get the a student data from our assets so here let's import the dummy student enroll data dat from asset
we have added this import statement right after that here we will create one function that will fetch the data from
this dummy student enrolled right so here let's add the function but before that we will create one a state where we
will store the data right so here we will add the state variable en students and the set of function name is set
enrolled students and we have initialized it with null and here we have used the user state so we will
import this user state from react after that we will create the function that will fetch and store the data in this
state so here we have added this fetch enrolled students function and here we have used this set function set enrolled
students and provided this dummy student enrolled next we have to execute this function whenever the component gets
loaded so for that here we have created this use effect and in this one we have called this function and next we have to
import this use effect so just click on the suggestion so use effect has been imported correct now we have to display
the data on web page but we will display the data whenever we have this enrolled a students data so here we'll add the
turn operator so after this return We'll add enrolled students and when it is available we
will return this div and if it is not available here we will add the colum and provide the loading component
like this after that from here we will remove this title and in this one we will display
the table in a div and in this one we have to add the table tag in this one we'll add the
table heading like this after that let's provide the CSS properties for all these div so in this first one we'll add the
CSS properties after that in the second div we will add these tnd
classes and in this table we will add this telin classes and here we have added the telin classes for
the table head and table heading data so after adding it if I come back to the web page and open this a student
enrolled page so here you can see we have this table heading correct next we have to display the data in table body
so we will come back and after closing of this table head we will add the T body and in this one we
will get the data from this estate that is enrolled students right so we will add this enrolled students here and in
this one we will use the map method so here we will add the C and provide this enroll. students. map so in this one
we'll get the individual a student and then we'll add the index in the parameter after that we will return the
table row where we will add the key index and to provided this classes after that in this table data first we have to
display the number so we will add the number using this index so the index start from zero that's why we will add
index + one after that we will add the student image and name so we will add the TD tag and here we have added the
image using the IMG tag and here we are adding this item student. image URL then we have added this a student name then
we have added the course title then we have added the date so after adding it next we have to add the CSS properties
in this table body right so here we will add the class name and provide these tent
classes after adding it just save the changes and come back to the web page so now you can see here we have the data of
a students enrolled for this educator course so here we have the a student profile image name then course title and
enrollment date correct after creating the student enrolled page my courses page and dashboard page we will create
this page add courses from where Educators can publish their new course so let me just come back to the figma
design and here you can see this is the UI design for our add course page so to create this one let's come back to the
vs code and from here we will open this sidebar and open this ad course. jsx file in this ad. jsx this file first we
have to import the unique ID and quill from the packages right so we will use the import statement and here we have
imported unique ID from unique ID package so that we can add a unique ID for each courses right next we have to
add the rich text in the course description so here we will import this quill from Quil so that we can write the
rich text it means the formated text in the course description after that we have to add the use ref so
before the return statement we will add con Quil re is equal to use ref and null we will import this use ref from react
now we will duplicate it and here we will add one more reference variable that is editor ref so that we can add
this edited ref in a HTML element and where we will add the course description correct now in this one we have to
create one form and from that form we will get different data like course title price discount image chapters
right so to store all these things we will create some State variable so here let me create the state
variables course title and the setter function name is set course title and initialize it with empty a string we
will import the user State also so user state has been imported from react then we have added the another state variable
course price then discount image chapters correct after that we will use the popups to add the lectures in the
course so to add the lectures and chapter we will add the popup for that also we will add one state variable so
here we will add cost so popup and set so popup so by default it will be false so initially the popup will be hidden
and when we enable the popup we can add the lectures detail after that we'll add the state variable where we'll add the
chapter ID so just add con current chapter ID and Set current chapter ID correct after that we will add one more
State variable where we will store the lectures details for each chapter so here we have added lecture details and
Setter function is set lecture details then we have added the use state now we will initialize it with object and in
this object we will add these properties that is lecture title so for the each lecture we need the lecture title
duration then lecture URL and then we'll add each preview free so if it is false then it won't be available for free
preview and if it is true user can preview this video for free without purchasing the course so we have added
these stage variables right after that we have to add one use effect so here we will
add use effect and in this one we have to add the add function and here we will add this
statement so it will check if the Quil ref do current is false and when we have the edited ref do current available then
in this Quil ri. current we will assign this new Quil editor ri. current and we will set the theme snow so that in the
editor ref element we can add the rich text and here we have to add the dependency areay that is empty
areay like this so here let me add the comment also we will add initiate Quil only once after that we will create one
form inside this div so first in this div we will add the Telvin classes so we will add these telin classes and after
that remove this title from here and here we will add the form tag and in this form tag first we have to add the
title and one input field so just add the text course title then we have the input field and in this one we have
added the onchange property and in this on change we have added set course title and provided e. target. Val so that if I
type anything in this input field that data will be stored in the course title State and here we have added the value
property also and provided these classes and this field will be required to submit the form so we have added the
first input field and one title for that after that we will add one more input field so here we will
add another div with the class name then the title is course description and here we have added one div and in this div
you can see we have added editor ref right so in this div we can add the text and we can format the text so if I save
the changes and come back to the web page here we have this course title input
field but this course description input field is not working so here we are using the quill package so we will come
to quilljs Doc and here go to documentation and go to installation scroll down and here you will find this
npm and here we have the steps to install it and we can create a new quill so we have already done this and after
that we have to add the CSS link right so we have to import the CSS from this screen so just copy this one and come
back to the vs code and we will open our app.jsx file and in this one we have to just import
the Quil CSS here in this import statement you can see we have this quill code. CSS so instead of this code we are
using the snow theme so here we'll add snow save the changes and let's come back to the web page so now you can see
we have this course description input field and in this input field we can write the formated text so let me write
JavaScript so we can format it like this we can use the heading one we can use the heading three like this we can
select normal text let me duplicate it and we can select it and we can use the ordered list or we can use the
unordered list we can add the Bold text by selecting here we can make it world we can make it italic right we can add
the underline right and we can also add the links so this is how we can add the
formated text in the course description after creting the course title and description field we will come back and
let's open our add course. jsx file and in this one after creating this two input field we will create the input
field for the course price and we'll add the input field for the course thumbnail right
and before that let me add the CSS properties in this form tag so here we'll add this class name like this and
here we will add one div and in this div we will add the two columns so here you can see we have
added this div and in this div this is the first column in this div we have added the flex item Center justify
between Flex lab so the content inside this di will be aligned side by side so this this is the First Column and in the
left side we have added the course price and then we have the input field in this input field we have added the onchange
property and provided the set function set course price so whatever price we will enter in this input field that will
be stored in the course price State using this e. target. value then we have the value property and here the input
type is number then we have added the placeholder so it is zero and then we have added the tmin classes and it is
required after that in the right side we will display one icon using that we can up the course image or course thumbnail
so in this div we have added the CSS properties then we have added the course thumbnail then we have the label tag and
in this one we have added this image right and in this image we have this input tag so here we have added the type
file so that we can upload a file using this input field then here we have added the ID thumbnail and here also we have
used this thumbnail in HTML for for this label tag so that when we click on the label tag it will open
the window to upload a file then we have added the onchange property that will store this file in this image state
after that we have this image so using this image we will display the uploaded image at this
place after that you can see we are using this assets so first we have to import the assets so just select on this
suggestion so assets has been imported after that we will come back to the web page so here you can see we have this
course price input field then we have this course thumbnail correct next we will add the input field
for the course discount so just come back and uh before this form tag we will add one
div so in this div you can see we have added the CSS properties then we have added the text in P tag discount perc
after that we have the input field with onchange property that will store the data in this discount State and after
that here we have added the minimum and maximum value 0 to 100 then placeholder is zero and then we have added the CSS
class name for this input field after adding it if I come back here you can see here we have this discount input
field correct next we have to display the chapters added here and we will also display a button using that we can add
the chapters right so the chapter state is an aray so we can use the math method so here let's add one comment so we will
add the comment adding chapters and lectures so so here we will add one div and in this
div we will display the chapters using the chapters estate and here we will add the map
method and let's create one addo function and in this Aro function we will return this small
bracket here we will add this bracket also now in this one we have to display One
D so in this D we will add the key property that will be chapter index that we are getting from this parameter
after that in this one we have to add some CSS class name so we will add this class name property and provide these
tan classes correct now here we have to add one more D and in this one we will add these
class name next we have to add the icon that will be down arrow icon
and we can also rotate this one right and with that icon we will dis play the number that will be chapter number like
1 two right and then we'll display the chapter title also so we will group all those things in a
d and for this one we will add the classes so just add the class name property and provide these classes and
here first we'll display the icon so we will use the image tag in this image SRC we will add the image from the assets
file so just add cly bres assets Dot and here we will display the drop down icon correct after that we will add the width
so here we will add this width for this image and after this image we have to display the chapter
number and chapter title so we will add the a span tag and in this one you can see we have added this font semi bold
then added this chapter index + one then we'll add chapter dot chapter title so we will add the drop- down icon then
number and chapter title now here in this image also we will add the class name
property and here we will add the classes so we will add the cly places and then write back tick so we can use
the template lital here now in this one we will add this one we will add the delant classes after that we'll add the
template literal and here we have added chapter do collapsed so if the chapter do collapsed is true then we will add
this Telvin classes that is rotate 90 so it will rotate the icon whenever the chapter is collapsed after adding it if
I come back here it should display the chapter but right now we have not added any chapter right so whenever we will
add the chapter that will be displayed here so after this div here we will add the asan tag and in this aspan tag we
have to display the total number of lectures available in this chapter so we will add this chapter
do chapter content. length then lectures and in this one we'll add some classes so we will add text gr
500 correct after this asan tag we have to display one cross icon in the right side so here we will add the IMG tag so
in this cross icon we will add the functionality that will remove the chapters right so so first we will add
the CSS properties in this one so we will add this class name and provide cursor pointer after that we have to add
the cross icon in this SRC so we have added cross icon and then save the changes after adding this image here we
have this div that is closing div tag so here we have to display the lectures available in this chapter whenever it is
not collapsed so here we will add the curly bres and we will check if it is not collapsed then
we will return this bracket and in this one we will display a d where we will display
the lectures right so here we will add this class name and in this one we will display the lectures so we will get the
lectures from where we will get it from chapter only so we will add the curly veres chapter dot chapter content and we
will use the map method now in this one we will create Arrow function and in this function
parameter we will get lecture and lecture index and here we will return one
div so in this div we need the key property so here we will use the key and we will add the lecture index and we
will also add the class name property and provide these classes right so in this one we have to
display the lecture number then lecture title and after that we will display the lecture duration in minutes then we will
add the lecture link and after that we will add the text whether this lecture is available for free preview or it is
paid so to display that here we will add the aspan tag and in this aspan tag we will
add the curly bres and provide lecture index + one then lecture do lecture title then lecture duration
in minutes then we'll add the link tag so we are using the a tag for link and in this one we'll add lecture. lecture
URL after that we will add this terity operator and we are checking if this preview is true then we will add
free preview and if it is false then we'll add the text called paid like this after that we have to add
one icon also so we will use this icon to remove this lecture so we will add the image tag and here we will add the
class name so we will add class name property and provide cursor pointer and in this one we have
to add the cross icon so we will add this assets. cross icon so we have added the div that will
display the chapter and lectures after that we have to add one button that we will use to add a new lecture so after
adding this cross icon we have this closing div tag then we have this closing cly Braes so here we will add
one div and in this div we have to add the text called add lecture correct so in this
one we'll add some CSS properties so let's add the class name and read these telling classes correct
next we have to add one button that will add a new chapter so here you can see we have this small
bracket and curly bres and here we will add one D and in this one we will add the text called add chapter here we have
added the button text add lecture and here we have this text add chapter and in this one also add the class name and
we'll add these classes correct after that we have to add add one div that will add
the lecture detail right so we will add this as a popup right and it will be displayed whenever the so popup estate
is true so for that here after closing of this div we will add one
craes and we will add so popup so whenever this so popup is true then only we will display this
div right in this div we will add some classes so we will add the class name and provide these telin classes after
that we will add another div and here also we will add some telin classes so we have provided these
classes after that in this one we have to add one title so we will add the title in S2 tag and this is the title
add lecture right and after this title we have to different input field with the title so here we have added one div
you can see in this div we have added margin from bottom and then we have added one text in P tag that is lecture
title then we have the input field and in this input field we have added the type text then provided some classes and
then we will add the onchange property and this will store the input field data in the lecture details state
right and here we have added the value property also so similarly we will add other data so let me just duplicate
it and here we will update the content so in this one we have to add the dur so let me update all the content here and
here we have added duration in minutes then we have this input field where the type is numbered and we have added this
C function that will update the lecture duration correct now we'll add one more
div so here we'll add this space and here let's add another div where we will add the
text lecture URL and with this lecture URL we will add the input field where we can paste the lecture URL right and
after that here we will add another div where we will add the checkbox so just add one text is preview free and here we
have the input type checkbox correct and here we have the set function that will set this each freev view property either
true or false right now in this one we have to add one button also so after that here
we will add the button and in this button we will add the button text that is ADD so it will add the
individual lecture correct and here we'll add the button type so the type will be button and then we'll add the
class name and provided these classes after that we have to add one image using that we can remove the
lecture after this button tag will add the image using that we will close the popup so we have added this image tag in
this one you can see we have added the on property set so popup false so it will hide the popup and here we have
added the cross icon and provided these classes correct after that here you can see we have this closing form tag so
before that we we have to add one button also so after this closing div here we will add one button tag and the type is
submit and here we have added these classes and in this one we have added the text add so it will add one button
using that we can submit the form so here you can see we have the button to add a chapter and here we have
the button to submit this form right now we have to add the functionality on this add chapter button correct so for that
we'll add the functions so let me see where we have added this
button here you can see we have this add chapter button right so in this one we have to add one on click property so
let's add on click and provide the Aro function and in this Aro function we have to provide
one function so in this AR function we have added one handle chapter function and provided this parameter
add right so next we have to declare this function that is handle chapter for that
we will scroll up and uh here we will create that handle chapter
function so you can see here we have added this function handle chapter and in this parameter we are getting the
ation and we are getting the chapter ID right and here we will check if the ation is ADD then what will happen we
will open a prompt and the text is enter chapter name so we will add the chapter name right now when we have the chapter
title that is getting from the prompt so when we get the title we will create this object that is new chapter and in
this new chapter we will add one ID that is unique ID correct after that we will add the chapter title chapter content
collapsed will be false so default it will be open and when we toggle it it will collapse this and hide the lectures
inside this chapter then we have the chapter orders and in this chapter order we have added chapter length greater
than Z then chapters do slice minus one index0 dot chapter order + 1 hence it will be
one then we are using this set function set chapters and in this one we will provide our chapters and added our new
chapter that is created here now if this ation is something else so instead of add if the action is
remove then we have to remove that chapter so here we will add this seter function set chapters and in this one we
will add the filter and provide the chapter and here we will check if the chapter ID does not match with this
chapter ID then we will filter that after that here we will add another LC statement and we'll check the action
if the action is toggled so instead of add and remove the action is toggled then what we have to do we have to
toggle the chapter content so it will hide and display the lectures inside that chapter so here you can see we have
added this chapter. chapter ID and in this one we will find this collapsed and here we will add not of chapter.
collapsed so whenever the chapter collapsed is false so it will become true and whenever it is true it will
become false so after adding it if I come back here click on this one so you can see it is
opening this prompt and here if I write the chapter name like introduction click on okay so you can
see this introduction chapter name has been added here and with that here we have this chapter number one and in this
chapter we have total zero lectures right and here we have the cross icon to remove this chapter and here we have the
button to add a new lecture in this particular chapter and here we have this drop down icon if I click here it should
collapse it right so for that we'll add the on click property on this cross icon so to hide this chapter and we'll add
the on click property on this drop down icon also and then we'll add the on click property on this add lecture so
that we can add a new lecture in this chapter so just come back and here this is the function to add the chapter so
after that we have to add one fun add the lectures so here before this use effect we will add one function to add
lecture so here we will add handle lectur and in this one we'll get ation chapter ID and lecture index and here we
will check if the action is ADD then we will add this set function Set current chapter ID and provide the ID then we'll
add set so popup so it will open the popup after that we will add as if and if the acction is removed then we have
to remove the lecture right so to remove the lecture here we are using this map and in this one we will add chapter.
chapter ID equal to chapter ID then in this one we will provide chapter. chapter content do splice here we will
add lecture index comma 1 and it will return the chapter so after creating this handle
lecture we have to link it with our HTML elements and just copy this function handle lecture and scroll down so in
this form here we have added this div to map the chapters then we have this div where we will display the
lectures right so in this one you can see we have this function add lecture so so in this D you can see we have this
button add lecture so in this one we will add the on property we will add on click and we
will provide the arrow function and here we will call this handle lecture function and in this one
we will add the parameter add after that we will add one more parameter so here we will
add chapter do chapter ID in this parameter after that we have to link it here with this cross icon so that we can
use this function to remove the lecture so let me see where it is here we have the
image right so in this image we will add the on click property and uh in this on
click we will add the Aro function and here we will add the same function that is handle
lecture after that here we have to add the parameter so in the parameter we will add remove and with that we will
add one more parameter that is chapter do chapter ID after that we will add one more
parameter that is lecture index like this after adding it we will come back here and now you can see if I
click on this add lecture button it will open this popup right and if I click on this cross icon it will hide it if I
click again it will open it and if I click here it will hide it right now we will add the click functionality on this
cross icon and this drop down icon so just come back SC scroll up and here you can see we have this cross icon right so
on this one also we will add the Handler function so here we will add on click property in this
image and provide on click and here we have the handle chapter and it will remove the chapter so we have provided
the parameter remove then we have to provide the chapter ID using chapter. chapter ID right next we have to add the
on click property on the drop- down icon right so that we can toggle the content so here we have the image so in this one
we'll add on click handle chapter and provide the parameter toggle and provide the
chapter ID right after adding it if I come back here you can see if I click on this one
we can collapse and display the lectures inside this chapter right and if I click on this
cross icon it will remove it and if I click on this Plus add chapter it will open
this prompt and ask the chapter title we will add the chapter title introduction click okay then click on this add
lecture button so that we can enter the lecture details like lecture title duration lecture URL and this one next
we have to add the functionality for this add button so that this lecture will be added right so let's create the
function for that we will come back scroll up and here before this use effect we
will add one function that will add the lecture so here we have added this function you
can see the function name is ADD lecture and in this one we will use this Setter function set chapters so in this one we
will add if the chapter do chapter ID is equal to content chapter ID then we will create a new lecture and in this one we
will provide these data right after that we will push this new lecture in the chapter contain and return
[Music] to and provide these EMP strings and false correct next we have to add one
more function that is the form Handler function so here we'll add handle submit and it will be as
synchronous function and we have added e do prevent default and we have to link this with our form tag so here we have
this form tag and in this one we'll add on click and provide the function that is
handle submit like this and after that we have to link that function in the add button
so let's see where we have the add button for the lectures so it will be in this popup right so in this popup uh
let's see where we have this add button so it is here so in this add button we have to add the on click property
and uh we will add the function that is ADD lecture so just add on click and function name is ADD
lectur that's it save the changes now just come back to the web page and if I click here click on
lecture title lecture title is what is JS duration is 30 minutes then we will add any
URL then select this is preview free if I click on this check box it is not working right so to fix it we will come
back to the vs code and here you can see we have added the
form tag and in this form tag by mistake we have added on click so here we have to add on submit so whenever we will
submit the form then only this handle submit function will be executed so just correct this it will be on submit and
come back here now you can see if I click here we can check or uncheck this checkbox now if I click on the add
button so you can see this first lecture has been added correct now let me add the another lecture so let me add the
lecture title then duration and Link greatest st.dev click add so you can see here we
have the free preview and in the other one we have paid and we can use this cross icon to remove this particular
lecture and if I want to remove the entire lecture we can click on this cross icon and here we can collapse it
so here we have the two lectures in this chapter we can see and collapse it and we can add the another chapter using
this button right so now we have completed our add course page my dashboard my courses and my students
enrolled pages right and we have also completed the homepage and a student page where a student can see the
enrolled courses and this course description page and all courses page so finally we have completed the front end
of our LMS project now we will create the back end where we will create the apis to create the back end we will come
back to the vs code and we will close all these files so right click here and
select close saved now in this left side bar you can see we have created this client folder
in this LMS folder we have to create one more folder so first click on this LMS then click on create new folder and here
we will write the folder name server So In This Server folder we will create the back end of our LMS project
so in This Server folder we will create a new file and write the file name server.js after that we have to open the
integrated terminal in This Server folder so right click on this server folder and select open in integrated
terminal so in this terminal you can see the path we are at the LMS folder then server folder correct now here we have
to initialize the npm package so here we will add the
npm in it and write y so we have added npm in it- y press enter after that you will see this
package.json file in the left side bar if I open it you can see here we have this package.json file where you can see
this script taste and a start and here we have the name that is server right now
we have to add some packages in our backend project that we will be using to create our back end so let's come back
to the terminal again and in this one we have to install the Express package so that we can create
our backend application so here we'll add npm
install and write the package name Express after that we have to add the node Monon package using the node modon
package we will restart the backend server whenever we will make any changes in the code code file so we will
add node modon and after that we will install another package that is EnV using this package we can use the
environment variables in our project after that we will add C using this course we can connect our back end with
any other domain after that we will add the cloud NY because we will store the images on cloud NY storage so we will
add Cloud NY and after that we will connect the project with the mongod DB database for that we will use this
Mongo's package next we have to install the images so we will use this multer package using that we can upload the
images after that in this project we have to add the stripe payment Gateway so here we will add the package stripe
after that we have to add the B Hooks and to manage the B hooks we will use the SX package and here we will add the
version of of this SX that is 1. 42.0 next we have to install the color
for the express so just add at theate Coler SL Express so that we can use the colored
web hooks in our backend project after adding all these packages press enter so it will start installing all these
packages after completing this installation if I open the sidebar so here in this server
folder you can see we have this nodecore modules folder where we have all the packages and if I come to package.json
here you can see we have this dependencies and in this dependencies we have all the packages that we have
installed right now here you can see we have the test script we don't need it we will remove it and here we will add a
new script so here let me just copy the same that is start node server.js and here we will add
server so we have added the a script name server and instead of this node we will use node Monon that we have
installed right so we will use this node Monon here so whenever we will write npm run a start it will execute this command
node server.js so it will start the project right but whenever we make any changes in the code file then we have to
restart the project for that we are going to use this script server that will execute this nodemon server.js so
that when we make any changes in the code file it will automatically restart our
project now before this script we have to add one more property so here let's add
type and in this type will add module so that we can use the Import and Export a statement in our
project right so after adding this type module now just close this file and we will open server.js file and here we
will create a basic Express server so to create the express server first we have to
import Express from Express package correct and after
that we will import course from course
package next we will import EnV SL
config so that we can use the involment variables right after that we have to initialize the express application so
first we will add this comment initialize Express and here we will add const and write the app name that is app
and equal to express and we have created one Express app right after that we have
to add the middle we so here we will add the comment and uh here let's add
app. use and in this middle Weare we will use this course right so we will add course
so that we can connect our back end with any other domain after that we have to create one default route that will be
the Home Route right so here let me add one comment first that is Route and after that we will add the app dot get
in this one we have to provide the route path that is slash after that we have to add one function that will be executed
when we hit this route so here we will add the Aro function like this and in this parameter
we will get request and response and this function will return the
response and in this response we will send the message so we will use this send method and in this send method we
will add the text called API working like this now for this application we need the port number so
here we will add the comment port and here we will Define the port number so just add
const we will add variable name Port equal to and we will get the port number from environment so just
add process do EnV do Port but if the port number is not
available in the environment then we will add the port number 5,000 so here we have used the or operator after that
we have to run this application that is Express app on this port number right for that we will use the app.
listen and in this one first we have to add this port correct and after that we have to add
the function so just add this addo function and in this addo function simply add
this console log message so just add console. log and here we will add any message so
we will add the back Tex so that we can insert the variables using template l so here we will add the message server is
is running on Port and after that we will add the port number using this dollar sign CES and provide this
port so this is our simple express application correct after that we have to run our project to run our project we
will come to terminal and here in this terminal you can see in we are in the server folder
so here we will add the command npm run server that's it press
enter now you can see the message server is running on Port 5000 correct and we can also test this route to test this
route we will come back to the web browser and here we will open Local
Host Port 5000 press enter so you can see this message Api is working it means our Express app
is successfully working we can also use Postman application to test the apis so let me open
Postman if you don't have this Postman application you can download it from the official website just search Postman
download that's it and you will get the official website to download it in this Postman application we will click on
this Plus icon and here we have to add the URL so we will add the URL from here that is Local Host
5,000 and click on send button you can see here we have selected the get method if I click
here you can see this message in the response that is API working so we will use this tool to test our apis now just
come back to the vs code and let me hide this terminal and next we have to create the
folder structure for our project so open the sidebar and here in this server folder we will create the other folders
so here in this folder that is server we will create a new folder called routes where we will create all the
routes after that in this server folder we will create new folder that is
controllers so in this one we will add all the controller functions after that in the server
folder create new folder called configs where we will create all the configuration files for mongod DV and
Cloud NY after that here we'll create another folder that will be middle
Wares so create the folder with name middlewares after that here we will create another folder with the name
models where we will create all the mongod DB models after that we have to create one
file in This Server folder that is EnV where we will store the environment
variables so after creating all the folder structure and creating this environment variable next we have to
connect our project with the mongod DB database for that we need the mongod DB connection
URI and we will paste it in this environment variable so to get the mongod DB connection string we will come
back to the website and open mongod DV Atlas so here we will search for mongod DV
Atlas open this link and here you have to create an account I already have an account so
I'll click on the sign in I'll choose my Google account after completing this sign up
you will come to this page where you can see this button create a cluster so I'll click on this
button to create a new cluster and here you can choose this m0 free server so it is free for use we will select this m0
free and here you can change the cluster name I'll keep it like this cluster zero and here you can choose the cloud
provider so I'll use Google cloud and here from this drop down you can choose the nearest location and
after that just click on this create deployment button after that it will open this
window where you can enter the username and password so let me write the username greatest stack and in this
password we'll write greatest stack 1 2 3 do not use the adate symbol in this password right
so keep the password simple don't use the at theate so I'm adding password create is T1 123 and just click on this
button create database user so for this database we have created the user and password now now just click on this
button choose a connection method from here we will select this compass and select this I have mongod DB Compass
installed after that you need to wait for 10 to 15 seconds then it will display the connection string so just
wait for it so now our connection string has been generated and we can copy this string
from here so just click on this icon to copy this connection string right after that we will come back to the vs code
and from here we will open this envirment variable file and in this one we have to paste our mongod DV
connection string so here we'll add the envirment variable name mongod
dvore URI equal to and paste this string here and in this
one you can see we have added this forward slash so just remove this so whenever we will copy the string from
the mongod DV we will get the forward slash at the end so make sure to remove that forward slash so we have added the
mongodb connection string here after that come back to the mongod DB website again click on this button done and here
we have to go to this network access and here our current IP address
has been added so just delete it and click on this add IP address and here you have to choose allow access
from anywhere so it will add this 0.0.0.0 then click on this confirm so now we can connect our
database from any IP address you can see the status is pending so after updating this status we can connect our project
with database so just wait for this status to be updated now you can see the status it is active right now we
will come back to the vs code and here we will create a configuration file so here you can see we have this config
folder so in this one we'll create a new file with the name mongod db. JS now now in this file we have to
create the function that will connect our project with the mongod DV right so to create that first we will
import the from Mongo's package correct and after that we have to create one
function so first We'll add this commment connect to the mongod DB database right and here we will add the
function name const connect DB equal to it will be a synchronous function and in this one
first we have to register one event so to register an event we will add do connection on and here we will add
the event name connected right so whenever we will be connected with the database then we will
execute this function and through this function we will display one message in the
terminal so just add console log and provide the message here that is database connected so first
we have registered this event right after registering the event we have to connect with our database so here we'll
add the await and we'll add the do connect and in this one we have to provide the mongod DB connection string
right so here we will add the back Tex so that you can use the template literal so added the back Tex and dollar
sign CES correct and here we need the mongod DV string so we will get it from the
envirment variable so to access the envirment variable we will add process. EnV and after that we have to
provide the environment variable name that is mongod DB URI so we will paste it here so now we have the mongod DB
connection string and at the end of this string we have to add our project name right so it will create one database
with that name so here after this curly Braes we will add forward slash and write the project name
we will add LMS or you can add any name right so I have added the project name
LMS after that we have to export this function so that we can use it in any other file so just add export
default and provide this connect DV function that's it so now we have to
call this function in our server file so that when we run our server we will be connected with the
database so let's come back to the server.js file and here after initializing the express application we
will call the connect DB function so first we will add one comment here that is connect to database and here we'll
add the function just add await and then we'll add the connect DV function and we will call
this function like this so you can see this connect DV has been imported from config folder
and mongod DV file and here in this one we have to add the file name extension also so just add Js mongod dev. Js make
sure to add the file name extension after adding it if I open the terminal here you can see we have this message
database connected correct so this message is coming from this file you can see here we have added console log
database connected in the mongod db. JS file right so the same message is displayed here in this
terminal so we have connected our Express app with our mongod DV database after that we have to create
the user model using that model we can store the new user data in the database so whenever a new user will be created
on our project using cler then we will use the Coler web Hooks and we will get the user data from the weo and we will
store the user data in our database also right so to store the data in the database first we will create one model
so we will create this model in this models folder so in this models folder we will create new file called user.js
in this one we will import Express
from Express package in this one we will import from package after that we have to
create the schema so we will add the const and write the name user schema and we will create this schema using this
new do schema Constructor and here in this schema
Constructor we have to create the structure of our user database right so here we'll add one
object and in this object we will add the first property that will be underscore ID so for the user we will
add one ID and for this ID we will Define the type so the type will be a string and it will be required so we
have added type A String required true so to create any user data in the database we need
this ID that's why we have added required true after that we will add the second property so just add comma and
here we will add the second property so the second property will be name right so in this name we will add type A
String required true after that we will add another property that will be email so here we will add email the type is a
string and required true after that we need to store the image URL of the user so so here we will
add property name image URL and the type will be a string and required true after that for the user data we need one
another object where we will store the enrolled courses right so here we'll add another
property enrolled courses and in this one we can store multiple courses right so here we will add one are a
and in this aray we will add the first object and here we will Define the type and in this type we will add
Mongo's schema types dot object ID after that we will add
reference and in this reference we will add course here we will add
comma and after this object here we will add one object and in this one we will add time stamp and the time stamp will
be true like this now we have created the schema for
the user after creating the schema we have to create the user model so just add
const user equal to do model and in this model we will add the name user and provide the schema
that is user schema so we have created the user model with this name user now we have to export it so that we can use
it in any file so just add export default user after that we have to create the
beook controller function so that we can get the data of user from our clerk books right so here in
this controllers folder we will create a new file with the name books. JS in this web hooks. JS file we will
import the we hook from svx after that we will import
the user model so just add import user from Models folder SL user.js
correct after that we will create the controller function so here we'll add the comment that is API controller
function to manage color user with database now we will create the function so just add const and the function name
is cler be Hooks and it will be asynchronous function
and in this function parameter we will get the request and response now we have to access this
function in another component also so here we will add the export so we have exported this
function now in this one we will add the TR catch block now in this Tri block first we need the clerk B hooks secret
key right so first we will declare one environment variable in this environment file and here we will add
B Hook secret and let me add the empty string for now after that come back here and in
this one we will add const W hook equal
to new Bev hook and here we need the secret key so just add process do EnV do
color book secret after that we will verify the headers so here let's add a wait and
here we'll add W hook dot verify and here just provide Json do a
stringify in this one we will add request do body after that we will add the comma and
here we will add this object now in this object we will add the property svx ID and in this SX ID we
will add request do headers and in this
headers we will add this svx ID after that add the comma and here
we'll add SX timestamp and it will be request dot
headers svx Tim stamp after that we will add the another property
SX signature and here we will add request. headers and provide svx
signature after that we need the data from request body so here we will add const and add the CES so we will get the
data and with that we will get the type also and we will get it from request.
body right now after getting this data we have to add the switch case statement for different events right so in this
one we will get the events like user created user deleted user updated So based on that different event we will
add different switch case so here let's add switch and here we will add the type after that in this first case we
will add the type that is user do created right so whenever the user will be
created then we'll add this object and here we will create the user data that we will store in the
database so here just add con and we will add user
data and it will be one object in this one first we need the ID so WR underscore ID and here we will store the
data do ID that we are getting from weok after
that we will add the email and in this email we will store data
dot email _ address and it will be one add a so here we will add the index zero and from this
one we will find email address after that we will add the comma
and write the next property that is name so we will store the users name in the database so we will get the
data do first name and in this one we have to add second name also so here we will add
plus and provide this space and write plus and here we'll add data do last name correct after that we will store
the image URL also so we will add image URL and we will get this URL from data do image uncore
URL so here we have added the image URL and now we have this user data next we have to save this user data in our
database for that here after this object we will add await and we will add the user model
and in this user model we will add create method and here just provide this user
data so it will store this user data in our mongod DV database after that we will add the
response and in this response just add the Json and in this Json just add the empty
object after that we will add break after that we will remove this break and here we will create the next
case so here we will add the case and in this one we will add the type that
is user dot updated and uh in this one we'll add this object and here we need the updated
us user data so again just copy this paste it here and in this one we'll get the user data then we will remove this
ID because we cannot update the ID and here we'll get the email name and image URL so this will be the updated data and
after that we will update this data in the database also so just add await and here we will use this user
model and then we'll add the find by ID and update this one find by ID and update
method and here we will provide the ID so just add data do ID after that we will update
this user data after that we have to generate the response so just add response.
Json and provide the empty object then we will add the breaker statement now we'll add the another case
so here we'll add the case and write the event type so it will be user
deleted so whenever the user will be deleted then we will execute this code so here we will add await and what we
have to do we have to delete the user from our database so here just add user model
dot find by ID and delete right and in this one just provide the ID so we will add the ID
using this data. ID correct after that we will add the response using Json method and in this one provide the empty
object after that we will add break then we have this default case now if any error occurs in this Tri
block then this catch block will be executed right so in this catch block simply add
response do Json here we will add the object and write
success success fals and here we'll add the message and in the message we will add this error do message
so we have created the function to handle the color B hooks right now we have to create the route using this
controller function so to create that we will come back to the server.js file and here we have this routes so in
this one let's add app Dot
post here we will add the path SL color and at this route that is/ color we will add
the Express dot Json so
the request will be passed using this Json method and after that we will add the B controller function so just
add Coler B hooks that we have just created so you can see this Coler B Hook has been imported from controllers
folder we hook. JS file that's it after that we have to upload our
project on GitHub and then we will publish our backend project using versal and then we will get the backend URL and
using that URL we will generate the beook secret from the color dashboard so first we have to upload
this project on GitHub so to upload this project on GitHub we will open this sidebar and here you will find this
option Source control and here we will click on this initialize repository button now in this one you can see we
have changes in 5,000 files right so we have to exclude the node modules file for that let's open this folder
structure and in this left sideb we have this LMS folder right so here we'll click on this white screen and here just
click on this new file and here we will create a new file with the name dog ignore so you can see here we have this
client server and here we have this dogit ignore in this one we will add the files and folders that I want to exclude
from GitHub so here we will add nodecore modules after that we will add
dotv so it will not upload these files and folder on GitHub after that again click on this Source control and here
you can see we have changes in 92 files it's correct now here we will add any message so I'll add the message first
commit and click on this commit button after that here you can see we have this GitHub ID because our vs code
is already connected with my GitHub profile if it is not connected for you you can simply connect it by providing
the GitHub Account Details In the prompts after that we'll click on this button publish branch
so here we have two options GitHub private repository and GitHub public repository and we have the project name
LMS so I'll choose this one GitHub private repository so now you can see the
message in the bottom right side it is uploading our files now you can see the success
message so our project has been uploaded on GitHub now let me check my GitHub profile so now on this GitHub profile
you can see we have this LMS project and here we have this client server folder right so we have uploaded the project on
GitHub after that we have to deploy our project using versal so go to versal and just sign up on this versal website and
here you will find this option add new project but before creating the project first we have to add the versal do Json
setup code in the project for that we will open GitHub SL great stack Dev here we will find this
notes then just go to this versal Json config for M open this one so in this one you can see we have two
configurations the first one is for the back end and this one is for the front end right so let me just copy the first
one versal Jon config for Express backend right now just come back to the vs
code and we will open the folder structure go to server and in This Server we will create a new file so here
in this server we will create a new file with the name versal do
Json and paste the configuration that we have just copied right after that in this client folder also we'll create one
file so in this client folder create a new file and write the file name versal do
Json and here we will paste the code from here from this notes just copy this configuration that is the front end
configuration for versal Jon just copy and paste it here save the changes now let's go to this Source
control and here you can see we have two changes in versal do Json file just click on this commit and here we will
add the message versal Jon added click on Commit now click on sync
changes okay after that we will come back to the GitHub profile and here you can see
in this client folder we have this versal do Json and if I go to
server folder here also we have this versal dojon correct now just come to versal and we will create a new
project and here we will choose the GitHub repository so we will use this LMS repository just click on
import after that here we have to add the project name so I'll add the LMS back
end for now we will just deploy the back end after that here you will find this root
directory so just click on this edit button and from here just select This Server folder and click on
continue after that here we have the environment variables just click here and here we have to provide our
environment variables from the back end so just come back to the VSS code and uh from here let's open server and open
environment variable just copy this one and we will will paste it here so these environment variables has been added now
just click on this deploy button so it is deploying our project on versal now you can see this message
congratulation it means our back end is deployed successfully on versal after that we'll go to
dashboard and here we have our backend URL let me click here so it will open this URL in Tab and here you can see the
message Api working now we will use this backend Link in our Coler account so we will
open Coler go to dashboard and here we are in this
greatest stack LMS project now go to configure and here you will find this we hooks from this left side bar open
this we hooks scroll down and here you can see this button
add endpoint just click here and in this one we have to provide the be hooks router here we have to provide the B
hooks end point so we will provide the backend link and after that we will add cler then we will subscribe the events
so from here scroll down and we will choose user events so just click this one user and after that just click on
this create button now here you will find this signing
secret so just click here and you will find this secret key just copy this one and we have to add it in our envirment
variable so let's come back to the vs code and paste it here in this color book
secret after that we have to add the color publishable key and secret key also so just come
back and from here I'll click on this API keys and from here we have this drop
down so from this drop down we will select Express so now we have this two environment
variables I'll click on this icon so it will display the secret key also so just copy this one and paste it here in this
environment variable now we have to update these environment variables in our versal
deployment also so just copy last two environment variables and we will come back to the versal dashboard
and here we will click on this settings and scroll down here you will find this involment
variables and in this one you can see here we have the mongod DB URI only and here in this field I'll paste the
environment variable so just paste this one that we have just copied and we will paste one more so let me just come back
and copy this one color beook Secret just copy this and paste it here click on add another and paste this one so we
have added all the color Keys then click on save so now you can see we have all
these color we hook secret color secret key color publishable key and mongod dvu and after that just go to
deployments from this menu here we'll click on this three Dot and click on this
redeploy and just click on this button so it will redeploy our project so now it is deploying our
project now deployment has been completed you can see this message Api working right so now whenever a new user
will be created in our Coler dashboard then we will get the user data in our mongod DB database also so to view this
one just come back and uh we will open our website so here you can see we have already created this account and if I
click on this manage account and uh we can delete this account also right so to delete this
account just click here and here we'll write this text delete account and click on this
button so now our account has been deleted now let me create the new account so I'll click on this button I
will sign up using the Google account I'll choose my email ID and click on
continue now our account has been created now let me go back to the homepage so you can see here we have the
profile icon then we have the name email ID right so we have created the account using cler right after that if I open
the mongod DV and from here we will open this cluster under this database and I'll click on this browse
collections so in this collections you can see we have the users collection and in this user
collections it should display a new user data here but it is not working so let me just come back and come to vs code so
in this user created case you can see data. email
address so it will be email addresses just correct it email addresses index0 and here if I scroll down we have
this catch block and in this one we will correct this as spelling JS o n Json that's it now we have to commit the
changes on GitHub so just click here and here we'll add conncted
user creation click on Commit sync
changes after that it will automatically redeploy our versal project and till now I'll just delete
the profile from our website so I'll open this website and from here let me go to manage account security then
delete and I'll delete the account after that I'll click on create account but before creating the account
let me verify our project has been redeployed or not so just come here let's go to all projects go to LMS
backend and go to deployments so here you can see our project has been redeployed
automatically when we commit the changes and after redeployment we will come back to the
website and we will create a new account click on sign up and choose the Google
account now our account has been created on our website and now if I again come back to the mongod DV database and click
on this refresh button so now you can see here we have stored the newly created user data so we
have the ID name email and image URL and we have other data like enrolled courses so we have successfully created an
account and we can store the new user data in our database next we will create the other
routes for our project so we will come back to the vs code now we have to create the controller function for
educator so in this controllers folder we will create a new file with the name educator controllers.js
now in this educator controller.js file we have to create one function that will update the role of educator so that uh
regular user can become an educator for that here we will create one function so we will export this function and
write the function name update role educator and it will be a
synchronous function and create this AR function in this function we will add
the TR catch block and here first we need the user ID and we will get this user ID from request so just
add user ID and we will get it from
request. do user ID after that we will add await and we will use the color client so first we have to import the
color client so here we will add the import Coler client from Coler SL Express now here we will add this color
client and in this one we will add users and here we will add the update metadata so in the users metadata we have to
update the property so here in this one first we will provide the user ID for which we want to update the metadata so
we will provide the user ID then add the comma and provide the second parameter this will be object and in this one
let's add the property public metadata so we have to update the the public metadata and in
the public metadata we will add the role and in this role we will add educator so by updating the public
metadata of educator account in cler we can assign different role for different users right after changing the
metadata we will add response. Json and here we will add success true and we will add the message that is you
can publish a course now right so after becoming educator they can publish a new course
on our LMS website and if any error occurs in this triy block then this catch block will be executed so here we
will return a response so just add response. Json success false and the message is error. message so we have
created this function so let me add the comment before this function so this is for the update role to educator correct
now for this one we have to create the routes also so from this left side bar we will open this routes folder and in
this routes folder we will create a new file so write the file name educator routes.js
now in this one first we need the controller function that we have just created and before that we will import
the express from Express after that we will import the controller function that is
update role to educator so just add this and we will get it from controller folder and educator controller.js file
so we have imported the controller folder right after that we have to create one router so we will use the
express router to create a router so here we will add const educated router equal to express.
router now in this router we have to add the end points so first We'll add the comment so here we'll add add educator
role and here we will add educator router Dot get so we will create this route using
the get method and here we have to provide the route path that is update Ro and here we will add our controller
function that we have imported that is this one so we have created the endpoint to update the users role and after
updating the user role user can become the educator after that we have to export this router so here at the end
We'll add export default and educator router now we will provide this router
in our server.js file so in this server.js here we will add app.use and here we will add the path so
it will be/ API slash
educator and after that here we'll add the exp. Json and then we will add educator router right so just
add educator router so you can see this educator router has been imported
right so we have created the API endpoint using that we can update a normal user to a
educator after adding this router if I come back to the controller function that we have just created here you can
see in this controller function we are getting the user ID from the request do o right so we have to add this o in the
request and it will be added using the color middleware for that just come back to the server.js file and here in this
middle Wares we will add app.use and here we will add color middleware
and this color middleware will add the O property in all the request we have to import this color
middleware so we will add this so we are getting the suggestions just click here so you can see the Coler
middleware has been imported from cl/ Express correct now we can and test this API endpoint but for testing the API
endpoint we need the authentication token so to get the token we will come back to the client project from this
left sideb we will open this client and here we will go to SRC and open our context folder and app context. jsx file
from here we will generate the token here first we need the get Au and get user from the Coler so here we will add
const and we will add get token and we will get it from use Au so we are not getting the
suggestion so we can manually import it so first here we'll add import use o and use user and we will
import it from color color- react now we can use it here here use o and from this use o we will get get token after
that we need the user also so just add const and here we'll add user and we will get this user
from use user that we have already imported here so now we have this get token and
user after that we will scroll down and here we will create one use effect so just add use effect and in this one we
will add the arrow function and here we will add the dependency array here we will add if
statement and we will check if we have the user then we will execute this block and in this one we will call one
asynchronous function so let me declare that function that is const
function name is log token it will be asynchronous
function and here simply add the console log in this console log we will add await get token so it will display the
token in the front end console after that we will call this function here in this if statement
and in this dependency array we will add this user that's it after adding it save the
changes and we will come back to the web page now if I refresh this website and open the dep tool then go to
console so in this console here we have this token that we have just printed using console log so now we will use
this token to test our AP and points to test the API we will open our Postman application and here we will create uh
new get request so I'll click on this plus icon and paste the Local Host Port 5,000 and then we'll
add the path that is/ API SL
educator then update role so write the complete API end point after that in this headers we have to
provide the token so for providing the token here we have to add the key and value so in this key we will add
authorization so just add this authorization here in this value first we have to add b
error and after that we have to add a space and here we will provide the token that we have generated so if I come back
to the web page here we have this token but this token will usually expired in 1 minute so make sure to refresh this web
page and get the new token and now we will test it so just paste this token here after
this be eror and click on this send button here we are getting some error because we have some space here in this
authorization let me correct this now click on the send button again here we are getting some error when we click on
send button so just come back and we will open vs code and go to educator controller.js file and here we have used
this response so in this parameter we have to get request and response now save the changes and now
just come back to the web page again and refresh this web page to generate create a new
token copy the token and we will paste it here in this value after that we will click on the
send button so now you can see the response and here you can see the success message
success true and the message is you can publish a course now so a normal user can become educator when they hit this
API endpoint with this token so this API endpoint is successfully working now we have to
create another API we will use this for creating a new course or uploading a new course but with the course we will
upload the image also so first we will set up the cloud NY so that we can store our images on cloud Nery storage before
that let me verify whether the user role has been updated or not for that we will come back to the color
dashboard and from here we will open users and here we have this user let me open
this and in this one I'll scroll down and here you can see we have this metadata and we have this public
metadata right so in this public metadata you can see a new role has been added role educator so this is how we
can update the role of any user and the user will become educator now we will set up the cloud n for our project so we
will open Cloud NY open this cloudy.com and here you have to create an account I
already have an account so I'll click on login I'll login with my Google account after login come to this
dashboard and here you have this button go to API Keys click here and here I have already created these API keys so
just click on this generate new API key I'll click here and we will get a confirmation code on the email ID so
just paste the confirmation code here to generate the API key so this is the confirmation code I
have received on the email ID I'll paste it here click on this
button so this is the newly generated API key I'll write the name also greatest tack
LMS and here we have the API key then we have the secret
key and here we have this Cloud name so we need all these data we need the cloud name then API key and secret key we will
save these key in the environment variables so just come back to the vs code and here we will open This Server
folder and then go to EnV file and here let's add the involment variables name so the name will be Cloud Ny
name after that we will add the another variable that is the envirment variable Cloud NY API
key after that let's add one more envirment variable Cloud NY secret key now we will paste the values
here so just come back and from here I'll copy this name paste it here then copy the API key
from here we will paste it here then copy the secret
key and I'll paste it here now we have all the cloud n details like name API key and secret key now we will create
the configuration f file so just come to this config folder and here we will create a new file with the name cloudy.
JS in this file we have to import the cloud NY so we have to import the V2 from cloud NY so just add import and we
will import V2 as Cloud
NY and we will import it from Cloud NY package that we have already installed after that we will create one
function so we'll add the cost and write the function name connect cloud nudy and it will be a synchronous function so
create one addo function and in this one we will add Cloud Nery and add the configurations so just add config and
here in this one we will add the object and in this object we have to provide the cloud name API key and secret key so
let me add the first property Cloud name and In This Cloud name we need the cloud name from the environment variable so
just add process do EnV Dot and write the environment
variable name from here like this just add one comma and DC at this line here we will
add the property name that is API key and here we will add the variable name that is cloud NY API
key now in this one we will add API secret so just add the API secret in the third property and here we will add this
envirment variable name so now we have configured the cloud NY next we have to export this function so
that we can use it in any other component so just add export default and provide this function
name now we have to call this function in our server.js file so we will come to server.js and in this one here we will
add await then connect Cloud nuty so we will click here to import this one so you can see connect Cloud NY
has been imported and just call this function so now our project will be connected with the cloud NY
storage next we have to create the controller function using that we can upload the new
courses before creating the controller function to upload course first we need to create the model for our courses so
to create the models we will come back and here in this models folder we have
this user.js file so here we'll create one more file so in this models we'll create a new file with the name course.
JS and in this one we'll create the model for our courses so here let's add import
we will import mongos from mongos and from this mongos we will get the schema and we will create one model a schema so
let's add const we will add the name course schema and here we will Define what
properties we will add in the courses so here we will add new and Dot
a schema Constructor and here in this one we'll add the object and we'll declare all the properties that will be
available in the courses so first We'll add the course title and in this course title we have
to add the type so the type will be a string and then we'll add the required true so to create any course we need the
course title that's why we have added required true let's add comma and next we'll add the second property for the
course that is course description here also type is a string and required true after that we'll add the course
thumbnail and here we will add the type A String because in this course thumbnail we will store the URL that's
why we have added type A String after that we have to store the course price and to store the price we will use the
type number so we have added type number and required true after that we will add is published so here we can add either
true or false so we will add the type bullion so that is published will be either true or false so we will add the
default value true so whenever a new course will be published is published will be true after that we will add the
discount and this discount will be added in the numbers so we will add the type number required is true and here we'll
add the discount minimum zero and maximum 100 because we will add the discount in percentage so it could be
between 0 to 100 after that we have to add the course content and in the course content we
have to add the course chapter and the chapter will contains the lecture so instead of adding all the properties
here for the course chapter we'll create a separate schema for course chapter so here we'll add the empty are and in this
one we'll add another schema and after that we have the course ratings also so here we'll add the next property
course ratings and in this course ratings we will add one aray and in this aray we'll add one object and here we
will define the properties for the course rating so for the course rating we will add the user ID and the type
will be a string then we'll add the rating and the rating will be number and we can add the rating between one to
five so we have added minimum one maximum five right and in this one we'll add one more property that is Educator
so here we'll add the educator property and this will be type a string and in this reference We'll add the user so
we'll use this user model after that we'll add required true after that we have to add the student
enrolled data in the courses right so for each courses We'll add the data of enrolled students so here we'll add
another property enrolled students and here we'll add type a string and here we'll add the
reference of user model right and after that here we will add the comma and add the C Braes in
this one we will Define time stamp true so it will automatically add the time stamp when this course was created after
that we will add the minimize property and it will be false so if we don't provide any value
for these properties then it will create these properties without any value also and it will create the course data now
you can see here we have added the course content so in this one we have to add another schema so here before this
course schema We'll add one more schema that will be chapter schema and here again we will use the new
mongos do schema Constructor and here we have to create the schema for the
chapter so in each chapter we will add the chapter ID and the type is a string and required
true after that we will add the chapter order then we'll add the chapter title and after that in in each chapter
we will add the lectures so there could be multiple lectures and lectures will have other properties also right so
instead of adding all the details of the lecture here we will add chapter content and in this chapter content
We'll add another schema that is lecture SCH schema that we will create right now and here we will add the comma and we'll
add cly presses here we'll addore ID it will be false so whenever a new chapter will be created so it won't
create the ID for this chapter because we are already providing the unique ID from the front end because we have used
the unique ID package after that we will assign this chapter SCH schema here in this course schema here we have the
course contain so just provide this chapter schema here right and here we have the chapter content and in this one
we have the lecture schemas so now we have to create the lecture schema also so before this chapter schema We'll add
a space WR const lecture schema equal to
new do schema and here we will add the lecture ID after that we'll add the lecture
title lecture duration and lecture URL right and then we'll add one more property is preview free so it could be
either true or false so we will add the type Boolean so after adding it we'll add the lecture order also and in this
one we will store the number so we'll add type number and required true and here also we don't need the ID so again
we'll add the same thing underscore ID and it will be false so now we have created this lecture schema and using
this lecture schema we have created this chapter schema and we have added this chapter schema in this course schema so
finally we have created the course schema Now using this course schema we'll create our course model so at the
end here we'll add const and write the model name course and here we'll add do
model and provide the model name course and provide the schema that is course schema so we have created the
course model after that we have to export this model so just add export default and course so we have
created this course model and exported it now using this course model we will create the controller function to upload
our courses so here in this left side bar you can see here we have this educator controller.js file so in this
one we'll create a new function for adding a new course so scroll down and here let me add one comment so we'll add
the comment add new course and here we'll add the function and we will export this
function so just add export con add course and it will be asynchronous function so just add async and create
the arrow function and in this parameter we will get request and
response after that in this function we'll add the try catch block and in this Tri block we will add
the course data and we will get the course data from the request body so just add const course data and get it
from request. body after for that we need the image file also and we will get the image file from the request so we
will add const image file from request. file after that for uploading the course we need the educator ID also and we will
get the educated ID from the Au and user ID as you can see here we have this just copy and paste it here so in the same
way we will get the educator ID so here we'll add this name educator ID we will get it from request or user ID after
that first we will check whether we have this image file or not so we'll add the if statement and we'll add not
of image file so when the image file is not available we will return a response so we will
add return response. Json success will be false and the message is thumbnail not
attached right after that will add the code that will pass our data that is received in the request so we will
receive the data as a string so we have to pass it using the Json method so here we'll add the variable con and the
variable name is passed course data equal to await and here we'll
add Json method then write FSE and here we'll add the course data that we are getting from the body just add it here
so now we have passed the course data now in this one we have to add the educator ID that we are getting from
this Au to add the educator ID just use this here and in this one we'll add one property called
educator and in this educator we will assign this educator ID right so now we have the complete
course data and in this course data we have this educated ID also so now we can store this course data in the database
so to store it we will use the course model that we have just created so here we'll add await
course click here so this model will be imported after that we'll add create so in this course we have added this create
method so it will create a new data in the mongod DB database and here we have to provide this passed data that is
passed course data right now we will store it here in one variable so just add
cost new course equal to await course create past data so here we'll get the newly created course right so now we
have created a new course but in this course we have not added the image so first we have to upload this image that
we are reing here we have this image file so we have to upload it on cloud NY and we will get the public URL of this
image for that here we'll add await and we'll add Cloud nuty so just add Cloud nuty to use this Cloud nudy first we
have to import it so here scroll up and we will import V2 as cloud nuty from cloud NY right now we can use this Cloud
NY here and in this one we'll add upload or we will use uploader and in this uploader we will
use the upload method and here we will add this image file and then write dot
path correct now we will get one response so here we'll add const and we will store this response in
one variable called image upload now in this response we will get the URL of
our image and that will be a public URL and we will get this URL in a property called secure URL so here let's add
image upload do secure URL so we will get the public URL of our image now we have to add this image URL in our new
course so here we have this new course right so here let's add new course dot add a new property
that is course thumbnail and in this course thumbnail we will add this image URL after that we will add
await and write new course do save so it will save this updated course
in the database after that we have to create the response so we'll add
response. Json and here we'll add the object with success property true and with that we'll add the message
course added after that if any error occurs in the tri block then the catch block will be executed so in this catch
block will add the response with the Json method and provide success Falls and the message is error. message so now
we have created the function that will help us to upload the courses on the database now we have to create one route
using this controller function but before creating the route we have to pass this image because we are getting
this image as a form data so we have to pass this image using the molter package that we have already installed so from
this left sideb we will open this conf folder and in this one we will create a new file that is multer
DJs and here we will configure the molter so first we will import molter from molter package after that we will
create one a storage variable so just add const storage equal to it will be molter do disk
storage and in this one we will add one empty object after that we'll add one upload variable so just
add const upload and here we will use molter and in this one we'll add object and in this object we will
add this a storage from here after that we have to export this upload so just add
export default and upload so we have configured this
molter after that we have to protect our educator route so that only Educators can upload the courses for that we have
to create a middleware so in this middleware folder we'll create a new file with the name Au middleware do
JS in this o middleware DJs first we will import the color client from color SL
Express now we will create the middleware function so just add middleware protect educator route added
this comment and after that we will create one function so write the function name
const protect educator and it will be asynchronous addo function and we have to export this function so here just
add export now in this one we will get the request and we will get the
response and after that we will execute the next function so just add the next next we have to add the try and catch
Block in this function so just add try catch a statement and here first we need the user ID from the request so we'll
add con user ID and it will be request. do user user ID now we have this user ID Now using
this user ID we have to get the user so that we can check whether the user is educated or not so to get this user here
we'll add con response and it will be
await we will get the user from this color client and in this one we'll add user users and
write get user and provide the user ID so now in this response we will get the user and for this user we have to
check its public metadata and if the public metadata contains a role with the value educator it means the user is one
educator and user can upload the course and if the metadata does not contain the role educator then we will return a
response with success false for that here we'll add the if statement and in this if statement we'll
add this response and in this response we are getting the user right so for this user
we will check the public metadata and in this one we will check the role and if this role is not equal to
educator then we will return a response with the Json method and here we'll add the success
property false and with that we will add the message unauthorized access so whenever a user does not have the role
educator then user cannot access the educator dashboard and user cannot upload a new course when we apply this
middle bear before the route after that we will simply add this next so it will call this next function and now if any
error occurs in this Tri block then the catch block will be executed so here just add this response and in this
response We'll add success false and the message is error. message so we have created this middle bear that will
protect the educator route after that we have created the protect educator middleware then we have created the
molter configuration and we have the controller function to upload a new course now using this we will create a
new route so we'll come to left side bar from here we will open educator
routes.js file and in this one we'll add a new route so here just add educator route or educator
router Dot post method and in this post we will add the API Endo that
is/ add course and after that we have to add the molter configuration so just add
upload so this upload has been imported from configs SL m. JS file and here we'll add dot single and in this one we
will add this image so whenever we will pass the form data and in the form data we will add the image using this image
property then that form data will be passed using this molter after that we have to protect this route so just add
this middleware protect educator so this protu educator has been imported from middleware folder and Au middleware DJs
file after that we have to to add our controller function that is ADD course so you can see this add
course function has been imported so now we have created this route now we can test this route so to test it we will
come back to the postman here we will create a new request so just click on this plus icon
and here we will add the API end point Local Host Port 5000 / API / educator SL add course and here we will add the post
method and now in this body we have to provide the form data so select this form data and here we have to add the
course data so here let me add the first property that is course data right and in this value we have to provide one
Json object where we'll add all the properties and values required for a course so here we add
this data where we have the course title course description course price discount and course content so we have created
this data for testing and uh after that here we'll add one more property so here just add
image and in this image we will add this file and choose a file from the computer so let me choose this
file and after that let's click on this send button but here we are getting some
error because we have not provided the headers so here in this headers we have to add the authorization so just
add authorization and then we'll add beor and here we have to add the token
so let me just collect this as filling be error and then we'll add the tokens so just come back to the website
and open the console Tab and refresh it to generate a new token just copy this token paste it
here and click on this send button so here we are getting one eror so if I come back to the vs codee
let me open the terminal here you can see this message cannot find module course right so to
connect this one just hide it and here in this educator controller.js file we have this course so we have imported it
from the models folder and here we have to add the file name extension. JS just correct this one save the changes and
come back to the website refresh it to generate a new token now get the new token just copy this one and come back
to the postman application and remove the previous token from here paste the new one and click on the
send button now you can see the message success true and the message is course
added it means this API is successfully working and if I come back to the database
so let me just come back here in this mongod DV database and I'll open this cluster then go to browse
Collections and here we have this courses and in this courses we have a new course where you can see the course
title description price is published true and all other details here we have the course content also that is an aray
where we have the object here we have we have the chapter ID then in this one we have the chapter content where we have
the object and then we have the lecture ID lecture 01 so here we have all the data that we have provided using the
postman application to test our API so we have created this API endpoint to upload a new
course now we will come back to the vs code now we will create the controller function to get all courses of any
educator so right now I am in this page educator controller.js file so here let's scroll
down and at the end we will create a new controller function so here first we will add the comment get
educator courses and here we will create our function so let's
add export const get educator courses and it will be a synchronous function so create the async arrow function and in
this one we will get the request and response in the parameter now here we will add the TR
catch statement and in this one first we need the user ID so we will add this request
or user ID or I can copy from here here we have this just copy and paste it
here and here we will get the variable name called educator
now we have to find the courses so to find the courses we'll add
const courses equal to await and here we will use the course
model and from this course model we have to find the course with this educator so here we'll
add find and in this one we will provide this educator so here we have this educator
ID using this user ID and then we are finding the course in the course model and here we'll get all the courses of
this particular educator after that we have to return the response so we'll add response. Json and provide success true
and then provide this courses correct after that we have to create the code for the catch block so
if any error occurs in the tri block then catch block will be executed so here simply add this response. Jon
success false and the message is error. message after that we have to create the route for
this educator courses function right so just come back here in this educated route do JS file
and here let me add a new route so here we will add educator
router dot get method and here we have to add the path that is
courses and after that we have to add the the protect educator middleware then we will add the
controller function that we have just created that is get educator courses so this get educator courses controller
function has been imported after creating this route we can test it so for that we will use this
Postman application and here instead of this add course we will add
courses so here we have the API endpoint SL API SL educator SL courses and with that we have to provide the headers and
in the headers we will add authorization VOR and then with this VOR we have to add the new token right so let me just
come back to the website refresh it to generate a new token just copy this token
and paste it here so here you can see we have added the authorization beer and token and here we have to select the
method get and click on the send button so now you can see we are getting the response with a status code 200 okay
and here we have the success true and with that we are getting the CES and in this one we have this aray and here we
have this object right so this object object contains one course details we have the course ID course title
description price published discount and course content so this course content have the chapters and lectures so right
now we have uploaded only one course in our database so we are getting only one course for
this educator so this API is working fine now we will come back to the vs code and come to educator controller .js
file and here we have to create another controller function so we will create another controller function to get the
educator dashboard data but before that we have to create one new model for the purchase so let's open this sidebar and
here we have the models folder so in this one we will create a new file with the name
purchase. Js in this one first we have to import from
after that we have to create one schema so we will add the name cost purchase a schema and here we will use
the new do schema Constructor and here we will define the
properties that will be added in the purchase model so first We'll add the course ID so if anyone purchase the
course there will be course ID then we will store the users ID and we will store the amount and Status whether it
is completed pending or failed right so here we will add the course ID and here we will add the
type so the type will be mongos Dot schema
dot types dot object ID after that we will add reference and here we will add
the course model and then we'll add required property so the required will be true
now let's add the comma here and here we will add the another property that will be user ID so in this user ID we will
add the string type and the reference will be user that is user model and then we will add required true after that we
have to add the new property that is amount so the type will be number and required true then we will add the a
status so here we will add the a status property and here we will add the type type will be
string after that we have to add the values so here we will add inum and here we'll add the values it could be either
pending completed or failed so the payment status will be either pending completed or failed after that here
we'll add the comma and we'll add the default value so just add default and here we'll add the default value that is
pending now here we'll add one comma and add the object and here we will add the time stamp true so it will store the
time stamp when this order was created so after that we have to create the model using this schema so to create
that we will add Con purchase equal to do
model and here we have to provide the model name so the model name is purchase and with that we will add the
schema so it will be purchase a schema and we have to export it so simply add export like this
so we have created the purchase a schema and exported it after that we'll come to this
educator controller.js file and here we'll create the controller function to get all the data of educator to display
the data in the educator dashboard right right so here let's add the comment and we will add the
comment get educated dashboard data where we will get total earning enrolled students and number of
courses so to create this function we will add the function name so just add const function name is educated
dashboard data it will be a synchronous Arrow function and here we will export this function so
just add export right and after that in this function we will add the TR catcher
statement and in this Tri block first we need the educator so we will copy it from
here we will get the educator from request. o. user ID after that we have to find the
courses of this particular educator so so here just add const and we'll
add this one so here we have all the courses of this particular educator now we need the
total number of courses right so here we'll add one variable with the con and variable name is total courses equal to
this courses are a then we'll add do length so we will get the total number of
courses of this educator after that we have to calculate the total earning right to calculate the total earning we
need the ID of each courses right so to get the ID of each courses here we'll add
con course IDs equal to this courses do app and in this one we will add
individual course and create this Aro function and here we will
add course doore ID so it will return the IDS of each courses right now we will calculate
the total earning right so let me add the comment calculate total earning from purchases
so here we'll add cost purchases equal to await then write purchase model do
find and here we have to find the purchase data for different course ID and we need to check where the status is
completed so here we'll add one object and in this one we will add course
ID and then write cly bres Dollar in then write course IDs after that we'll add the comma and here we'll add a
status and we will add the status completed after that here we will add const total
earnings so it will purchases dot reduce and in this one we will add
this add function and here we'll get sum and in the second parameter we will get
purchase and it will return this sum plus purchase dot amount comma
0 so so here we will get the total earnings after calculating the total earning next we have to get the a
student data who has enrolled into this educator course right so here we'll add one comment we will add the comment
collect unique enrolled student IDs with their course titles right so we'll add the
const enrolled a student data and it will be empty array now we'll add
for and here we'll add const course of courses and here will will add
const a students equal to a wait user dot
find and in this one we will add this object and here we will find _ ID equal to dollar sign
in we will add the course dot enrolled students after that here we will add the
comma and we will provide name image URL so it will give only name and image
URL of the students after that here let's add a students dot for
each and here we will add the student and in this one we will add enrolled a students data
dot P here we will add the the object and then we'll add the course
title and in this course title We'll add course dot course title then add the comma and here we will add a
student after that we have to create the response so here let's
add response. Json and in this one we will add the success property where we will add
success true then add the comma and here we'll add dashboard data and in this dashboard
data we will provide one object and in this object we will provide the total earning that is here
we will add this total earnings after that we will provide enrolled a students
data and we will provide total courses so here we have this total courses like this now if any error
occurs in the tri block then the catch block will be executed so in this catch block simply add response. Json success
fals and message error. message so we have created One controller function that will return the data for educator
dashboard where we will display the total earnings enrolled students and we will display total
courses after that we'll create another controller function where we will get the enrolled a students data with
purchase data so here we'll add the comment get enrolled a student data with purchase data and here we'll create the
function so we'll add the function with export con and the function name is get enrolled a students data it will be a
sync and addo function here you'll get the request and response if I come back here in this
previous function here also we will add this request and response now just a scroll
down and uh in this one we will add the TR catch block so just add this try catch a statement and in this Tri block
again we need the educator so we'll copy it from here like this after that we have to
fetch all courses created by the educator so again we will add this line so it will give all the courses
created by this educator after that here we'll add the code that will get
the list of course IDs right so here again copy this code from the previous one here we have this course
IDs paste it here so now we have the list of all courses ID right now we will find the
purchases with the user and course data for that here we'll add
con purchases equal to await and
write purchase dot find in this one we will add the object and here we'll add
this course ID and a status after that here we'll add dot populate in this one we have to provide
the user ID after that we will provide name and image
URL and then we will again add populate and here we will provide the course
ID then add the comma and we will add the course title so it will provide the user ID name
image URL then course ID and course title after that we have to find the a students data so here we'll
add const we will add the variable name enrolled a students it will be purchases do
map and here we add purchase create the arrow
function and write this small bracket here we will add this object and in this one we will
add a student and here we'll add the purchase. user ID then we'll add the course title it will be purchase doour
ID doour title then we'll add the purchase date and it will be purchase do created at
so now we have the enrolled students after that we can create the response so here we'll add response.
Json in this one we'll add the object and here first We'll add the success property so the success will be true and
after that we will add the data so here we'll add enrolled students so it will return the enrolled students data in the
respon response and if any error occurs in the tri block then the catch block will be executed so simply add this
statement here in this catch block so it will return success false and the message is error. message so we have
created this controller function that will provide the enrolled student data right now we have to create the routes
for these controller function for that let me just come back to the educat routes.js file and in this one we will
just duplicate this route and here we will add the path it will be dashboard and this route will be
protected using this protect educator and here we have to provide the controller function that
is Educator dashboard data now duplicate this line and here we'll add another path so let me add the path name
enrolled students and here we will add get enrolled students data so we have imported these
controller function here so we have created the route for dashboard and enrolled a students data
after creating the apis for educator now we will create the API to get all courses and we will get the individual
course with the ID so for that here in this controllers folder we will create a new file with the name course
controller.js in this one we need the course model so we will add import course from Models folder and
course. JS file make sure to add the file name extension after that in this one first
we will create the controller function that will return all the courses so here we will add get all courses in the
comment and here we will create the function with the name get all courses so just add
export const get all courses and it will be asynchronous Aro
function in this function parameter we will get request and response and after that here we will add the TR
catch statement in this Tri block we have to find all courses from the course model so here we will add one variable
where we will store the courses so just add con courses equal to await use the course
model and in this one we will use find and here we have to find all the courses where the is published property
is true so if any course is in published State then we will display it on web page so here we will add is
published Pro after that in this one we have to remove some other data like in this one
we have the course content and enrolled a student right so we don't want this on the front end right so so here we will
add do select and in this one we will provide one are a and here we will add the first
property that I want to remove from this data so just add colon and here we will remove the course content so just add
minus course content after that we will add the comma and here we'll add another property to be removed from the data so
just add minus enrolled students so these properties will be removed after that we'll use do
populate in this populate we have to add one property so here we will add cly
bres path and in this one we will add educator let's remove this equal to now
it is correct so here we have added populate path educator it is because if I come back to
the course model here we have this course do JS so in this one you can see we have this
course schema and in this one you can see we have added this educator so in this one we are simply passing the
reference of user model so here we'll get the user ID but we want all the details of the educator like I want the
educator name also right for that here in this one we are adding this populate path educator so it will
provide all the data of user so that we can display the educator name on our front end after that we have
to generate the response so we will use the response. Json method in this response we will add
success true and with that we will add the course variable this one so here just add success true and provided this
courses after that if any error occurs in the tri block then the catch block will be executed so in this catch block
we will add this response. Json success Falls and the message is error. message so we have created the controller
function that will provide all courses correct now we'll create another controller function that will provide
individual course when we will provide the ID so will add this comment get course by
ID here we have to create one function so just add export con get course ID equal
to as sync and create the Aro function here we will get the request and response in the parameter and here
first we have to add the try catcher statement and before that we have to find the ID so we will get the ID from
the parameter so just add con C say ID equal to request do
padams so we will get the ID from the URL parameters after adding it we have the
ID now we will come to this Tri block and hit here we have to find individual CES using this ID for that let's create
one variable so just add const and the variable name is course data equal to we will use the await and provide the
course model dot find by ID and in this one simply provide this
ID now in this one also we have to add the educator details so just add populate
and in this one just provide this one where we have this path educator add it
here now in this individual course details we will get all the lectures and chapters but from this chapter we have
to remove the chapter URL if the preview is not free for that here we'll add one comment so let me add the
comment remove lecture URL if his preview is false so here we'll add this course data and in this course data
We'll add course content and from this course content we have to remove the lecture URL from the
chapter and lecture so just add one forage and in this one we will get the individual chapter so just add the
chapter and create the arrow function in this one we will get the chapter that is
here and in this chapter we will have the chapter content right so in this chapter content we will add
forage and again we will use one Aro function so in this chapter we will get the individual lecture and create the
arrow function and here we will add the if statement and we will add not of lecture do each
preview free so if each preview free is false in that case what will happen we have to add this lecture URL and provide
the Mt string that's it after adding it we have to return a response so simply
add response b. Json and in this one we have to provide the success true and with that we will
provide this course data so we will add it here success true and course data after that if any error occurs in the
tri block then the catch block will be executed so in this catch block simply add response. Json success false and the
message is error. message so we have created Two controller function Now using this controller function we
will create the routes so for that we will create a new file in this routes folder we will create a new file and
write the file name course route. JS in this one first we will import Express from Express package after that
using this Express we have to create a router so just add const and write the router name course
router and we will create it using Express dot router now in this router we have to
create different Endo so here we'll add course router dot get method so we will create this API endpoint using get
method and write the path all we will add the forward slash also and here we have to provide the
controller function so the controller function is get all cores so it has been imported
let me add the file name extension. JS here now we'll create one more route so just duplicate it and here we'll add the
method get and here we have to provide colum ID like this and after that here we'll
add the other controller function that is get course
ID so you can see this get course ID controller function has been imported correct after that we have to export
this router from here so simply add export and provide this default and add course
router so we have created this router next we have to add this router in our server.js file so we will open
server.js and in this one here we have added the route for the educator so after that we will add another route so
here let's add app. use then we will add the path so in this
one we'll add the path / API slash course and after that we'll add the
comma and here we will provide express. Json so all the request will be passed using the Json method after that we have
to add the router so we will add the router that is course
router click here so you can see this course router has been imported right now save the changes and
now we can test our routes so to test it we will come back to the postman application and here we'll create a new
request so in this URL we will add/ API SL c/ all and uh we don't have to provide
anything here we can delete like this and here it will be the get method only right and and after that simply click on
the send button so in this response we are getting success true and here we have
the course detail correct so here we have this one array and in this array we have
the first object that is one course detail we have the course ID title and other details of this
course right and in this details you can see we have removed the course content that includes the chapter
and lectures so we have removed that data and with that here we have the educator property also and in this
educator property we have the user ID Educator's name then we have the email ID and image of that educator right so
that we can display the educator image and name on the website below the course thumbnail now let's test the second AP
end point that we have just created for that here after this course we will
add slash and provide this ID if I provide this ID like this and click on the send
button now you can see we are getting the individual course and here we have the course content also so in the course
Details page we can display the course content but in this one if I come here here we have the is preview true so we
have this URL and if the is preview was false then here it will add empty string in the lecture
URL right so if I scroll down here we have only one lecture right then we have the educator
details also and other details correct so we have created the routes for the
courses after that we have to create the route to get the user data for that here let's come back to the vs code and we
will open this left side bar and here in this controller folder we will create a new file called user controller.js so
here we have this controller folder create a new file user
controller.js so here we have created user controller.js file and in this one we will create the controller function
to get the users data so here we will create a controller function with the name get user data so just add
export const get user data equal to create one asynchronous
function and in this function parameter we will get the request and it is
response like this now here we have to add the TR catch statement and in this Tri block first we
have to add a variable where we will store the user ID that we will get from the request so here we will add const
user ID equal to request. o. user ID right and after that using this user ID we have to find the user so just add
const user is equal to await and user model find by ID and here we have this user
ID right now we'll add the if statement and we'll check this user not user so if there is
no user with this ID then what will happen we will return a response so just add return statement and create create a
response using the Json method and in this one we will add the success fals and we will add the message
that is user not found here we are using this user model so we will import it so just add
user and import it from Models folder so you can see import user from Models folder SL
user.js file right now here we have this user and we have
added if the user does not exist then we'll return this response with success false after that suppose we have this
user then we will add a new response with Json method and here we will add success true
and with that we will add the user data also so just add success true and provided this
user here after that here we have the catch block so if any error occurs in the tri block then catch block will
be executed so in this one simply add success false and message is error. message so this return will be sent when
any error occurs in the tri block after that we will add one more controller function that will return the
users enrolled courses right so here let me add the comment that is user enrolled courses with
lecture link and for the first one we will add a comment here that is get user data right now let's create
this controller function for user enrolled courses with lecture link so we will add the controller function name
that is export con user enrolled courses it will be
asynchronous addo function and in this parameter we will get request and response and uh after
that we will create the TR catch statement now in this Tri block first we
need the user ID and using the user ID we will find the user so we will copy it from here paste it here
so we have added user ID and we will get it from request or user ID after that we will find the user data so here we will
add the variable name user data is equal to await user. findy ID and provided the user ID on this one we have to add
populate in this populate simply provide enrolled courses so now we have this user data
next we will generate a dis response so just add response. Json and we'll add one success property
that is true with that we will add the enrolled courses so just add
enrolled courses and it will be user data dot enrolled courses like this
after that if any error occur in the tri block then this catch block will be executed and in this one we will return
a response with success false and this error message so we have created Two
controller functions that is get user data and another one is user enrolled courses after creating these controller
function we have to create the API endpoint using this controller function so first we'll create the route so here
in this sidebar we will open this routes folder and here we'll create a new file called user routes.js
in this one we have to create a router so we will import the Express package so we will add import Express from Express
after that we will create a router with the name user router so just add const user router equal to Express dot
router now in this router we will create different Endo so just add router dot get method we will create the endpoint
with get method and here we will add the path SL data so when we will hit this path it
will return the user data so here we'll add the controller function that we have just created that is get
user data so this get user data has been imported and here we will add the file name extension user
controller.js now we have created one more controller function so just add one more route and write the path that is
enrolled courses and here we will add the controller function that is user
enrolled courses so this user enrolled courses has been imported next we have to export this router so here let's add
export default and provide this user router now we have to add this user
router in our server file so just open server.js and here let's add
app.use and in this one we have to add the path so it will be/ API sluser and after that we have to add
the express. Json so all the request will be passed using the Json method after that we will provide the router
that we have just created that is user router so if I scroll up here we have this user router it has been imported
right so we have created the API endpoint that will return the user data and it will also return the user
enrolled courses to test this one we will come back to the postman
application in this Postman application here we will add the path SL API SL user SL
data and now we have to add the headers also so in this headers We'll add authorization and here we'll add
beor a space and then we will provide the token to authenticate our request so again just come back to the
website open the console Tab and refresh this web page so it will generate a new token so just copy this
token and come back here in Postman paste this token here and click on the send
button here we are getting one error message request Json is not a function so let me just come back and uh here in
this user controller.js file you can see we have added request so it should be response RDS response. Json so we are
sending the response save the changes and come back to the website again refresh it to generate a new token copy
the token from the console and update the token here in this value so let me add the new token
then click on send button so now you can see we have the response with success
true and then we have the user data so in this user data we have the user ID name email ID and user profile
image right so now we are getting the user data using the API so this API is working fine after that we have created
one more API endpoint that is enrolled courses that will return all the enrolled courses of this particular user
so here we'll add the / API SL user SL enrolled courses and again add the new authentication token because the token
will expire in 1 minute so we will copy this new token and paste it
here click on send button so here you can see the response success true and here we have the
enrolled courses and it is an so right now we have not enrolled in any course that's why we are getting the
empty ad once you will enroll in any course then you will get the course details within this aday and you can see
the success property true so this API is also working that Returns the enrolled courses
data after that we have to create a new API using that we will allow user to purchase the course and to purchase a
course we need need to add the payment Gateway also for that we will use the arrip payment gateway to set up the
arrip payment Gateway we will open a new tab and open a stripe.com so let me open a stripe.com
and here we have to create an account so I already have an account and if I go to create
account let me click on sign in and here we have the option to create account so in this one you will find
their limited country right so if it is not available for your country you can
choose any other country also and you can create a test account so I already have the account I'll click on this
signin button and I'll sign in with my email ID and
password after sign up you will come to this page and here you will find this publishable key and secret key right now
you can see we are in the test mode you can see here correct and you can also find the keys in this developer menu
I'll click here on developers and then go to API keys from here you can copy the
publishable key and secret key so let me just copy the first one click here to copy the publishable key and come back
to the vs code and here we will open the involvement variable and and in this one we will create a new envirment variable
so I'll type a stripe stripe publishable key and in this one we will store this key that we
have just copied let me add it in single code after that we will add the another
environment variable with the name stripe secret key and here we will store the secret key
so to get the secret key again come back to the stripe and copy this key just paste it
here so I have added the AR stripe publishable key and secret key Now using this we have to generate the payment
link when we purchase a course so just come back to the user controller.js file and here we will create a new controller
function to purchase any course for that here let's add a function so we will use use the export
to export this function export const and write the function name purchase
course it will be a synchronous function and in this function we will get the parameter that is request and
response before this function let me add the comment also so this is the comment purchase course so we have created the
function now in this one we'll add the try catch statement now in this one first we need the course ID and we will
get the course ID from request body so we will add C course ID equal to request. body after that we need the
origin so let me add const origin and we will get the origin from request. headers right after that we need the
user ID and course data to get the user ID again we will add the same thing so just add const user ID request o. user
ID Now using this user ID we have to find the user data so just add const user
data equal to we will use the await and we will add the user model now in this one we will add find
by ID and provide this user ID here so now we have the user data using this user ID
after that we need the course data also so just add const course data equal to
await and here we will use the course model and in this course model we will add find by ID and here we will provide
the course ID that we are getting from the body so just add this course ID here after that we will add the if
statement that will check whether we have the user data and course data available or not so we will add the if
statement right not of user data or not of course data so if any of this data is
missing then we will return a response with success false and with that we will add the message data not found right and
if we have both user data and course data available in that case we will create a purchase data so just add
con create a variable purchase data and it will be one object and in this one we have to store the course ID user ID and
amount as you can see in this purchase model in this purchase model you can see we have added course ID user ID amount
and and a status and for this a status we have added the default value pending right
so again come back to the course controller and here we will create the data for purchase data right so here
first we need the course ID and in this course ID We'll add course
data dot uncore ID after that we need the user ID then we need the
amount in this amount property we will add the amount after calculating using actual course price and applying the
discount so just add course data dot price so this is the course price and in this one we will decrease the discount
amount so just add course data. discount m mli by course data do price divide by
100 right now we'll add two fixed and provide the number two that's it so we have added the
purchase data next we have to store this purchase data in the mongod DV database for that let's add
const and in this one we will add variable new purchase it will be await and provide
the purchase model so this purchase model has been imported right now in this one we will add create
method and here we will provide this data so we have created a new purchase and it will be stored in the mongodb
database after we stored the purchase data in the database we have to initialize the payment Gateway for that
we need to add the stripe so here we will add the comment a stripe Gateway initialize so
here let's add const a stripe instance equal to new stripe
we will click on this suggestion so here we have added new stripe in this one we will
add the stripe secret key so we will get it from environment variable so just add process dot
EnV Dot and provide the envirment variable name that is a stripe secret key so we have created one instance of a
stripe right now you can see we have created this controller function in this course controller.js file but we
have to create it in user controller so let me move it to other file so let me just copy the entire code of this
function so I will cut this function from here now we will open user controller.js
file from this sidebar here we have this user controller and in this one we will paste
this controller function that is purchase course right and in this one we have to add the Imports so again come
back here in the course controller and in this course controller you can see we have
imported user and purchase let me remove from here and we will remove this a stripe also so let's
add it here and cut these Imports and we will open user controller.js file and provide this
import a statement here like this so this user is already imported
here I'll remove this line now save the changes and here let me complete this
function so after creating the instance we need the currency also right so first we have to create one environment
variable so we will open EnV file and in this one let me come to the top and here only
we will add a new environment variable and the variable name is currency and here we'll
add the currency USD you need to add it in capital letter USD you can add your own currency code here make sure to add
the same currency code for which you have created the stripe account after that we will come back to the user
controller.js file and here we will get that currency for that let's add one variable con
currency equal to we will get it from envirment variable so just add process. env. currency so we have imported the
currency from the environment variable using process. env. currency after that in the EST stripe we need the currency
code in lower case so we will add two lower case now we have the stripe instance and
currency next we have to create the line items where we will store the purchase data like we will store the product name
we will add the amount and we will add the quantity so let me add the comment here we will add the
comment creating line items for a stripe right and after that we will add the variable const line items it will be one
array and in this one we'll add one object where we'll add the first property that will be price data in this
one let's add one object and here we'll add the currency after adding this currency here
we will add the next property that is product data and in this product data we will add one object and here we will add
the name of the product so first We'll add the property name that is name and we will store the course title so just
add course data doour title if I scroll up you can see we have already stored this course data right here you
can see this course is not imported so let me import it we will add this course select here so the
course will be imported if I scroll up you can see this course has been imported from course model scroll down
so now we have added the product data after that let's add the next property that will be unit amount right so here
we'll add unit amount in this unit amount we have to add the price of this particular course
so here we have created this new purchase data so in this new purchase data we have the amount property so we
will add new purchase do amount right now we have to add the amount in round figure so just add math.
Flor like this now we will multiply it with 100 after that here we'll add the comma
and add the next property so it will be quantity so we will add the quantity one so the course quantity is one now we
have created the line items Now using this line items we will create one payment session for that here we will
add con and write the variable name session in this one we will add a
wait and here we will add the a stripe instance that we have already created a stripe instance and here we'll add
checkout then we will add sessions and we will add create so it will create one session now
in this one we will add the object and here we will provide the properties and values so first we'll add the success
URL so just add success URL and in this success URL we will add the URL from the origin variable so just
add the back Tex so that we can add the template leral so just add dollar sign cly Braes and provide the
origin that we are getting from request do headers after that we will add slash and provide the path so we will add
loading SL my enrollments after that we will add the comma and add the next property so the
next property is cancel URL so in this cancel URL we will add only origin so just add this and here we will remove
this path that's it after that we have to add the line items so here we'll add the
line items and provide our line items that we have created next we have to add the mode so in the mode we will add
payment right and after that we have to add the metad data so let's add the metadata and in this metadata property
we will add the object where we will add the purchase ID and in the purchase ID we will add
the ID using our purchase data so we have created new purchase right and in this
one we have the ID also so just add doore ID and here we'll add two a string so it will convert it in a string
format right after creating this session we have to create one response so to send the response we will use response.
Json in this s we will add the object and in this object we will add success true
right and after that we will add the session URL and in this session URL we will provide the
session do URL so in this session we will get one URL property that we are sending in this response that's it and
if any error occurs in the tri block then we will send this response using this catch block that is Success false
and message is error. message that's it so we have created this controller function purchase course now for this
controller function we will set up the routes so let's come back to the user routes.js file and in this one
we will duplicate this line and here we will use the post method we are using the post method and
in this one we will add the path that is purchase right and after that we will add the controller function that
is purchase course so this purchase course controller function has been imported
right now we have created the endpoint that will help us to purchase any course now to test this one we will
come back to the postman application and here we will add the path that is/ API SL user
SL purchase here we will change the method it will be post right after that let me
clear this response so in this API we have to send the course ID to purchase the course
right so here we'll go to body and here we will select this Raw in this RW we have selected this Json
and here we have to provide one Json data so here we have to add the course ID so let me add the course ID
property and we have to add the value make sure to use this double code right and here we have to add one course ID so
let me just come back to the mongodb database and in this database you can see we have this
course and for this one we have this course ID so let's copy this course ID and paste it
here right so we have added the course ID in the body in this headers we have to add the authorization beor and after
that we have to add the token so again we will generate a new token so we will come back to the website refresh it to
generate a new token copy the token and come back here we will paste the token here and click
on the send button here we are getting the success false and the message is invalid URL
undefined because in the controller function we are fetching the origin from the request and we are sending this
request using the postman not from the website so here we have to define the origin also so in this headers we will
add origin and let me add any or in so let's add HTTP or I'll copy from
here like this so I'll type this one or instead of this one let me just
copy the URL of our front end and we will paste it [Music]
here so we have provided the origin after that in this authorization we have to provide a
new key that is token so just refresh it and generate a new token copy this come back and uh let's
paste the new token here then click on send button so now you can see the response
and in this response we are getting success true and we have the session URL and this session URL is actually a
payment URL let me open this URL in web browser so I'll copy this and open it in the web
browser so you can see it is opening this payment gway where user can purchase this course online and after
purchasing we have to verify the payment right to verify this payment we will use the stripe B hooks to set up the AR
stripe B hooks we need the be hook secret key to generate that here we will click on this developers menu then we
will click on this web hooks here I have generated some other
web hooks for different project to generate a new one I'll click here on ADD destination button just click here
and here we have to subscribe the event so scroll down and in this one you will find
this payment intent just expand this one and in this payment intent I'll subscribe for this intent payment failed
just click on this checkbox and with that we will add one more intent do succeed so we are
subscribing two events payment failed and succeed then click on this continue button then again click on continue
button and here we have to provide the end point of our we hooks so first We'll add the backend
URL so let me just copy the backend URL from this versal here we have the live URL of the backend project so just copy
the link and paste it here and after that here we will add the Endo path that is a
stripe like this then click on this button create destination so here in the right side we
have this signing secret so this is our secret key for the stripe web hook so we have to add this secret key in the
involment variable so let me just come back to the environment variable before that I'll
copy this key and here let's open the environment variable here we have added a stripe
publishable key a stripe secret key after that we will add our we hook secret key so just add the variable name
a stripe be hook secret and here we will provide our key that we have just copied so I have added the a stripe B
Hook secret in the involvement variable after that we have to create a function to handle the be hooks for that we will
open this be hooks. JS file and here we have to create a function to handle the B hooks for that we need the
documentation of a stripe so just come back to the web browser and we will open this URL docs. stripe.com
/bb hooks open this link here you have to scroll down
then go to this option verify with official
libraries come at this point and here we have the steps to handle the web hooks so first let's create a
function so in this be hooks. JS file we will create our function so let's write the function
name a stripe web hooks we will add const and we will export this function right and this will be a
synchronous function and in this one we will get the request and
response now in this one we need the a stripe instance right so to create the stripe instance here before this
function let's add const a stripe instance equal to
new a stripe you can see this a stripe has been imported from a stripe package
right now in this one we need the a stripe secret key so we will add process.
EnV then write the envirment variable name that is stripe secret key so now we have initialize the stripe
instance and after that in this one we will add this code from this website so just come back here here you can
see first we need the a stripe signature so let me just copy this code
from here and paste it here so in this one you can see we have
the signature then we have added let event and in this event we are getting the event from this stripe B
hooks here we have to make it capital S because we have imported it as capital s from the stripe package now in this one
we have to add the be hook secret key to add that we will use the involment variable right so here we will
add process. EnV Dot and the variable name that is a
stripe book secret correct after that we have to handle the
event that we are getting here right so to handle the event let me just come back
here in this documentation here we have the steps to handle the event so to handle the event we are using switch
case statement right so let me just copy this one this switch case statement and I'll copy till
here and come back here and paste it in this function now we have to change the code here so
in this one you can see we have this first case payment intent do succeed and in this one let me remove these lines or
I'll just remove this console log and I'll wrap this one in a curly braces like this so we have added the
curly braces and here we have the payment intent and we will get it from event. dat
doob right next we need the payment ID right so just add con payment ID and it will
be payment intent do ID next we need the purchase ID and we
will get the purchase ID from the session so here let me get the session so just
add con session equal to await then we'll add the stripe instance in this one we will add
checkout dot sessions do list here we will provide payment intent
and uh it will be payment intent id that's it now from this session we will extract
the purchase ID so here let's add const purchase ID equal to the session dot
data then we'll add the index 0 dot metadata so now we have the purchase ID Now using this purchase ID we will find
the purchase data so let's add cost purchase
data equal to await and we will use the purchase model so we will import this purchase
model from Models folder and in this one we will use find by ID and we will provide the ID that we
have extracted here that is purchase ID so now we have the purchase data now we will find the
user data also right so to get the user data we will add con user data equal to it will
be user model so before that we'll add a wait
user dot find by ID and we will get the ID from this
purchase data right so in every purchase data we will get the course ID and we will get the user ID so just use this
here purchase data and find the user ID so now we have the user data next we need the course data that is available
in this purchase data so just add the variable con course data equal to
await here we will use the course model then we will add find y ID in this one we have to provide the purchase data
and in this purchase data we have the course ID and here we will add two a string
method so now we have the user data and course data here we have to add this space like
this after getting the user data and course data next we have to add this user data in this course data and in
this course data we will add the user data for that let's add course data
dot enrolled students because in this course data we have the enrolled a students property
and in this one we have to add this push so we will push this user data here so in our course data we have added
this user data and after that we have to save this in the mongod DV database so we will add
await course data dot
save after that next we have to push the course data in the user data so let's add user
data dot enrolled courses and in this enrolled courses we will add
push and provide this course data doore
ID next we have to save it in the mongod DB database so we will add await user data do save next we have the purchase
data here so in this one whenever a new order is created then the status will be pending right so we
have to change the status as completed because we are handling the event succeed right so here we will
add purchase data do status and it will be completed and after that we have to save it in the
mongod DB database so we will add await Pur data do save so we have created this first case when the event is
succeed correct now let's see the second case so we have subscribed the second event that is payment failed so here we
will update this one it will be payment intent dot payment failed write it here so this
is the second event that we have subscribed now in this one we have to wrap everything in the curly
bres like this so here we have added this cly Braes now let me just remove this code from
here and I'll copy the code from the previous event so here we have this code just copy this line and paste it
here so we have added payment intent then payment ID then we have the session right and in this
session we will get the metadata so here we are getting the purchase ID from this metadata right and now using this
purchase ID we will get the purchase data so here let's add cost purchase data and it will be a wait purchase.
find by ID purchase ID correct next we have to add the status because here we have added the payment failed event so
simply we will update the status of our purchase data that is failed so just add purchase data do
status it will be failed correct next we have to save this data in the mongodb database so just add
await purchase data. save that's it so we have added the case for the second event now we will handle
the other type of event so simply add default case and in this default We'll add console log unhandled event type and
event do type correct after that we have to return a response so we will add response. Json and here we will add
received true so here we have created our function to handle the stripe we Hooks and you can see here we are using
the course model but we have not imported it so to import this course model let me use this suggestion so we
are getting course from Models folder click here now this course model has been
imported so we have completed our be hooks controller function now we'll create the API endpoint for this a
stripe be hooks so just open this server.js file and in this one here we will create a new API endpoint so just
add app do post and in this one we have to add the path it will be/ a
stripe correct and then we have to add the Express and instead of this Json we will
use Express dot raw correct and in this one we have to add
the object and in this object we will add type application Json after that here we will add the bi
hooks controller function so just add a stripe web hooks that we have just created so
if I scroll up it is imported from books. JS file correct after adding it we have to
redeploy our project on versal for that let's open versal then we will go to
settings and here we will open environments or I'll go here in this environment variables so here we have
added some environment variables but we have to add one more environment variable that we have just added that is
be hook secret correct so to add it we will come back to the envirment variable in vs
code let's open the envirment variable here we have added these envirment variables so let me just copy
all these three envirment variable for a stripe publishable key key secret key and a stripe book secret just copy this
and add it here so I'll click on this add another so I'll click here in this key
and I'll paste the variables that we have just copied so we have added all three environment variables we will add
one more so let's click on this add another button and here we'll add this one if I come back here we have added
this currency so just copy this and we will paste it here so now we have added a stripe publ
key secret key book secret and currency then click on save so we have updated the environment
variables in our versal project next we have to redeploy our code for that we will come back here in vs
code and let's click on this Source control icon and here I'll add
this message for this commit so we'll add a stripe added and click on this
commit then click on sync changes after that we have to check our versal project and here we will come to
this deployments so you can see our project has been redeployed again again you can
see just now correct so after redeployment we can test our payment integration right so for that we'll
again purchase a new course to test it we will come back to the postman application in this one we have already
tested this user purchase right and here we have address this body and in this body we have added one course ID in the
Raw after that in this headers we have added origin and authorization and here we have the beer and token so next we
have to replace this token so we will come back to the website refresh it to generate a new
token just copy this token and paste it here now click on send
button so here you can see success true and here we have a new session URL now I'll copy this URL and open it in the
web browser so it is opening this payment page and here we have to complete this
payment so here I'll add the email ID and use this card option here we are using this payment gway in test mode so
we can use the test card number so I'll add the test card number this one then we'll add any future month and year
so just add like this add any three-digit number then add the name and I'll click on this pay
button after the payment it is redirecting us to this URL right let it be and now we will come back to the
mongod DB database in this mongod DB database here we have this purchases just click
here and here we have the previous payment data that is pending pending and this is the new one where we
have completed the payment and you can see the status completed so our payment verification is working fine using the
stripe B hooks so now we have completed our payment Gateway integration in our LMS
project after updating this status if I open the courses so you can see in this course we have this inal students data
and in this inall students we have a new user right so this user has been added in this course data right and if I open
this users data and in this user data here we have this enrolled courses and in this one we have this course ID so so
in this user data we have added the course data and in this course data we have added
the user data so we have completed this function now we will create the API to manage the course progress of the
student for that we will come back to the vs code here first we'll create the models to store the progress data in the
mongod DB database to create the model we will open this models folder and in this
models folder we will create a new file that is course progress. JS now in this one first we will import
from package and now we will create the schema for our progress model so just add const course progress a
schema it will be new mongos do schema Constructor here we will add the object and we will define the properties that
will be added in the progress data so first We'll add the user ID and here we will add the type a
string and it will be required true so just add type A String required true for this
now we'll add the multiple property in this one so we will add course ID and it is also a string and required true then
we will add the next property completed and it will be type Boolean so it could be either true or
false right and here will add the default value false so by default the course completed will be
false and instead of this required we will add default so the default value is is false
after that we will add the next property that is lecture completed and for this lecture completed we will simply add one
empty aray where we will add the list of lectures that is completed right and after that here we will
add minimize false right now we have created the SCH
schema and using this SCH schema we will create the models so just and Export con course progress and we will create the
model using do model and in this one we have to add the model name that is course progress after
that we have to add the schema that we have created here like this so we have created the course progress model Now
using this model we will create the controller function using that controller function fun we can update
the course progress and we will get the data of course progress so again we will open user controller.js file scroll down
and here we will create our controller function so first We'll add the comment update user course
progress now we will create the function so just add const update user course progress equal to async and
create the addo function and next we have to export this function so that we can use it in another files so we will
add export and in this one we will get the request and response correct now in this one we will
add the try catcher statement now in this one first we need the user ID so just add const user ID
equal to request of user ID right after that we need the course ID and lecture ID so we will get the course ID and
lecture ID from the body so whenever we will make the request in the body we have to provide the course ID lecture ID
and we will get the user ID from the request of user ID property after that from the course progress model we
have to find the progress data right so we will add add one
variable cost progress data equal to a wait and we will use the
model course progress so it has been imported after that here we will use find one and in this one we have to
add one object where we will add the user ID and course ID right now we will add the if
statement and here we will check when we have the progress data right so when we have the progress data
in that case again we will check if the progress data do lecture completed and it
includes the lecture ID that we getting from the body so if this lecture ID is included in the progress data right then
what will happen we will return a response so just add response. Json and here we will add the object and
here we will add the success true and we will add the message lecture already completed right because in this progress
data this lecture ID is already available it means this lecture is already
completed right now here we will add progress data do lecture completed dot
post so what is happening here if it is not completed then we have to push this data this lecture ID in this
progress data so that it will be marked as completed so just add this lecture ID here right and after that we have to
update it in the database so we will add await and we will use this progress data do
save right now here we will add the else statement suppose we don't have this progress data this progress data is
false in that case we have to create this so just add await and write course progress model do
create and in this one we will add the object and in this object we will add the user ID then we will
add course ID and we will add lecture completed and in this one let's add the array and provide the lecture ID
like this because in this model you can see we have added user ID course ID then completed
and lecture completed and for this one we have added this default value so here we have added this after
that we have to send the response to generate the response here we will simply add response. Json
and in this one we will add the object where we will add success true and we will add the message progress updated
correct and if any error occurs in the tri block then we will return this response using this catch block so we
will add success false and message will be error. message so we have created the controller function that will update the
course progress right next we will create another controller function that will provide us the progress details
right so just add the comment get user course progress and we will create the function and we will export the function
so just add export const get user course progress and it will be a synchronous Aro function so create it and in this
function parameter we will get the request and response now now in this one also we
will add the try catcher statement in this one we need the user ID and then we need the course ID also
so let me just copy it from here copy these three lines and paste it here here we will get the user ID from
this Au user ID then we will extract the course ID from body right and after that we will find the
progress data using this course progress model find one and provided this user ID and course ID so now we have this
progress data and next we have to Simply return this progress data in the response so just add response dot Json
and provide this object where we will add success true and with that we will provide
this progress data variable correct now if any error occurs in the tri block then we will send this response using
the catch block so we have added success false and the message is error. message correct so we have created both
controller function to get the progress data and to update the progress data now using this controller function we will
create the route so we will open this user routes.js file right and after that here we will
add user router. poost and in this one we will add the
path that is update course progress like this and then we will add the controller function that
is update course progress and uh here we have to add the SL also SL update course progress and you can see this function
has been imported now let's duplicate it and here we will add another path that is get course
progress after that here we will update the controller function so it will be get user course progress so this
function has been imported get user course progress so we have have created the
Endo to get the progress details and update the course progress next we will create the feature
to rate this course right for that we need to create a new controller function to create the rating function we will
come back to the user controller.js file in this one I scroll down and here let's create the
comment add user rating to course correct now we will create a function and we will
export this function so just add export con user rating equal to we will create the asynchronous
function and in this parameter we will get request and
response correct now for this one we need the user details rating and course details right so we will get the user ID
from the request. do user ID after that we need the course ID and rating and we will
provide it in the request body so just add request do body
correct next we need to validate whether we have the user ID course ID rating available or not in the request for the
we will add the if statement and here we'll add not of course ID if the course ID is not available or we will add not
of user ID if the user ID is not available then we'll add not of rating if rating is not provided in
the request then we will add or if the rating value is less than
one then we'll add all operator and again add if the rating is greater than five so in such
cases we will return the response with success false and we will add the message also that
is invalid details that's it right now if all these things are valid then we will add the TR catcher statement
and here first we will find the course data using this course ID for that we will add cons course equal
to we will add the await course model
dot find by ID and provide this course ID here like this so now we have the course
details now we will check
if we don't have the course using this course ID right so in such case again we will return the response with success
false and we will add the message that is course not found right now suppose we found the
course in that case we will execute the next line and in the next line we will find the the user using the user ID that
is here right so to find the user let's add const user equal to
await we will add the user model do find by ID and here we will add the user
ID so now we will get the user so again we'll add the check so here we'll add the if statement and we'll check if we
don't have the user or if we don't have the enrolled courses data where we have
this course ID this one so in this user we will check for user enrolled
courses and in this enrolled courses we will add includes and if it includes the course
ID right and here we will add not it means this course ID is not available in this enrolled courses data so in that
case we cannot rate this course right because we have not enrolled into the course so we cannot rate the course so
simply we will return a response here so just add returned response. Json success Falls and the message is user has not
purchased this course that's it because without purchasing we cannot rate the course now after that we will
check if we have purchased the course and we have already provided the rating or not for that we will add
con existing rating index suppose user has already provided the rating so in that aray this user ID will be available
so we will find that index so just add course. course rating and in this course rating we will
find index and here just add rating and so we will get the individual rating and here
we'll add rating. user ID equal to the user
ID that we are getting from the response so here we are finding the rating index and if this user ID is available then it
will return the positive number in the index and if it is not available then it will return the negative value so here
we'll add if and we will add existing rating greater than minus 1 it means if
it is positive value it means the rating is already available so we have to update that rating so just add P
ratings and in this one let's find this index and on this index we will update the
rating and here we will add the rating that we are getting from the body like
this after that we will add the else statement if this user has not given the rating earlier right so we will create a
new rating for that we will use this course. ratings and in this one we will push a new data so just add
push and here we will add the object where we will add user ID and with that we will add
the rating that's it so we have added the rating using this if Els a statement
after that we have to save this data in the database so just add await we will use the course data and
then write save so this course will be saved in the database after that we have to return
the response so simply add return response. Chon and in this one we will add the object where we will
add success true and we will add the message rating added correct after that here we will
add the catch block so in this catch block we will return a response with success property false and
with that we will add the message error. message so we have completed this controller function that will
handle our ratings right now we will create the route using this controller function so just open user routes.js
file and in this one let me duplicate this line and here we will add the path that is ADD
rating and with that we will add the controller function that we have just created that
is add user rating so this add user rating controller function has
been imported so we have created all the apis for our project so now we have completed the back end of our LMS
project and after that we have to connect this back end with our front end so that we can display these courses
from our database and we can enroll into the courses and students can watch the course online before connecting our
front end with our back end let me first deploy the latest changes on versal for that we will come back
here and now just open this Source control and here we will add one commit message backend
complete click on Commit button click on sync changes after completing it we will come
back to the versal dashboard then go to deployments and you can see it is redeploying our
project correct now you can see this ready message it means our backend project is
successfully redeployed on versal now we will connect our backend apis with our front end project so just come back to
the vs code and here we will close all these files so right click here and select close saved
correct and from this left side bar let me collapse This Server and we will open this client right because in this client
project we will add the apis and we will get the data using the apis so here in this one we have the envirment variable
so just open the envirment variable where we have added the color public key and currency with that we need the
backend link correct so our backend is is running on Port 5,000 so here we will add the environment variable name V
backend URL equal to and here we will provide the URL that is Local Host Port
5000 correct save the changes now we will open our context file so let's open
SRC context and open app context. jsx file so let me scroll
up in this file you can see here we have this function that will fetch all courses right so right now it is finding
the course from the dummy courses that is available in the assets so instead of getting the
course data from the assets we will get the course data from database and we will get it from our API so here we will
add the TR catch block now in this Tri block we will add the API call for that we will use the
exos package so to make the API call we will use the exos so first we have to install the exos package in our client
project so just open this sidebar and here we'll click on this package.json so in this one you can
see we have not installed that xos package so we will open the terminal and uh let me switch to the
first terminal where our client project is running so you can see our client project is running using this terminal
you can see Local Host 5173 so first we have to stop this project so just add contrl C
yes so you can see in the LMS folder we are in the client folder right and here we will install the package so just add
npm install and and write the package name exos right and after the API call either
we will get the success or false response then we will display the response or notification using the react
toasttify so just add the new package that is react toasttify so we are installing exos and react
toasttify just press enter so it will install these packages you can see exos package has
been added in this dependencies now let's come back here in this app context. jsx file and in this
Tri block we will make the API call so just add a wait then write exos and we have to import this exos so
here we will add import exos from exos package and here we will add await exos dot
get in this one we have to provide the backend URL so we will add the backend URL here so let's add one variable we
will add con backend URL and we will get the backend URL from the environment
variable so just add import do meta do
EnV then write the environment variable name that is we backend URL now just copy it and paste it here
so here we have this backend URL and in this URL we have to add the complete API path right so here we'll add the
concatenate and we will add the remaining path that is/ API slash course SL all so it will return all the courses
available in our database correct and next we will store this response in a variable so just add
const write craes data so in this response we will get one data right and now we will check if we have this data
then we will set the course and if it is not available then we will display the errored message so just add if statement
and we will write data and write data. success so if the response data. success is true then we will use this Setter
function set all courses and in this one we will provide data dot
courses like this then we'll add the Els statement and here we have to display the error message using the react
toasttify so let's open the react toasttify website just open this npm website for
react toasttify and here we have the steps to use react toasttify in the react project so first
we have to install it that we have already done then we have to import this toast container from react toasttify
right and then we can use this toast container tag so let's copy this import statement here
and come back to the vs code and we will open app.jsx file and here we will import it
so simply add this import toast container from react toasttify we will remove this toast from here I just want
this toast container now we can add this tag here in this return so here let's add toast container and close this tag
here like this now we can use the toast notification in any component so let me
close this or come back here in this app context. jsx file and here we can use
the toast notification so here we will add toast click here so this toast has been imported from react toi and after
that in this one we will use do error because we have to display the eror and here we will add this
data Dot message like this so we will get the data from the API and we will set that
course data using this Setter function set all courses now if any error occurs in this
try block then the catch block will be executed so here also we will add this toast. eror
and provide this error do message so just add this error do message so now we have added the
function that will fetch the course data after updating this function let me start this front end project so I'll
open the terminal and you can see we are in the client project and here we will add npm run Dev to start our front end
project again so our front end cont is running on Local Host 5173 so let me just come
back to the website so if I come to this website you can see here we have only one course we
have this test course title then we have the price and if I go to all courses here also we have only one
course right because we have added only one course in the database so this function is working fine that will set
all the courses now just come back to the app context let me minimize this terminal
and here we have the function now we will create a function that will fetch the user data from our
API and we will store that user data in a a state so here we will create one a state variable so we will duplicate this
line and here we will add the variable name name user data and the setter function name is set user data
and we will initialize it with null like this and here you can see we have added is Educator so let me make it
false so by default it will be false correct now we will create the function using that we will set this
user data so here after this fetch all all course say let's create another function that is fetch user
data and in this one let's add the function name cost F user data and it will be a
synchronous function and in this function we will add the TR catcher statement because we have to handle the
apis so so here we will add the cost and we will get the token because to get the user data we
need to send the token in request and we will get this token from here using this get token function so here we'll
add con token equal to await and provide this get token function right now we can make the API
call so we will add a wait then write exos dot get method and in this one we have to add the backend
URL with that we will add this path so it is slash API sluser SL
data so it will return the user data now in this one we have to provide other details also so we have to provide the
headers and in this headers we have to send the authorization token so just add column and add the object and in this
object we will add authorization and in this authorization we have to
add beor and token so we will add the back tick so that we can add the template
literal so we will add beer then we'll add dollar sign C addresses and here we will provide
token like this so we have provided this token from here after that we will get the data and
we will store that data here so just add const and we will store it in this one
data now we will check this data do success property is true or false so we will add the if statement and here we'll
add data. success and if it is true it means we have this data and we will use the
setter function that we have just created that is set user data and in this one just provide data dot user
property now we will add the Elsa statement and here we will add the notification so just add
toast. error then data. message and if any error occurs in the tri block here we will add the
notification in the catch block so it will be toast. error and the message will be error. message like
this now whenever we will execute this fetch user data we will also update the
educator so we have added one educator State here you can see is Educator and set is Educator and
here we have the false right and here we are getting the user so now in this user we will check
the meta data so let's add if this user
Dot Public metadata do rooll equal
to educator so in that case we will set that state variable true so just add the setter function set is educated and we
will make it true that's it next we have to call this function whenever the component gets loaded so here scroll
down and here you can see we have added this use effect right and here we have added this dependency add a user so in
this one we will add this function fet user data and now we don't need this token in the front end so we will remove
this function and remove this function from here that's it so it will fish the user
data whenever the component gets loaded next we have to pass these State and function you using this
value object so in this one let's add comma and here we'll add the variable that is backend URL we need the backend
URL in other component also then we will pass the user data and set function set user
data correct now we will pass this get token also and after that we will pass the
fetch all courses you can see here we have this pitch all courses so we will pass
it using this value object so that we can access it in any other
components that's it after that we will find the enrolled courses for each user right for that we
have already created the API so here we will create one function that will Fitch the user enrolled
courses if I scroll this page you can see we have already created that function here F user enrolled courses
and we are getting the course data from the assets using this dummy courses so let me remove it and here we will fit
the enrolled courses data from the API so to make the API call first we need the token and we will get it from get
token function like this and after that we can make the API call and we will get the response so here we'll add cons data
that we will get from the response and here we'll add the API call so just add await
exos dot get method and in this one we will add the backend URL and with that we will concatenate the remaining path
that is SL API slash user SL enrolled
courses correct after that here we will add the comma and we will add the headers so
just add the object and provide the headers and in this headers we will provide
this authorization beer token right now we will check this data do success property so just add if
statement and here we'll add data do success and if it is success then we will set the enrolled courses so
we will use the setter function that is set enrolled courses and in this one we will provide
this data dot enrolled courses then we will add the reverse
method so it will reverse the list of courses and we will get the new courses at the top after that we will add the
else statement and in this one we will add the error message so simply just copy it from
here post. error data do message here we are getting the data
from the API so let me wrap all these statement in a TR catch block so we will add TR catch state M and let's move
these code in the tri block like this and if any error occurs in the tri block then the catch block will be
executed so here we will add this toast. error and the message will be error. message so we have updated this F user
enrolled courses function correct now if I scroll down here you can see we are calling
this function here in this use effect so let me we remove it from here and we will add it in this second use
effect in this one because this function will be executed whenever the user changes so it will Fitch the indal
courses again after adding it if I scroll up here we have one function to
calculate the rating here we have this calculate rating function and in this one we have returned this total rating
divide by course rating do length but if we get the value in fraction then it will display the error so here we will
wrap it using the math. FL so let's add math. Flo and provide this
one total rating divide by course course rating. length that's it now after updating it we will come
back to the website right and here we have this course and if I go to my
enrollments here we have one course that is test course title right so in this my enrollments we are getting this course
and if I click on this one it will open this course Details page where user can watch the course and if I expand this
chapter here we have the lecture so in this course I have added only one chapter and one lecture and here we have
the option to rate this this course correct now here in this navigation bar you can see we have this educated
dashboard option because in the metadata I have already added the role educator if I go to this Coler dashboard and go
to users so here we have this user and in this user public metadata you can see we
have added role educator let me remove it I'll click on edit and delete this one click on
save so we have removed the data from this public metadata and if I refresh it here you can see we have the link for
become educator correct earlier it was educator dashboard now we will add the functionality here so that if I click
here any normal user can become educator and publish the course correct for that we will come back to the vs code and
from this left sidebar we will open this components then go to student and open na. jsx
file in this file first we have to import the backend URL so that we can make the API call then we will import
the is Educator Setter function that is set is Educator so that we can make a normal user educator after
that we will import the token also to make the API call so here in this line where we are getting the data from App
context here we will add comma and we will import backend URL after that we will import the seter
function set is Educator then we will import get token like this now here before this
return statement will create a function so we will add the function name become educator so just add
const become educator equal to async function and in this function we will
add the try catcher statement correct now in this one first we will check
if this is Educator is true it means the user is already educator right then we will navigate them to educator route so
here we will add navigate and provide the path that is Educator and then we'll add
return that's it and if this is false then it will execute the remaining lines so here we'll add const
and we will get the token using the get token function so just add
await get token so now we have the token right so now we have the token and backend URL also so that we can make the
API call and after making API call we will get the data from the response and let's add the API call using exos so
just add this exos so exos has been imported after that we will add await here so just add await exos
dot get method and in this one we have to add the back end uel and after that we will
concatenate the remaining path that is/ API SL educator SL update role we have created this
API endpoint to update the user role now we'll add the headers and in this headers we have to
add the authorization and beer right so just add authorization beor and we'll add the
token correct now we will get the response here and in this data we will check whether it
is success or false so here we will add if data. success property is true then we will set the educator right so here
we'll add the setter function set educator true after setting the educator true we will display one notification
also so here we will add the toast so click here so it will import the toast from react toasttify then add
toast. success and here we will add the message that we are getting from the response so just add data do
message that's it now we'll add the Els state M if the data. success is false in that case again we will add the toast
notification and we will add the error so just add toast. error data. message and if any error occurs in the tri block
then this catch block will be executed so here we'll add toast. error error. message like
this so we have created the function using that and user can become educator now we have to link this function with
our menu so scroll down and so here we have this button where we
have added the text educator dashboard and become educator so in this one we have the on click property so let me
remove everything from this on click property and here we will simply call our function that is become educator
like this now if I scroll down here we have the mobile menu and in this one also we
have the become educator button so let me clear this and in this on click just provide
this become educator function that's it after adding it if I come back to the
website and if I click on this button become educator here you can see we have a
notification you can publish a course now correct and here you can see a new button that is Educator dashboard and if
I click again it will redirect us to the educator dashboard correct so it is working fine now let me just come back
to the homepage again and here in this one you can see here we have the course data on homepage and here we have the
course title rating price correct and here we have the educator name that is the static data right so we have to get
this educator name from the dashboard for that we will come back to the vs code and from this sideward we will open
this course card and in this course card you can see we have this text greatest tag that is the educator name so instead
of this one we have to display the educator name from the database for that here we will
add cly addes we will get the course and in this course we have the educator
property and in this educator we have the name property that's it save the changes and come back
to the web page now again you can see here we have this Greatest Tag because the educator name is greatest tag and if
I go to this page that is all courses here also we have this educat name greatest tag
correct after that if I click on this course thumbnail it will open this course Details page right now you can
see it is blank so we have to get the course data from the API and we will also enable the feature to purchase the
CES so we will come back to the vs code and let's open sidebar and from here go to pages and open a student and open
course details. jsx file correct now in this one we have to make the API call so we need the backend
URL right so here we are getting the data from the app context so in this one we'll add the comma and we'll add
backend URL and after that we need the user data also for purchase so here we'll add the
user data and we will get the user data from App [Music]
context correct now so here we have this fetch course data function we will remove all the code from this function
and we will add try catch a statement in this try block we will add the AP that will provide the course
detail with the course ID so just add const data equal to await and we'll add exos
dot get method here we will add the backend URL and in this one we will concatenate
the API Endo so write the remaining path / API SL course and right slash and after that we
have to add the ID also and we are getting this ID here from this use padams so we have added
the API endpoint and in this one we have added the ID also so in this one we'll get the individual course data right now
we'll check the response so just add if data do success so if the data do success is true then we will use the
setter function set course data and in this one provide this data dot course data property correct now if it is false
we will add the elsea statement and here we will display the error message using toast so just add toast. error it will
be data do message and here we will add this toast in the catch block also and and here we will add toast do error it
will be error do message and uh we have to import this toast also so here we'll add this toast
from this suggestion so the toast will be imported correct after that we will add
one more function that is enroll course so that user can enroll into the course or user
can purchase the course for for that scroll down and here we have added this use effect and in this one we have this
fetch course data which is here so from here we will remove this data from the dependency are now
here let me add the another function so we will add const and write the function name enroll
course that will allow us to buy the course here we'll add the asynchronous function and uh in this function we have
to make the API call so we will add the try catch statement so here we have created this enroll course function and
in this one we will make the API call before completing this function if I come back to the website here you can
see we are getting the course details if I refresh it still we have this course details we have the course title
description rating and we have the course structure we have the chapter and in this chapter we have the lecture
correct and in the right side we have the other detail of this course and we have the thumbnail now here you can see
we have this course by and the educator name and it is a static name so we will add the code here in this vs
code so in this one you can see here we have added the educator name course by greatest tag
so instead of this one we will add curly bres we will add course data dot educator dot name save the changes and
come back to the web page so still you can see this Greatest Tag because the educator name is greatest tag it is
coming from the database now let's complete our function that allow us to buy the course so here we have this
enroll course function so in this one we will add the TR catch blog and in this one we'll check if not of user data
it means the user data is not available in that case we will simply return a toast notification so just add return
toast doving and the message is login to enroll it means the user is not logged in then we will display the notification
login to enroll after that there could be another case like user has already enrolled in
this course so we will add the if statement and we'll add is already enrolled right and in this one we will
return uh notification so just add return toast. warning and we'll add the message already enrolled correct now
before making the API call first we will add the function or code that will fetch the data user has already enrolled into
this course or not so here after this use effect We'll add one more use effect so just duplicate it and in this one we
have this function so remove it and here we will add the if statement and we will write user
data and course data so when we have the user data and course data then we will add set is already
enrolled and in this one we'll add the user data then inall code courses it will be
enrolled courses dot includes and in this one we have to provide the course
data doore ID so if this user data enrolled courses property includes this course ID it
means the user has already enrolled in this course and this will be executed when the component gets loaded and we
will execute this function whenever the user data or course data changes so here we will add this dependency that is user
data and course data right after that let's complete this enroll course function so in this
one next we need the token right to make the API call we need the token so here we will get the token from the context
so here let's add the comma and we'll add get token we will get it
from App context after that scroll down and here we will add con token equal to a wait and get
token right after that we will make the API call and we will get the response data so just add
const cly data equal to a wait and we will use the exos package so just add
exos and in this one we will add the post method right and in this one we have to
add the backend URL and with that we will add the API path so just add SL API SL
user SL purchase and after that we we have to provide the data in the body so just add
the object and in this object we have to provide the course ID and in this course ID property we
will add the course data doore ID correct after that we'll add
the comma and write object and in this object we will provide the headers and in the headers
we will provide authorization be and token like this now we'll get the data from the
response and we'll check the response so just add if statement and we'll add if data. success is true in that case we
will get one session URL in this response data so we will add con session URL and we will get the session URL from
this data right and now we have to send the users on this URL so that
user can make the payment right so we will add window do location and we will add do
replace and here we will add this session URL now if the data. success is false
then we'll add the elsea statement and here we'll add toast. error and we will provide
data do message and if this Tri block gives any error then this catch block will be executed so in this catch block
also we will add toast notification with error and it will be error. message so after creating this function
that is enroll course we have to link this function with our button that is enroll now so scroll down and let's see
where we have the button so here we have this button where you can see the message
already enrolled and enroll now so in this button we will add the onclick property and provide this
function enroll course that's it so when we will click on this button it will open the payment Gateway
and we can buy this course and after purchasing this course we will be redirected to the enrolled courses but
the payment Gateway B hooks will take few seconds to process the request so we'll add the loading screen after the
payment done right so here let's come back here in this left sideb and we will open this loading.
jsx and in this one here let's
add path we will get the path from use padams so we will add the cost path and equal
to use padams after that we will add the navigate function so that we can
navigate the user on another link so just add con navigate equal to use navigate and import this use navigate
from react router down right now we'll add the use effect and in this use effect we will
add the Aro function and here we will check if this path is available in that case what will
happen we will add one timer so just add const timer equal to set
timeout and in this set timeout let's add the arrow function and after that we'll add the
timer 5,000 millisecs right and in this one we will simply call this
navigate and and provide the path so let's add back ticks then for/ dollar sign cly
Braes and here we will insert this path and here we will add the dependency array that is empty
array now we will add the return and in this return we will clear the
timeout so just add one AR a function and it will return turn the clear time
out and here we will provide this timer so it will create it that's it after adding it let's come back to the
website and here you can see this text already enrolled because we have already enrolled in this course so let me just
come back to the mongod DB database and here we have this courses and in this courses we have this enrolled students
so let me delete this entry from here so I'll click on edit and I'll delete this
one then click on update so we have removed the enrolled user from this course now we'll
go to users and in this one we have this user and in this user enrolled courses
we have this course data right so let me remove this course from this user so here we have this enrolled courses we
will delete it and click on update cor after that we'll go to this purchases and let me clear this
purchases data so I'll just delete it after that we will come back to the website refresh it so now we have the
option to enroll right you can see enroll now so I'll click here so it is opening this check check
out page so here we will add the email ID then select card and write the test card
number write any future expiry time and write the three-digit number then write the
card name and click on pay button so after payment you can see we are redirected to this loading screen
and after 5 Seconds we are redirected to this my enrollments so on this my enrollments
page you can see we have the enrolled courses right that we have just purchased now we will come back to the
vs code and from here we will go to this left sideb and open my enrollments right and in this one we have to add the
functionality to get the course progress data right so here we have this a state where we have added the lectures
manually so let's delete it and in this state now we have only empty aray that is progress aray set progress
array correct after that here we need the user data so we will get it from App context so here just add comma user
data then we need the fetch inrolled courses that is fetch user enrolled courses so we will get it from App
context after that we will get the backend URL so that we can make the API call after that we need the get token
function next we need the calculate number of lectures function from the app context right now here we will create
one function that will give you the course progress data right so just add const get
course progress and it will be asynchronous function so just
add as sync and create the arrow function now in this function we will add the TR catcher
statement and in this trive block first we need the token to make the API call so just add cost token is equal to a
weit get token function now here we will add the function that will get the progress data
of multiple courses and to handle the multiple async operation here we will add
const and write the variable name temp progress aray and here we will add the
await and in this one we will use promise.all now in this one let's add enrolled
courses do map here we'll add the another asnc function so just add asnc and create the arrow
function and here we will get the individual course now here we will add const data
we will get this data from API response and here we will make the API call so just add await then we will add
the exos dot we will add post method now in this one first we have to
add the backend URL so we will add the back Tex dollar sign curly Braes we will add the backend URL and
after that slash API SL user SLG course progress we have added the
complete path right now in this one we have to provide the data in body so we will add
the object and here we will provide the course ID and it will be course doore ID after that we have to add the headers
and in this headers we will provide the authorization and be token so just add headers authorization and be token
now we will get the response in this data after that here we will add let we will add total
lectures it will be calculate number of lectures and provide the course correct after that we will add
const and here we will add lecture completed and it will be this date data do progress
data and we will add theary operator we will add if it is true then data do progress data dot lecture completed do
length correct and if the data. progress data is false then we will add lecture completed zero like this after that we
have to return the total lectures and completed lecture so we will add cly bres and provide
total lectures and lecture completed and we have to get this data for each courses so let me
move it from here we will cut all this code and we will provide it here after this response so let's add it
here after that here we will add the set function set progress array and in this
one simply provide this temp progress array that's it after that if any error
occurs in this strip block then catch block will be executed so here we will add toast. error is equal to error.
message correct now we will add the use effect and in this use effect let's add the Aro
function and write the dependency aray and in this dependency are we will add user data and here we will add if
statement so when the user data is available in that case we will fetch enrolled
courses that's it after that let's add one more use effect so I'll duplicate this one paste it here and in this one
we will add the if statement and we will add inrolled course. length is greater than Z if it is greater than zero then
we will call the get course progress function and here in this one we will add the
dependency array and provide this enrolled courses correct after that if I come
back to the website here you can see for this course this progress word is displaying like
this and here you can see the completed property in this one we have the total one lecture and zero lecture
completed so this function is working fine after completing this page let's click on this button ongoing and this is
the player page where user can watch the course after purchase now in this one if I expand it
here we have the link to watch this course and in this one we will add the option to Mark the lecture as completed
and we will also enable this rating feature so that user can rate this course so just come back to the vs code
and from here we will open this left sideward and in this one we will open pages and in this pages we have this
player. jsx file now in this one we need some other data from the context so here we are
getting the data from the context file and in this one we will get the backend URL to make the API
call and then we will get the get token function that we will send in the API request after that we will get the user
data also and then we will get the fetch enrolled courses
function like this and after that we will create some states so here let's add a space and here we will add con and
we will create the state variable so the state variable name is progress data and the setter function name is set progress
data it will be user State and in this one we will add null after that we will add the another
Setter function so just add const and the setter function name is initial rating and the state variable
name is initial rating and Setter function is set initial rating it will be user State and the initial rating
will be zero like this now here we have added this function get course data right so
with this course data we have to display the rating also so after this set course data here we will
add course dot course ratings and here we will use the map method and in this one we will add the
Aro function and here we will get the individual rating correct now here we
will add add set inl rating and here we will provide item do rating but before adding this line we
will add one if statement also so here we'll add if and we'll add item do user
ID and we will check if this user ID is equal to user data
doore ID and in this if a statement we will provide this
code like this so here we have added the code that will get the course
rating correct after that here we will add the use effect so after this toggle function we have this use effect and in
this use effect we have this get course data so here also we will add the if statement we will add
if then we will add the inrolled courses do length so if the enrolled courses do
length is greater than zero then only we will provide this function get course data that's it after
that we will create another function using that we can Mark any lecture completed so here we'll add const and
write Mark lecture as completed correct and here we will add the asynchronous function and in this
one we will add the arrow function here we'll add lecture ID and with that we'll add the TR catch
statement now in this Tri block we will make the a I call for that we need the token so we will add cost token equal to
await token function and now we'll make the API call so we will add
the cost we will get the data from the response and we will add the API call using await
xos and we will add dot post method in this one we have to add the backend URL and with that we will add the API
Endo so just add the path SL API SL user SL update course progress like this now in this one we
have to add the data in the body so we will provide the course ID and lecture ID like this after that we will pass the
headers also so here we will add the object where here we will add the headers and in this headers we will add
authorization beor and token now we will get the response here and next we will check the response so we will add the if
statement so here we are checking if the data. success is true so in that case we will display the toast notification so
just add toast from react toasttify then we will add the success and in this one we will add
data. message and if it is false in that case we will add the Elsa statement and here we will
add toast do error and here we will add the data Dot message and if any error occur in the
triy block then we'll add this tost notification in the catch block and here we'll
add error. message correct so here we are making the API call to Mark the lecture completed and if we successfully
Mark the lecture completed we will display the notification and if we get any error we will get the data. success
false and we will get that notification using this else statement correct now after making the
lecture completed we will create a function that will give us the latest data of progress right so
here let's add one function with the name get course progress so just add
cost get course progress and it will be a synchronous function and here we'll add this Aro function now we will add
the TR cacher statement and in this Tri block again we need the token and after this we will make the
API call so just add con data equal to await ao. post method and here we have to add the backend
URL and with that we will add the end point so just add the path that is/ API SL user SL G course progress right and
here we are using this update course progress so it will update the course progress and here we will get the data
of course progress after that we'll add the the data in the body so we will add CES and in this one simply provide the
course ID after that we have to provide the headers so just copy it from here and paste it here so we will
provide the headers also correct now we will get the response here so we will check if the data. success is true so
just add the if statement and here if it is true then we will set the state variable so just add set progress data
and provide this data. progress data and if we get any error it means the data. success is
false in that case we will display a notification so just add toast. error data. message and if any error occurs in
the tri block then the catch block will be executed so in this catch block we will add toast. error then error.
message like this after that whenever we will update this lecture we will mark it as completed again we need
the updated course progress data so let me just call this function here in this one so after updating we will get the
notification and we will call this function like this so we have added the function that
will get the latest data of course progress and using that we can update the lecture we will mark it as completed
after that we'll create another function using that we can rate any course so here we will add con and write handle
rate and we will create the asynchronous function and in this one we will add the TR catcher
statement and in this TR catch statement we will add const and in this one we will add the token because to make the
API call we need the token right now we will make the API call so we will add the con data equal to await exuse do
Post method and here we have to add the backend URL and in this one we will concatenate the API end point so just
add / API slash user slash add rating right now we have to pass the rating and course ID in the body so here we will
add the curly Dres and here we will provide this course ID and rating and we will get this rating as a parameter of
this function so let's add this parameter here rating correct now with this rating we have to add the headers
also so let's copy the header from here and paste it here so now we have made the API call
after that we will check the response so just add if statement and we will check if the data. success is true in that
case we will display a toast notification so just add toast. success data. message right and after that we
will again fetch the enrolled course data right so just add fetch user enrolled
courses like this after that here we will add the else statement and in this else statement we
will add the notification so just add toast do error and we will add data do message and if any error occurs in the
tri block here we will add the notification in catch block that is error.
message that's it after that here we have to add the use effect and in this one we will add the
function that will be ex executed when the component gets loaded here we will add the dependency areay that is mty are
and in this one simply call this get course progress so here it is get course progress we will call it
here after that we have to render these element whenever we have the course data available so here after
this return we will add course data and question mark right if the course data is available then we will return
this components so when this course data is available then we will display these
elements right and if this course data is not available till then we will display the loading component so scroll
down and here after this small bracket we will add column and we will add loading
component so click here so this loading component will be imported from components right
after that we have to link our rating feature so here we have added this rating component right so in this rating
component we have to add some other properties as props so in this one here we have added the initial
rating so instead of adding zero we will add initial rating after that we'll add the on rate and in this one we'll add
the handle rate that's it next here we have the button to Mark the lecture as completed
right so in this one also we will add the on click so here let's add the on click
property and in this on click We'll add the addo function and in this Arrow function we will
call Mark lecture as completed and here we have to provide the parameter so just
add player data dot lecture ID that's it now here we have added this
text completed and Mark as completed and we have added false right so instead of this false we will add
the logic we will add the progress data so when we have the progress data available and with that we will add the
end operator we have the progress data dot lecture completed and in this lecture completed
we will find includes and if this includes this particular lecture ID so just add player
data dot lecture ID right so it means whenever this lectured ID includes in the progress data it
means it is already completed right so if it is true we will display completed and if it is not included in this one
then we will display Mark complete now we will add the same logic for displaying the icon so let me
just copy this one and scroll up you can see here we are displaying the
icon in front of each lecture name so here we have this Blue Tick icon and play icon right so
here we'll add this and first remove this false and paste this same code so if the progress data is available and in
the progress data lecture completed includes this lecture ID then we will add Bluetick it means it is already
completed and if it is not completed then we will display this player icon that's it now save the changes and come
back to the web page Let me refresh it so here we have this data and if I click on this rating so you can see we have
the notification rating added correct and if I open this chapter then we have this lecture and if I click on this
watch it will start playing this lecture here but right now we have provided the incorrect ID that's why it is displaying
this the screen like this and here we have the option to mark it as completed so here we have this link Mark complete
let me just click here so you can see progress updated and here we have the text completed and after that you can
see here we have this Blue Tick icon it means this lecture has been completed if I refresh this web page we
are getting some error so let me inspect it open console so here we have the error in line number
126 cannot read property of null lecture ID so let me just correct it I'll come back
here and in this one here we have added this player data. lecture ID but in this one we are getting this lecture right so
just add this lecture. lecture ID that's it save the ch changes and come back to the web
page now if I refresh it still it is working and we have this course rating as it is that we have rated and here we
have this check mark also it means this lecture has been completed so now we have created all the functionality for a
students a student can purchase the course a student can watch the course and they can also Mark the lecture as
completed if I come here in my enroll ments here you can see this progress bar is full it means this lecture has been
completed right and you can see the status completed it means when we have total lectures completed in the course
then it will display this a status completed and if I go to homepage and open the all courses here we have the
course that we have uploaded right now will add the API for our educator dashboard from there educator can upload
the course they can see the enrolled students they can see the uploaded courses so to add the apis in the
educated dashboard we will come back to the vs code first in the educated dashboard we
will add the feature to upload a new course so we will open this sidebar and from here we will open pages educator
and go to addc course. jsx file so this is the add course. jsx file in this one we have to add the courses
using the API and to call the API we need the backend link that is backend URL so we will get this backend URL from
the use context app context so let's add const backend URL and with that we will get the get token function
also that we will pass in the request headers so here we will add use context then add the app
context so use context and app context has been imported so now we have the backend URL and get token
now scroll down and here we have created a function handle submit right so in this function
we have to add the API so let's add a try catch statement we will add TR catch and in this Tri block we will add this
e. prevent default now after that first we have to check we have the image available or not so we will add not of
image then we will display uh notification so just add toast so import the toast from react
toasttify then error and in this one we will add the error message that is thumbnail not
selected right now suppose we have the image available in that case we will create a course data and using that data
we will create a form data so we will add one object const course data equal to object and here in this course data
we have to add the course title then we will add the course description and we will get the
description using qure do current dot
root dot iner HTML here we have added comma so it will be semicolon like this after that we
will add course price and in this course price we have to add the price in numbers so just add number
and we will provide the course price after that we have to add the discount so let's add discount and here
also we will add number and provide the discount State then we will add course content
and in this course content we will provide the chapters like
this now here we have this course data and now using this course data we will create a form data that we will send on
API so just add const form data equal to new form
data here we have created this form data variable now in this one we have to append this course data so just
add form data do append method and in this one let's add this course data and then write comma
Json and do a stringify and provide this course data here like this after that we have to
append the image also with the image property here we have added the property name course data and provided this data
here and after that we'll add form data. append and then write the property image and in this one we will provide the
image state so now we have the form data ready next we have to make the API call and in
the API header we have to send the token so just add con token equal to a
wait get token and after that we will add the API call so just at const we will get the
data from API response and equal to await then we will use the exos
package for the API call and in this one we will use the post method now we have to add the backend URL and
in this backend URL we will concatenate the remaining API path so just add SL API SL
educator SL add course after that on this API we have to send the form data that we have created
here like this and with that we will add the headers so we will add the same thing that we have added in the
earlier API request so we will add headers authorization beer token here we will add one more curly
Braes like this so now we have added the API call and after that we will get the response data right and now we will
check the response so here we will add the if statement so let's write if data.
success and if it is true then we will display a success message in the notification so just add to. success and
provide the data. message right so our new course will be added in the database and after that we have to reset all the
input fields for that we will use the setter functions so just add set course title and so
empty string now we will reset the course price so just add set course price and provide zero after that we
will reset the discount so just add set discount zero then we will add set image null so we will reset the input field
for the image now we will reset the chapter so just add set chapters and empty add
after that we will reset the description field so we will add this one Quil ref current root in HTML and Mt string
correct so if the data. success is true then we are sending the success message in the notification and we will reset
the input Fields but if it is false then we'll add the Elsa statement and in this one we will
display the errored message in notification so just add toast. error data. message and if any error occurs in
the tri block then in this catch block we will add the notification toast. error eror do
message that's it so we have added the functionality for our add course page now we will test it so we will come back
to the website then let's go to educat dashboard and from here we will open add course and here we will add the course
title so let me add the title so here I have added the title nodejs complete course then I'll add the
description in this field so we can add the rich text like this in the description after that here we will add
the price and then we'll add the discount 20% Then we will add the course
thumbnail so let me select any image so here I have some images so
let me select this one react router or I'll select this one then I'll add the chapters in this
course so I'll click on this add chapter and here we have to add the chapter name so let's add the chapter
name introduction and in this chapter we have to add lectures so here we will click on
this button add lecture and we'll add the lecture title what is
nodejs then we'll add the duration and we'll add the URL so let me add the YouTube video URL
here so open any YouTube video right click and click on copy video URL after that let's come back to the
form and here we will provide the lecture URL after that if I click on the add
button you can see this lecture has been added similarly you can add more lectures here and you can add more
chapters in this course then click on the add button so it will publish this course so now you can see the
notification course added correct and after that if I come back to the mongod DB database then go to
courses and here you can see we have another course that is this nodejs complete course that we have just added
right and after that let's come back here and go to homepage and here we have to refresh it so you can see we have
another course that we have just uploaded nodejs complete course and if I click here so it will open the course
description page where you can see the course title then we have the description then we
have the chapters and lectures now let me again come back to the educator dashboard so we have
completed this add course feature after that we will display the added course in this my courses so if I click here here
we are getting some error it is displaying the blank page because we have to fish the my courses data from
the API so we will come back here and from this left side bar we will open educator then go to my courses. jsx
file correct so in this file first we have to get the backend URL and token from the app context and here we are
getting this all courses that is from the asset so we will remove it and we will get the courses from the API so
first we will add the back end model right and after that we will get the is
educated estate right after that we will add the get token function so we will get it from App
Conta after that here we have this courses estate and set courses Setter function so in this one we will
set the course data that we will fetch from the API so now here we have this function
fetch educator courses and this is the asynchronous function so in this one let me just remove it and here we will add
the try catcher statement now in this Tri block we have to make the API call so first we need
the token so just add con token equal to and we will get it from
await get token fun F now we will make the API call so just add const data and equal to
await exos select it so exos will be imported then we will add the get method
and in this one we have to add the back end URL and with that we will concatenate the API endpoint path so
just add/ API SL educator SL courses that will return the courses and after that we'll add
the comma and we have to pass the headers and in this headers again we will add the authoriz and token so
simply add this headers authorization be token after that we will get the
response data and now we will check data do success if it is true then we will add
this and operator and we will set the course data so just add the set function set courses and provide this data dot
courses now if any error occurs in the tri block then the catch block will be executed so here we'll add
the error message in the notification so just add toast. error and in this one we will provide
this error do message that's it after that here we have this use effect and in this use effect we
have to call this fet educator courses function and we will call it whenever the is Educator state is true so here we
will add the if statement and we will check is Educator and provide this function
within this if statement and after that we will add the dependency aray here so in this dependency add will add
this is Educator so whenever the is Educator changes then it will again call this
function after adding it we will come back to the website and now you can see and here we have the published courses
for this educator so earlier we have added this course using the postman and this is the new course that we have
added using this add course page so this my courses page is working fine we have completed it now we will create
this a student enrolled page so in this one we are getting this dummy data from the assets so we will get the data from
the API for that we will come back here so now will create the functionality to display the enrolled students so here
from this left side bar we will open this students enrolled do jsx file and in this one we have to make the
API call so we will get the backend URL from the app context so just add const we will add the backend URL from
App context and with that we will get the token and is educated State and get it from use context and
app context after that here we have this function that will fetch the enrolled
student data right so here we'll add try cach statement and in this Tri block first we
need the token from the get token function like this after that we will make the API call so we will add
const data is equal to await exos dot get method and in
this API request we will add the back endend URL and we will concatenate the API end point so we will add SL API SL
educator SL enrolled students now here also we have to add the authorization token so we will add
headers authorization V token so after that we will get the response in this data so here we will
check the response so we will add the if statement if data. success is true so in that case we will display the enrolled a
student data on our web page for that we will use this Setter function that is here so just add set enrolled a students
and in this one we will provide this data do enrolled students dot
reverse so it will display the new student on the top in the table after that we will add the Elsa
statement and in this Elsa statement we will add the notification so just add toast.
error it will be this data do message and let's add this notification in the catch block also so we will
add error do message so we have added this function and this function will be called in this
use effect so here also we will call this function whenever the is Educator state is true so we will add the if
statement and we will check is Educator and in this one we will provide this function now we'll add this is
Educator state in this dependency areay that's it after that we will come back to the web
page and here you can see we have only one student right who has enrolled to this course
correct so in this one we are getting the student name course title and date correct so you can see the course title
test course title and in the my courses we have this test course title so this page is also working fine so we have
completed this add course my courses enrolled a student and then we will create this
dashboard page where we will display the total enrollments then total number of courses
and total earnings then we will display the latest enrollment data where we will display the a student profile image name
and course title that's it for that we will come back here and uh we will open the sidebar and
in this educated folder we will open this dashboard. jsx file in this dashboard. jsx file file we will make
the API call for that we need the backend URL token and we need the is Educator estate so here we'll add comma
and provide backend URL is Educator and get token function from use context app context after that
here we have this function so let me remove this dummy data from here and here we will add the try catcher
statement and in this Tri block we will make the API calls so first we will get the token from get token function after
that we will make the API call and we'll get the response in data and here we'll add a wait exos do get
method now in this one we will add the back endel and then we will concatenate the
API end point that is/ API SL educator SL dashboard and here we will send the authorization token in the headers so
here we'll add the headers and provide the authorization beer token here we will add one more curly
brushes like this now it is correct after that we'll check this data that we are getting from response so we
will add if data. success and if it is true then we will use the setter function that is set dashboard data here
and in this this one simply provide the data that we are getting from response and provide data do dashboard
data like this and if it is false then we'll add the Elsa statement and in this else statement we will add the
notification so just add toast. error and provide this data do message
after that we will add the notification in this catch block also so just add toast. eror error.
message now in this use effect also again we will check if this is Educator is true then only we will call
this fetch dashboard data and in this dependency are we will add this is Educator State that's it now save the
changes and come back to the web page you can see we have this loading screen Let me refresh
it here we have the error user is not defined so let me just come
back and we will open This Server folder and in This Server we have created this controllers then we
have this educator controller.js file in this one we have created this educated dashboard data
right so in this dashboard data we are using this user model right user model is used here but it is not imported so
we will import it so let's add import user from we will
add slash models SL user doj s after adding this import a
statement now we will come back to the web page and Let me refresh it so now you can see we are getting the
dashboard data where we have the total number of enrollments total number of course and total earnings and we have
the enrolled a student data so now we have completed this dashboard also this add course my
courses and enrolled students then if I go to homepage here we have this course from the database
and if I add two more courses then all four courses will be aligned side by side so it will look better and then we
have this all course page then my enrollments then we have this page to watch this
course so finally we have completed our full stack LMS project using M Stack and we have used the color for user
authentication and a stripe as a payment Gateway now we will deploy this project on versal for that we will come back
here and uh let's click on this Source control and uh we will add one message project
completed click on Commit then sync changes so now we have deployed this
course on GitHub and uh if I open this sidebar here we have this client and server right so in this client we have
this envirment variable so let me just copy the envirment variables from here and after that we will come back to
the versal platform and here we have this LMS back end let me open it and uh if I go to deployment you can
see our project has been redeployed again right because we have made the changes now we will deploy our front end
project for that go to Project or let me go to the homepage and here we have the option to add a new
project now we will select this GitHub depository LMS click on import and here we have to add the
project name that is LMS front [Music] end and after that here we have the root
directory in this root directory we will select this client folder then click on continue after that here we have to add
the envirment variables so I'll click here and in this one we will paste the envirment variables that we have just
copied after that here you can see we have the backend URL so a Shad of this local URL we will add the backend URL
that we have deployed on versal so let me open our backend URL in the new tab so here we have this LMS backend URL
so I'll right click and copy link address and I'll paste it here and in this one you can see at the
end we have this forward slash so we will remove it then click on deploy so it is deploying our LMS front
end now you can see this message congratulation and our project has been successfully deployed on versal so let's
click on continue to dashboard and here we will get the live link of our project so let me open it in
the new tab so now you can see our full stack LMS project is successfully running on
this URL so we have finally created and deployed our full stack LMS
project I hope this video will be helpful for you if you have any question you can ask me in the comment section
please like and share this video and also subscribe my channel great stack to watch more videos like this one thank
you so much for watching this video
To implement user authentication, integrate Clerk's React SDK into your frontend to provide sign-in, sign-up, and user profile management with pre-built components. On the backend, use Clerk middleware to protect API routes by verifying user sessions. This approach ensures seamless authentication flow and secure access control across your MERN stack application.
First, configure Stripe API keys in your backend environment. Create checkout sessions on the server when a student initiates a purchase and redirect them to Stripe's hosted payment page. Implement Stripe webhooks on your backend to listen for successful payment events and update the purchase records in your MongoDB database. Use Stripe's test mode during development to simulate transactions securely.
Educators can use a dashboard interface where they create courses by filling in details like title, description(using a rich text editor), pricing, and discounts. They can add multiple chapters and lectures by providing video URLs and organizing the course structure. Backend APIs manage creation, updating, and storage of nested course content inside MongoDB schemas, facilitating dynamic content management.
The frontend is built with React, utilizing React Router for navigation and Tailwind CSS for styling to achieve a responsive and modern UI. State management is handled via React's Context API, maintaining app-wide states like authentication status, course data, and user progress. Integration with Clerk manages authentication state seamlessly within React components.
Students watch course videos via the course player which supports features like free previews and marking lectures as complete. The frontend captures completion status and progress updates, sending them to the backend via API calls. These updates are stored in MongoDB, allowing the LMS to display accurate progress on student dashboards and support resuming courses where left off.
Deploy the backend and frontend separately on platforms like Vercel, managing environment variables securely for database connections, Clerk keys, and Stripe secrets. Use GitHub for version control and continuous deployment. Ensure backend APIs have proper CORS settings and that frontend API calls target correct production endpoints. Following deployment best practices helps maintain application stability and security.
You can extend the LMS by adding features such as quizzes, certifications, or discussion forums. Customize components leveraging React's modularity and expand backend APIs with new routes and MongoDB schemas. Integrate additional services or enhance payment options by leveraging Stripe’s capabilities. The project’s modular architecture and extensive documentation support easy customization.
Heads up!
This summary and transcript were automatically generated using AI with the Free YouTube Transcript Summary Tool by LunaNotes.
Generate a summary for freeRelated Summaries
Complete TypeScript Course: From Basics to Advanced React Integration
Master TypeScript with this comprehensive course covering fundamentals, advanced types, object-oriented programming, decorators, modules, integration with JavaScript, and building React applications. Gain practical skills to build robust, scalable, and maintainable applications using real-world examples and best practices.
Build and Deploy a Responsive GPT-3 Landing Page with React.js
Learn how to transform a Figma design into a modern, fully responsive GPT-3 landing page using React.js. This beginner-friendly tutorial covers project setup, component structure, CSS styling, responsiveness, and deployment on Hostinger with a custom domain.
Maîtrisez React : JSX, ReactDOM et création de composants
Découvrez les bases essentielles pour débuter avec React dans cette vidéo complète. Apprenez le fonctionnement du JSX, la gestion du ReactDOM, ainsi que la création et l'utilisation efficace des composants React. Ce guide pratique est accompagné de conseils pour optimiser votre code, gérer les mises à jour et structurer vos projets React.
Build a Modern Frontend Developer Portfolio Using Next.js, Tailwind CSS, and Sentry
Learn to create a stunning developer portfolio with animations, responsive layout, and performance tracking.
Unlocking the Power of Go: A Comprehensive Programming Course for Beginners
Learn Go programming with our comprehensive course for beginners. Master the fundamentals and build real-world projects!
Most Viewed Summaries
Kolonyalismo at Imperyalismo: Ang Kasaysayan ng Pagsakop sa Pilipinas
Tuklasin ang kasaysayan ng kolonyalismo at imperyalismo sa Pilipinas sa pamamagitan ni Ferdinand Magellan.
A Comprehensive Guide to Using Stable Diffusion Forge UI
Explore the Stable Diffusion Forge UI, customizable settings, models, and more to enhance your image generation experience.
Mastering Inpainting with Stable Diffusion: Fix Mistakes and Enhance Your Images
Learn to fix mistakes and enhance images with Stable Diffusion's inpainting features effectively.
Pamamaraan at Patakarang Kolonyal ng mga Espanyol sa Pilipinas
Tuklasin ang mga pamamaraan at patakaran ng mga Espanyol sa Pilipinas, at ang epekto nito sa mga Pilipino.
Pamaraan at Patakarang Kolonyal ng mga Espanyol sa Pilipinas
Tuklasin ang mga pamamaraan at patakarang kolonyal ng mga Espanyol sa Pilipinas at ang mga epekto nito sa mga Pilipino.

