Olddevs UI4.14.0

Orders (CRM)

A web shop's order desk with filters, saved views, bulk actions and an order panel.

Open full screen

What it is built from

Try it

  • Switch the view: “Awaiting payment” sorts by age, “My refunds” stacks two filters at once.
  • “Add filter” offers status, channel, amount, date or manager; amount and date take two fields, “From” and “To”, and one is enough. Remove any tag with its × button or Delete.
  • Change the filters or the sorting and press “Save view”: your own view appears next to the ready-made ones.
  • Select some orders and turn the page — the selection stays; “Select all” selects all filtered rows, not just one page.
  • “Mark as shipped” ships the paid orders and skips the rest; “Export” shows a toast.
  • Click an order row, or focus it and press Enter: the panel shows its items, status history and customer, and the button at the bottom moves the order forward. Once something is selected, a click on a row selects it, and Enter opens the panel.

How it is built

The table state lives in one place. Filters, sorting, page, selection and the visibility and order of columns sit in a single useTableState, and DataTable, FilterBar and Pagination read it and hand changes back as a patch. The invariants belong to the hook, not to the Gallery screen: changing a filter or the sorting resets to the first page, but leaves the selection alone. That is why the selection survives turning pages, and “Select all” can select all filtered rows rather than a page.

The table does not own the data. DataTable shows exactly the rows it is given: the Gallery screen does the filtering, sorting and pagination, the way a server query would in an app. Hence two loading states: the initial load shows a skeleton, while a repeat load keeps the rows in place, dimmed — the page does not jump on every step. Here the “server” is a timer.

A filter is an equality or a range, and a view is a whole snapshot. A FilterBar tag for status, channel and manager means “field equals value”. Amount and date are fields with kind: "number-range" and kind: "date-range" and an empty values: FilterBarAdd shows two fields, “From” and “To”; the kit builds the tag label from its message catalog and the UiProvider locale, and an empty bound is an open one. The Gallery screen computes the result from filter.value and filter.to. What several tags mean is also up to the Gallery screen: one field is “or”, different fields are “and”. SavedViews stores nothing and hands over the whole view, so the Gallery screen applies filters and sorting in a single set call; the ready-made views leave the ranges alone. The Gallery screen does not remember the active view; it finds it by comparing with the current state: after a manual edit the state no longer matches the view, so the view stops being active. Saving a new view is the Gallery screen's job as well.

On a narrow screen the user decides. Table hides no columns on its own: the kit offers TablePreferences behind the gear icon for that. The Gallery screen hides the secondary columns up front on a phone and a small window, the customer's name moves under the order number, and a table wider than the window scrolls inside its own box.

A row opens the order. DataTable does it through onRowAction: a click on the row or Enter opens the panel, while the checkboxes handle selection, so the order number in the cell stays plain text and no manual stopPropagation is needed. The react-aria rule: while nothing is selected, a click on a row is the action; once a row is selected, a click toggles it and the action stays on Enter.