update table views

This commit is contained in:
Dimas Atmodjo 2024-11-05 02:23:26 +07:00
parent 5f386e079f
commit ef00467309
11 changed files with 130 additions and 85 deletions

View File

@ -106,12 +106,13 @@ const ManageClasses = () => {
</td> </td>
</tr> </tr>
):( ):(
classes.length > 0 ?(
classes.map((data, index) => ( classes.map((data, index) => (
<tr key={data.ID_CLASS}> <tr key={data.ID_CLASS}>
<td>{index + 1}</td> <td>{index + 1}</td>
<td>{data.NAME_CLASS}</td> <td>{data.NAME_CLASS}</td>
<td>{data.TOTAL_STUDENT}</td> <td>{data.TOTAL_STUDENT}</td>
<td className='text-center action-col'> <td className='text-center action-col d-flex justify-content-center'>
<NavLink className='btn btn-sm btn-view' to={`class-detail/${data.ID_CLASS}`}><i className="bi bi-eye"></i></NavLink> <NavLink className='btn btn-sm btn-view' to={`class-detail/${data.ID_CLASS}`}><i className="bi bi-eye"></i></NavLink>
<Button size='sm' className='btn-edit' onClick={() => handleShow(data)}> <Button size='sm' className='btn-edit' onClick={() => handleShow(data)}>
<i className="bi bi-pencil-square"></i> <i className="bi bi-pencil-square"></i>
@ -122,6 +123,13 @@ const ManageClasses = () => {
</td> </td>
</tr> </tr>
)) ))
):(
<tr>
<td colSpan={5} style={{height:'20vh'}}>
<h3>Empty Data</h3>
</td>
</tr>
)
)} )}
</tbody> </tbody>
</Table> </Table>

View File

@ -23,7 +23,7 @@ const ManageExercises = () => {
<h2 className='page-title strip'>Exercise</h2> <h2 className='page-title strip'>Exercise</h2>
<p className='page-desc'>Description of Exercise.</p> <p className='page-desc'>Description of Exercise.</p>
<Tab.Container id="left-tabs-example" defaultActiveKey="detail"> <Tab.Container id="left-tabs-example" defaultActiveKey="detail">
<Row className='mb-45'> {/* <Row className='mb-45'>
<Col xs={12}> <Col xs={12}>
<Nav variant="pills" className='col-tabs'> <Nav variant="pills" className='col-tabs'>
<Nav.Item> <Nav.Item>
@ -38,7 +38,7 @@ const ManageExercises = () => {
</Nav.Item> </Nav.Item>
</Nav> </Nav>
</Col> </Col>
</Row> </Row> */}
<Row className='mb-45'> <Row className='mb-45'>
<Col xs={12} className='col-tabs-content'> <Col xs={12} className='col-tabs-content'>
<Tab.Content> <Tab.Content>
@ -62,7 +62,7 @@ const ManageExercises = () => {
<thead> <thead>
<tr> <tr>
<th>No</th> <th>No</th>
<th>Level</th> <th>Section</th>
<th>Topic</th> <th>Topic</th>
<th className='text-center'>Level</th> <th className='text-center'>Level</th>
<th className='text-center'>Action</th> <th className='text-center'>Action</th>
@ -81,19 +81,27 @@ const ManageExercises = () => {
</td> </td>
</tr> </tr>
):( ):(
levels.length > 0 ?(
levels.map((level, index) => ( levels.map((level, index) => (
<tr key={level.ID_LEVEL}> <tr key={level.ID_LEVEL}>
<td>{index + 1}</td> <td>{index + 1}</td>
<td>{level.NAME_SECTION}</td> <td>{level.NAME_SECTION}</td>
<td>{level.NAME_TOPIC}</td> <td>{level.NAME_TOPIC}</td>
<td>{level.NAME_LEVEL}</td> <td className='text-center'>{level.NAME_LEVEL}</td>
<td className='text-center action-col'> <td className='text-center action-col d-flex justify-content-center'>
<Link className='btn btn-sm btn-edit' to={`update-exercise/${level.ID_LEVEL}`}> <Link className='btn btn-sm btn-edit' to={`update-exercise/${level.ID_LEVEL}`}>
<i className="bi bi-pencil-square"></i> <i className="bi bi-pencil-square"></i>
</Link> </Link>
</td> </td>
</tr> </tr>
)) ))
):(
<tr>
<td colSpan={5} style={{height:'20vh'}}>
<h3>Empty Data</h3>
</td>
</tr>
)
)} )}
</tbody> </tbody>
</Table> </Table>

View File

@ -30,13 +30,13 @@ const ManageMaterials = () => {
<Nav.Item> <Nav.Item>
<Nav.Link eventKey="detail">View Entries</Nav.Link> <Nav.Link eventKey="detail">View Entries</Nav.Link>
</Nav.Item> </Nav.Item>
<Nav.Item> {/* <Nav.Item>
<OverlayTrigger overlay={<Tooltip id="tooltip-disabled">Select the level below </Tooltip>}> <OverlayTrigger overlay={<Tooltip id="tooltip-disabled">Select the level below </Tooltip>}>
<span className="d-inline-block"> <span className="d-inline-block">
<Nav.Link disabled onClick={(e)=>{e.preventDefault();}}>Create Data</Nav.Link> <Nav.Link disabled onClick={(e)=>{e.preventDefault();}}>Create Data</Nav.Link>
</span> </span>
</OverlayTrigger> </OverlayTrigger>
</Nav.Item> </Nav.Item> */}
</Nav> </Nav>
</Col> </Col>
</Row> </Row>
@ -63,7 +63,7 @@ const ManageMaterials = () => {
<thead> <thead>
<tr> <tr>
<th>No</th> <th>No</th>
<th>Level</th> <th>Section</th>
<th>Topic</th> <th>Topic</th>
<th className='text-center'>Level</th> <th className='text-center'>Level</th>
<th className='text-center'>Action</th> <th className='text-center'>Action</th>
@ -82,25 +82,27 @@ const ManageMaterials = () => {
</td> </td>
</tr> </tr>
):( ):(
levels.length > 0 ?(
levels.map((level, index) => ( levels.map((level, index) => (
<tr key={level.ID_LEVEL}> <tr key={level.ID_LEVEL}>
<td>{index + 1}</td> <td>{index + 1}</td>
<td>{level.NAME_SECTION}</td> <td>{level.NAME_SECTION}</td>
<td>{level.NAME_TOPIC}</td> <td>{level.NAME_TOPIC}</td>
<td>{level.NAME_LEVEL}</td> <td className='text-center'>{level.NAME_LEVEL}</td>
<td className='text-center action-col'> <td className='text-center action-col d-flex justify-content-center'>
{/* <Button size='sm' className='btn-edit' onClick={() => handleShow(level)}>
<i className="bi bi-pencil-square"></i>
</Button> */}
<Link className='btn btn-sm btn-edit' to={`update-material/${level.ID_LEVEL}`}> <Link className='btn btn-sm btn-edit' to={`update-material/${level.ID_LEVEL}`}>
<i className="bi bi-pencil-square"></i> <i className="bi bi-pencil-square"></i>
</Link> </Link>
{/* <Button size='sm' className='btn-edit' onClick={() => handleShow(level)}>
<i className="bi bi-pencil-square"></i>
</Button> */}
</td> </td>
</tr> </tr>
)) ))
):(
<tr>
<td colSpan={5} style={{height:'20vh'}}>
<h3>Empty Data</h3>
</td>
</tr>
)
)} )}
</tbody> </tbody>
</Table> </Table>

View File

@ -68,15 +68,20 @@ const useSections = () => {
try { try {
const createdSection = await sectionService.createData(createData); const createdSection = await sectionService.createData(createData);
setSections((prevSections) => [...prevSections, createdSection.payload]); setSections((prevSections) => [...prevSections, createdSection.payload]);
} catch (err) {
setError(err);
}finally{
resetForm(); resetForm();
setLoaderState(prev => ({ setLoaderState(prev => ({
...prev, ...prev,
loading: false, loading: false,
successMessage: 'Your new entry has been successfully created and saved.' successMessage: 'Your new entry has been successfully created and saved.'
})); }));
} catch (err) {
setError(err);
setLoaderState(prev => ({
...prev,
title: "ERROR",
loading: false,
successMessage: err.message
}));
} }
}; };

View File

@ -95,12 +95,13 @@ const ManageSections = () => {
</td> </td>
</tr> </tr>
):( ):(
sections.length > 0 ?(
sections.map((section, index) => ( sections.map((section, index) => (
<tr key={section.ID_SECTION}> <tr key={section.ID_SECTION}>
<td>{index + 1}</td> <td>{index + 1}</td>
<td>{section.NAME_SECTION}</td> <td>{section.NAME_SECTION}</td>
<td>{section.DESCRIPTION_SECTION}</td> <td>{section.DESCRIPTION_SECTION}</td>
<td className='text-center action-col'> <td className='text-center action-col d-flex justify-content-center'>
<Button size='sm' className='btn-edit' onClick={() => handleShow(section)}> <Button size='sm' className='btn-edit' onClick={() => handleShow(section)}>
<i className="bi bi-pencil-square"></i> <i className="bi bi-pencil-square"></i>
</Button> </Button>
@ -110,6 +111,13 @@ const ManageSections = () => {
</td> </td>
</tr> </tr>
)) ))
):(
<tr>
<td colSpan={5} style={{height:'20vh'}}>
<h3>Empty Data</h3>
</td>
</tr>
)
)} )}
</tbody> </tbody>
</Table> </Table>

View File

@ -130,7 +130,7 @@ const ManageStudents = () => {
<td>{student.NISN}</td> <td>{student.NISN}</td>
<td>{student.NAME_USERS}</td> <td>{student.NAME_USERS}</td>
<td>{student.EMAIL}</td> <td>{student.EMAIL}</td>
<td className='text-center action-col'> <td className='text-center action-col d-flex justify-content-center'>
<Button size='sm' className='btn-edit' onClick={() => handleShow(student)}> <Button size='sm' className='btn-edit' onClick={() => handleShow(student)}>
<i className="bi bi-pencil-square"></i> <i className="bi bi-pencil-square"></i>
</Button> </Button>

View File

@ -130,7 +130,7 @@ const ManageTeachers = () => {
<td>{teacher.NIP}</td> <td>{teacher.NIP}</td>
<td>{teacher.NAME_USERS}</td> <td>{teacher.NAME_USERS}</td>
<td>{teacher.EMAIL}</td> <td>{teacher.EMAIL}</td>
<td className='text-center action-col'> <td className='text-center action-col d-flex justify-content-center'>
<Button size='sm' className='btn-edit' onClick={() => handleShow(teacher)}> <Button size='sm' className='btn-edit' onClick={() => handleShow(teacher)}>
<i className="bi bi-pencil-square"></i> <i className="bi bi-pencil-square"></i>
</Button> </Button>

View File

@ -74,16 +74,21 @@ const useTopics = () => {
DESCRIPTION_TOPIC: data.description, DESCRIPTION_TOPIC: data.description,
}; };
const createdTopic = await topicService.createData(newTopic); const createdTopic = await topicService.createData(newTopic);
setTopics((prevTopics) => [...prevTopics, createdTopic.payload]); setTopics((prevTopics) => [...prevTopics, createdTopic.payload.topic]);
} catch (err) {
setError(err);
}finally{
resetForm(); resetForm();
setLoaderState(prev => ({ setLoaderState(prev => ({
...prev, ...prev,
loading: false, loading: false,
successMessage: 'Your new entry has been successfully created and saved.' successMessage: 'Your new entry has been successfully created and saved.'
})); }));
} catch (err) {
setError(err);
setLoaderState(prev => ({
...prev,
title: "ERROR",
loading: false,
successMessage: err.message
}));
} }
}; };

View File

@ -22,10 +22,10 @@ const fetchDataSection = async () => {
const getTopicById = async (id) => { const getTopicById = async (id) => {
try { try {
const response = await axiosInstance.get(`/${id}`); const response = await axiosInstance.get(`/topic/${id}`);
return response.data; return response.data;
} catch (error) { } catch (error) {
console.error(`Error fetching topic with ID ${id}:`, error); console.error(`Error get topic with ID ${id}:`, error);
throw error; throw error;
} }
}; };

View File

@ -99,12 +99,13 @@ const ManageTopics = () => {
</td> </td>
</tr> </tr>
):( ):(
topics.length > 0 ?(
topics.map((topic, index) => ( topics.map((topic, index) => (
<tr key={topic.ID_TOPIC}> <tr key={index}>
<td>{index + 1}</td> <td>{index + 1}</td>
<td>{sectionSlug[topic.ID_SECTION]}</td> <td>{sectionSlug[topic.ID_SECTION]}</td>
<td>{topic.NAME_TOPIC}</td> <td>{topic.NAME_TOPIC}</td>
<td className='text-center action-col'> <td className='text-center action-col d-flex justify-content-center'>
<Button size='sm' className='btn-edit' onClick={() => handleShow(topic)}> <Button size='sm' className='btn-edit' onClick={() => handleShow(topic)}>
<i className="bi bi-pencil-square"></i> <i className="bi bi-pencil-square"></i>
</Button> </Button>
@ -114,6 +115,13 @@ const ManageTopics = () => {
</td> </td>
</tr> </tr>
)) ))
):(
<tr>
<td colSpan={5} style={{height:'20vh'}}>
<h3>Empty Data</h3>
</td>
</tr>
)
)} )}
</tbody> </tbody>
</Table> </Table>

View File

@ -16,6 +16,7 @@ const useSettings = () => {
const fetchData = async () => { const fetchData = async () => {
try { try {
const data = await settingService.fetchProfile(); const data = await settingService.fetchProfile();
console.log(data);
setProfile(data.payload); setProfile(data.payload);
setIdUser(data.payload.ID) setIdUser(data.payload.ID)
} catch (err) { } catch (err) {