Skip to content

Commit

Permalink
Center checkboxes and tidy up
Browse files Browse the repository at this point in the history
  • Loading branch information
CaitBarnard committed Feb 26, 2025
1 parent 2c7d85a commit b139c69
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const monthsWithActuals = (previousMonths) => {
return previousMonths
.filter((month) => month.is_actual)
.map((month) => month.short_name.toLowerCase());
};
14 changes: 9 additions & 5 deletions front_end/src/Components/EditPayroll/PayrollNewTable/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ import {
} from "@tanstack/react-table";
import { monthsToTitleCase } from "../../../Util";
import { useState } from "react";
import { monthsWithActuals } from "./helpers";

function PayrollNewTable({ data, onTogglePayPeriods, previousMonths }) {
const monthsWithActuals = previousMonths
.filter((month) => month.is_actual)
.map((month) => month.short_name.toLowerCase());
const monthColumns = monthsToTitleCase.map((header, index) => ({
header: header,
id: header.toLowerCase(),
Expand All @@ -22,6 +20,9 @@ function PayrollNewTable({ data, onTogglePayPeriods, previousMonths }) {
onChange={() => onTogglePayPeriods(row.original.id, index, getValue())}
/>
),
meta: {
className: "payroll-checkbox",
},
}));
const employeeColumns = [
{
Expand Down Expand Up @@ -62,7 +63,7 @@ function PayrollNewTable({ data, onTogglePayPeriods, previousMonths }) {
const [showPreviousMonths, setShowPreviousMonths] = useState(false);
const togglePreviousMonthsVisibility = () => {
setShowPreviousMonths((prev) => !prev);
const monthColumnIds = monthsWithActuals;
const monthColumnIds = monthsWithActuals(previousMonths);
monthColumnIds.forEach((columnId) => {
const column = table.getColumn(columnId);
if (column) {
Expand Down Expand Up @@ -106,7 +107,10 @@ function PayrollNewTable({ data, onTogglePayPeriods, previousMonths }) {
{table.getRowModel().rows.map((row) => (
<tr key={row.id}>
{row.getVisibleCells().map((cell) => (
<td key={cell.id}>
<td
key={cell.id}
className={cell.column.columnDef.meta?.className ?? ""}
>
{flexRender(cell.column.columnDef.cell, cell.getContext())}
</td>
))}
Expand Down
9 changes: 6 additions & 3 deletions front_end/styles/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -387,9 +387,8 @@ th {

.new-table {
table {
width: 100%;
border-collapse: collapse;
margin: 1rem 0;
@extend .govuk-table;
font-size: 16px;
}

th,
Expand All @@ -403,4 +402,8 @@ th {
background-color: #f4f4f4;
font-weight: bold;
}

.payroll-checkbox {
text-align: center;
}
}

0 comments on commit b139c69

Please sign in to comment.