Skip to content
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

[SBRP-111] Remove all redundant codes #66

Merged
merged 2 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion client/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ const {Header, Footer, Sider, Content} = Layout;
const footerStyle: React.CSSProperties = {
textAlign: 'center',
color: 'grey',
// backgroundColor: '#7dbcea',
};

const rowGutterStyle = {xs: 8, sm: 16, md: 24, lg: 32};
Expand Down
18 changes: 0 additions & 18 deletions client/src/actions/applications.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ export const getApplicationsByStaffId = (payload: GetApplicationsByStaffIdPayloa
} else {
list_of_applications_by_staff_id.data[i].rl_status = "Open";
}
// a
}
}
}
Expand Down Expand Up @@ -71,13 +70,6 @@ export const getApplicationByStaffIdAndRLId = (rl_id: number) => async (dispatch
export const postApplication = (payload: PostApplicationPayloadType) => async (dispatch: (action: ActionType) => void) => {
// post data retrieved from frontend with data retrieved from the frontend
try {
console.log("got clicked")

// let payload = {"rl_id": 1,
// "staff_id":1, // staff_id here has a different convention from the usual staffId used in payload
// "role_app_status": "applied"
// }
console.log(payload)
const list_of_applications_by_staff_id = await axios.post('/api/staff/application/', payload)


Expand All @@ -93,17 +85,7 @@ export const postApplication = (payload: PostApplicationPayloadType) => async (d
export const updateApplication = (payload: UploadApplicationPayloadType ) => async (dispatch: (action: ActionType) => void) => {
// post data retrieved from frontend with data retrieved from the frontend
try {
console.log("got clicked")

// let payload = {"rl_id": 3,
// "staff_id":3, // staff_id here has a different convention from the usual staffId used in payload
// "role_app_status": "applied",
// "app_text": "Hello word"
// }
console.log(payload)
const {rl_id, staff_id} = payload;
console.log("role_id: "+ rl_id)
console.log("staff_id: "+ staff_id)
const list_of_applications_by_staff_id = await axios.put(`/api/staff/application/${rl_id}/${staff_id}`, payload)


Expand Down
1 change: 0 additions & 1 deletion client/src/actions/roleListings.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import {store} from '../mockStore';
import {calcSkillMatch} from "./roleListings";

// create a test script to test the calcSkillMatch function
Expand Down
6 changes: 0 additions & 6 deletions client/src/actions/roleListings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -280,14 +280,8 @@ export const updateRoleListing = (id: number, payload: UpdateRoleListingLoadType

export const postRoleListing = (payload: PostRoleListingPayloadType) => async (dispatch: (action: ActionType) => void) => {
try {
console.log("postRL got clicked");
const {rl_id, role_id, rl_desc, rl_source, rl_open, rl_close, rl_creator, location, department} = payload;
console.log(payload);
const list_of_all_role_listing_details = await axios.post('/api/role_listing/', payload);
// dispatch({
// type: POST_ROLE_LISTING,
// payload: res.data
// });

} catch (err: any) {
dispatch({
Expand Down
6 changes: 0 additions & 6 deletions client/src/components/layout/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,6 @@ const Navbar = ({auth: {user, loading, isHR, logout}}: any) => {
}, []);

const items: MenuProps['items'] = [
// {
// label: "SBRP",
// key: 'logo',
// disabled: true,
// style: {height: 60, paddingTop: 10, cursor: "default"},
// },
{
label: (<Link to={"/"}>{"Home"}</Link>),
key: '/',
Expand Down
9 changes: 0 additions & 9 deletions client/src/components/pages/CreateRoleListing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ const CreateRoleListing = ({
getRoleListings(user);
}, [getRoles, getStaffListings,getRoleListings]);

// const dispatch = useDispatch();
let roleTypes: SelectProps['options'] = [
{
label: "Loading...",
Expand Down Expand Up @@ -88,9 +87,6 @@ const CreateRoleListing = ({
});
}

// const newRLID = roleListing.roleListings.length + 1;
// review in future according to RL table if can

const dispatch = useDispatch();
const navigate = useNavigate();

Expand All @@ -100,7 +96,6 @@ const CreateRoleListing = ({
const roleId = form.getFieldValue('roleName');
for (let i = 0; i < role.roles.length; i++) {
if (role.roles[i].role_id === roleId) {
console.log(role.roles[i].role_description)
form.setFieldsValue({ roleDescription: role.roles[i].role_description });
dispatch(getRoleSkillsByRoleId(roleId) as any);
return
Expand Down Expand Up @@ -132,7 +127,6 @@ const CreateRoleListing = ({
department: fieldsValue['department'],
}
dispatch(postRoleListing(payload) as any);
console.log('Received values of form: ', payload);
};

return (
Expand All @@ -147,7 +141,6 @@ const CreateRoleListing = ({
form={form}
name="control-hooks"
onFinish={onFinish}
// style={{ maxWidth: 600 }}
scrollToFirstError
size="large"
colon={false}
Expand Down Expand Up @@ -176,7 +169,6 @@ const CreateRoleListing = ({
<Form.Item name="rl_source" label="Manager" rules={[{ required: true, message: "Please input a manager"}]}>
<Select
showSearch
// style={{width: '30%'}}
optionFilterProp={"label"}
options={staffList}
suffixIcon={<SearchOutlined/>}
Expand All @@ -191,7 +183,6 @@ const CreateRoleListing = ({
<Form.Item name="applicationPeriod" label="Application Period" {...rangeConfig}>
<RangePicker
format="DD-MM-YYYY"
// disabledDate={disabledDate}
/>
</Form.Item>
<Form.Item label="Skills">
Expand Down
5 changes: 0 additions & 5 deletions client/src/components/pages/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,9 @@ const Home = ({
"rl_id": id,
"staff_id": user,
"role_app_status": "withdrawn",
// "app_text": textBody,
}
dispatch(updateApplication(payload) as any)
.catch(() => console.log('Oops errors!'));
// dispatch(getApplicationsByStaffId(user) as any)
},
onCancel() {},
width: '30rem'
Expand All @@ -84,7 +82,6 @@ const Home = ({
,
sorter: (a, b) => a.role_name.length - b.role_name.length,
sortOrder: sortedInfo.columnKey === 'roleName' ? sortedInfo.order : null,
// ellipsis: true,
width: '44rem',
},
{
Expand All @@ -97,7 +94,6 @@ const Home = ({
,
sorter: (a, b) => new Date(a.app_ts).getTime() - new Date(b.app_ts).getTime(),
sortOrder: sortedInfo.columnKey === 'dateApplied' ? sortedInfo.order : null,
// ellipsis: true,
width: '44rem',
responsive: ['md'],
},
Expand All @@ -120,7 +116,6 @@ const Home = ({
},
{
title: 'Actions',
// dataIndex: 'rl_id',
render: (record: any) =>
<Skeleton active style={{width: "100%"}} paragraph={{width: "100%", rows: 1}} title={false} loading={!dataloaded}>
<Space size={10}>
Expand Down
7 changes: 1 addition & 6 deletions client/src/components/pages/ManageRolePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,11 @@ const ManageRolePage = ({
children: new Date(roleListing.rl_close).getTime() > today.getTime() ?
<Tag color="green">Open</Tag> :
<Tag color="red">Closed</Tag>
,
// span: 2,
},

{
key: '5',
label: 'Manager',
children: <>{roleListing.source_name}</>,
// span: 3,
},
{
key: '3',
Expand Down Expand Up @@ -110,8 +106,7 @@ const ManageRolePage = ({
{
title: 'Name',
dataIndex: 'rl_updater_name',
key: 'name',
// render: (text) => <a>{text}</a>,
key: 'name'
},
{
title: 'Date Edited',
Expand Down
2 changes: 0 additions & 2 deletions client/src/components/pages/RoleApplicants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ interface filterOption {
label: string;
}

// Sort Example:
const sortOptions: filterOption[] = [
{
value: 'skillmatch',
Expand Down Expand Up @@ -106,7 +105,6 @@ const RoleApplicants = ({
<Space direction='vertical'>
<div style={{fontStyle: "italic"}}>Skill Match</div>
<Progress type="circle" size={60} percent={item.skill_match} data-testid="skill-match"
// <Progress type="circle" size={80} percent={90}
format={(percent) =>
`${percent}%`
}/>
Expand Down
2 changes: 0 additions & 2 deletions client/src/components/pages/RoleListing.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {render, screen, waitFor} from '@testing-library/react';
import {filterRoleListingsByDepartment, filterRoleListingsByLocation, filterRoleListingsByRoleId} from '../../actions/roleListings';
// import RoleList from './RoleList';
import {store} from '../../mockStore';
import {Provider} from 'react-redux';
import {mockMatchMedia} from "../../setupTests";
Expand Down Expand Up @@ -48,7 +47,6 @@ describe('RoleSearchFilter component tests', () => {
store.dispatch(filterRoleListingsByDepartment(payload) as any);

const actions = store.getActions();
// console.log(actions);
expect(actions).toEqual([expectedAction]);
});

Expand Down
2 changes: 0 additions & 2 deletions client/src/components/pages/RoleListing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ interface filterOption {
label: string;
}

// Sort Example:
const sortOptions: filterOption[] = [
{
value: 'asc',
Expand Down Expand Up @@ -253,7 +252,6 @@ const RoleListing = ({
<Space direction='vertical'>
<div style={{fontStyle: "italic"}}>Skill Match</div>
<Progress type="circle" size={60} percent={item.skill_match}
// <Progress type="circle" size={80} percent={90}
format={(percent) =>
`${percent}%`
}/>
Expand Down
1 change: 0 additions & 1 deletion client/src/components/pages/RoleListingManager.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ describe('Role Listings component tests', () => {
const listItemElement = screen.getAllByTestId('one-listing');

expect(listItemElement.length).toBe(2);
console.log(window.location.pathname)
});
});

Expand Down
1 change: 0 additions & 1 deletion client/src/components/pages/RoleListingManager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ const RoleListingManager = ({
const getHRName = (id: number) => {
let staff = staffListing.staffListings.find((staffListing: any) => staffListing.staff_id === id);
return staff.fname + " " + staff.lname;
// return "yo"
}

const today = new Date();
Expand Down
26 changes: 1 addition & 25 deletions client/src/components/pages/RolePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ const RolePage = ({
}, [getRoleListing]);

useEffect(() => {
// console.log(rl_id)
getApplicationByStaffIdAndRLId(Number(rl_id));
}, [applications]);

Expand All @@ -74,7 +73,6 @@ const RolePage = ({
}, 3000);

// onclick function that uses postapplication action when button is clicked which sends rl_id, staff_id, status from both the role listing and the staff as payload
// let isWithdrawn = false;
const [isApplyModalOpen, setIsApplyModalOpen] = useState(false);
const [buttonDisabled, setButtonDisabled] = useState(false);
const [isWithdrawModalOpen, setisWithdrawModalOpen] = useState(false);
Expand All @@ -84,45 +82,32 @@ const RolePage = ({


const checkIfApplied = () => {
// console.log("isApplied: " + isApplied)
if (application == null || application.length === 0) {
setIsApplied(false);
} else {
// console.log("status is withdrawn: ")
// console.log(application[0].role_app_status === "withdrawn")
if (application[0].role_app_status === "withdrawn") {
// isWithdrawn = true
// console.log("button disabled: " + buttonDisabled)
setIsApplied(true);
setButtonDisabled(true)
// console.log("button disabled (after): " + buttonDisabled)
} else {
setIsApplied(true);
setButtonDisabled(false)

}
}
}

// console.log("outside check"+buttonDisabled)

const showModal = () => {
setIsApplyModalOpen(true);
};


const handleOk = () => {
// console.log("clicked")
// console.log(application)

if (application == null || application.length === 0) {
let payload = {
"rl_id": roleListing.rl_id,
"staff_id": user,
"role_app_status": "applied",
"app_text": textBody,
}
// console.log(payload)
dispatch(postApplication(payload) as any)
dispatch(getApplicationsByStaffId(user) as any)

Expand All @@ -146,7 +131,6 @@ const RolePage = ({
"rl_id": roleListing.rl_id,
"staff_id": user,
"role_app_status": "withdrawn",
// "app_text": textBody,
}
dispatch(updateApplication(payload) as any)
dispatch(getApplicationsByStaffId(user) as any)
Expand All @@ -171,11 +155,9 @@ const RolePage = ({
const handleWithdraw = () => {
setisWithdrawModalOpen(true);


// setIsApplied(false);
}

/*
/*
Show apply when:
- Staff has not applied for the role
- getApplicationByStaffIdAndRLId returns empty array / null
Expand Down Expand Up @@ -215,8 +197,6 @@ Show withdraw when:
children: new Date(roleListing.rl_close).getTime() > today.getTime() ?
<Tag color="green">Open</Tag> :
<Tag color="red">Closed</Tag>
,
// span: 2,
},
{
key: '3',
Expand Down Expand Up @@ -404,8 +384,6 @@ RolePage.propTypes = {
roleListing: PropTypes.object.isRequired,
staffSkill: PropTypes.object.isRequired,
auth: PropTypes.object.isRequired,
// getApplicationsByStaffId: PropTypes.func.isRequired,
// postApplication: PropTypes.func.isRequired,
getApplicationByStaffIdAndRLId: PropTypes.func.isRequired,
getStaffSkillsByStaffId: PropTypes.func.isRequired,
};
Expand All @@ -421,8 +399,6 @@ const mapStateToProps = (state: any) => ({
export default connect(mapStateToProps, {
getRoleSkillsByRoleId,
getRoleListing,
// getApplicationsByStaffId,
// postApplication,
getApplicationByStaffIdAndRLId,
getStaffSkillsByStaffId,
})(RolePage);
1 change: 0 additions & 1 deletion client/src/components/pages/UpdateRoleListing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ const UpdateRoleListing = ({
<Form.Item name="applicationPeriod" label="Application Period" {...rangeConfig}>
<RangePicker
format="DD-MM-YYYY"
// disabledDate={disabledDate}
/>
</Form.Item>
<Form.Item label="Skills">
Expand Down
1 change: 0 additions & 1 deletion client/src/reducers/applications.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {ActionType} from "../types";
const initialState = {
applications: [],
application: null,
// isApplied: false,
loading: true,
error: {}
}
Expand Down