diff --git a/react-bootstrap-migration/src/pages/admin/EditMenuGroupPage.js b/react-bootstrap-migration/src/pages/admin/EditMenuGroupPage.js index e69de29..70d4d33 100644 --- a/react-bootstrap-migration/src/pages/admin/EditMenuGroupPage.js +++ b/react-bootstrap-migration/src/pages/admin/EditMenuGroupPage.js @@ -0,0 +1,151 @@ +import React, { useState, useEffect } from 'react'; +import { useParams, useNavigate } from 'react-router-dom'; +import { Form, Button, Container, Row, Col, Table, FloatingLabel } from 'react-bootstrap'; +import './EditMenuGroupPage.css'; + +const EditMenuGroupPage = () => { + const { id } = useParams(); + const navigate = useNavigate(); + + // Mock data based on Angular component analysis + const [header, setHeader] = useState({ + menu_name: '', + description: '', + active: true, + start_date: '', + end_date: '', + }); + + const [lines, setLines] = useState([]); + const types = ['user', 'admin', 'mis report', 'bi report']; + const [menuDropDown, setMenuDropDown] = useState([]); // Mocked menu items for dropdown + + useEffect(() => { + // Mock fetching data since services are commented out in Angular component + console.log("Fetching data for menu group with id:", id); + setHeader({ + menu_name: 'Admin Menu Group', + description: 'Main administrative menu group.', + active: true, + start_date: '2025-01-01', + end_date: '2025-12-31', + }); + setLines([ + { id: 1, name: 'User Management', type: 'admin', menu_id: '101', active: true, start_date: '2025-01-01', end_date: '2025-12-31', seq: 10 }, + { id: 2, name: 'System Reports', type: 'mis report', menu_id: '102', active: false, start_date: '2025-01-01', end_date: '2025-06-30', seq: 20 }, + ]); + setMenuDropDown([ + { id: '101', name: 'User Admin Menu' }, + { id: '102', name: 'Reporting Menu' }, + ]); + }, [id]); + + const handleHeaderChange = (e) => { + const { name, value, type, checked } = e.target; + setHeader(prev => ({ ...prev, [name]: type === 'checkbox' ? checked : value })); + }; + + const handleLineChange = (index, e) => { + const { name, value, type, checked } = e.target; + const newLines = [...lines]; + newLines[index] = { ...newLines[index], [name]: type === 'checkbox' ? checked : value }; + setLines(newLines); + }; + + const handleSubmit = (e) => { + e.preventDefault(); + console.log("Submitting data:", { id, header, lines }); + // Mock navigation on successful update + navigate('/admin/menu-group/all'); // A hypothetical route + }; + + const back = () => { + navigate(-1); // Go back to the previous page + } + + return ( + +

Menu Group Edit Form

+

ID: {id}

+
+ +
+
+

Menu Group Header

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

Menu Group Lines Details

+
+ + + + + + + + + + + + + + {lines.map((line, index) => ( + + + + + + + + + + ))} + +
NameTypeMenu NameActiveStart DateEnd DateOrder
handleLineChange(index, e)} /> + handleLineChange(index, e)}> + + {types.map(t => )} + + + handleLineChange(index, e)}> + + {menuDropDown.map(m => )} + + handleLineChange(index, e)} /> handleLineChange(index, e)} /> handleLineChange(index, e)} /> handleLineChange(index, e)} />
+ + + +
+
+ ); +}; + +export default EditMenuGroupPage; diff --git a/react-bootstrap-migration/task_list.md b/react-bootstrap-migration/task_list.md index e69de29..7741204 100644 --- a/react-bootstrap-migration/task_list.md +++ b/react-bootstrap-migration/task_list.md @@ -0,0 +1,65 @@ +# Task List: Angular to React Migration + +This document tracks the tasks for migrating the Angular Clarity application to React with Bootstrap. + +## Phase 1: Project Setup & Core Infrastructure + +- [x] **Task 1: Initialize React Project** + - [x] Use `create-react-app` or Vite to set up the project structure. + - [x] Create initial `package.json`. + - [x] Create placeholder `index.html` and `App.js`. +- [ ] **Task 2: Install Dependencies** + - [ ] `npm install bootstrap react-bootstrap` + - [ ] `npm install react-router-dom` + - [ ] `npm install axios` +- [x] **Task 3: Setup Project Folder Structure** + - [x] Create directories for `components`, `pages`, `hooks`, `services`, `contexts`, `utils`. +- [x] **Task 4: Implement Routing** + - [x] Set up `BrowserRouter` in `index.js`. + - [x] Create a main routing component (`AppRoutes.js`) to define public and private routes. +- [ ] **Task 5: Authentication & State Management** + - [ ] Create `AuthContext` to manage user session and info, replacing `UserInfoService`. + - [ ] Implement `useAuth` hook. +- [ ] **Task 6: API Service Layer** + - [ ] Create a generic `useApi` hook or an API client singleton (e.g., `api.js` using `axios`) to handle requests, replacing `ApiRequestService`. + +## Phase 2: Feature Migration (Module by Module) + +### Admin Module + +- [ ] **Task 7: User Registration (`user-registration.component.ts`)** + - [ ] Create `UserRegistration.js` page/component. + - [ ] Build the form using `react-bootstrap` components. + - [ ] Implement form state and validation (e.g., with `useState` or `react-hook-form`). + - [ ] Connect to the backend API using the API service layer. +- [ ] **Task 8: Password Reset (`password-reset.component.ts`)** + - [ ] Create `PasswordReset.js` page/component. + - [ ] ... (similar sub-tasks as above) +- [x] **Task 9: Menu Group (`edit-menu-group.component.ts`)** + - [x] Create `EditMenuGroupPage.js` component. + - [x] Translate Angular template to React with react-bootstrap. + - [x] Replicate component state and handlers. + - [x] Create corresponding CSS and import it. + - [x] Handle inconsistency in source HTML by matching table to headers. +- ... *More admin components to be listed here* ... + +### Builder Module + +- [ ] **Task 10: Dashboard (`dashboardnew.component.ts`)** + - [ ] Create `Dashboard.js` page. + - [ ] Migrate `line-chart.component` to a React chart component (using a library like `Chart.js` or `Recharts`). +- ... *More builder components to be listed here* ... + +### FND Module + +- ... *FND module components to be listed here* ... + +## Phase 3: Finalization + +- [ ] **Task 99: Final Review & Cleanup** + - [ ] Code review all migrated components. + - [ ] Remove dead code. +- [ ] **Task 100: Documentation** + - [x] Create `analysis_report.md`. + - [x] Create `task_list.md`. + - [ ] Write final `instruction.md` with setup and usage instructions.