- Podcasts
- ReactJS Developers Podcast
- Building an Employee Management System with React.js and Redux Toolkit – Complete Practical Tutorial
Building an Employee Management System with React.js and Redux Toolkit – Complete Practical Tutorial
ReactJS Developers Podcast
- December 3, 2026
- 2 h 9 min
- Episode 5
About this episodeIn this episode, we explore how to build an Employee Management System using React.js and Redux Toolkit, bringing together modern frontend…
- Understanding the architecture of an employee management system.
- Introduction to Redux Toolkit.
- Understanding Redux state management.
- Setting up Redux Toolkit in a React project.
- Creating and configuring the Redux Store.
- Understanding Redux Slices.
- Managing employee records using Redux.
- Implementing Create, Read, Update, and Delete (CRUD) operations.
- Connecting React components using React-Redux.
- Using useSelector and useDispatch.
- Managing application state across multiple components.
- Organising a scalable React project.
- Building reusable UI components.
- Best practices for state management in React applications.
- React.js beginners and intermediate developers.
- JavaScript and frontend developers.
- Software engineering students.
- Developers learning Redux Toolkit.
- Programmers interested in building real-world management systems
Transcript
From the publisherThis transcript comes from the podcast’s own feed, shown as the publisher wrote it.
Building an Employee Management System with React.js and Redux Toolkit – Complete Practical Tutorial
In the last lecture, we have understood Redux Toolkit properly. And now it's time to practice. So if you want to practice Redux Toolkit, then what is the best way you have? That you practice a project, implement it in a real-world project, everything will be clear. So a small, beautiful, and not exactly very small, it can look a little big if you work properly following production approaches. So Employee Management is our site. We have made a web application here. which is something like you can say to do all the applications are to do like Instagram, Facebook, create, update, delete so here our concept is that how you can manage something so here you can understand one way you are managing employees or users we can list multiple users here you can list your employees here also if there is any update in their details then you can update from here if you click on delete button then you can delete but The special thing here is that a pop-up will appear, you will not directly click on the delete button and it will be deleted. Clicking on the delete button, you will get a pop-up and clicking on yes will delete it. And for all these things, you have multiple pop-ups here, like when you click on edit, a pop-up opens. When you click on create, a pop-up opens from where you can create employees. When you click on delete, a pop-up opens from where you can delete. If you click on no, it will close. So we are managing all these things through Redux Toolkit. And along with API call, create async thunk, how can it be set up, what things can work in it, you will get an idea of everything. Overall, the project is very simple. But in Redux Toolkit, you will get to know how to follow good approaches in real-world implementation. So let's go through what you have to do in the whole project, what you have to make, UI, etc. And how you have to work. So here you can see a navbar where you have to click on the Create button, you will get a pop-up, you have to fill the employee details, submit, and your employee will be added. Let's say I copy the image address and paste the profile URL here. Why are you doing the URL and not the direct image handle? Because we don't have the database where we can upload the image directly. For that, you have to learn more things, so we are not doing that now. So you have to put the image URL here, the image address and whatever name you can put here. Let's say I put this name here. And here you have to put an email at the rate gmail.com. You can put some bio here. So I copied and pasted this bio from here. As soon as I submit, it will be added to you and here you will also get the details fetched for the second time. So you will start seeing new details here. Now look, I don't know why the image didn't load here. Maybe the net is running slow. No, actually, the image didn't come here. Did we put some wrong URL? Let's assume we paste the URL of this by copying the image address. All over here. I have submitted it and it should be updated here, so see here the image has been uploaded, ok, the patch is also done, this is the new image that we have put, this is the image, this is the old image, we have to see for a minute, let's reload here, so maybe my net is running slow, yes, actually the net is running slow, so it is loading very late, but only this image is loading late, So here you have this, you can create more new, so you understand the functionality of creating, there should be a pop-up when you click on the create button, you will submit it there and it will be created. After that, what to do, you can edit it on anyone, for example, I want to edit this Moonlight, I want to make it Moonlight from Moon Night, ok, you can update more details, so I will submit it here and this is your update, new details have been fetched, Moonlight has come here, So this is the way you have to work. If I want to delete the first one, I will click on the delete button. It should not be directly deleted, it will pop up. If you click on no, it will be deleted. If you click on delete again, it will be deleted. And I have left one task for you, you have to put a loader. If I click on delete and click on yes, it should be loaded. We have managed all the loading and states properly. You just have to know how to apply it. We have discussed in previous projects that how to do all that. So loading state is made for you. You can apply it very easily. You have seen in previous projects too. So that task is for you. And what are we doing here? So if we click on this button here, then that employee will be highlighted. It will go to the highlighted section. Like you add to cart, something like that. So suppose I highlighted this, this is highlighted, I highlighted this. If you reload it, it will be saved in the database and it will not be deleted. We are not using local storage, we are using mock API for the database. I have left one task for you. To click on this button, you have to create a separate page where you will see only highlighted users. You have to put a filter because mock API does not support query. So you put a normal JavaScript filter in all these data. you have to filter the highlighted employees and show them on that page. So, two simple tasks, first of all, you have to apply loading by yourself and here you have to make a page and show all the highlighted employees. So, you will do such a small and beautiful work by yourself. Rest, it looks simple to see, but when you go inside the code, you will get a lot of such things that you will feel that yes, we should definitely learn all these things. So, you will enjoy it. And Redux Toolkit is new for you. So, focus is on it. So, it will be a lot of fun. And to make UI, we are using Daisy UI here. So, you will learn Daisy UI along with it. And if you are using Tailwind CSS, then you will also get an idea. And so, nothing. We are just using this much. We have used the rest of the React icons. And how to do what. You will know while making the project. So, let's start making the project. Quickly. Come and have breakfast and come, then you can make the whole project in one go. It's not too big, you can make it in one go. Okay, let's go. So I have opened my VS Code, you guys also do it quickly. And here is our React folder where we are organizing all our code. And you will get the link of this whole code in the description. So you don't have to worry about the code. And first of all, we will quickly set up tailwind CSS and daisy UI. So for that, we will come to the official documentation of tailwind CSS. Because here we will also get the installation of Vite along with tailwind CSS. And we are doing all this with a lot of projects and a lot of lectures. So you have a good idea. So you have to keep copying here. And open the terminal and paste it here. Okay, so here is our CD my project and this installation. and here choose react, choose javascript and do experimental no and do we have to start? No, we have to set up more now. So here we will install tailwind css and see carefully that you are inside the project folder and you will come only when you will use the cd command otherwise you will be in the react folder. So where to install tailwind css is inside my project. So here you have to do this installation inside my project. All right. So it is being installed, till then we are VEED.CONFIG.TS and we don't have TS, we have JS because we are using Javascript. So here we will install it and go to the plugin and add it. As I have given in the documentation, I am doing the same here. Okay, and install it in CSS. So our main CSS file is this one. So we will remove it completely and paste it here. And we will remove the entire CSS from app.css. This is done. Everything is done. Now the last one is left, Daisy UI. Let's quickly configure this too. And this is also very easy to configure. I have closed the Tailwind site here. And click on how to use here. So here you will get the command to install. Quickly install it here. So this is our install. And after that it is saying that where you imported this Tailwind CSS, you can import Daisy UI just below it. So I copied it. and here in index.css, I will paste it just below it. So our daisy UI is properly set up. You want to see that you clear it and run the project from npm run dev and here as soon as you run this project, here you can see this and here you can see the daisy UI and its version. That means your daisy UI has been configured properly and now we will make the UI, then you will also know whether it is being used or not. So our project is running, can we hide it? Definitely, we hide it. And these useless things, the garbage here, we clear it quickly. So we will clear it from here to here. And we will remove all this. We don't need assets here. Okay, we will remove this strict mode in main.jsx. And this is our setup properly. Now let's quickly make some UI and then we will set up Redux Toolkit properly, we will configure the store and we will set up the thunk and start our work quickly. So first of all, let's make the UI. Come to the Desi UI. You will get the components made here. So you just have to search. What do you want? I want a navbar. I will search for navbar here. And here you will get different different suggestions. First of all, I will click on our network. So here you can see the network. Which network do you want to use? Select whatever you like. You can select. So I select this one here. I think this is fine. I will come to JSX and copy it from here. Okay. And because I need two buttons here. So I select this and I will bring it here and remove it. So our simple navbar will be ready. We will make a component folder. Component and here new file. Navbar and actually it is better to work by making folders. Navbar and inside the navbar we have navbar.jsx. Okay. Jsxd is here. It had to be jsx. Do JSX, R-A-F-C-E, and here we will get our complete navbar. So our navbar has been made properly, you can see and remove it, there is no need for it. So we can see the navbar, come to app.jsx and put the navbar here quickly and you can see what kind of navbar you have made. Ok, so let's come here and see here, your navbar looks like this, I have zoomed it, that's why. So here is your navbar and let's remove this button. We don't need it. So how will we remove it? You can see the navbar start is here and the navbar start is all the way from here to here. So we will remove this navbar start and we will make the center as start. This is the start and this is the navbar end. So you can see something like this. These two buttons are coming here. And we don't need these two buttons, we need a plus icon and here we need a heart icon. So where can we get that? Where can we get that? So we can use react icons to get that icon. And actually, let's make more first, then we will see the icons and see what else we have to put. So this is ours. And what do we have to do here? Let me think what else to do. And here if you want to take a footer for styling, you can take it. So I also make a footer here, a folder, footer. Okay, just for styling, the rest of the logic here is not going to put anything in the footer. So new file, footer.jsx, we will take a simple, beautiful footer and our work will be done. We will search for footer here. So take a footer here. Which footer do you want to take? Take a simple footer that you find beautiful, very small, small. Isn't there any footer? I'll take this one. I'll copy JSX from here. And come here, R-A-F-C-E. And here is our footer. Okay. Footer is installed. Let's come here and install it. This is our footer. Okay. So come here and see. Reload. Why can't I see anything in app.jsx? We have installed the footer and the navbar. Did we make any mistake? I don't think so. We haven't imported the footer here. Import the footer from dot slash component slash footer. Although it should have been automatically imported here, but there was no issue. We have imported it here. It looks something like this. Let's bring the footer down. So for this, we will make a div here and give its class name. Flax column, column wise will be coming in this way. And here, nothing else, we will simply make a div here by making flax, where our full content will be coming. So what will we do in this? We will give flax1. So the remaining space will be taken by this middle content. Here, whatever content will come, it will take the whole space, the navbar will stick up and the footer will stick down. The whole space of the middle will take this. So whatever content will come here, it will take the whole space. So I don't know why I'm not taking it now. Will I have to reload? There is no use in reloading. Actually, we have to give the height. Let's give the minimum height screen. So now look, it's fine, it's proper. It's working fine and with full. All right. Good. And what will we do? And we will make a wrapper as always. We will make a wrapper here. This time we give the name layout and new file. layout.jsx, rafc, you can make multiple layouts, I have only one need, so I gave the name layout. And what will I do here? Nothing much, only children will be rendered here. Whatever children we will wrap, that children will be coming here. And the same style will be applied here with everyone. All these things I have already told you in lectures, in projects, etc. If you haven't seen it, then it's okay, you will understand. As soon as I apply this layout, you will understand. So I will give its class name here. Maximum width 7xl, width full, and margin I will give auto. Now what will happen with this, see carefully. In navbar, now see, if our screen is very big, then it will come here and it will come to the side. So it is not that better. I want its maximum width to be something like this, from here to here, 70rem, 80rem, something like this. So what I did, I gave maximum width 70rem in layout, margin auto, so it will come to the center. How? What do you want to say? I will show you now. I will wrap the entire component in the layout. We have wrapped it with the layout. Whoever we will wrap with the layout, this layout has been imported and we have wrapped it with the layout. Whoever we will wrap with the layout, It will be aligned. See here. Here is also same margin. Here is also same margin on the side. Basically, the maximum width is set. This much width can be maximum. It can't be more than that. So if you are working on a big screen, then the maximum width will be maximum. It can't be more than that. It can be less. It can't be more than that. So you will get space in this way. And wherever you will apply the layout, the same work will be done. Okay. Now I will give a little color here. 200. So you will see that it is being applied in this much. But I want this background color in full, so I can do one thing. By removing this background color from here, I will make a div on top and give it in this. I will wrap it with this div. Basically, I just wrapped it with the layout to set the maximum width and nothing else. So wherever I wrap it with the layout, that layout will be here, basically children will come here, whatever components will come here and this class name will be applied in it. Maximum width 7xl means 7xl will be there. Margin auto means it will always remain in the center. So something like this will be applied here. And I will give its class name. So now see, this whole thing came like this. Same you can apply in footer also, but there is no need in footer. Otherwise, you can apply in footer also, you can do the same work. So wherever we will do, we will apply this layout and everything will come in our same line. Now we have got the map bar, what else do we need? We need a list, we can use a list, we can also use a card, but we will use a list. You can see the list properly here. We need this list. The name will come here, our email will come here. We will use it as a bio. We have to manage the employees. For now, I am telling you that you can do it in this way. You will also make a complex application. So you can put the details according to you. According to the list here, I will take the name, I will make it an email, I will make it a bio and a profile pic. we can't save the pic for profile because we don't have the database so here we will take a url for profile as a string we will save it and that url will be visible here ok and we will change this button we will make it delete and we will leave it as hot so that we can highlight it according to the way it is running in my mind let's make it first come to jsx and copy it and here we will create a new folder in component and name it employees alright and inside employees employees.jsx rafc and here we have all the employees and I will attach employees in app.jsx employees alright Now let's come here and see how it is looking on the screen. So see again, this whole thing has come here and I will show you the size of the screen by making it a little smaller. So see it is coming this way. If the screen is big, then you will see it this way here. So I want it to look the same on the whole screen, which means that it has the same maximum width set. So I will wrap it in the layout again by coming here. I will make a layout here and I will wrap it in this layout quickly. Wrap it quickly. I wrapped it in the layout, our work is done. Okay, very good. And this is our one, two, three users. There are only three users here for the time being, there are only three employees. So I just want to keep one, I will remove the rest because we have to map the data. So this is one of ours, this is also here. And here you can see most played songs this week. So remove all this, we don't need all this. Okay, so this is coming in this way. Very good. And here we will come to app.jsx. We will give it padding-wise of 10. So it is coming something like this. Is it looking good? It is looking good. Here we have to give an edit or delete button. So we will come to employees. Okay, here the heart button is already present. This heart button is already present. And if we use SVG, then it will be easy to fill here. If it is filled, then it will be done here. So we use this SVG here too. This is the heart SVG, which is in the last. So we will use this in the navbar too. I said that the icon of the heart is needed in the navbar. So the heart icon. remove this span, this span is not needed, this span is basically coming to put a dot on top. So we will use this SVG instead of this SVG. Okay, so much is understood. Good, here it came and here we have to change some icons, so for this we come to react icons. Otherwise, you can also put SVG, there is no issue, but we will install react icons here. It is a little easy to put react icons. So here I have installed the react icons. Alright. And here I will search react icons. Here are our react icons. And here I will search. We need a plus icon. And take any plus icon. Let's take this icon. So we will copy from here. And we have to put this in the navbar. So remove the footer. Open the navbar. And we have to put it in the navbar. We will do it a little bit below, we will close it, we are still inside the bar, so we have to remove this SVG and use the react icon. Sorry, sorry, not like this. First of all, import it here. We did not do it, we imported it by copying it. Now we have to put it here as a component in this way. See, it is given here also. You have to import it in this way and paste it here. And all these things are coming to you. These are very easy things. I have already told you. So, this is your icon. Okay. UI, you can design it as you want. There is no restriction for UI. It is your choice. If you want to make normal CSS, if you want to use daisy UI, if you want to use set scene, use set scene. Whatever is coming to you, you can use it and make basically UI. Our work is of logic. Okay. So this is done. These two are our one ad icon. And here we put a quick icon in employees. This employee's card is ours. Let's do one thing, let's remove it from here and make a card component here. Const employee card. And here is our employee card. We will put this here by returning. So this employee card has become ours and here We will use the employee card. Why? Because we are going to map here. So if we map, there will be no confusion. That's why we made an employee card here. We will pass the details in this by mapping. Whenever our data is coming. Now the data is not coming. We have not set up the Redux toolkit. So fine. Here is the employee card. I will use it multiple times. So you must be seeing something like this. It is looking good. It is looking good. If you want, you can use it more. So it will come something like this. And I want this map bar to be stuck a little above. It is sticky. So how will it happen? So for this, come to the map bar, here is the class. Sorry, sorry, sorry. We have given the class name. What will have to be applied here? Sticky class will have to be added. Sticky is this, right? Suggestion is getting. Yes, it is getting. Sticky. Apply 0 from the top. Great. And give the Z index of 10. So you will see this properly. So, okay, right? It is working properly. It is working great. And the old color of the navbar, give it the same color of the navbar, BG base 100, it was looking good. This is looking good. So it's looking good, it's looking nice, it's looking nice. This 200 is also looking good, there is no problem. This is also looking good. There is no issue, you give style according to you, give it as you like. So here it is made, here we have to put some buttons in the employ. So for that, we will come to react icons. Which button to put? First, we have to put the edit button. Here is our edit button. We will put one edit and one delete button. So this is our edit. And quickly find the delete one too. Delete. So let's put this one for delete. This is our delete. Edit. This was the one. Here we will make it edit and we will replicate it once. And here the delete one will also come. There are not many suggestions, there are actually many suggestions. So from above you go and copy paste it here. Here you have the delete button. Now see how the UI is looking. So here it looks like this, it has become a little small. We will give it a class name and text will be Excel. So Excel looks good. Let's do it in this too. Class name and text Excel. Wow. So now it looks beautiful. This is the edit button. This is the delete button. And here we can highlight the user with this. And we will see the highlighted user here. Very good. And here in the navbar, let's call it employees. Employees. All right. All the employees have come here, let's quickly do the work of nap bar, API, etc. Let's do the work of Redux Toolkit, let's set up the store, and we have to do the work of API, and we have to do a lot of things. Actually, first of all, there is one more UI left here, there should be a pop-up open by clicking on the plus button. We should have the option to fill the form where we will fill the employee's details and the employee will be submitted to submit. Basically, a new employee will be created and posted in your database. And here, edit should be done. Okay, so the same pop-up will open for that too. And you can delete it directly. There is no issue. But you will learn how to work by making a pop-up in this. So, make a pop-up here. For delete, there is a pop-up of are you sure you want to delete. You must have seen it somewhere. So, you should delete it again by clicking on yes. So what will we do for that? We will also set up a store and work in two reducers or two reducers in the store. So in SRC, we will make a store here, a store folder, and in the store, the first thing you will get here is store.js and configure store import. Okay, we have not installed the redux toolkit, so let's come here quickly and install the redux toolkit. Did we search something wrong? We searched something else, Redux Toolkit. We will come here on Redux Toolkit and click on Get Started. And here copy and paste quickly. So our Redux Toolkit is installed and we will use React Redux here for its connection. All this is coming, that's why you are coming here. It's not that you are coming to learn Redux Toolkit. Here we are practicing the project. You will learn a lot of things. But we have a separate lecture on Redux Toolkit. Previous lecture where I discussed Redux Toolkit properly. How Thunk works etc. I told you all that. Although here also you will learn a lot. But I hope that you are watching all that. So Redux Toolkit is properly installed. Okay. And let's hide it. So what we have to do next. Copy the code from here. Why are you wandering so much? Come to the quick start. And here javascript is selected already. If your typescript is selected, then select javascript. So we will copy here and paste it here. And this is our store configure. Export store and configure store. Reducer came here and we will also take this reducer slice. We have configured the store from the configure store and here multiple reducers will be coming to you. And we will make a folder and work on the reducer here. We will give the name of the features. Basically, if you have login, then login feature, authentication for authentication feature. And just like we have made a full employee, then employee feature. And here we are going to pop up, so we will make separate slides for pop up, so pop up feature. In this way, we are going to arrange the folder structure here. It looks good. You can keep the name of the rest of the folder. You can also keep slices. So I have kept the features. In the feature, you will have a pop-up feature. And here, what I am remembering for the moment, you will have an employee feature. That's it. Okay, in the pop-up, we will make a pop-up slice. Pop-up.. slice. js I am giving the name in this way. You can also write popup.slice.js. But there is no such problem if you give popup.slice.js. So it looks good to see. Popup.slice.js. You can also get it in this way in the project. So I give it in this way. Popup.slice.js. This is the last extension of the java script. It has. js here. So popup.slice.js. Okay. And here we will create a slice. We copied and pasted it. So I think the wrong thing has been copied. Copy it from here and paste it here. So what is happening here? Copy. Okay, I have copied the whole provider. Here is the slice. You have to copy this. So I pasted this and here all these useless things are coming. Increment, decrement, etc. We don't have to do all this. In the initial state, we will have an employee pop-up and we will have one delete pop-up. We will keep false in both initially. Both of these pop-ups will remain false. We have to make only two pop-ups, employee pop-up and delete pop-up. Both will remain false. We made a slice using the create slice. We gave the name of this employee. employeeInitialState is coming from here and inside the reducer we have to make openEmployPopup so basically we will call the action openEmployPopup and our popup will be opened. I will also tell you how to do that. So in openEmployPopup we will have a state here Action will be coming. So by using the state, we can update the current state. And you can understand the action as a function. You will call that function and your work will be related to it. Like if you call open employee pop-up, then what we will do here is, we will make the state.employee pop-up true. You can also make it true and one more work can be done here. Because in employee pop-up, we are going to use employee pop-up in two ways. One is, to create data basically to create and add employee's data and to update that employee's data we are going to use same employee pop-up which will be our form you have seen what was your UI so we are going to use it in two ways so here we will add employee's details if we are editing then we will have employee's details and if we are creating new user then we will have only true means you are understanding means here Let's come to our UI. If I am clicking on the Create button, then we don't have any detail to edit. So, our pop-up should be true only when creating. But if I am clicking on Edit, then we have user details which we will edit. So, we should have those old details. So, we will put those old details here. How? By using action.payload. If we are editing, then we will do the same open employee pop-up, but we will be sending details there. So, details will come. And if details will not come, then true will come here. True will be set. Okay. Alright. So, you understood open employee pop-up. One will become our close employee pop-up. And in close employee pop-up also again state comma action. And here action is not needed. Because here you don't have to do much. Here just false employee pop-up. Alright. Close employee pop-up. And here comma is left. So, you have some actions and here you have to export the actions. So, remove all these actions which we have taken from the boilerplate code. So, open employee pop-up and close employee pop-up. These two actions we have exported from here. So, whenever we call this, we will call this. When we call open employee pop-up, it will set the state like this and when we call close employee pop-up, it will false the state. Means popup will be closed. So, this works automatically. Basically, we are using Redux toolkit. So, the slides we have made here. This will automatically generate actions. And that actions which will be generated. In Redux, you must have seen that we had to do a lot of setup. Where we had to define action type etc. So, all those things are not here. With actions, you will automatically generate these two actions. And counterslice.reducer. This reducer will also be generated automatically. And this reducer you have to put in store. So, there are two things, the slice you are making, there are actually three things in this slice. One is the state, one is the action, and one is the reducer. So, the action, you understood the normal function, which you will call and it will make changes in the state. In which it will make changes? In the state. And the state will be visible everywhere. And then the last one is the reducer, which you will put in the store. So, first of all, I have to import. Import. Employ. Reducer. from default export from where it will come? it will come to us feature slash employee slash slash slash slash feature slash employee not pop up pop up slash pop up dot slice ok so this is actually pop up I am saying employee again and again this is pop up slice ok here also we have given wrong name not employee this is pop up alright And the rest is fine. We have given the name as pop-up and we have not done anything wrong. No, the rest is fine. And here instead of counter slice, call it pop-up slice. And here also you can change the name. Pop-up slice and here also pop-up slice. That's it. Okay. So I don't think there is any mistake anywhere. We took that boiler plate code from there, so it may be possible to make changes. If something is missing, then we will see later. And if something is missing, then I think everything else is set properly. And this pop-up reducer will be coming to you in the store and we will put it here. And we will give the name of its key as pop-up. We will use it as a pop-up wherever we have to use it. Otherwise, if you want, you can also keep this pop-up reducer. But I will give a key pop-up. So wherever you have to use, you have to write only pop-up. This pop-up reducer will not be written so long. Okay. So we have put it in the store and we have not provided it yet. So come to main.jsx. Here. using providers, we will also provide and provider import is not automatically done, so no problem. Let's import it. Where will it come from? From React Redux. Wherever we have to make a connection, we have to make a connectivity with Redux, there we use React Redux. So now we are connecting store, i.e. Redux store with React. So what will we use here? React Redux. Okay. So here you will get provider and this is provider. Alright. And here store will be We will link it and where will this store come from? From the store.js we made in the store folder. So we have provided it everywhere. Our reducer is set properly here. And here we have made the slides properly. We have exported the actions properly here. Now we can use it anywhere in our app. Really? Yes. So for this, first of all, we have to make a pop-up in the component. So let's open a new folder here. employ popup and employ popup employ popup dot jsx rafce we will come to daisy ui and choose a popup we need a form so search form ok hero with form footer with a form login form with field set form requirement validator form control and label So I think take a login form here and make changes in it, etc. It will work. So copy this JSX from here and come here and paste it. So this is our employee pop-up. We will paste it in app.jsx. So we paste this pop-up at the top. Employee pop-up. Here is our pop-up. Okay, you can see the pop-up here. It is visible. Very good. And where is the pop-up one? Remove this navbar for now. Here is the employee pop-up. Alright, now let's come here and see how it is looking. So it is looking something like this. It should not be like this. When we click on the button, it should come on the screen. So what will we do for this? Here in div, we will give its class name fixed. Top say 0. Left say 0. And width full. Height full. And bg height full. It was full. We will give bg red 500. All right. So you can see something like this. And Z index is a little low. So let's do one thing. Let's do Z index 20. So it has come up on the screen. Very good. We have to bring it in the middle. So we will do one thing. Flax item center and justify center. So here it is in the middle. And what to do? And this BG black. We will give BG black. BG black. And opacity of this a little. we will reduce it to 20% and it will look like 80% so this is how it is looking so this is our employee popup we have employee details here so employee details employee details here i have given the name employee details so this is how it is looking and we don't need email password we need what we need we need name here First of all, you need a profile URL profile URL. And here in the placeholder, profile URL and type will be our text and class name input. This is all given by Daisy Y. Class name, label, this is all fine. And here is not a password, this will be your email. Email and email. So profile URL, you also had a name, you also had to take the name, name, okay, this is the name you have and here in the placeholder, this is the name, alright, and name here, email, so quickly see according to yourself what you had to look for, profile URL, is done. Name is done. Email is done. And you will also get a text area. Text area. Go to Desi UI. Search form. In form, you have with form, control and labels. You will get different things in this. So, you can see this text area. Take this text area from here. Copy it. And come here and paste it just below email. Okay, very good. Now see how it is looking. So this is a little different from all this. This is coming boldly here. So use normal label instead of legend. Okay, and remove the field set. What is the need of the field set? This is normal HTML. All this is coming to you. We have left the label here and only bio will be written here. Remove the last name, the optional one. We should not see this. Placeholder by you and I think everything else is fine. And its class name will be labeled. It is filled set legend. Label the class name as normal. So look, it matched with everything else. And here this button is not login, it will be a submit button. We will submit and our work will be done. Okay, if we click somewhere else, then it should basically be removed. It should be false. It should only be visible when you click on the add button. So first of all, we will need this variable, which we have made in the state. remove the store, here in the pop-up slice, we have this initial state, employee pop-up false, so if it is false, then it should not be seen, it should be true, true or if there are any details in it, then it should be seen, so what will we do here, first of all, we will have to take this state from here, so what do we use to connect again, react redux, and there you will get a use selector, so you see whether you are getting a suggestion or not, use selector, so suggestion is not getting, no problem, here we import manually, from react redux useSelector you will get one from here useSelector ok so we got useSelector useSelector and with useSelector we have this way we can take state do you understand? this is an arrow function where we are getting state by default in a parameter and we are returning that state so we will get full state but we don't need subscription of full state we just need in that state, and here you have the dev tool also connected, the dev tool automatically connects to the redux tool kit, so see it is saying that you have taken the subscription of the whole state, the unnecessary rerender will be triggered, I have told you all these things, what happens, I showed you the whole internal working, all the things, okay, I have told you everything, so here in redux, you come and see, here you have a pop-up producer, inside the pop-up, basically, you have employee pop-up and delete pop-up, So, we will take the popup state.popup subscription and inside the popup also, we just need the employee popup. So, from here you will get the employee popup state. So, save it in some variable. I will give the name popup. Alright. So, if here popup is not there, false, null or any false value is there, that means if popup is not there, then we will return null. That means we should not see this component. And here a bracket is left. Okay. So now see this pop-up is not visible. Now I want to click on the button so that our pop-up is true. Our pop-up is visible. So how can we do that? So for that, you come here in the navbar. Where is the plus button in the navbar? Here it is. So I want to click on this button so that our pop-up is true. So what will we do? Nothing much. We will put onclick here. And here action, we have to trigger, so to trigger action, to dispatch action, we have a hook, use dispatch, and definitely, where will it come from, from react redux, exactly, use dispatch, will come from react redux, see, react redux is automatically imported, otherwise, you have to do it manually, ok, so cons dispatch, this way, we use it, like we don't navigate, navigate is equal to use navigate, in the same way, dispatch is equal to use dispatch, now, this dispatch function, you have got, by using it, here, one, action dispatch, which action dispatch, tell me quickly, we had made here, in slice, one action, open employee pop-up, ok, basically, we had made this reducer, and action automatically, we had generated, open employee pop-up, and close employee pop-up, so, we will call open employee pop-up, so, automatically, here, automatically, we have done it, here, so, as soon as open employee pop-up, will call, here, it will make this state, true, and if we will send some details, then it will set details, and if we will not send, then it will make it true, ok, So for now, we have to do true, so we will not send any details. So how will it be here? Where did we put onclick? Oh man, where did we put it? It was in the navbar, right? See, dispatch and here open employee popup. Just call it simply and our work will be done. See, where is open employee popup coming from? Feature slash popup slash popup slice. Dot js, if you want to put it, otherwise it will work if it is react. So see, it is true. And this is getting true again and again because we have done something wrong here. We had to do it this way. We have called this whole thing directly. We can't call directly this way. Or you can pass reference here. So you can make a separate function and work. You know all this. I am telling you why. So we had called directly here. That's why it was getting called again and again. Without clicking. So now as soon as we click. So now it is getting called. Did you understand the confusion here? Normally we work in this way by making a function. So what I had to do here? Dispatch. Which one did I have to dispatch? Open employee pop-up. So here I have dispatched it, called it. So our work is done here. Now as soon as I click on plus, our pop-up has been opened. Now I want to click somewhere else so that it closes. If I click here, it will not close. But if I click somewhere else, it will close. For this, I have taught you proper bubbling, tickling, capturing, all this in JavaScript. So we will use that and think about how it will work. So employee pop-up is here. So what I will do is, I will put onclick on the main parent. And here I will dispatch an action. const dispatch is equal to useDispatch. If it is looking a bit fast, that means you have not seen the toolkit video. I am doing all the things on the previous toolkit video. There shouldn't be any problem in setting up the toolkit. There shouldn't be any problem. I had practiced properly. Here we are just looking at the implementation of the real world project. So if you think that I am telling you the whole basics, then that is not possible. I have told you in the previous video. So on click and here we will dispatch the close employee pop-up. So we will just call this action and our will be closed. We will click anywhere and it will be closed. But the problem is that if we click anywhere on this, then it will also be closed. We have put it on parent. So obviously, if we click anywhere, it will be closed. So if we want to avoid this, then what can we do? You tell yourself, think quickly, event delegation, tickling, capturing, if you have read it. These are all very important interview topics. If you have seen, if you have read a little bit, then tell me quickly. I told you in event handling, in JavaScript. If you are not in focus, then I will tell you. What happens here, right? Whenever you click on a child element, let's say this email is a child element, so if you click on it, then its event will propagate and go to the parent. Who is the parent? This whole card of yours. Then it will propagate and go to its parent. So who is its parent? This whole div. So as soon as you click on it, then the event will propagate to its parent, to its parent, to its parent, to its parent, it keeps going to the last. So whatever event you have put on your parent, that will also be triggered. For example, the event we have put is on the main div. It is put on the outer div, on the entire outer div. But we are also clicking on the child inside, so because the event propagates and goes to the parent, then the event of the parent is also getting triggered. The event of the parent is getting triggered and due to the event of the parent, it is getting closed. Because what have we given in the event of the parent? We have given close employee pop-up on click. So what I want to do, I want that the event should not propagate outside from here, it should not go to the parent. So what I will do, I will come here in the card and I will put onclick here and say that you are getting an event object from here and stop the propagation using the event object. So now whenever I click inside, even the event will not propagate outside, it will not go to the main parent. See, now I am clicking, so the event is not propagating on the parent. I'm clicking here too, see it's not propagating anywhere. Now, when I click on the outside dip, then only this pop-up will be false. Wow, it was fun. And give me one minute, I have a little bit of charge here. The charge has been completely sucked, the charge is over, so I will quickly connect the charger. Okay, give me one minute. Okay, our charger is connected. Now let's move forward. Now our main work is done. Now let's see what else we have to do next. Did you also do the delete pop-up? This delete one. Let's make a delete one too. So the UI problem will be solved. Delete pop-up. Okay, and why am I keeping the spelling capital of the folder here? I don't know. Here I should keep it small. And actually I should also I should keep it small and now I have done this, so now it will be a little bit here, see here, it is small, but again I don't know why it is giving me this error, I will have to reload so I did this reload and now I think the error should be finished, ok, so very good and here delete pop up quickly delete pop up and this was to be written in capital delete pop up dot jsx rafc alright And here we will copy the entire employee pop-up in delete and make some changes. So what do we need in delete pop-up? We need something of a card type. Okay, a normal simple card type. So take anything. I will take this one, which is the medium card here. So this is the medium one, MD medium. Okay, I will pick up this medium card from here. And this is the entire field set. So we don't need the form by removing this form. We need this entire card. So here is our pop-up. And here is not employee pop-up, here we are going to use our delete pop-up. Ok, delete pop-up and here close delete pop-up. Ok, we didn't make anything like close delete pop-up here, we didn't work on delete pop-up. So we will do one thing, open delete pop-up and it is better to write so many times, copy and paste from here like this, because there is something similar to do in delete pop-up. Open, delete, pop-up and action.payload will be coming here. Think about our payload in delete. Yes, the payload will be coming because if we delete, then we will click on whichever we will click. Suppose we click on this user here, then we will have to tell us the ID of which one we have to delete. We will basically send the ID to the mock API or whatever we will use, we will send it to the database. there will be an ID, it will find that ID and delete it. So at least we should know the ID. So not much, here you will have an ID in action.payload, we will put that ID here. Okay, and if the ID is not sent, then simply it will remain true here and nothing else. So both will work in the same way. And here not employee popup, delete popup. Okay, here also delete popup. And here instead of close employee popup, close delete delete pop up. All right. And here there is no need for action, so remove it. There is no need for action here either. There is no problem if you leave it, but I removed it. Neat and clean looks a little bit. So here also export the action. Open delete pop up and close delete pop up. Ok, you have exported. So now come here and put close delete pop up. Close delete pop up. All right. So, our work is done. Close employee pop-up, not close delete pop-up. And the rest of the things are fine. So, let's quickly come here and see how our UI is looking. So, as soon as I click on the delete button, delete pop-up should not be open. Because we have not written the logic. We have written the logic of close. It should be closed when you click close. But to be closed, it should be open first. So, it should be pop-up open when you click on the delete button first. So, we will come here. Where is this delete button? Inside the employee card. So, where will the employee card be? So our pop-up is not open. And what is the reason behind this? Our open delete pop-up has been imported properly. This means that our open delete pop-up is not working. But why? It shouldn't have happened. So let's come here. Open delete pop-up. And here is our open delete pop-up. And open delete pop-up is here. Here in the state.delete popup we are putting action.payload or true. If there is no payload then we are putting true. First let's see if it is running or not. Is it running? Come to control shift I and console here and see if it is working or not by clicking on delete. So it is working. So let's see what is coming in action.payload. So we didn't send anything to action.payload so it will be undefined. We didn't do CLG. Let's do CLG action.payload. Payload must be coming undefined. It's coming undefined. So it's coming undefined. So I have put true here. If there is nothing in the payload, then put true. True should be there. Okay. Let's do it. So we deleted it. See, true. So if true is happening, delete pop-up, then why isn't it working? Okay. If delete pop-up is happening here, then it should also work. Open delete pop-up. We have called here. Open, delete, pop-up, call. Where did it go? Open, delete, pop-up. We have dispatched here. Very good. After being dispatched, it should also change in its state. So here it is changing to see the state in Redux or not. So here, for now, it is false for both of them. I clicked on delete, pop-up. So this is true. So it is true. That means there is no problem here. Here it is being dispatched properly. The problem is in the delete pop-up. So, bring it here. There is some problem in the delete pop-up. So, state.popup.deletePopup. So, delete pop-up. So, delete pop-up should come here. And if delete pop-up is not there, then we will return it. And if it is there, then it should be visible here. But it is not visible. I don't know why. What is the problem? Let's do CLG and see what's coming in the pop-up. Is something coming or not? Let's come to the console and reload. So, nothing is coming in the pop-up. Okay. Why is it not coming? We'll have to see that. No, no, no, no, no, no, no. Oh, man, we've already put this delete pop-up in app.jsx. How crazy are we? Delete pop-up. It was delete pop-up, right? What name did we give? It is delete pop-up. Why don't we get suggestions? Here delete pop-up slash delete pop-up. Alright. So we have put this delete pop-up here in app.jsx. Now it will work. If it was not installed, then how will it work? So everything is fine in delete pop-up. And here also what was before was fine. Now it will work. So come here, reload, see the pop-up is coming. We clicked on delete, see the pop-up has opened. So what will we do with this delete pop-up? Here we will write delete and here in the paragraph we will write are you sure? Are you sure you want to delete this? Are you sure you want to delete this? And here we will give a yes button and a no button. One yes and one no. To click on the no button, the popup should be false. So we will dispatch here. Close, delete, popup. So let's reload and click on the plus button. If we click on the delete button, then the delete popup is opening and clicking on the no button is false. So we made a mistake. We have copied the whole div. Remove this onclick from here. And remove this div too. We made a mistake. We just had to replicate the button. We have replicated the whole div. Okay. See, we didn't have to do this. Here, this button was one. Format a little. Okay. This button was to replicate this button. One button yes and one button no. And here, put that on click. So, now both will be coming side by side. Okay. Something like this. Now it's okay. So, if you want, you can give margin-top of 6. It will look nice. If you do no, it will be false. If you do yes, it should be deleted. We will write logic for that. So, this pop-up is done. And this pop-up we have made, delete will work for a specific delete functionality. If you want to bring it in general use case, you can do that too. With just one pop-up, you can do all the work. You make a confirmation pop-up, there you pass title as a prop, description as a prop, pass confirmation function separately, and pass reject function separately, so it will work in everything. Basically, any confirmation you get, it will work for that. Do you want to rename this? Do you want to delete this? So, in this way, you can work there. With just one pop-up, you will be doing multiple work. So, you can call it confirmation pop-up and make it. So we will learn all those things later. For now, there was only one need of pop-up, the delete one, and we used the create pop-up in both of them. Actually, we haven't used it in the edit as well, because we don't have details in the edit. And we didn't have details in the delete as well. So, simply, by clicking on the delete button, we have just made an open-delete pop-up here, when we had to pass the data here. Okay, so let's do one thing here. click on the edit button. We will pass the data later when we have data, so open employee pop-up, click on edit, then it is also opening and when we have data, we will actually pass the data here, there is no data, we have not fetched the data, so now we don't have to do anything like this, All right, so this much work is done. Our toolkit is properly set up. Let the react icons and daisy UI remain. Okay, so what do we have to do now? Now we have to do work related to API. So remove employee pop-up, remove navbar, delete pop-up. Remove everything for now. Remove pop-up slice too. Here now we have to make what we have to make for API. So for API, asynchronous programming does not support our Redux toolkit. No, for that, we have to make an extra reducer. Thunk etc. is already set up in the middleware in Redux toolkit. You just have to know how to use it. I told you in the previous lecture. I will still tell you. I will show you by doing proper setup. First of all, let's order the API. Where will our API come from? So we are using mock API for practice. We will come to mock API. And here we will click on the plus button and give the name of the app. Simply app. and here click on new resource and I have already told you about mock API so nothing much, we have made a project and we will make a new resource in it and here you can see what you want, I don't want all these things ID will be there, this is compulsory and here the name of the field will be, we will have a profile pic so profile URL, this is profile URL for profile pic and will it come from faker.js, no, we don't have to generate it automatically whether that user is highlighted or not, whether that employee is highlighted or not. So let's take a highlight field and this will be your boolean, true false. So this is done and here you can get, post, put, delete. If you can't put a query here, then there is not so much functionality here. So we will do this much work, we don't have to do more than that. So we will create it and it should be created. Ok, name of the resource has to be given. So let's give the name of the resource employee. and create it. So this employee one has been created and by default some data has been generated. And here we clicked on the employee one. So here we got this whole API. This is the API you see. Okay, this is the API. So how will we work for this? You can also work directly with this API. I always work by making an instance. So the production approach is the same. So here we will make a new folder in SRC. We will name it config. and in config, look at the folder structure, otherwise you will get confused, how we have done it here, in SRC, we already had these four, we have a folder named components, in which we are making components, and a folder named config, in which we will create xuse instance, there is a folder named store, where there are features and store, ok, so in config, our xuse instance will be coming, xuse instance.js, and we will make an instance in this exios instance and how we will make it, then we will search exios instance on google and it will tell us how to make an exios instance. So here you have to make an exios instance in this way, for that we will have to install exios, so quickly split the terminal and do npm i exios. So, this is installed. Now, you know all these things, right? Why are we making this instance? You can directly do exios.get and exios.put. You have to write the entire URL again and again. I don't want to give the entire URL again and again. I don't want to do this timeout setup again and again. Where is our URL? API. Here is our API. So, why should I give this entire API again and again? Think for yourself. From here to here, it will remain the same every time. If we have an employee, then we have to fetch the details related to the employee. If there is a user, then we have to fetch the details related to the user. The previous will be the same. So why don't I put it here as a base URL. Now we don't need to put it again and again. We just have to put the employee. If there is a user, then we have to put the user. And I will put the timeout of 5 seconds. Now we don't even need to mention the timeout in the configuration every time. and I will add content type application suggestion in the header so I don't need to mention the header every time so I have done this default configuration already by using exeos.create I have made an instance I have given the name of that instance API a variable API you can also give exeos instance here I have given API here looks small and cute and first of all import exeos here import exeos from exeos and we have to export it as well export default api ok so this is our instance now we will use this instance whenever we have to call api alright very good ok so now let's quickly make another feature in redux toolkit in store we made a feature of popup come to employee employee.slice.jsx and create slice this time I will make it myself and you will understand it better I don't know, sometimes it doesn't give suggestions. Our reduction tool kitty is here. Here you will get create slice. Okay. And we will make a slice using create slice. Where we will give name. Employee. Employee's slice is here. And name is used to generate type constants. So try to give unique name of every slice. Okay. And here our initial state will come. We will make a variable of initial state here. Const initial state. and here employees details will come of employees data will come you will have an array and loading etc. will be false for now error will be null now ok so initial state is done reducers do we need reducers? now we don't need reducers here we are going to do asynchronous task and asynchronous task we can't do with normal reducer we have to use async thunk So for that you have extra reducers. You will make it yourself. And this extra reducer is a function of yours. And in this function, you get a default parameter. Add builder. Builder name. Builder. This builder is basically your helper object. In that helper object, you have multiple things. Builder dot add case. Add as in thunk. Different different things. So I have to add case. And in case, I will keep adding different different here. Now I will add that case in some way, I will tell you now. But before that, your slice has been made here. Give it a name. I give a name to the employee slice. And here by this slice, some things will be generated by default. Like actions and reducer. So I told you. Action you will get here. Employee slice dot actions. See, suggestion is also getting. Then you will get employee slice dot reducer. Okay. so we will export the reducer default export default and we will put it in the store come to the store here employee slash employee slice and here popup reducer here will come your employee reducer and here we will give the key employee reducer also you can write but then it will have to write so long state dot employee reducer dot employee So, I have given the key here and I have put it in the store. So, the work of the store is done. And the actions that we will get from here, if there is a need, then we will do the export const destructure and export. Right now, there is nothing in the reducer, so we do not have action and action will not be generated. If we would have made reducer, then only action would have been generated. So, now the action is empty. We have to make an extra reducer. Why? Because we have to do API call etc. So you can make an extra reducer using create async thunk in this file. And you can make it in a different file. So there will be different functions. So if you make a different file, it's better. So I will make a new file here. I call it employ.thunk.js. Thunk is one way and simply you can also call it. js. There is no issue. I wrote. thunk. js. No need to worry about this. Here we will use createAsyncThunk. Where will createAsyncThunk come from? From Redux Toolkit. CreateAsyncThunk allows us to do API calls and asynchronous tasks in Redux Toolkit. Otherwise, we couldn't do API calls in Redux. We had to set up thunk. Here also you have to set up and then you can use it. But they have automatically set up middlewares. You just have to use it. CreateAsyncThunk has two parameters, one is type and the other is constant. If you don't know, then forget it. Here you have an async function. So first of all, type. I will give employee here. I told you that type is generated by using this name. I will give the type as employee. I told you that type is generated by using this name. If you are not making reducer, then it will automatically generate. If you are making thunk, then you have to give manually. I will give the name as employee. and the name of the function will be the same name here. You can give something else, but this is the standard approach. Because what is generated in slice is also generated in the same way. If it is employee, then employee slash open model. If it is closed model, then employee slash closed model. It is generated in this way. So if we are doing it manually here, then we will do it in the same way. So what is the name of the cost here? we will give its name getEmployees and here employees less getEmployees we have made its constant or type or name now this second parameter takes the cussing function so here we will give the cussing function that's it our work is done now we can do API call here, really yes so we will not do this to call API and here we are putting the full API in this way, we copied it from here and we are putting the full API. No, we have made an instance, so we will use that instance. So import the instance quickly. API from dot dot slash dot dot slash dot dot slash config slash exeos instance slash. Okay, it was just exeos instance dot js, right? So from here you will get the API. You will do API dot gate instead of exeos dot gate because you have made an instance. So API.get and now you don't need to give the full. From here, you are giving it again and again like this. You don't need to give the full. You will only give the last. If it is a user, then user slash something. If there is something else, then in this way. So you will do this much and you will get data from here. So you are here. Const response is equal to await. And from here you will get a response. You can see the response by doing CLG. I can show you and also export it because you have to call it to call API. So this will call your API. But then you will say that everything is happening from here. So what is the need of slice? To make changes in the state. Exactly. But then you will think that we are doing work here. So how will we make changes in the state? Now tell me how to make changes in the state. Work is happening there. I will tell you now. Have patience. Everything will be known. Have patience. Here we will come to app.jsx. and we will fetch the details of the employees. We will put a useEffect. Okay. And thunk, we have made this in the employee thunk of gate employees. This is also a kind of action, even though you have done it yourself, it has not been generated by yourself. So what do you have to do here? Here you have to dispatch from app.jsx, like a normal action. Okay. And you will need dispatch here. So cons dispatch is equal to useDispatch. All right. And here you have dispatch. And how to dispatch? Tell me quickly. Get employees. Get employees action. So I did dispatch. And it has to be dispatched only once. On loading. So we should have data on dispatch. Let's see. We have data. There is some error. Let's reload. So we have some error. Cannot read properties of undefined reading type. Extra reducer. Okay. Okay. So in this employee slice, we have to reduce it a little bit. This is disturbing. Here, the extra reducer that we have put builder.add case, we have not told anything about the type here. So correct this comment for the time being. So this will work. Let's reload. So here you see this data is coming. Wow. So what have we done now? We have simply made this action ourselves here. Okay. We called this app.jsx. We basically dispatched it. So, here it is dispatched and we got the data. Now, if we want to set the data in the state, how will we do it? This is the problem. Because we have done all the work here. So, how will we set it in the state? So, for that, I just told you that you get a helper function in builder. And here you can add cases by doing add case. What cases can you add? So, the create async thing that you have used, it generates three types. The first type is employee slash get employees. This was it. It generates three types, one, two, three. First of all, you have pending, which means it has been initiated, the data has not yet come, it is waiting in pending status. The second one can be fulfilled, which means the data has come, we have got the data, it is very good, it has been fulfilled. The third one can be rejected, which means the data has not come, there is some problem, it has been rejected on the server. So it generates three types, you have to apply three cases here for every API call, or for one thunk, or for one action. Where? Here. so builder.addcase was our first getemployee we have made so getemployees will be imported here see it has been imported from thunk getemployees. if you will put dot you will get multiple things see the three types we have discussed fulfilled pending and rejected those three are here so one is pending ok so here it is type ok so first it is taking type here you will hover on addcase so it will tell you here that how it is working here and here it is telling that it is taking type action creator and after that it is taking action basically it is taking reducer that what you have to do in it so here you will come and type employee sorry get employee dot pending and second you will give a reducer here like this and here again you can understand the function that what you have to do so if you want to do changes in the state then from here you will get the state just like in normal reducer state comma action is the same thing here you have made an extra thunk or you can say your own extra reducer you have made an action here that you are using here ok where you can do API calls etc. so you got the state here now you can do changes in this state state dot employees you will put details in this empty area from where details will come tell me this so here the call you have done response Now whatever you will return from here, like you have returned the response, then you will get this response here in action.payload. So whatever you will return from here, you will get the same thing here. So keep this in mind. So what I will return here is response.data. Because in response I was getting a data named key where the whole data was. Basically it was the data of the employees. So I returned response.data. so here in action.payload that data will come and I will set it in employees so initial state will be set basically it will update in any current state alright, what else we have to do and actually we don't have to do this in pending this is pending status we don't have to do this in pending we have to do this in fulfilled ok fulfilled when data will come to you means it is fulfilled fulfilled means data has come so we have to do this in that ok, this will not work in pending status what will happen in pending in pending you will make loading true state.loading state.loading you will do true here loading will start ok and as soon as data will come by setting data you will do loading false loading will be false here and by chance if some error comes ok rejected error came so here data will not be set because error came loading will be false but and here state.error you will set error By default, the error that you are getting is coming from the action here. And here also I am using the action, so here also you have to take the action. So here action dot, you can see whatever error is coming, action dot error dot something will be coming. But we don't use it that way. In the previous lecture, I told you that we manually want to show the error that you are getting from the database. Custom error. So what do we do here? First of all, the payload that you will send in the function while getting employed will be coming. In getemploy, you will not send any payload, you will not send any details while getting employed. You will send it when you put it or you will send it when you delete it. So this will not come. So I will leave it empty with a dash. The first parameter is nothing. In the second parameter, you can destructure rejectWithValues. You can call it thunk API. You have a lot of things in this thunk API. Reject with values, fulfilled with values, dispatch etc etc. So you can destructure it. And you can see a lot of things in this suggestion. So for now I have to use reject with values to throw error. So I will use try cache here. and I will put all of this in try if data comes then it is ok and if data doesn't come then I will return reject with value and here I will give something went wrong I want to show my own error if there is any error coming from database then I will pass that error here ok I want to show custom error otherwise if you will put error here with action.error then it will come with only one error which is fail to fetch just this much error will come again and again So not that, I want to show custom error from here. Something went wrong or whatever error you are getting from the database. So this will come to you in action.payload. If it is rejected, then here reject with value. I am passing this value here. Something went wrong. So that will come and set here. And if try is fulfilled, basically data comes, then I am returning response.data. So action.payload will get data and that data will set. And here the spelling of the state is wrong. And in pending, the loading will be true and the error will be null. Whenever it starts, if there is an old error, then we will null it. And then if there is a new error, then it will be set here. So in the same way, you have to add cases for every API call and this is good practice. In the same way, our work happens in the industry. And whenever loading is true, you can show a loader. And I have told you all these things many times. Here I will not set the loader. In the previous 2-3 lectures, not 2-3 lectures, in the 2-3 projects, you can go to any project and see how to install this loading and loader. I have told you that. Here also you have to take the same state. You will install a loader and it will work. Okay. So employee, we have details coming. Let's see that in app.jsx. We have basically called the employee. You can come and see in the network tab. One API must have been hit. So after hitting, if you come and see in Redux, then the data must have been set. Employee's. Wow, look at this. Employee's data is set with you. And here I can't even see it properly. Okay, look at the employee in the reducer slice. Employee's details have come to you. See how many employees are coming. Six employees are coming. Wow. So we have employee details. has arrived. Very good. Very good. So now what to do? You have employee details. So in app.jsx you have ordered employee details. Where do you want to use? Use in this employees component. So here using useSelector const employee details we will order using useSelector. useSelector and here state and state. which is inside the employee, right? Look carefully who you are inside. You can also come here and see. You can go to Redux and see. Look, is it a pop-up key or an employee key? See who is inside. This is an object. Employee is inside the employee. And if you want, you can also come here and see in the slice. Okay. Employee slice is here. You can also come and see in the store here. Store which you have. You have given the key to the employee in the store. So inside the employee you have employees, loading and error. So here the employee inside employees, you have full data, right? See employees. Alright. So here employee details will be coming to you. You can check here by doing CLG whether it is coming or not. Console it. So see here you have full details coming. Okay. With user. Now you have to map it. So we will map it. What is the problem in mapping? Employee employee details or call it employees only. It looks good. Employees and employees.map and we will map it like this. There is no need to return it. We don't use this syntax, curly braces. We use direct parenthesis. Okay. Sorry, sorry, sorry, sorry. There was a little mistake. Wait a minute. Employees.map and here we will use direct parenthesis and put it directly. So there is no need to return it. It will be automatically returned. Okay, so this is the employee card and here you will see six employees coming to you and you will get the details of every employee in six employees and we will pass those details in this card. Copy from here and we will pass this as a props in the card and we will receive the details here and you can see what things you have in these details. So in details, you have profile URL, name, highlight, email, bio. So here you have name, details.name and then you have bio. Details.bio and this is not name, this is email. Name is above it. Details.name. Details.name. OK, anything else here? And so nothing is there. And this image, remove it. Details dot profile URL. OK, so now look here, something is coming in this way and the profile is not something, so what will come? If there was a profile, something would definitely come, but now there is nothing and it is asking to enter the key, so let's put the key here. we will put details.id in the key. Okay, so the get work is done. Now we have to do the upload work, how to upload the user etc etc. So remove app.jsx for now. To upload, our upload work will be inside the employee pop-up. So here is our employee pop-up. And here we have to take all the form details. We will make a state of form details. Set form details. Is equal to use state. Sorry use selector. Use state. And here we have. Profile URL. And name. And email. And. And what. Email. And what will happen. Tell me. Profile URL. Name. Email. And what else. One more bio. We had bio. So we have these few details. We have these few details. There is one more thing. And that is highlight. Highlight. Okay. And by default, the highlight will be false here. Good. Highlight will be false. Okay. When we are making, we will not highlight while making. So by default, the highlight will always be false. When we click on this button, then the highlight should be true. and that will be updated in the database. So for now we have this much and we will make a single function so that our whole work will be done. Form detail will be set. Again and again we will not do different work on different on click. So how will we do it? I have told you all this. It is very simple, it is very easy. So we will make a function. Handle input change. And our whole work will be done with this single function. Here you will have an event object. We will destructure two things from the event object. which two things name and value. Okay. E dot target name and value destructure. And set form details. We will use set form details. And here in this way you will get an object where dot dot dot old form details will be with you. Form details. Okay. and we just have to focus on the change. So here you will get the key and you will get the value. So I have also treated the key as a variable. That means whatever name will be here, we will pass the attribute here. Like in the profile picture, we will have the name, profile URL. We will pass the exact same spelling which is here, profile URL. So from here you will get the name, profile URL. So here you will get the profile URL and in the value you will have whatever you type here, the value will come. So name profile URL is done and pass the name attribute in it. You will get its name. And in this name attribute we will pass the email and then here you will get bio in the name attribute and then there is nothing here, this is the submit button. So we have done so much work, we will put the handle input change in sum and it will work in the same handle input change sum. These are all basic things, you know all this. We have discussed 3-4 videos on proper form handling in React. We have discussed a lot of standard approaches in that. So here, onChange, take this and put the same in all. This same function will work in all. Copy this and paste it here. Paste it in email and paste it in bio. So now if we type anything, it will come here and you will get handle input change. E dot target will be restructured into two things, name and value. Name will be your key, whatever key we have given here, profile URL, name, email, bio. So it will come here and you will get the value related to it, which we will be typing. And here you can see by cross-checking that you have the details set or not. So let's click on it. See this. For now, we have this empty one. And where are these details coming from? You must be coming from employees. This console that we have kept. Remove the console from here. Now it's okay. Now it's all empty. So as soon as I type in the URL, look at this. Data is going in the URL. If I type in the name, then data is going in the name. If I type in the email, then data is going in the email. If I type in the bio, then data is going in the bio. So this is all set. And the highlight is false. and we have taken the highlight as a string, I am so sorry, it had to be taken as a boolean. Very good. So we have the details, the form details. Now we have to upload it, so to upload it, we have to go to the thunk and make it here. So here we will put the API dot and instead of get employee, we will have this post employee. post employee and we will also put this post employee in the name and we have to make some changes. So definitely you will be getting payload here. Details will be coming. So, we will pass these details here as it is. Because we will send all the details in object format. So, it will pass in object format here in put. Okay. And we will return response.data. Anyway, it does not need here. But still return it. It is good practice. Very good. So, not api.put. Post. I have put. I have to post. Okay. And something went wrong here. Now we will show something went wrong everywhere. Because we don't have our own database. So we are not sending custom data. Custom error etc. Okay. So something went wrong. We will pass it ahead. So will the details be posted? Whatever we will send here. It should be done. And come here. In Thunk. Quickly in Slice. Add cases too. So you have three cases. Get employees. These are with you. Upload or post employees employees so this post employee employee and here post employee post employee now what to do here is to do loading true, do error null and do you have to set any data, think for yourself, if you post, then you will post a single data, single user details And you will get the details of single user in return. So if you want to save that data, you can do it. But here there is no need for single user details. We will just call the gate employees. Our action. And all the details will be fetched. So here we don't need to set anything separately. Here we are setting the whole array. Means we are setting the whole data together. You can make it single for employee. If a single employee details comes here, then you can set that too. But if there is no need, then Let it be for now. Okay. So while editing, we just have to edit again and the rest is to fetch. We have the get employee function. All right. And we will do loading false and here we will set the loading false error. Great. We are done. So let's come to the employee pop-up. To submit, here we will make a handle submit function on click. Okay. And come here. const handle submit and here we have to dispatch who to dispatch quickly tell me who to dispatch so we have to dispatch here post employee and here we have to pass the form details so whatever form details we will pass will come here as a details and details will be passed here ok so what will be our work here let's await together sorry here it will be async Async and here await and as soon as the data is posted, we will also close the pop-up model. So we will do another dispatch here and close employee pop-up. So as soon as the employee details come, it will wait whether the employee details come or not. So it will wait as soon as the employee details come, it will close it here. Let's reload. So let's create it and see if it's being created or not. For now, let's give anything in the profile URL. So let's assume this is an exact profile URL. So let's put this. I must have copied it a little earlier, so you can see it here. You can go to Google and take it from here. You can go to Google and copy the image address and put it. So I put this, I put the name Alicia something and in the email Alicia at the rate gmail.com. And I put something random in the bio. Submit. So our details have not been submitted. This will not be known now because we have not fetched the details again. So let's fetch again. If it has been submitted, it will come. Look at this. Wow, our post has been done. That means our post is being done properly. You can check the response by consoling. Okay. Here you can come and check the response in Thunk by consoling. You can check the response by consoling. So here it is being submitted properly. Okay, I want to do one more thing here. As soon as our data is posted, I want to dispatch the employee just after it is posted. So I want to do it here. How will I do it? So along with reject with values, you were getting one more thing here. Dispatch, do you remember something? So using this dispatch, as soon as the response comes here, I will dispatch the gate employees. So new current details will also come to us. Okay, let's reload. So now see this is I put something else. This is the profile URL and here I put MKL MKL at the rate something something something dot something something and I will put something in bio and submit it. So look at this, you have uploaded and also fetched new details. Wow, so this is working properly. Now let's make the delete functionality. Now delete should be deleted after doing yes. So when you delete it, it is very good to pop up, so it should be deleted when you click on Yes in the pop-up. So first of all, we will come here in Thunk, we will make it for delete. So what will you have to do for delete? You know all this, right? If you have never used mock API in documentation, then you can come and see here. What things do you get here? Get, Post, Put, Delete. So to delete, in the end, you just have to pass the ID like this. Just pass the ID, it will work. So, not post employee, delete employee. From here, delete employee, copy, paste. And instead of post, it will be deleted here. And employee will remain. In details, you will not have much here. ID will be coming. Here you just have to take ID. And you don't have to pass ID like this. You have to pass ID like this. We will use template literally here. In the URL, you have to pass the ID in this way. So it will go to that ID and delete it. And here we will also get employees with the delete. So it's a good thing here. That's it. Our delete one is also done. So let's quickly come to the delete pop-up. Here is our delete pop-up. So in delete pop-up, on the click of the button, on the click of the yes button, here on click, delete it. So here we make a function handle confirmation. Handle confirmation. And here. Const handle confirmation. Alright. This is done. And here we will dispatch. Delete. Delete employee. And this is coming from the proper place. Very good. And we have to pass ID in this. Now tell me where will the ID come from? Where will the ID come from? Okay. on which we will click here on the delete button, then there should also be an ID here, then only it will be done, so I told you that whenever you click on the delete button here, inside the employees, where is the delete button, in the employee card, so inside the employees, in the employee card, here is the delete button, okay, so here I told you that we will pass the ID here, see the details are coming to you, so the ID will also be coming in the details, so here we will pass the details.id, This card that you had, see, we were mapping details, so you must be getting ID in details as well. So, while we are doing open, delete, pop-up, we will pass ID, 1, 2, 3, 4. So, whenever delete pop-up will open, your ID will be in delete pop-up. Okay? It will not be true value, it will be ID. Alright. So, whenever you will have pop-up open, your ID will be in pop-up. You can see if you want. Okay? I will show you by doing CLG. You can see. CLG, pop-up. So, whenever you will open delete pop-up, see this. You will have an ID. You have to pass the same ID here. I have passed the pop-up. Wow. So I have passed the ID. And here in delete employee, you will get an ID. And it will send that ID and it will delete it from that ID. So let's see if the delete functionality is working. After deleting, there should be one more thing. As soon as it is deleted, first of all, wait here. Async. Await. And as soon as it gets deleted, do one more action dispatch. Close delete popup. Close the delete popup. Call it like this. Suppose I want to delete it. I said yes. Wow, it got deleted. Did you see? I delete this one. It got deleted. I delete this one. Look at this. Delete. Oh man, it's getting clicked in the wrong place. Okay, it's getting closed even when it's clicked in the wrong place. Okay. Oh, oh, oh. I'm so sorry. I made a mistake here. I didn't put that here. event.stoppropagation. So, it is getting deleted even after clicking on it. So, let's do one thing. Let's come to delete pop-up. And here, in on click, event and event.stoppropagation will be done. So, it is fine now. So, now, yes, good. Clicking outside, it is closing. So, we will do yes. Delete is done. Delete again. Delete is done. Delete again. Delete. Delete. Delete. Now let's come to edit, edit is also very easy, just pass the details in edit, that employee component was ours, come to the employee component, while deleting, This was for the handle input change. And this is the pop-up. You must be getting the details in the pop-up. Listen to me carefully. Listen to me very carefully. You have to do two things with the same handle submit button. If you don't have the details present. Listen carefully. It is the same submit button. It is the same submit button when you click on it. It is the same submit button when you click on it. If I click on the edit button, I will have the details in the state. So if I have details present, then by clicking on submit, details should be updated. Update function should be called. Update action trigger should be there. And if I click on this, then I don't have any details in the state. There are no details in the state in the pop-up. Okay. In the pop-up, it will only prove. I'll show you here. Use effect. I'll put one. And use effect, directly I can do pop-up CLG here. CLG. CLG pop-up, okay? So, I'll reload. So, now see, as I'm clicking here and opening, so see, what's in the state? True. What's in that pop-up? True. So, if true, means if there are no details of the user, employee, then to submit, I have to create a new user. I'll fill the form and submit, so I have to create a new user, add to my database. Okay. But if I click on the edit button, then I have details of the user. If I have the details of the user, let's say I only have the ID, I have the ID of the user, that means the previous details of the user are there. If you have the previous details of the user, then what you have to do is to use the update functionality on submitting. Okay, did you understand? Yes, okay, that's all you have to do. So how will it be? First of all, first of all, first of all, as here, I click on it, it will remain empty, but as soon as I click on this button, the details should be filled in it. So what will I do for that? For that, I will run a use effect here. I will run a use effect here or I can do it at the very end here. Use effect. Okay. I will run a use effect like this. Very good. And I will put a pop-up in dependency. What will I put? Pop-up. I have added a popup in dependency and I will console this popup here. So whenever something changes in popup, this use effect will run. I agree with this. So if I am doing it true, then it will also run. If it is false, then it will also run. And if details are being added to it, basically it is getting true again, then it will also run. So I will put some condition here. What condition will I put? If popup.id If you have If you have the popup.id, then set the old details in the form details. Set the details of the user. I will do it first and then I will tell you. This is fine. Set form details. Highlight will be false. You have the profile URL. Okay, okay, okay, okay. One more thing to pay attention to here. Highlight is false, right? And you can't even edit the highlight from here. Okay, so the highlight will remain false. Where will this profile URL come from? So you have details in the pop-up. Now I told you that there are details in the state. As soon as you prove it, you have details in the state. So you will set those details in the form details. That's it. If you set it in the form details, then you will also have to show here. Because we have a link. We have linked, right? No, no, we have not linked actually. then we have to add a value here as well. formDetails.profileUrl And in the same way, we have to add this value to the sum. Okay? We have to add a value here as well. We have to add a value here as well. We have to add a value here as well. formDetails.profileUrl And here is the name. And here you will get the email. Okay? And here you will get the bio. Okay? Great! So, as soon as I set the details in the set form details, which we have details coming from here, we will set them, then our details will start showing. So, popup.profileurl. Okay. And here you will get popup.name. Okay. Alright. And here you will get popup.email. And here you will get popup.bio. So, listen to me carefully. I am reloading. Here I am doing CLG again to the popup. Wait a minute. I am doing CLG here. I am setting the details. As soon as I click on the plus button, no detail will be set. Why? Because I have set the condition. If you have details, then only set the details. Otherwise, don't do it. So what are the details you have to click on the add button? There is no detail. There is no detail to click on the add button. So the details will not be set. But as soon as I click on edit on this user, then I will have the details of this user. Because I had sent the details there while doing the open model. So as soon as I click on this, there will be details in the pop-up. And because there will be details, then it will set the details. Okay, now see here. I click on this. So it is saying that I am setting the details. And it has set the details. So the old details that we had with it, that came here. If I click on this one, then the details of this one will come here. Wow! So the details are filled and already coming to you. You will submit here and it will be updated. For that, we will write logic now. So much work has been done. But if we close, then the details should also be removed after closing. If I click on the add button again, then also the full details are coming. It should be removed, right? Exactly, it should be removed. So here we will have to apply more conditions. What condition will have to be applied? If you do not have pop-up, If you don't have pop-up, then we have to reset the set form details. If you don't have pop-up, then pop-up is getting false. If you click somewhere else, then pop-up is getting false. It is getting false, that means there is a false value. It is empty here. There is nothing here. It is false. So what you have to do here is set form details. Set form details. And in it, you have to reset all these details. That's it. I have reset it. As soon as the popup is false, the details will also disappear. If there is no popup, reset the details. If instead of if, put else if here. Only one of the two conditions will run. If there is no popup, reset the details. If there is a popup id, that means you have all the details. then set the details here. That's it. This is the work of the use effect. So if there are details, then the details will be set. And if not, then you will get it empty. Good. This much work is done. Now do one more work here on handle submit. If you have details, then you have to do update employee instead of post employee. So here you have to make the update employee functionality in thunk. So here you have delete employee. because of this you will get update employee update employee now in update employee you will get two things here we will destructure it you will take id and along with id you will take details to identify id who to update and you will send details that these details have to be added you will identify from id who to update and you will add actual details while updating Ok, so ID and details, two things must be coming, we will destructure it and give it here and what we have to do here instead of delete, we have to put it, update it. Ok, very good and as soon as the update is done, we will dispatch it to get employees. So our update employee has been made. Now let's quickly put the update employee here in the slice too. So here is the post employee and we did not do this work for the delete one. Come here and see, we have not put this loading etc. in the slice for the delete one. There should be a loading for the delete employee as well. The loading is true for the delete employee and the error is null. And as soon as it is fulfilled, the loading will be false. Even if it is rejected, the loading will be false and the error will be set. And after that, you have to update the employee as well. Update Employee Update Employee Update Employee Update Employee And you have this delete employee. Delete employee. Delete employee. Okay. We did it right. These three are for get. These three are for post. These three are for delete. These three are for update. Very good. Very good. So, now come here. What condition do you want to set? Tell me quickly. If in state, i.e. in pop-up. In pop-up. Okay. In pop-up. If you have present id, then you have to dispatch it. Update Employee. That means if the old details are present, then the user has clicked on Edit then only the old details are present. So you have to update. And while updating, you have to send two things in object format. Because here we are destructing the object. Keep this in mind. Where did it go? By destructing the object, you need ID and details. So here in ID, popup.id and You need updated details in details. Where will the updated details come from? From the form details. The old details will be set here. As soon as I click on it, this is the old details which is set in the form details. And as soon as I update, it is also being updated in the form details. These form details are your updated details. You will pass it here. While updating, you will give the ID to tell who to update and you will send the details to update. Okay. And if this does not happen, else if, sorry, else, else if what else, you have to do this work. Okay. Here we did, if this happens, then you have to do this. Else if there is a pop-up ID, then you have to do this. Very good. If this happens here, then you have to update. And if not, then you have to create a new employee. And to create, and if create or update, Close the employee pop-up in both cases. So we have written it separately. So is it working? Let's see. Let's reload. Great. I will update it. Instead of Alisa, I will do something else. Instead of Alisa. Oh man, what is happening? Okay, I am going out of it. Click here. So what will I do here? Instead of Alisa, I will do Alisha. Okay, I will submit it. So look at this, it has been updated, it has been updated, we have done it in a very proper way, so it is also being updated, it is also being deleted, and if we add it, it will also be added. To add, again, someone from here, remove all this, remove the mock API, remove the react icon, we have made it different, so here we take the model image and come to the image, you guys take a beautiful image, so let's take this image, I will copy the image address from here, and here I will put this image, I will put the name, I will put some mustan and here mustan at the rate gmail.com and in bio I will put some fruits and vegetables and it was also put, oh man, let's put bio, okay, so see this, you can put this validation that there is nothing here, see as it is not here, then it has gone, So this is your task that you will put here that if there is nothing, then click on the submit button. There should be an alert message here that please fill all the details or you will set the error here. Please fill all the details. And I can update by putting bio here. I will submit. So see this is updated. It was fun. I will delete. Delete is also happening. Yes. And with pop-up. Are you sure you want to delete this? So it cannot be deleted by mistake. A pop-up will come after deleting. This will come for editing. And the last try is to highlight. This should be highlighted. And go to the highlighted page and show all the highlighted employees that I have highlighted this. It must have been done for some work that it does not work well, it is dirty, I have to meet this. You can highlight it for any reason. So highlighted employees will be shown on this page. So you will make the page. You will do the filter, how will it be highlighted, I will tell you that. So you have to do the same work for the highlight. It is very easy, I will tell you immediately. You will come to the employees component. Here is the employees component. Okay, you have to highlight by clicking on this button. This is the last button, see this. You had this edit, you had this delete, you have this highlight button. So on click, what do you have to do here? Save it quickly. Tell me. Dispatch. Now, what do you have to dispatch in dispatch? The same, update employee. Update employee. You have to update the employee. You have to make the highlight key true. That's it. You have to do this much work. So, here I am making an object in this way. What was he taking? He was taking ID. He was taking ID. Details.id will be given. And at the same time, he was taking details. Right? So, here we will take details. But this will not work. This will not work. Why will it not work? Because here you have to do it this way. dot dot dot details all the details have to be spread highlight highlight ok highlight key have to be true then only it will be highlight so this is a little long so let's do one thing let's make a function separately handle highlight ok handle highlight let's make it here const handle highlight ok So here our work will be happening. Let's format and there will be a function in it too. So I didn't have to do this. The rest is fine. Okay, this is all I had to do. Okay, so dispatch update employee. Here we have given the ID. Details will be coming to you here. Details and details will also have to be sent here. So you have to do something like this. Details. Sorry. details, so here you will get details, we will give the details ID in the ID and here in the details, we will make an object using the spread operator in which the old details will come and we will make the highlight key only true, then it will be highlighted and new details will be fetched automatically on updating. So let's click on this, nothing is left, we will have to see what problem has come. We are putting on click on this button. OK, so let's do CLG. The work is going on. The work is going on. The work is going on and the update employee has come to us here. The update employee has also come in a proper way and the update employee should also be updated. Let's go inside the update employee and see what is happening here. Let's do CLG here. ID and details are coming or not. So let's click on it. ID is also coming. Details are also coming. Still it is not working. Why? Why? Why? Why? Hmm. ID is also coming. Details are also coming. So put should be done here. Some error is coming. We are in the console only. No error is coming. Let's reload. So what is the problem? Okay, let's see what's coming here. Okay, highlight. Highlight is coming here twice. Highlight, highlight. One is spelling mistake. H-I-G-H. H-I-G-H-T-L-I-G-H-T. Wrong. Did we spell it wrong? Spelling mistake, I think. Highlight. Highlight is fine here. Highlight is somewhere else we made a mistake. Here we made the form details, right? Form details. in employee pop-up, we have made a mistake here. So two highlights are going from here. So look, wherever you have written this height light, there will be a highlight here, there will be a highlight here. Okay, so now it's fine. Now see if the highlight is happening or not. Okay, we haven't even written the logic of the highlight properly that the color should be filled here. We have to come here and see in Redux. Okay, so let's come to the employee. And inside the employees, let's see the data of the first one. Highlight is false. And this highlight is false. Both highlights are false. So let's click on it and see what happened. So the highlight is true or not. So, see, the highlight is true. It means it is working properly. And there is a little mistake in the details. So, we will do one thing. We will reset it. We will make it zero. Okay. So, now you will not have any details here. Nothing will happen. So, you can show here. No employees found. Something like that. So, I will do one thing. I will show you. Take this. If you have employees.length triple equal to zero. I'll show you a paragraph here. No employees found. Okay. So, here. It had to be 2 ampersand. No employees found is coming to you. Okay. And here you can wrap it in the layout if you want. Or you can make something separately. So, that's it for now. And see you in the next video. I'm scaring you. Just like that. The work hasn't been done yet. We'll do it. Okay, so let's add some quick details here. Something random. Add something, submit. So one user has been added. And let's add something here. Submit. Okay, these two users have come to us. And now let's come here and see in Redux. So in employees, the first user whose highlight is false. I will click on it. Highlight is true. It is working properly. Now it is working properly. We were in employee pop-up. the pop-up, we fixed the pop-up that we had to fix, and here we were updating, where did it go? Here we were doing highlight true, okay, so now how to show it while being highlighted, so here we are getting this fill, we have used SVG, here is the fill, so show you the current color of the fill, You can do this. So in fill, what I will do here is that if details.highlight is true, then show red color here, otherwise none. So let's see. Here red color is visible, otherwise nothing is visible here. So red color can also be shown or current color can also be shown. Current color is white, so current color will be visible. So current color can also be shown. See this. You can also change the color of the current color. You can also change the color of the current color. You can also change the color of the current color. You can also change the color of the current color. You can change the color of the current color. You can also change the color of the current color. You can also change the color of the current color. You can also change the color of the current color. I have to do the opposite of the highlight. If it is true, then you have to force it. If it is false, then you have to make it true. So if I click here. So look at this. It moved away from the highlight. If I click on it, it is highlighted. I will reload. So this is because it is saved in the database. So our work is working properly. So this much work has been done and everything has been done properly here. You go to the network tab once and check if the extra API is being called. One API is being hit on reloading. Employee one. Let's edit something here. Let's submit. So see this was edited and just after editing, an API was called to fetch data for the get employee. And here on deleting, one was for deleting and one was for fetching data. And this was for highlighting and then again for fetching data. And let's create. To create, we put something here. Random, random, random. Submit. So it has come to us. And here too, one employee is being called. It was called only once, right? That it happened twice. Wait a minute, let me see. Let's add here. So something, something, something, something, something, something. And here submit. It's being called twice. Why is it like this when adding? Why is it being called twice when creating? So let's come to the employee. and two times call is happening, we have to see why two times call is happening ok, we are adding this in employee pop-up ok, two times call will happen, once call will happen to post and once, see both will be different, one will be for post and one will be for get so this one will be for your post, ok, this is for post and this is for get, ok, no problem, you are going right Rest, you can check in Redux how your action is working or not. So, according to me, the project is done. I am giving you two tasks. The first task, not two, keep only one task. For this project, only one task is fine. Don't make search functionality here. Otherwise, you will have to do extra filters. Query does not support mock API. If it would support query, then it would be easy to search here. But it does not support query. So, here you just have to do one thing. Make this one page. Highlight one. Go to the highlighted page and filter the highlighted employees. You will only see the highlighted employees on that page. You just have to do this much work. As I highlighted this and highlighted this, you should see two highlighted users here. On going to this page, you should see only these two users and nothing else. So you have to do this much work. And the rest is made in our proper way. Employee management is a small one. Basically, we had to understand Redux Toolkit in a proper way that we can work by setting up in this way. What can be good approaches here? Okay. Rest, there are many other things which I have not maintained here. Which we should do in big projects. And definitely we will do. That depends on the project. That's why you should practice multiple projects. The more projects you practice, you will get an idea that how much work you have to do according to which project. Okay, so this will be ours. And here we did everything. What you had to understand is that all this will continue to work in the component. You didn't have to focus on this. The focus you had to do was that you have to create this instance and work. And what you had to focus on was this store. We made this store in this way. Here multiple reducers are coming to you. Okay. And you have features. And I have arranged features in the folder. So that it can be possible because In one folder, you have a slice and a thunk as well. So, look at this. 1, 2, 3, 4. Generally, you can have 8 to 9, 10 thunks in one feature. It won't be more than that. Otherwise, if it is, then you have to separate it in the next file. You have to make a separate feature. Like, you are handling authentication in this. So, that's wrong. Authentication is a separate feature. So, you have to work on it separately. You work separately for the user. You work separately for the product. You work separately for the cart items. So for all of them, you make separate features. Okay? And for every feature, you will make one slice. In that slice, you may have reducers where you are doing synchronous work. Or for asynchronous work, you have made an extra reducer. And there you may have to apply cases in this way. So you have to do it in this way, by making cases. So that every case maintain in three phases, three types, three basically maintain in status. One is in pending status, meaning if you want to show loading or if you want to remove error or null, then that phase, that status. Then the second may be that you have fulfilled data, what do you have to do? Then the third may be rejected, that the data did not come, you have to set some error, you have to show error on the UI screen. In this, I have not done a lot of things, like I have not made a reload one. I have not made a loading phase so that the loader can be seen. OK. When loading is done, show a nice loader here. It is loading and then all the data is coming to you. So you can do all these things according to yourself. Rest, whatever customizations we could have, I have done that. I am just leaving some tasks for you. And that is a very basic task. In previous projects, I have also told you how to install loading etc. I have already told you about the routing. I have also made small projects on it. So you can see that. Okay. Now some more topics that are left in Redux, they also complete them. And some libraries and so on, we have to explore more. And then after that, we just have to practice projects. So you Now you can tell what kind of projects are coming. First there are some topics, we will do that. And then you can tell from now on what kind of projects you want. Because you have to practice from projects. And the pending that we left, which is JavaScript interview, interview.js, that was saved. We are going to do that too. So these are the things we are going to do now. And all this will happen properly. Now let's give it a little time. When this will happen, then we will discuss the backend and how to do it. how to design a database, how to create a model there, how to optimize there. So that will be more fun for you. Like in the front-end, you can see something, but there is the work of logic. And what I think is better than this, those who love more than logic, they like the back-end, and those who want to see the UI, they like the front-end. But according to me, I like back-end better. You tell me, do you like front-end or back-end better? Although you can work on both, but if there is one developer, then one of the two looks better. Either back-end or front-end. Front-end looks better, which wants to work more in design. Which wants to work more in logic, that while writing, you don't have to go again and again and see what design is being made, how it is being made, what is happening. Perform logic calculation once and for all, And then after that, we are going to debug that there is a bug here, there is a bug here, all these things. So there is a different fun in that too. So that depends on what you are interested in, what you are interested in. Are you enjoying logic or are you enjoying making such designs? Okay, it's not like there is no logic in the front-end. Don't tease anyone that you are a front-end engineer, you have nothing to do with logic. There is terrible logic. You should also try CSS. Okay, work on core CSS. You will enjoy it. I still get stuck in CSS a lot of times that why is it not working? Yesterday in a project, yesterday or two days ago, in the project, it happened that we had put the sticky, like this sticky navbar, here some more users create, so here we submit and make one more, here, okay, so we have made this. This sticky is sticking on top. So, what happened was that it was sticky but till some distance. In this way, I was scrolling. So, it was sticky till some distance. Then it would enter inside while taking all the components. I don't know what was happening. Like, it came here. So, it is sticky till this distance. And then it entered inside while taking all the components. So in this way, some products were in our list. And in those products, after going a good distance, after going a little distance, suppose after going 2-3 screens, then after that, as we used to go up, it used to go inside. Now we don't know what the problem is. After debugging a lot, we came to know that there was a height problem. We removed the height fully, set the minimum height there and our work was done. So something different starts happening in that. CSS, that's why I have a little logic. Those who know the logic very well, they will enjoy it. But if you move a little bit there, then your mind will be ruined. So it still happens and it happens with good developers. It will happen with you too. And you will get stuck in small things many times. So a lot of nonsense has happened. So do some work with yourself. And this project has been completed. Reduction toolkit setup has been done properly. Implementation has come to us. And that's all for now. See you in the next lecture. Till then, keep exploring and bye-bye.
