Skip to content

Commit eb8038d

Browse files
committed
deferred action cell is disabled button
1 parent 83857e2 commit eb8038d

1 file changed

Lines changed: 20 additions & 11 deletions

File tree

src/components/Search/SearchList/ListItem/ActionCell/DeferredActionCell.tsx

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,37 @@
11
import React, {useDeferredValue} from 'react';
2-
import {View} from 'react-native';
3-
import PulsingView from '@components/PulsingView';
4-
import useTheme from '@hooks/useTheme';
2+
import Button from '@components/Button';
3+
import useLocalize from '@hooks/useLocalize';
54
import useThemeStyles from '@hooks/useThemeStyles';
5+
import CONST from '@src/CONST';
66
import ActionCell from '.';
77
import type {ActionCellProps} from '.';
8+
import actionTranslationsMap from './actionTranslationsMap';
89

910
function DeferredActionCell(actionCellProps: ActionCellProps) {
1011
const styles = useThemeStyles();
11-
const theme = useTheme();
12+
const {translate} = useLocalize();
1213
const shouldRender = useDeferredValue(true, false);
1314

1415
if (!shouldRender) {
15-
const sizeStyle = actionCellProps.extraSmall ? styles.buttonExtraSmall : styles.buttonSmall;
16+
const action = actionCellProps.action ?? CONST.SEARCH.ACTION_TYPES.VIEW;
17+
const shouldUseViewAction = action === CONST.SEARCH.ACTION_TYPES.VIEW || action === CONST.SEARCH.ACTION_TYPES.PAID || action === CONST.SEARCH.ACTION_TYPES.DONE;
18+
const isSuccess = !shouldUseViewAction && action !== CONST.SEARCH.ACTION_TYPES.UNDELETE;
19+
const text = shouldUseViewAction ? translate(actionTranslationsMap[CONST.SEARCH.ACTION_TYPES.VIEW]) : translate(actionTranslationsMap[action]);
20+
1621
return (
17-
<PulsingView
18-
shouldPulse
19-
style={styles.w100}
20-
>
21-
<View style={[styles.w100, sizeStyle, {backgroundColor: theme.skeletonLHNIn}]} />
22-
</PulsingView>
22+
<Button
23+
text={text}
24+
small={!actionCellProps.extraSmall}
25+
extraSmall={actionCellProps.extraSmall}
26+
style={[styles.w100, styles.pointerEventsNone]}
27+
isDisabled
28+
success={isSuccess}
29+
isNested
30+
/>
2331
);
2432
}
2533

34+
// Deferred wrapper intentionally forwards all props to the underlying component
2635
// eslint-disable-next-line react/jsx-props-no-spreading
2736
return <ActionCell {...actionCellProps} />;
2837
}

0 commit comments

Comments
 (0)