Routing & porting hooks

The headless layer behind the routing and porting components: read and update a voice routing config, and drive a port-in through its lifecycle. Added in @handset/react 0.5.0.

useRoutingConfig / useRoutingConfigs

const { config, update, isSaving } = useRoutingConfig(routingConfigId);

// Edit just the business hours, preserving the rest of the config.
await update({
  business_hours: { schedule: [{ days: ["mon","tue","wed","thu","fri"], open: "09:00", close: "17:00" }] },
  open_behavior: config!.open_behavior,
});

const { configs } = useRoutingConfigs({ tenantId }); // list, to pick one

useRoutingConfig reads one config and update PATCHes it. The API requires open_behavior, so send it (and any closed_behavior / recording) alongside your hours rather than a bare business_hours. This is the hook behind business-hours-editor.

usePorting

const { checkPortability, createPortIn, submitPortIn, cancelPortIn, isSubmitting } = usePorting();

const results = await checkPortability(["+14155550142"]);   // [{ phone_number, portable, reason }]

const draft = await createPortIn({
  tenantId,
  phoneNumbers: results.filter((r) => r.portable).map((r) => r.phone_number),
  entityName: "Bayview Dental LLC",
  authorizedPerson: "Alex Rivera",
  billingPhoneNumber: "+14155550142",
  accountNumber: "4821",
  serviceAddress: { street: "500 Ocean Ave", city: "San Francisco", state: "CA", postalCode: "94112" },
});

const submitted = await submitPortIn(draft.id);   // status → in_review

The full port-in lifecycle as mutations. Pair with usePortIn(id) to follow the order's status afterward. This is the hook behind port-in-wizard; isSubmitting / error cover whichever call is in flight.