Description of icon
Flex UI
API Reference

TaskStatusBasedType

Used to define a value based on task status. TaskStatusBasedType accepts a type parameter T which defaults to string.

The valid types are: T, TaskCallbackType and TaskStatusBasedTypeBase

  • T is a generic type.
  • TaskCallbackType is a function to provide values for Flex. Called from various areas of Flex.
  • TaskStatusBasedTypeBase is an object with ReservationStatus as its key and the parameter type T as the value.

Example:

import { TaskStatusBasedType, TaskCallbackType, TaskStatusBasedTypeBase } from "@twilio/flex-ui";
const taskHeaderStatus: TaskStatusBasedType = "Live | {{helper.durationSinceUpdate}}";
const statusMap: TaskStatusBasedTypeBase = {
Assigned: "assigned",
Wrapping: "wrapping"
};
const header = statusMap[task.status];
const componentCallback: TaskCallbackType<React.ReactNode> = (task, DefaultComponent, TaskAcceptedComponent) => {
if (task.status === "accepted") {
return <TaskAcceptedComponent />;
}
return <DefaultComponent />;
}
Rate this page

Need some help?

We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd by visiting Twilio's Stack Overflow Collective or browsing the Twilio tag on Stack Overflow.