-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
124 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import * as React from 'react'; | ||
import Table from '@mui/material/Table'; | ||
import TableBody from '@mui/material/TableBody'; | ||
import TableCell from '@mui/material/TableCell'; | ||
import TableContainer from '@mui/material/TableContainer'; | ||
import TableHead from '@mui/material/TableHead'; | ||
import TableRow from '@mui/material/TableRow'; | ||
import Paper from '@mui/material/Paper'; | ||
import DoneIcon from '@mui/icons-material/Done'; | ||
import CloseIcon from '@mui/icons-material/Close'; | ||
import styles from './Table.module.css'; | ||
|
||
export default function CustomTable({ fullData = [], headers = [], data = [] }) { | ||
const tableHeaders = fullData.length > 0 | ||
? Object.keys(fullData[0]) | ||
: headers; | ||
|
||
const tableData = fullData.length > 0 | ||
? fullData.map(item => Object.values(item)) | ||
: data; | ||
|
||
return ( | ||
<TableContainer component={Paper}> | ||
<Table sx={{ minWidth: 650 }}> | ||
<TableHead> | ||
<TableRow className={styles.tableHeader}> | ||
{tableHeaders.map((header, index) => ( | ||
<TableCell key={index} className={styles.heading}>{header}</TableCell> | ||
))} | ||
</TableRow> | ||
</TableHead> | ||
<TableBody> | ||
{tableData.map((row, rowIndex) => ( | ||
<TableRow key={rowIndex}> | ||
{row.map((cell, cellIndex) => ( | ||
<TableCell key={cellIndex} className={styles.data}> | ||
{typeof cell === 'boolean' ? ( | ||
cell ? <DoneIcon style={{ color: 'var(--checkIcon-green)' }} /> : <CloseIcon style={{ color: 'var(--red-500)' }} /> | ||
) : ( | ||
cell | ||
)} | ||
</TableCell> | ||
))} | ||
</TableRow> | ||
))} | ||
</TableBody> | ||
</Table> | ||
</TableContainer> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
.tableHeader { | ||
background-color: rgba(250, 250, 250, 1); | ||
} | ||
|
||
.heading { | ||
color: var(--second-text-color) !important ; | ||
font-size: 12px ; | ||
} | ||
|
||
.data { | ||
font-size: var(--font-regular) ; | ||
color: var(--second-text-color) !important; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import CustomTable from "../../components/Table/Table"; | ||
import { getAllGuideLogs } from "../../services/guidelogService"; | ||
import { useEffect, useState, React } from "react"; | ||
import styles from './UserStatisticsPage.module.css'; | ||
|
||
const UserStatisticsPage = () => { | ||
const [guideLogs, setGuideLogs] = useState([]); | ||
|
||
useEffect(() => { | ||
const fetchGuideLogs = async () => { | ||
try { | ||
const guideLogsData = await getAllGuideLogs(); | ||
setGuideLogs(guideLogsData); | ||
} catch (err) { | ||
console.error("Error fetching guide logs:", err); | ||
} | ||
}; | ||
fetchGuideLogs(); | ||
}, []); | ||
|
||
return ( | ||
<div className={styles.container}> | ||
<CustomTable fullData={guideLogs} /> | ||
</div> | ||
); | ||
}; | ||
|
||
export default UserStatisticsPage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.container{ | ||
padding: 3rem 3.5rem; | ||
width: 100%; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { apiClient } from './apiClient'; | ||
|
||
export const getAllGuideLogs = async () => { | ||
try { | ||
const response = await apiClient.get('/guide_log/all_guide_logs'); | ||
return response.data; | ||
} catch (error) { | ||
console.error('Get Guide Logs error:', error.response.data.errors); | ||
throw error; | ||
} | ||
}; | ||
|
||
export const addGuideLog = async (logData) => { | ||
try { | ||
const response = await apiClient.post('/guide_log/add_guide_log', logData); | ||
return response.data; | ||
} catch (error) { | ||
console.error('Add Guide Logs error:', error.response.data.errors); | ||
throw error; | ||
} | ||
}; | ||
|