-
Notifications
You must be signed in to change notification settings - Fork 1
Staging #175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Staging #175
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,32 @@ | ||||||||||||||||||||||||||||
| import "./styles.css"; | ||||||||||||||||||||||||||||
| import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; | ||||||||||||||||||||||||||||
| import { faPenToSquare } from "@fortawesome/free-solid-svg-icons"; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| const Table = ({ headers, data }) => { | ||||||||||||||||||||||||||||
| return ( | ||||||||||||||||||||||||||||
| <table className="admin-table"> | ||||||||||||||||||||||||||||
| <thead> | ||||||||||||||||||||||||||||
| <tr> | ||||||||||||||||||||||||||||
| {headers.map((header, idx) => ( | ||||||||||||||||||||||||||||
| <th key={idx}>{header}</th> | ||||||||||||||||||||||||||||
| ))} | ||||||||||||||||||||||||||||
| </tr> | ||||||||||||||||||||||||||||
| </thead> | ||||||||||||||||||||||||||||
| <tbody> | ||||||||||||||||||||||||||||
| {data.map((item, idx) => ( | ||||||||||||||||||||||||||||
| <tr key={idx}> | ||||||||||||||||||||||||||||
|
Comment on lines
+15
to
+17
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: No empty state handling for tables with no data Add a fallback row (e.g. 'No records found') when data is empty to prevent a blank table body and improve user feedback.
Suggested change
|
||||||||||||||||||||||||||||
| <td>{item.name}</td> | ||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. issue: Table component hardcodes data fields and doesn't align with provided headers This will break if headers don’t match these hardcoded fields (e.g., missing message). Refactor Table to accept column accessors or render functions so each page can map its own data shape. |
||||||||||||||||||||||||||||
| <td>{item.email}</td> | ||||||||||||||||||||||||||||
| <td>{item.phone_number}</td> | ||||||||||||||||||||||||||||
| <td>{item.message}</td> | ||||||||||||||||||||||||||||
| <td> | ||||||||||||||||||||||||||||
| <FontAwesomeIcon icon={faPenToSquare} className="admin-edit-icon" /> | ||||||||||||||||||||||||||||
| </td> | ||||||||||||||||||||||||||||
| </tr> | ||||||||||||||||||||||||||||
| ))} | ||||||||||||||||||||||||||||
| </tbody> | ||||||||||||||||||||||||||||
| </table> | ||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| export default Table; | ||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| /* Table.css */ | ||
| .admin-table { | ||
| width: 100%; | ||
| border-collapse: collapse; | ||
| margin-top: 20px; | ||
| margin-bottom: 50px; | ||
| } | ||
|
|
||
| .admin-table thead tr { | ||
| background-color: #f9a43a; | ||
| color: #000000; | ||
| text-align: left; | ||
| } | ||
|
|
||
| .admin-table th, | ||
| .admin-table td { | ||
| padding: 12px 15px; | ||
| } | ||
|
|
||
| .admin-table tbody tr { | ||
| background-color: #fff9f3; | ||
| color: #000000; | ||
| border-bottom: 1px solid #ddd; | ||
| } | ||
|
|
||
| .admin-edit-icon { | ||
| cursor: pointer; | ||
| color: #000000; | ||
| font-size: 18px; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| import axiosInstance from "../../../../Axios/axios"; | ||
|
|
||
| export const fetchContactMessages = async () => { | ||
| try { | ||
| const response = await axiosInstance.get("admins/getAllContactMessages"); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nitpick (bug_risk): Inconsistent endpoint format between services Use a consistent leading slash for your API paths to prevent URL resolution issues. |
||
| return response.data.data; | ||
| } catch (error) { | ||
| console.error("Failed to fetch contact messages:", error); | ||
| return []; | ||
| } | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| import axiosInstance from "../../../../Axios/axios"; | ||
|
|
||
| export const fetchAllProviders = async () => { | ||
| try { | ||
| const response = await axiosInstance.get("/admins/getAllProviders"); | ||
| return response.data.data; | ||
| } catch (error) { | ||
| console.error("Error fetching providers:", error); | ||
| return []; | ||
| } | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (bug_risk): Avoid using array index as key in list rendering
Use a stable unique identifier (e.g., item.id or item.provider_id) instead of the array index to avoid rendering glitches when the list changes.