Total a Filtered Table

Write the code, see it run, pass the checks.

The problem

  • medium
  • Code

The Orders component gets an orders prop: a list of { id, customer, region, amount } objects, where amount is a whole number of pounds. Show them in a real table: a header row in a thead with the columns "Customer", "Region" and "Amount", one row per order in a tbody in the given order, and a total row in a tfoot whose first cell reads "Total" and whose last cell holds the sum of the shown amounts. Amounts are shown like "£120" (a pound sign and the whole number). Above the table, two filters narrow the rows: a select labelled "Region" with "All regions" first and then each region once, in the order they first appear, and a text input labelled "Customer" that keeps the orders whose customer contains the typed text, ignoring case. Both filters apply together, and the total always sums only the rows shown; with no rows it's "£0".

Your code must pass

  • Shows every order and their total at first
  • The Region list offers "All regions", then each region once
  • Choosing a region shows only its orders and totals them
  • Typing a customer filters by name, ignoring case
  • Both filters apply together, and no matches total £0