SpeedLimitSection/types/index.ts

src/ui/components/widgets/SpeedLimitSection/types/index.ts
mail@pastecode.io avatar
unknown
typescript
9 days ago
4.6 kB
0
Indexable
Never
export enum ActionTypes {
  View = 'View',
  Edit = 'Edit',
  EditItem = 'EditItem',
  Add = 'Add'
}

export enum Direction {
  ASC = 'ASC',
  DESC = 'DESC'
}

export enum SpeedLimitType {
  Zone = 'Zone',
  TSO = 'TSO'
}

export interface speedLimitStates {
  type: string
  subdivision: string
  subdivisionList: any[]
  limit: number
  startMile: string
  endMile: string
  startLimit: string
  endLimit: string
  heavy: boolean
  hazardous: boolean
  page: string
  actionType: ActionTypes
  indexItemSelected: number | null
  dataItemSelected: speedLimitItemType | null
  addSpeedLimitData: any | null
  editSpeedLimitData: any | null
  temporarySpeedLimitIdDelete: string | null
  routes: any[]
  routeId: string
  direction: string
  directionList: any[]
  isDeleteModal: boolean
  isAddModal: boolean
  isEditModal: boolean
  errorModal: string
  TSOSpeedLimitSelected: any | null
  // edit: boolean
}

export interface speedLimitItemType {
  type?: string
  speed_limit_type?: string
  subdivision?: string
  speed_limit_mph?: number
  start_mile?: number
  end_mile?: number
  heavy?: boolean
  hazardous?: boolean
  temporary_speed_limit_id?: string
  start_distance_miles?: number
  end_distance_miles?: number
}

export enum speedLimitActions {
  INITIALIZE_STATES = 'INITIALIZE_STATES',
  INITIALIZE_ROUTES = 'INITIALIZE_ROUTES',
  ON_CHANGE_TYPE = 'ON_CHANGE_TYPE',
  ON_CHANGE_ACTION_TYPE = 'ON_CHANGE_ACTION_TYPE',
  ON_CHANGE_START_MP = 'ON_CHANGE_START_MP',
  ON_CHANGE_END_MP = 'ON_CHANGE_END_MP',
  ON_CHANGE_PAGE = 'ON_CHANGE_PAGE',
  ON_SELECTED_ITEM = 'ON_SELECTED_ITEM',
  ON_SELECTED_DELETE_ITEM = 'ON_SELECTED_DELETE_ITEM',
  ON_ADD_SPEED_LIMIT_DATA = 'ON_ADD_SPEED_LIMIT_DATA',
  ON_EDIT_SPEED_LIMIT_DATA = 'ON_EDIT_SPEED_LIMIT_DATA',
  ON_CHANGE_ROUTE_ID = 'ON_CHANGE_ROUTE_ID',
  ON_CHANGE_DIRECTION = 'ON_CHANGE_DIRECTION',
  ON_DELETE_SPEED_LIMIT = 'ON_DELETE_SPEED_LIMIT',
  ON_ADD_SPEED_LIMIT = 'ON_ADD_SPEED_LIMIT',
  ON_EDIT_SPEED_LIMIT = 'ON_EDIT_SPEED_LIMIT',
  ON_CHANGE_SUBDIVISION_LIST = 'ON_CHANGE_SUBDIVISION_LIST',
  ON_CHANGE_SUBDIVISION = 'ON_CHANGE_SUBDIVISION',
  ERROR_ADD_OR_EDIT = 'ERROR_ADD_OR_EDIT',
  ON_EDIT = 'ON_EDIT',
  ON_TSO_SPEED_LIMIT_SELECTED = 'ON_TSO_SPEED_LIMIT_SELECTED'
}

export interface reducerActionProps {
  type:
    | speedLimitActions.INITIALIZE_STATES
    | speedLimitActions.INITIALIZE_ROUTES
    | speedLimitActions.ON_CHANGE_TYPE
    | speedLimitActions.ON_CHANGE_ACTION_TYPE
    | speedLimitActions.ON_CHANGE_START_MP
    | speedLimitActions.ON_CHANGE_END_MP
    | speedLimitActions.ON_CHANGE_PAGE
    | speedLimitActions.ON_SELECTED_ITEM
    | speedLimitActions.ON_CHANGE_ROUTE_ID
    | speedLimitActions.ON_EDIT
    | speedLimitActions.ON_CHANGE_DIRECTION
    | speedLimitActions.ON_DELETE_SPEED_LIMIT
    | speedLimitActions.ON_ADD_SPEED_LIMIT_DATA
    | speedLimitActions.ON_EDIT_SPEED_LIMIT_DATA
    | speedLimitActions.ON_ADD_SPEED_LIMIT
    | speedLimitActions.ON_EDIT_SPEED_LIMIT
    | speedLimitActions.ON_SELECTED_DELETE_ITEM
    | speedLimitActions.ON_CHANGE_SUBDIVISION_LIST
    | speedLimitActions.ON_CHANGE_SUBDIVISION
    | speedLimitActions.ERROR_ADD_OR_EDIT
    | speedLimitActions.ON_TSO_SPEED_LIMIT_SELECTED
  payload: any
}

export interface actionCreatorsProps {
  onInitStates: (initData: any) => void
  onInitRoutes: (initRoutes: any) => void
  onChangeType: (type: string) => void
  onChangeActionType: (actionType: ActionTypes) => void
  onChangePage: (selectedPage: string) => void
  onSelectedItem: ({
    selectedItemData,
    selectedIndex
  }: {
    selectedItemData: speedLimitItemType | null
    selectedIndex: number
  }) => void
  onSelectedDeleteItem: (temporarySpeedLimitId: string | null) => void
  onChangeRouteId: (routeId: string) => void
  onChangeDirection: (direction: string) => void

  onChangeIsOpenModalDelete: (isOpen: boolean) => void
  onChangeIsOpenModalAdd: (isOpen: boolean) => void
  onChangeIsOpenModalEdit: (isOpen: boolean) => void

  onChangeAddSpeedLimitData: (addSpeedLimitData: any) => void
  onChangeEditSpeedLimitData: (editSpeedLimitData: any) => void

  onChangeSubdivisionList: (subdivisionData: any[]) => void
  onIsOpenError: (error: string) => void
  onChangeStartMP: (startMP: string) => void
  onChangeEndMP: (endMP: string) => void
  onChangeSubdivision: (subdivision: string) => void

  onChangeTSOSpeedLimitSelected: (TSOSpeedLimit: any) => void
  // onEdit: (isEdit: boolean) => void
}
Leave a Comment