src/redux/track/actions.ts

mail@pastecode.io avatar
unknown
plain_text
6 months ago
1.3 kB
1
Indexable
Never
import {ActionType} from '../type';
import * as Actions from './constants';

export function getTrackGroupData(
  startDestinationId: string | any,
  endDestinationId: string | any,
  routeId: string | any,
  railroadId: string | any,
  stops: string[],
): ActionType {
  const payload = {
    end_destination_id: endDestinationId,
    railroad_id: railroadId,
    route_id: routeId,
    start_destination_id: startDestinationId,
    stops: stops,
  };
  return {
    type: Actions.GET_TRACK_DATA,
    payload,
  };
}

export function setTrackTotalLength(payload: number): ActionType {
  return {
    type: Actions.SET_TRACK_TOTAL_LENGTH,
    payload,
  };
}
export function clearStopStation(): ActionType {
  return {
    type: Actions.CLEAR_STOP_STATION,
  };
}

export function setStopStation(payload: {
  key: string;
  order: number;
}): ActionType {
  return {
    type: Actions.SET_STOP_STATION,
    payload,
  };
}

export function getNearestTrackData(payload: {
  centre_lat: number;
  centre_lng: number;
  area_of_interest_radius_m: number;
}): ActionType {
  return {
    type: Actions.GET_NEAREST_TRACK,
    payload,
  };
}

export function clearAllTrackReduxExceptNearestTrack(): ActionType {
  return {
    type: Actions.CLEAR_TRACK_REDUX_EXCEPT_NEAREST_TRACK,
  };
}