Skip to content

Commit 0ae7090

Browse files
committed
RD-T42 PR#13 fixes
1 parent 096c556 commit 0ae7090

39 files changed

Lines changed: 251 additions & 660 deletions

src/api/weatherAlerts/weatherAlerts.ts

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,13 @@ export const getWeatherAlert = async (alertId: string, signal?: AbortSignal) =>
2323
return response.data;
2424
};
2525

26-
export const getAlertsNearLocation = async (
27-
lat: number,
28-
lng: number,
29-
radiusMiles: number = 25,
30-
signal?: AbortSignal
31-
) => {
32-
const response = await alertsNearLocationApi.get<ActiveWeatherAlertsResult>(
33-
{ lat, lng, radiusMiles },
34-
signal
35-
);
26+
export const getAlertsNearLocation = async (lat: number, lng: number, radiusMiles: number = 25, signal?: AbortSignal) => {
27+
const response = await alertsNearLocationApi.get<ActiveWeatherAlertsResult>({ lat, lng, radiusMiles }, signal);
3628
return response.data;
3729
};
3830

3931
export const getAlertHistory = async (startDate: string, endDate: string, signal?: AbortSignal) => {
40-
const response = await alertHistoryApi.get<ActiveWeatherAlertsResult>(
41-
{ startDate, endDate },
42-
signal
43-
);
32+
const response = await alertHistoryApi.get<ActiveWeatherAlertsResult>({ startDate, endDate }, signal);
4433
return response.data;
4534
};
4635

src/app/(app)/home.tsx

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ import { getMapDataAndMarkers } from '@/api/mapping/mapping';
1111
import { AudioStreamBottomSheet } from '@/components/audio-stream/audio-stream-bottom-sheet';
1212
import { CloseCallBottomSheet } from '@/components/calls/close-call-bottom-sheet';
1313
import { ActiveCallFilterBanner, ActiveCallsPanel, ActivityLogPanel, AddNoteBottomSheet, MapWidget, NotesPanel, PersonnelPanel, PTTInterface, StatsHeader, UnitsPanel } from '@/components/dispatch-console';
14-
import { WeatherAlertBanner } from '@/components/weatherAlerts/weather-alert-banner';
1514
import { Box } from '@/components/ui/box';
1615
import { FocusAwareStatusBar } from '@/components/ui/focus-aware-status-bar';
1716
import { HStack } from '@/components/ui/hstack';
1817
import { VStack } from '@/components/ui/vstack';
18+
import { WeatherAlertBanner } from '@/components/weatherAlerts/weather-alert-banner';
1919
import { useAnalytics } from '@/hooks/use-analytics';
2020
import { logger } from '@/lib/logging';
2121
import { isCallActive, isCallPending, isCallScheduled } from '@/lib/utils';
@@ -688,12 +688,7 @@ export default function DispatchConsole() {
688688
/>
689689

690690
{/* Weather Alert Banner */}
691-
{weatherSettings?.WeatherAlertsEnabled !== false && weatherAlerts.length > 0 && (
692-
<WeatherAlertBanner
693-
alerts={weatherAlerts}
694-
onPress={() => router.push('/(app)/weather-alerts' as Href)}
695-
/>
696-
)}
691+
{weatherSettings?.WeatherAlertsEnabled !== false && weatherAlerts.length > 0 && <WeatherAlertBanner alerts={weatherAlerts} onPress={() => router.push('/(app)/weather-alerts' as Href)} />}
697692

698693
{/* Active Call Filter Banner */}
699694
{isCallFilterActive && selectedCall && <ActiveCallFilterBanner call={selectedCall} priority={selectedCallPriority} onClearFilter={handleClearCallFilter} />}
@@ -708,13 +703,7 @@ export default function DispatchConsole() {
708703
<AddNoteBottomSheet isOpen={isAddNoteSheetOpen} onClose={() => setIsAddNoteSheetOpen(false)} onNoteAdded={handleNoteAdded} />
709704

710705
{/* Close Call Bottom Sheet */}
711-
{selectedCallId && (
712-
<CloseCallBottomSheet
713-
isOpen={isCloseCallSheetOpen}
714-
onClose={() => setIsCloseCallSheetOpen(false)}
715-
callId={selectedCallId}
716-
/>
717-
)}
706+
{selectedCallId && <CloseCallBottomSheet isOpen={isCloseCallSheetOpen} onClose={() => setIsCloseCallSheetOpen(false)} callId={selectedCallId} />}
718707
</View>
719708
);
720709
}

src/app/(app)/home.web.tsx

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -760,14 +760,7 @@ export default function DispatchConsoleWeb() {
760760
<AddNoteBottomSheet isOpen={isAddNoteSheetOpen} onClose={() => setIsAddNoteSheetOpen(false)} onNoteAdded={handleNoteAdded} />
761761

762762
{/* Close Call Bottom Sheet */}
763-
{selectedCallId && (
764-
<CloseCallBottomSheet
765-
key={selectedCallId}
766-
isOpen={isCloseCallSheetOpen}
767-
onClose={() => setIsCloseCallSheetOpen(false)}
768-
callId={selectedCallId}
769-
/>
770-
)}
763+
{selectedCallId && <CloseCallBottomSheet key={selectedCallId} isOpen={isCloseCallSheetOpen} onClose={() => setIsCloseCallSheetOpen(false)} callId={selectedCallId} />}
771764
</View>
772765
);
773766
}

src/app/(app)/personnel.tsx

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,7 @@ export default function Personnel() {
9595
const status = (p.Status || '').toLowerCase();
9696
const staffing = (p.Staffing || '').toLowerCase();
9797
const roles = (p.Roles || []).join(' ').toLowerCase();
98-
return (
99-
fullName.includes(query) ||
100-
group.includes(query) ||
101-
status.includes(query) ||
102-
staffing.includes(query) ||
103-
roles.includes(query)
104-
);
98+
return fullName.includes(query) || group.includes(query) || status.includes(query) || staffing.includes(query) || roles.includes(query);
10599
});
106100
}, [personnel, searchQuery]);
107101

@@ -113,12 +107,7 @@ export default function Personnel() {
113107
[trackEvent]
114108
);
115109

116-
const renderItem = useCallback(
117-
({ item }: { item: PersonnelInfoResultData }) => (
118-
<PersonnelCard person={item} onPress={() => handlePersonPress(item)} />
119-
),
120-
[handlePersonPress]
121-
);
110+
const renderItem = useCallback(({ item }: { item: PersonnelInfoResultData }) => <PersonnelCard person={item} onPress={() => handlePersonPress(item)} />, [handlePersonPress]);
122111

123112
const keyExtractor = useCallback((item: PersonnelInfoResultData) => item.UserId, []);
124113

@@ -142,9 +131,7 @@ export default function Personnel() {
142131
renderItem={renderItem}
143132
keyExtractor={keyExtractor}
144133
refreshControl={<RefreshControl refreshing={isLoading} onRefresh={fetchPersonnel} />}
145-
ListEmptyComponent={
146-
<ZeroState heading={emptyHeading} description={emptyDescription} icon={Users} />
147-
}
134+
ListEmptyComponent={<ZeroState heading={emptyHeading} description={emptyDescription} icon={Users} />}
148135
contentContainerStyle={styles.listContent}
149136
/>
150137
);
@@ -159,11 +146,7 @@ export default function Personnel() {
159146
<InputSlot className="pl-3">
160147
<InputIcon as={Search} />
161148
</InputSlot>
162-
<InputField
163-
placeholder={t('personnel.search')}
164-
value={searchQuery}
165-
onChangeText={setSearchQuery}
166-
/>
149+
<InputField placeholder={t('personnel.search')} value={searchQuery} onChangeText={setSearchQuery} />
167150
{searchQuery ? (
168151
<InputSlot className="pr-3" onPress={() => setSearchQuery('')}>
169152
<InputIcon as={X} />
@@ -174,11 +157,7 @@ export default function Personnel() {
174157
{/* Results count */}
175158
{personnel.length > 0 && !isLoading ? (
176159
<HStack className="mb-2 items-center justify-between px-1">
177-
<Text className="text-xs text-gray-500 dark:text-gray-400">
178-
{searchQuery.trim()
179-
? `${filteredPersonnel.length} of ${personnel.length}`
180-
: `${personnel.length} personnel`}
181-
</Text>
160+
<Text className="text-xs text-gray-500 dark:text-gray-400">{searchQuery.trim() ? `${filteredPersonnel.length} of ${personnel.length}` : `${personnel.length} personnel`}</Text>
182161
</HStack>
183162
) : null}
184163

src/app/(app)/units.tsx

Lines changed: 9 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -103,15 +103,11 @@ export default function Units() {
103103
const groupName = (u.GroupName || '').toLowerCase();
104104
const status = (u.CurrentStatus || '').toLowerCase();
105105
const note = (u.Note || '').toLowerCase();
106-
const roles = (u.Roles || []).map((r) => `${r.RoleName} ${r.Name}`).join(' ').toLowerCase();
107-
return (
108-
name.includes(query) ||
109-
type.includes(query) ||
110-
groupName.includes(query) ||
111-
status.includes(query) ||
112-
note.includes(query) ||
113-
roles.includes(query)
114-
);
106+
const roles = (u.Roles || [])
107+
.map((r) => `${r.RoleName} ${r.Name}`)
108+
.join(' ')
109+
.toLowerCase();
110+
return name.includes(query) || type.includes(query) || groupName.includes(query) || status.includes(query) || note.includes(query) || roles.includes(query);
115111
});
116112
}, [units, searchQuery]);
117113

@@ -123,12 +119,7 @@ export default function Units() {
123119
[trackEvent]
124120
);
125121

126-
const renderItem = useCallback(
127-
({ item }: { item: UnitInfoResultData }) => (
128-
<UnitCard unit={item} onPress={() => handleUnitPress(item)} />
129-
),
130-
[handleUnitPress]
131-
);
122+
const renderItem = useCallback(({ item }: { item: UnitInfoResultData }) => <UnitCard unit={item} onPress={() => handleUnitPress(item)} />, [handleUnitPress]);
132123

133124
const keyExtractor = useCallback((item: UnitInfoResultData) => item.UnitId, []);
134125

@@ -152,9 +143,7 @@ export default function Units() {
152143
renderItem={renderItem}
153144
keyExtractor={keyExtractor}
154145
refreshControl={<RefreshControl refreshing={isLoading} onRefresh={fetchUnits} />}
155-
ListEmptyComponent={
156-
<ZeroState heading={emptyHeading} description={emptyDescription} icon={Truck} />
157-
}
146+
ListEmptyComponent={<ZeroState heading={emptyHeading} description={emptyDescription} icon={Truck} />}
158147
contentContainerStyle={styles.listContent}
159148
/>
160149
);
@@ -169,11 +158,7 @@ export default function Units() {
169158
<InputSlot className="pl-3">
170159
<InputIcon as={Search} />
171160
</InputSlot>
172-
<InputField
173-
placeholder={t('units.search')}
174-
value={searchQuery}
175-
onChangeText={setSearchQuery}
176-
/>
161+
<InputField placeholder={t('units.search')} value={searchQuery} onChangeText={setSearchQuery} />
177162
{searchQuery ? (
178163
<InputSlot className="pr-3" onPress={() => setSearchQuery('')}>
179164
<InputIcon as={X} />
@@ -184,11 +169,7 @@ export default function Units() {
184169
{/* Results count */}
185170
{units.length > 0 && !isLoading ? (
186171
<HStack className="mb-2 items-center justify-between px-1">
187-
<Text className="text-xs text-gray-500 dark:text-gray-400">
188-
{searchQuery.trim()
189-
? `${filteredUnits.length} of ${units.length}`
190-
: `${units.length} units`}
191-
</Text>
172+
<Text className="text-xs text-gray-500 dark:text-gray-400">{searchQuery.trim() ? `${filteredUnits.length} of ${units.length}` : `${units.length} units`}</Text>
192173
</HStack>
193174
) : null}
194175

src/app/(app)/weather-alerts/index.tsx

Lines changed: 11 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,11 @@ import { type Href, router } from 'expo-router';
33
import { useColorScheme } from 'nativewind';
44
import React, { useCallback, useMemo, useState } from 'react';
55
import { useTranslation } from 'react-i18next';
6-
import {
7-
ActivityIndicator,
8-
FlatList,
9-
Pressable,
10-
RefreshControl,
11-
ScrollView,
12-
StyleSheet,
13-
Text as RNText,
14-
View,
15-
} from 'react-native';
6+
import { ActivityIndicator, FlatList, Pressable, RefreshControl, ScrollView, StyleSheet, Text as RNText, View } from 'react-native';
167

17-
import { WeatherAlertCard } from '@/components/weatherAlerts/weather-alert-card';
188
import { Text } from '@/components/ui/text';
199
import { VStack } from '@/components/ui/vstack';
10+
import { WeatherAlertCard } from '@/components/weatherAlerts/weather-alert-card';
2011
import { WeatherAlertSeverity } from '@/models/v4/weatherAlerts/weatherAlertEnums';
2112
import { type WeatherAlertResultData } from '@/models/v4/weatherAlerts/weatherAlertResultData';
2213
import { useWeatherAlertsStore } from '@/stores/weatherAlerts/store';
@@ -84,29 +75,8 @@ export default function WeatherAlertsListScreen() {
8475
const renderFilterButton = (key: FilterType, label: string) => {
8576
const isActive = filter === key;
8677
return (
87-
<Pressable
88-
key={key}
89-
onPress={() => setFilter(key)}
90-
style={[
91-
styles.filterPill,
92-
isActive
93-
? styles.filterPillActive
94-
: isDark
95-
? styles.filterPillDark
96-
: styles.filterPillLight,
97-
]}
98-
>
99-
<RNText
100-
style={[
101-
styles.filterPillText,
102-
isActive
103-
? styles.filterPillTextActive
104-
: isDark
105-
? styles.filterPillTextDark
106-
: styles.filterPillTextLight,
107-
]}
108-
numberOfLines={1}
109-
>
78+
<Pressable key={key} onPress={() => setFilter(key)} style={[styles.filterPill, isActive ? styles.filterPillActive : isDark ? styles.filterPillDark : styles.filterPillLight]}>
79+
<RNText style={[styles.filterPillText, isActive ? styles.filterPillTextActive : isDark ? styles.filterPillTextDark : styles.filterPillTextLight]} numberOfLines={1}>
11080
{label}
11181
</RNText>
11282
</Pressable>
@@ -116,25 +86,8 @@ export default function WeatherAlertsListScreen() {
11686
const renderSortButton = (key: SortType, label: string) => {
11787
const isActive = sort === key;
11888
return (
119-
<Pressable
120-
key={key}
121-
onPress={() => setSort(key)}
122-
style={[styles.sortPill, isActive && styles.sortPillActive]}
123-
>
124-
<RNText
125-
style={[
126-
styles.sortPillText,
127-
isActive
128-
? isDark
129-
? styles.sortPillTextActiveDark
130-
: styles.sortPillTextActive
131-
: isDark
132-
? styles.sortPillTextDark
133-
: styles.sortPillTextLight,
134-
]}
135-
>
136-
{label}
137-
</RNText>
89+
<Pressable key={key} onPress={() => setSort(key)} style={[styles.sortPill, isActive && styles.sortPillActive]}>
90+
<RNText style={[styles.sortPillText, isActive ? (isDark ? styles.sortPillTextActiveDark : styles.sortPillTextActive) : isDark ? styles.sortPillTextDark : styles.sortPillTextLight]}>{label}</RNText>
13891
</Pressable>
13992
);
14093
};
@@ -143,34 +96,20 @@ export default function WeatherAlertsListScreen() {
14396
if (isLoading) return null;
14497
return (
14598
<VStack className="flex-1 items-center justify-center py-12" space="sm">
146-
<Text className="text-base text-gray-500 dark:text-gray-400">
147-
{t('weatherAlerts.noActiveAlerts')}
148-
</Text>
99+
<Text className="text-base text-gray-500 dark:text-gray-400">{t('weatherAlerts.noActiveAlerts')}</Text>
149100
</VStack>
150101
);
151102
};
152103

153-
const renderItem = useCallback(
154-
({ item }: { item: WeatherAlertResultData }) => (
155-
<WeatherAlertCard alert={item} onPress={handleAlertPress} />
156-
),
157-
[]
158-
);
104+
const renderItem = useCallback(({ item }: { item: WeatherAlertResultData }) => <WeatherAlertCard alert={item} onPress={handleAlertPress} />, []);
159105

160106
return (
161107
<View style={[styles.container, isDark ? styles.containerDark : styles.containerLight]}>
162108
{/* Header */}
163-
<RNText style={[styles.title, isDark ? styles.titleDark : styles.titleLight]}>
164-
{t('weatherAlerts.title')}
165-
</RNText>
109+
<RNText style={[styles.title, isDark ? styles.titleDark : styles.titleLight]}>{t('weatherAlerts.title')}</RNText>
166110

167111
{/* Filter pills */}
168-
<ScrollView
169-
horizontal
170-
showsHorizontalScrollIndicator={false}
171-
style={styles.filterScroll}
172-
contentContainerStyle={styles.filterRow}
173-
>
112+
<ScrollView horizontal showsHorizontalScrollIndicator={false} style={styles.filterScroll} contentContainerStyle={styles.filterRow}>
174113
{renderFilterButton('all', t('weatherAlerts.filter.all'))}
175114
{renderFilterButton('extreme', t('weatherAlerts.severity.extreme'))}
176115
{renderFilterButton('severe', t('weatherAlerts.severity.severe'))}
@@ -195,9 +134,7 @@ export default function WeatherAlertsListScreen() {
195134
renderItem={renderItem}
196135
contentContainerStyle={styles.listContent}
197136
ListEmptyComponent={renderEmpty}
198-
refreshControl={
199-
<RefreshControl refreshing={isLoading} onRefresh={fetchActiveAlerts} />
200-
}
137+
refreshControl={<RefreshControl refreshing={isLoading} onRefresh={fetchActiveAlerts} />}
201138
/>
202139
)}
203140
</View>

0 commit comments

Comments
 (0)