call(back)

TypeScript Kanban Board I

Build a kanban board in React and TypeScript. Tasks are grouped by status into columns, and each task moves to an adjacent status with left and right controls instead of drag-and-drop. The starter renders the board from INITIAL_TASKS with both arrows on every task, and neither arrow does anything yet.

Requirements

  • The left arrow moves a task to the previous status and the right arrow to the next one, in the order of STATUSES.
  • Hide a direction control when the task cannot move farther that way: no left arrow in the first column and no right arrow in the last.
  • Route every move through one reducer action, MOVE_TASK, and keep updates immutable. A move past either end changes nothing.
  • Type the state and the action. The order of tasks within a column is up to you.
  • Keep the starter's markup: each column is a <section> labelled by its heading, each task a list item showing its title, and the controls are buttons labelled Move <title> left and Move <title> right.

Hints

Hint 1

Keep the status order in one constant. A move is the task's position in it plus or minus one, rejected when it falls off either end.

Hint 2

useReducer with a single MOVE_TASK action carrying { id, direction } gives both arrows one code path. Return the same state when nothing changes.

Hint 3

Whether an arrow shows depends only on the column's position in that constant: the first has no left arrow and the last no right one.

Asked at

Similar Problems6