Skip to content
This repository was archived by the owner on Sep 8, 2025. It is now read-only.

Commit fa35ccd

Browse files
committed
init
1 parent 8413e60 commit fa35ccd

File tree

7 files changed

+41
-71
lines changed

7 files changed

+41
-71
lines changed

client/src/_nav.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import React from 'react';
12
import { CNavGroup, CNavItem, CNavTitle } from '@coreui/react';
23
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
34
import {

client/src/components/ErrorBoundary.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React from 'react';
2+
import PropTypes from 'prop-types'; // ✅ Import prop-types
23

34
class ErrorBoundary extends React.Component {
45
constructor(props) {
@@ -31,4 +32,9 @@ class ErrorBoundary extends React.Component {
3132
}
3233
}
3334

34-
export default ErrorBoundary;
35+
// ✅ Define prop types
36+
ErrorBoundary.propTypes = {
37+
children: PropTypes.node.isRequired, // Ensures `children` is passed
38+
};
39+
40+
export default ErrorBoundary;
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import React from 'react';
2+
import PropTypes from 'prop-types'; // ✅ Import prop-types
23
import { Navigate } from 'react-router-dom';
34

45
const ProtectedLogin = ({ children }) => {
56
const accessToken = localStorage.getItem('accessToken');
6-
const department = sessionStorage.getItem('department');
77

88
if (!accessToken) {
99
return <Navigate to="/login" replace />;
@@ -12,4 +12,9 @@ const ProtectedLogin = ({ children }) => {
1212
return children;
1313
};
1414

15-
export default ProtectedLogin;
15+
// ✅ Define prop types
16+
ProtectedLogin.propTypes = {
17+
children: PropTypes.node.isRequired, // Ensures `children` is passed
18+
};
19+
20+
export default ProtectedLogin;

client/src/components/RedirectIfAuthenticated.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React from 'react';
2+
import PropTypes from 'prop-types'; // ✅ Import prop-types
23
import { Navigate } from 'react-router-dom';
34

45
const RedirectIfAuthenticated = ({ children }) => {
@@ -13,12 +14,10 @@ const RedirectIfAuthenticated = ({ children }) => {
1314
});
1415

1516
if (accessToken) {
16-
// For superadmin, redirect to employeedash regardless of department
1717
if (role?.toLowerCase() === 'superadmin') {
1818
return <Navigate to="/employeedash" replace />;
1919
}
2020

21-
// For other roles, redirect based on department
2221
switch (department?.toLowerCase()) {
2322
case "administrative":
2423
return <Navigate to="/employeedash" replace />;
@@ -38,4 +37,9 @@ const RedirectIfAuthenticated = ({ children }) => {
3837
return children;
3938
};
4039

41-
export default RedirectIfAuthenticated;
40+
// ✅ Define prop types
41+
RedirectIfAuthenticated.propTypes = {
42+
children: PropTypes.node.isRequired, // Ensures `children` is passed
43+
};
44+
45+
export default RedirectIfAuthenticated;

client/src/views/pages/integrate/hr/jobposting.js

Lines changed: 9 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React, { useState } from 'react';
2+
import PropTypes from 'prop-types'; // ✅ Import prop-types
23
import {
34
CCard,
45
CCardBody,
@@ -23,40 +24,14 @@ const RecruitmentModule = () => {
2324
const { data: jobPostings, error, isLoading } = useGetJobPostingsQuery();
2425
const [selectedJobId, setSelectedJobId] = useState(null);
2526
const [modalVisible, setModalVisible] = useState(false);
26-
const [activityTracked, setActivityTracked] = useState({ jobId: null, jobTitle: null, jobDepartment: null }); // State for tracking activity
2727

2828
const { data: jobDetails, isLoading: isJobLoading } = useGetJobPostingByIdQuery(selectedJobId, {
2929
skip: !selectedJobId, // Only fetch details when a job is selected
3030
});
3131

32-
const trackActivity = (jobId, action) => {
33-
const job = jobPostings.find((job) => job._id === jobId);
34-
const jobTitle = job ? job.title : 'Unknown Job';
35-
const jobDepartment = job ? job.department : 'Unknown Department';
36-
37-
// Track the activity
38-
setActivityTracked({ jobId, jobTitle, jobDepartment });
39-
40-
// Log the action (optional, for debugging)
41-
console.log(`${action} job: ${jobTitle}`);
42-
};
43-
4432
const viewApplications = (jobId) => {
4533
setSelectedJobId(jobId);
4634
setModalVisible(true);
47-
trackActivity(jobId, 'View');
48-
};
49-
50-
const editJob = (jobId) => {
51-
trackActivity(jobId, 'Edit');
52-
// Add your edit logic here
53-
console.log(`Editing job: ${jobId}`);
54-
};
55-
56-
const deleteJob = (jobId) => {
57-
trackActivity(jobId, 'Delete');
58-
// Add your delete logic here
59-
console.log(`Deleting job: ${jobId}`);
6035
};
6136

6237
const closeModal = () => {
@@ -99,7 +74,6 @@ const RecruitmentModule = () => {
9974
View
10075
</CButton>
10176
</CTableDataCell>
102-
10377
</CTableRow>
10478
))}
10579
</CTableBody>
@@ -108,14 +82,6 @@ const RecruitmentModule = () => {
10882
</CCardBody>
10983
</CCard>
11084

111-
{/* Track Activity */}
112-
{activityTracked.jobId && (
113-
<ActivityTracker
114-
action={`Interacted with ${activityTracked.jobTitle}`}
115-
description={`Interacted with job: ${activityTracked.jobTitle} in the ${activityTracked.jobDepartment} department`}
116-
/>
117-
)}
118-
11985
{/* Modal to view applications */}
12086
<CModal visible={modalVisible} onClose={closeModal}>
12187
<CModalHeader>
@@ -162,4 +128,11 @@ const RecruitmentModule = () => {
162128
);
163129
};
164130

165-
export default RecruitmentModule;
131+
// ✅ Add Prop Validation
132+
RecruitmentModule.propTypes = {
133+
jobPostings: PropTypes.array, // Array of job postings (fetched from API)
134+
error: PropTypes.object, // Error state from API
135+
isLoading: PropTypes.bool, // Loading state from API
136+
};
137+
138+
export default RecruitmentModule;

client/src/views/pages/integrate/hr/works.js

Lines changed: 9 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React, { useEffect, useState } from 'react';
2+
import PropTypes from 'prop-types';
23
import {
34
CContainer,
45
CRow,
@@ -14,6 +15,7 @@ import {
1415
CBadge,
1516
} from '@coreui/react';
1617
import { usePostForgotPasswordMutation } from '../../../../state/adminApi';
18+
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
1719
import {
1820
usePostToHrMutation,
1921
usePostToFinanceMutation,
@@ -25,14 +27,10 @@ import {
2527
usePostgenerateMutation
2628
} from '../../../../state/hrApi';
2729
import CustomHeader from '../../../../components/header/customhead';
28-
import ExcelJS from 'exceljs';
29-
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
30-
import { faDownload } from '@fortawesome/free-solid-svg-icons';
3130
import GrantAccessModal from '../../scene/modal.js';
31+
import ExcelJS from 'exceljs';
3232
// Import the mutations for the departments
3333

34-
import axios from 'axios';
35-
3634
const Works = () => {
3735
const { data, isLoading, error } = useGetWorkersQuery();
3836
const [changeRole] = useChangeRoleMutation();
@@ -302,30 +300,6 @@ const Works = () => {
302300
</CCol>
303301
</CRow>
304302

305-
{/* Track Download All button click */}
306-
{downloadAllClicked && (
307-
<ActivityTracker
308-
action="Download All"
309-
description="User downloaded all employee data as an Excel file"
310-
/>
311-
)}
312-
313-
{/* Track Role Change */}
314-
{roleChangeTracked.userId && (
315-
<ActivityTracker
316-
action="Change Role"
317-
description={`Changed role for user ${roleChangeTracked.userName} to ${roleChangeTracked.newRole}`}
318-
/>
319-
)}
320-
321-
{/* Track Delete User */}
322-
{deleteTracked.userId && (
323-
<ActivityTracker
324-
action="Delete User"
325-
description={`Deleted user ${deleteTracked.userName}`}
326-
/>
327-
)}
328-
329303
{filteredData.map((item) => (
330304
<CCard
331305
key={item._id}
@@ -460,4 +434,10 @@ const Works = () => {
460434
);
461435
};
462436

437+
Works.propTypes = {
438+
data: PropTypes.array, // Array of employees
439+
isLoading: PropTypes.bool, // Loading state
440+
error: PropTypes.object, // Error object
441+
};
442+
463443
export default Works;

client/src/views/pages/scene/PendingRequest.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import React from 'react';
12
import { useState, useEffect } from "react";
23
import {
34
CCard,

0 commit comments

Comments
 (0)