Skip to content

Commit 684f5e1

Browse files
committed
Update Gusto sync result shape
1 parent 07534df commit 684f5e1

2 files changed

Lines changed: 15 additions & 22 deletions

File tree

src/components/GustoSyncResultsModal.tsx

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,14 @@ import {useMemoizedLazyExpensifyIcons, useMemoizedLazyIllustrations} from '@hook
1414
import useLocalize from '@hooks/useLocalize';
1515
import useTheme from '@hooks/useTheme';
1616
import useThemeStyles from '@hooks/useThemeStyles';
17-
import type {GustoSyncResult, GustoSyncResultUser} from '@libs/API/GustoSyncResult';
17+
import type {GustoSyncResult} from '@libs/API/GustoSyncResult';
1818
import CONST from '@src/CONST';
1919

2020
type GustoSyncResultsModalProps = ModalProps & {
2121
/** Sync result returned by the completed Gusto sync job */
2222
result: GustoSyncResult;
2323
};
2424

25-
function getResultCount(users?: GustoSyncResultUser[]) {
26-
return users?.length ?? 0;
27-
}
28-
2925
function GustoSyncResultsModal({result, closeModal}: GustoSyncResultsModalProps) {
3026
const {translate} = useLocalize();
3127
const styles = useThemeStyles();
@@ -34,9 +30,9 @@ function GustoSyncResultsModal({result, closeModal}: GustoSyncResultsModalProps)
3430
const illustrations = useMemoizedLazyIllustrations(['NewUser']);
3531
const [isSkippedSectionExpanded, setIsSkippedSectionExpanded] = useState(false);
3632

37-
const addedCount = getResultCount(result.added);
38-
const removedCount = getResultCount(result.removed);
39-
const skippedCount = getResultCount(result.skipped);
33+
const addedCount = result.addedEmployeesCount ?? 0;
34+
const removedCount = result.removedEmployeesCount ?? 0;
35+
const skippedCount = result.skippedEmployees?.length ?? 0;
4036
const closeResultsModal = () => closeModal();
4137

4238
const renderResultSummary = (label: string, count: number) => (
@@ -99,13 +95,13 @@ function GustoSyncResultsModal({result, closeModal}: GustoSyncResultsModalProps)
9995
/>
10096
</PressableWithoutFeedback>
10197
{isSkippedSectionExpanded &&
102-
result.skipped?.map((user) => (
98+
result.skippedEmployees?.map((employee) => (
10399
<View
104-
key={user.email}
100+
key={employee.id}
105101
style={[styles.mt4]}
106102
>
107-
<Text style={[styles.textNormalThemeText, styles.textStrong]}>{user.displayName ?? user.email}</Text>
108-
<Text style={[styles.textSupporting]}>{user.reason}</Text>
103+
<Text style={[styles.textNormalThemeText, styles.textStrong]}>{employee.name}</Text>
104+
<Text style={[styles.textSupporting]}>{employee.reason}</Text>
109105
</View>
110106
))}
111107
</ScrollView>

src/libs/API/GustoSyncResult.ts

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
1-
type GustoSyncResultUser = {
2-
email: string;
3-
displayName?: string;
4-
};
5-
6-
type GustoSyncSkippedResultUser = GustoSyncResultUser & {
1+
type GustoSyncSkippedEmployee = {
2+
name: string;
3+
id: string;
74
reason: string;
85
};
96

107
type GustoSyncResult = {
11-
added?: GustoSyncResultUser[];
12-
removed?: GustoSyncResultUser[];
13-
skipped?: GustoSyncSkippedResultUser[];
8+
addedEmployeesCount?: number;
9+
removedEmployeesCount?: number;
10+
skippedEmployees?: GustoSyncSkippedEmployee[];
1411
};
1512

16-
export type {GustoSyncResult, GustoSyncResultUser};
13+
export type {GustoSyncResult, GustoSyncSkippedEmployee};

0 commit comments

Comments
 (0)