Skip to content

Commit

Permalink
Refactor payroll table component to be generic with headers
Browse files Browse the repository at this point in the history
  • Loading branch information
CaitBarnard committed Nov 19, 2024
1 parent 5b76e5e commit 7e4cc61
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 24 deletions.
13 changes: 11 additions & 2 deletions front_end/src/Apps/Payroll.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { useEffect, useReducer, useState, useMemo } from "react";

import EditPayroll from "../Components/EditPayroll";
import * as api from "../Components/EditPayroll/api";
import { payrollHeaders, vacancyHeaders } from "../Components/EditPayroll/constants";

const initialPayrollState = [];

Expand Down Expand Up @@ -64,14 +65,22 @@ export default function Payroll() {
</div>
</div>
)}
<h2 class="govuk-heading-m">Payroll</h2>
<h2 className="govuk-heading-m">Payroll</h2>
<EditPayroll
payroll={payroll}
headers={payrollHeaders}
onTogglePayPeriods={handleTogglePayPeriods}
/>
<h2 class="govuk-heading-m">Non-payroll</h2>
<h2 className="govuk-heading-m">Non-payroll</h2>
<EditPayroll
payroll={nonPayroll}
headers={payrollHeaders}
onTogglePayPeriods={handleTogglePayPeriods}
/>
<h2 className="govuk-heading-m">Vacancies</h2>
<EditPayroll
payroll={nonPayroll}
headers={vacancyHeaders}
onTogglePayPeriods={handleTogglePayPeriods}
/>
<button className="govuk-button" onClick={handleSavePayroll}>
Expand Down
35 changes: 35 additions & 0 deletions front_end/src/Components/EditPayroll/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
const monthHeaders = [
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec",
"Jan",
"Feb",
"Mar",
];

export const payrollHeaders = [
"Name",
"Grade",
"Employee No",
"FTE",
"Programme Code",
"Budget Type",
"Assignment Status",
].concat(monthHeaders);

export const vacancyHeaders = [
"Recruitment Type",
"Grade",
"Programme",
"Budget Type",
"Appointee Name",
"Hiring Manager",
"HR Ref",
"Recruitment Stage",
].concat(monthHeaders);
23 changes: 1 addition & 22 deletions front_end/src/Components/EditPayroll/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,7 @@ import PayrollTable from "./PayrollTable/index";
* @param {types.PayrollData[]} props.payroll
* @returns
*/
export default function EditPayroll({ payroll, onTogglePayPeriods }) {
const headers = [
"Name",
"Grade",
"Employee No",
"FTE",
"Programme Code",
"Budget Type",
"Assignment Status",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec",
"Jan",
"Feb",
"Mar",
];
export default function EditPayroll({ payroll, headers, onTogglePayPeriods }) {
return (
<PayrollTable
headers={headers}
Expand Down

0 comments on commit 7e4cc61

Please sign in to comment.