Skip to content

Commit

Permalink
Wip add override value to forecast table cells
Browse files Browse the repository at this point in the history
  • Loading branch information
CaitBarnard committed Oct 31, 2024
1 parent f39151e commit fc455f0
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
17 changes: 14 additions & 3 deletions front_end/src/Components/TableCell/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@ const TableCell = ({rowIndex, cellId, cellKey, sheetUpdating}) => {
const cell = useSelector(state => state.allCells.cells[rowIndex][cellKey]);
const editCellId = useSelector(state => state.edit.cellId, checkValue);

const isOverride = () => {
return (cell && cell.overrideAmount && cell.isEditable) // Add 'toggle is on' logic

// If cell is override then add not editable class and colour change etc
}

if (isOverride()) {
cell.amount = cell.overrideAmount
}

const [isUpdating, setIsUpdating] = useState(false)

const selectedRow = useSelector(state => state.selected.selectedRow, checkSelectRow);
Expand Down Expand Up @@ -83,16 +93,17 @@ const TableCell = ({rowIndex, cellId, cellKey, sheetUpdating}) => {
}

const wasEdited = () => {
if (!isEditable)
if (!isEditable || isOverride())
return false


return cell.amount !== cell.startingAmount
}

const getClasses = () => {
let editable = ''

if (!isEditable) {
if (!isEditable || isOverride()) { // or isOverride
editable = ' not-editable'
}

Expand All @@ -105,7 +116,7 @@ const TableCell = ({rowIndex, cellId, cellKey, sheetUpdating}) => {
negative = " negative"
}

return "govuk-table__cell forecast-month-cell figure-cell " + (wasEdited() ? 'edited ' : '') + (isSelected() ? 'selected' : '') + editable + negative
return "govuk-table__cell forecast-month-cell figure-cell " + (wasEdited() ? 'edited ' : '') + (isSelected() ? 'selected' : '') + (isOverride() ? 'override ' : '') + editable + negative
}

const setContentState = (value) => {
Expand Down
5 changes: 4 additions & 1 deletion front_end/src/Util.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,16 @@ export const processForecastData = (forecastData) => {

// eslint-disable-next-line
for (const [key, monthlyFigure] of Object.entries(rowData["monthly_figures"])) {
// if toggled, do lookup, change monthly figures else:
// Replace forecast only, not actuals
cells[monthlyFigure.month] = {
rowIndex: rowIndex,
colIndex: colIndex,
key: monthlyFigure.month,
amount: monthlyFigure.amount,
startingAmount: monthlyFigure.starting_amount,
isEditable: !monthlyFigure.actual
isEditable: !monthlyFigure.actual,
overrideAmount: 40102 // Test figure, needs to pull from payroll forecast table
}

colIndex++
Expand Down
4 changes: 4 additions & 0 deletions front_end/styles/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,10 @@ th {
background-color: rgba(86, 148, 202, 0.25);
}

.override {
background-color: rgba(201, 155, 75, 0.25);
}

.link-button {
border: none;
padding: 0 !important;
Expand Down

0 comments on commit fc455f0

Please sign in to comment.