Update README.md

parent ac3e4015
...@@ -83,8 +83,8 @@ my-product-management-system/ ...@@ -83,8 +83,8 @@ my-product-management-system/
- Create `CategoryFormClass.js` and `CategoryListClass.js` as class components. - Create `CategoryFormClass.js` and `CategoryListClass.js` as class components.
- Discuss state management, event handling, and lifecycle methods. - Discuss state management, event handling, and lifecycle methods.
CategoryFormClass.js CategoryFormClass.js
```bash
```jsx
import React, { Component } from 'react'; import React, { Component } from 'react';
import { createCategory } from '../../services/ApiCategory'; import { createCategory } from '../../services/ApiCategory';
...@@ -133,7 +133,9 @@ class CategoryFormClass extends Component { ...@@ -133,7 +133,9 @@ class CategoryFormClass extends Component {
export default CategoryFormClass; export default CategoryFormClass;
``` ```
CategoryListClass.js CategoryListClass.js
```jsx ```jsx
import React, { Component } from 'react'; import React, { Component } from 'react';
...@@ -247,7 +249,9 @@ export default CategoryListClass; ...@@ -247,7 +249,9 @@ export default CategoryListClass;
- Deep dive into creating functional components with hooks. - Deep dive into creating functional components with hooks.
- Create `CategoryFormFunction.js` and `CategoryListFunction.js` as functional components. - Create `CategoryFormFunction.js` and `CategoryListFunction.js` as functional components.
- Discuss useState and useEffect hooks. - Discuss useState and useEffect hooks.
CategoryFormFunction.js CategoryFormFunction.js
```jsx ```jsx
import React, { useState } from 'react'; import React, { useState } from 'react';
import { createCategory } from '../../services/ApiCategory'; import { createCategory } from '../../services/ApiCategory';
...@@ -293,7 +297,9 @@ const CategoryFormFunction = ({ fetchCategories }) => { ...@@ -293,7 +297,9 @@ const CategoryFormFunction = ({ fetchCategories }) => {
export default CategoryFormFunction; export default CategoryFormFunction;
``` ```
CategoryListFunction.js CategoryListFunction.js
```jsx ```jsx
import React, { useEffect, useState } from 'react'; import React, { useEffect, useState } from 'react';
import { getCategories, deleteCategory, updateCategory } from '../../services/ApiCategory'; import { getCategories, deleteCategory, updateCategory } from '../../services/ApiCategory';
...@@ -414,7 +420,8 @@ export default CategoryListFunction; ...@@ -414,7 +420,8 @@ export default CategoryListFunction;
### 6. Adding CSS (15 minutes) ### 6. Adding CSS (15 minutes)
- Demonstrate how to add and apply CSS in React. - Demonstrate how to add and apply CSS in React.
- Style the category and product forms. - Style the category and product forms.
Category.css * Category.css
```css ```css
form { form {
margin: 20px; margin: 20px;
...@@ -471,18 +478,19 @@ export default CategoryListFunction; ...@@ -471,18 +478,19 @@ export default CategoryListFunction;
.button-update:hover { .button-update:hover {
background-color: blue; background-color: blue;
} }
``` ```
### 7. Break (5 minutes) ### 7. Break (5 minutes)
### 8. Integrating MockAPI for CRUD Operations (60 minutes) ### 8. Integrating MockAPI for CRUD Operations (30 minutes)
- Set up MockAPI for category and product management. - Set up MockAPI for category and product management.
- Perform CRUD operations (Create, Read, Update, Delete) using MockAPI. - Perform CRUD operations (Create, Read, Update, Delete) using MockAPI.
- Url Localhost / Mockapi: 'https://66b1b4381ca8ad33d4f4d9c0.mockapi.io/api/v1/category'; - Url Localhost / Mockapi: 'https://66b1b4381ca8ad33d4f4d9c0.mockapi.io/api/v1/category';
- Discuss Axios/ Await Fectch - Discuss Axios/ Await Fectch
ApiCategory.js ApiCategory.js
```jsx ```jsx
const apiUrl = 'https://mockapi.io/endpoint'; const apiUrl = 'https://mockapi.io/endpoint';
...@@ -517,7 +525,8 @@ export const updateCategory = (id, category) => ...@@ -517,7 +525,8 @@ export const updateCategory = (id, category) =>
- Link forms to MockAPI for data submission. - Link forms to MockAPI for data submission.
- Url localhost / Mockapi: 'https://66b1b4381ca8ad33d4f4d9c0.mockapi.io/api/v1/product'; - Url localhost / Mockapi: 'https://66b1b4381ca8ad33d4f4d9c0.mockapi.io/api/v1/product';
- Implement similar logic for \`ProductForm.js\` & \`ProductList.js\` - Implement similar logic for \`ProductForm.js\` & \`ProductList.js\`
Example form and list structure with API integration
```jsx ```jsx
import React, { Component } from 'react'; import React, { Component } from 'react';
import ProductForm from './ProductForm'; import ProductForm from './ProductForm';
...@@ -553,12 +562,16 @@ export default ProductList; ...@@ -553,12 +562,16 @@ export default ProductList;
- Step-by-Step Instructions: - Step-by-Step Instructions:
- **Install React Router:** - **Install React Router:**
- Run the following command to install React Router: - Run the following command to install React Router:
```bash
npm install react-router-dom
```
- **Modify App.js:** ```bash
- Replace the content of \`App.js\` with the following code: npm install react-router-dom
```
- **Modify App.js:**
- Replace the content of App.js with the following code:
```jsx ```jsx
import React from 'react'; import React from 'react';
import { BrowserRouter as Router, Route, Link } from 'react-router-dom'; import { BrowserRouter as Router, Route, Link } from 'react-router-dom';
...@@ -599,67 +612,95 @@ export default ProductList; ...@@ -599,67 +612,95 @@ export default ProductList;
- Step-by-Step Instructions: - Step-by-Step Instructions:
- **Modify App.js:** - **Modify App.js:**
- Replace code to App.js: - Replace code to App.js:
```jsx
.App { ```jsx
font-family: sans-serif;
text-align: center; function App() {
display: flex; return (
flex-direction: column; <Router>
height: 100vh; <div className="App">
} <div className="topbar">
<h1>Product Management System</h1>
``` </div>
<div className="container">
<nav className="sidebar">
- **Modify App.css:** <ul>
<li>
<Link to="/category1">Category Class</Link>
</li>
<li>
<Link to="/category2">Category Functional</Link>
</li>
<li>
<Link to="/product">Product</Link>
</li>
</ul>
</nav>
<div className="content">
<Routes>
<Route path="/category1" element={<CategoryListClass />} />
<Route path="/category2" element={<CategoryListFunction />} />
<Route path="/product" element={<ProductList />} />
</Routes>
</div>
</div>
</div>
</Router>
);
}
```
- **Modify App.css:**
- Add the content of \`App.css\` with the following code: - Add the content of \`App.css\` with the following code:
```css ```css
.App { .App {
font-family: sans-serif; font-family: sans-serif;
text-align: center; text-align: center;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
height: 100vh; height: 100vh;
} }
.topbar { .topbar {
background-color: #f8f9fa; background-color: #f8f9fa;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1); box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
padding: 20px; padding: 20px;
} }
.container { .container {
display: flex; display: flex;
flex-grow: 1; flex-grow: 1;
} }
.sidebar { .sidebar {
width: 200px; width: 200px;
background-color: #f8f9fa; background-color: #f8f9fa;
padding: 15px; padding: 15px;
box-shadow: 2px 0 5px rgba(0, 0, 0, 0.1); box-shadow: 2px 0 5px rgba(0, 0, 0, 0.1);
text-align: left; text-align: left;
} }
.sidebar ul { .sidebar ul {
list-style-type: none; list-style-type: none;
padding: 0; padding: 0;
} }
.sidebar ul li { .sidebar ul li {
margin: 10px 0; margin: 10px 0;
} }
.sidebar ul li a { .sidebar ul li a {
text-decoration: none; text-decoration: none;
color: #007bff; color: #007bff;
font-weight: bold; font-weight: bold;
} }
.content { .content {
flex-grow: 1; flex-grow: 1;
padding: 40px; padding: 40px;
} }
``` ```
...@@ -712,5 +753,5 @@ export default ProductList; ...@@ -712,5 +753,5 @@ export default ProductList;
This comprehensive 4-hour training module ensures that students gain an in-depth understanding of React components, styling, and CRUD operations, with ample time for hands-on practice and advanced topics. This comprehensive 3-hour training module ensures that students gain an in-depth understanding of React components, styling, and CRUD operations, with ample time for hands-on practice and advanced topics.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment