Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/DavidCevallos15/Crucidrive---APP/llms.txt

Use this file to discover all available pages before exploring further.

useTariff uses the static TARIFFS lookup table defined in src/constants/sectors.ts to return formatted fare information between two sectors in Crucita. All results are memoized via useMemo and only recompute when either sector ID changes — making it safe to call on every render of the ride-request screen without performance concerns.

Signature

import { useTariff } from '@/hooks/useTariff';

const result: TariffResult = useTariff(
  originSectorId,       // string | null
  destinationSectorId   // string | null
);

Parameters

originSectorId
string | null
required
The ID of the departure sector. Pass null when the user has not yet selected an origin. Valid values: centro, playa, las_gilces, los_arenales, san_jacinto.
destinationSectorId
string | null
required
The ID of the destination sector. Pass null when the user has not yet selected a destination. Valid values: centro, playa, las_gilces, los_arenales, san_jacinto.

Return type

interface TariffResult {
  tariff:            TariffEntry | null;
  originName:        string;
  destinationName:   string;
  formattedPrice:    string;
  formattedTime:     string;
  formattedDistance: string;
}
FieldTypeExample
tariffTariffEntry | nullFull tariff object, or null if no route exists between the two sectors
originNamestring"Centro de Crucita"
destinationNamestring"Malecón / Playa"
formattedPricestring"$1.50"
formattedTimestring"~5 min"
formattedDistancestring"1.2 km"

Available routes

All ten routes in the TARIFFS table. Tariffs are bidirectional — the same entry is returned regardless of which sector is the origin and which is the destination.
Origin → DestinationPriceDistanceTime
Centro → Playa$1.501.2 km~5 min
Centro → Las Gilces$2.002.0 km~8 min
Centro → Los Arenales$1.751.5 km~6 min
Centro → San Jacinto$2.403.2 km~10 min
Playa → Las Gilces$2.503.0 km~12 min
Playa → Los Arenales$1.501.0 km~4 min
Playa → San Jacinto$2.202.8 km~9 min
Las Gilces → Los Arenales$2.002.2 km~8 min
Las Gilces → San Jacinto$3.004.0 km~15 min
Los Arenales → San Jacinto$1.501.3 km~5 min
The lookup is performed by findTariff(originId, destinationId) from sectors.ts, which checks both orderings of the pair:
TARIFFS.find(
  (t) =>
    (t.originId === originId && t.destinationId === destinationId) ||
    (t.originId === destinationId && t.destinationId === originId)
);

Usage example

import { useTariff } from '@/hooks/useTariff';

const RideSummary = ({ origin, destination }) => {
  const {
    formattedPrice,
    formattedTime,
    formattedDistance,
    tariff,
  } = useTariff(origin, destination);

  return (
    <View>
      <Text>{formattedPrice}</Text>       {/* "$1.50"  */}
      <Text>{formattedTime}</Text>        {/* "~5 min" */}
      <Text>{formattedDistance}</Text>    {/* "1.2 km" */}
    </View>
  );
};
Passing 'centro' and 'playa' in either order yields the same result:
const a = useTariff('centro', 'playa');
const b = useTariff('playa', 'centro');

a.formattedPrice === b.formattedPrice; // true → "$1.50"
Tariffs are bidirectionaluseTariff('playa', 'centro') returns exactly the same TariffEntry as useTariff('centro', 'playa'). This mirrors real-world tricimoto pricing in Crucita, where the fare is fixed per route regardless of direction.
If either originSectorId or destinationSectorId is null, the hook returns safe UI-ready defaults: formattedPrice: "$0.00", formattedTime: "--", formattedDistance: "--", and tariff: null. This lets you render the fare card before the user has completed sector selection without adding null checks in every component.

Build docs developers (and LLMs) love