Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove calltaker index imports #1011

Merged
merged 9 commits into from
Oct 19, 2023
2 changes: 1 addition & 1 deletion .github/workflows/percy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
- name: Download OTP2 config file
run: curl $PERCY_OTP2_CONFIG_URL --output /tmp/otp2config.yml
env:
PERCY_OTP2_CONFIG_URL: ${{ secrets.PERCY_MOCK_OTP2_GEOCODER_CONFIG }}
PERCY_OTP2_CONFIG_URL: ${{ secrets.PERCY_MOCK_OTP2_GEOCODER_CALLTAKER_CONFIG }}
- name: Build OTP-RR Calltaker
# Calltaker has a separate config file, so another build should be produced.
run: yarn build
Expand Down
17 changes: 2 additions & 15 deletions lib/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,7 @@ import {
BatchResultsScreen,
BatchRoutingPanel,
BatchSearchScreen,
CallHistoryWindow,
CallTakerControls,
CallTakerPanel,
DefaultItinerary,
FieldTripWindows,
MailablesWindow,
ResponsiveWebapp
} from './index'

Expand Down Expand Up @@ -178,17 +173,9 @@ const components = {

ItineraryBody: DefaultItinerary,

MainControls: isCallTakerModuleEnabled ? CallTakerControls : null,
MainPanel: BatchRoutingPanel,

MainPanel: isCallTakerModuleEnabled ? CallTakerPanel : BatchRoutingPanel,

MapWindows: isCallTakerModuleEnabled ? (
<>
<CallHistoryWindow />
<FieldTripWindows />
<MailablesWindow />
</>
) : null,
MapWindows: isCallTakerModuleEnabled ? jsConfig.MapWindows : null,

MobileResultsScreen: BatchResultsScreen,

Expand Down
12 changes: 0 additions & 12 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
/* eslint-disable prettier/prettier */
/* eslint-disable sort-imports-es6-autofix/sort-imports-es6 */
import CallTakerControls from './components/admin/call-taker-controls'
import CallHistoryWindow from './components/admin/call-history-window'
import FieldTripWindows from './components/admin/field-trip-windows'
import MailablesWindow from './components/admin/mailables-window'
import DateTimeModal from './components/form/date-time-modal'
import DateTimePreview from './components/form/date-time-preview'
import ErrorMessage from './components/form/error-message'
Expand All @@ -29,7 +25,6 @@ import ViewStopButton from './components/viewers/view-stop-button'
import ViewerContainer from './components/viewers/viewer-container'
import ResponsiveWebapp from './components/app/responsive-webapp'
import AppMenu from './components/app/app-menu'
import CallTakerPanel from './components/app/call-taker-panel'
import DesktopNav from './components/app/desktop-nav'
import BatchRoutingPanel from './components/app/batch-routing-panel'
import BatchResultsScreen from './components/mobile/batch-results-screen'
Expand All @@ -50,12 +45,6 @@ const MobileResultsScreen = BatchResultsScreen
const MobileSearchScreen = BatchSearchScreen

export {
// module components
CallHistoryWindow,
CallTakerControls,
FieldTripWindows,
MailablesWindow,

// form components
DateTimeModal,
DateTimePreview,
Expand Down Expand Up @@ -96,7 +85,6 @@ export {
// app components,
ResponsiveWebapp,
AppMenu,
CallTakerPanel,
DesktopNav,

// batch routing components
Expand Down
14 changes: 10 additions & 4 deletions lib/reducers/call-taker.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,17 @@ import { FETCH_STATUS } from '../util/constants'
import { getISOLikeTimestamp } from '../util/state'
import { getModuleConfig, Modules } from '../util/config'

function getCalltakerConfig(config) {
return getModuleConfig({ otp: { config } }, Modules.CALL_TAKER)
}

function createCallTakerReducer(config) {
const calltakerConfig = getModuleConfig(
{ otp: { config } },
Modules.CALL_TAKER
)
const calltakerConfig = getCalltakerConfig(config)
if (!calltakerConfig) {
// Don't include the calltaker reducer at all if calltaker is not enabled in config.
return undefined
}

const initialState = {
activeCall: null,
callHistory: {
Expand Down
4 changes: 2 additions & 2 deletions lib/util/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,8 @@ function getActiveSearchRealtimeResponse(state) {
* https://decembersoft.com/posts/error-selector-creators-expect-all-input-selectors-to-be-functions/
*/
export const getActiveFieldTripRequest = createSelector(
(state) => state.callTaker?.fieldTrip.activeId,
(state) => state.callTaker?.fieldTrip.requests,
(state) => state.callTaker?.fieldTrip?.activeId,
(state) => state.callTaker?.fieldTrip?.requests,
(activeId, requests) => {
if (!activeId || !requests) return
return requests.data.find((req) => req.id === activeId)
Expand Down
8 changes: 4 additions & 4 deletions percy/har-mock-config-call-taker.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ import React from 'react'
import {
BatchResultsScreen,
BatchSearchScreen,
CallHistoryWindow,
CallTakerPanel,
FieldTripWindows,
MailablesWindow,
MetroItinerary
// Webpack sets this file to run from a subdirectory within otp-react-redux
// ../lib points to the index file of otp-react-redux's source code
} from '../lib'
import CallHistoryWindow from '../lib/components/admin/call-history-window'
import CallTakerPanel from '../lib/components/app/call-taker-panel'
import FieldTripWindows from '../lib/components/admin/field-trip-windows'
import MailablesWindow from '../lib/components/admin/mailables-window'

/**
* Custom itinerary footer for this deployment.
Expand Down
Loading