• A hook that will help manage the use of region information on a dispenser.

    Type Parameters

    • T extends {} = any

    Parameters

    • timeFormatMap: TimeFormatMap<T> = DEFAULT_FORMAT_MAP

      a function that maps a region string a structure that can be used as an option in a select box. The default is to return an option element with the region as the value and label.

    Returns KosTimeFormatHookData<T>

    KosRegionHookData - the data returned from the hook.

    Example

    In this example the default region map is used to populate a select box with the available regions. If using a third party select box component where the options are passed in as a prop, the options property can be spread into the props for the component. In this case, a region map function could be passed in to map the region to a structure that the component expects.

    interface RegionData extends RegionServices.BaseRegionResponse {
    rfidRegion: string;
    }
    const { regionSelectProps, regionModel, regionData, selectedRegion, updateRegion } = useKosRegions<RegionData>();
    const { options, ...selectAttributes } = regionSelectProps;
    ...
    <div>
    <label>Select region: </label>
    <select {...selectAttributes}>{options}</select>
    </div>
    <div>Selected Region: {selectedRegion}</div>
    <div>Region Data: {regionData?.rfidRegion}</div>