|
1 | 1 | 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'; |
5 | 4 | import useThemeStyles from '@hooks/useThemeStyles'; |
| 5 | +import CONST from '@src/CONST'; |
6 | 6 | import ActionCell from '.'; |
7 | 7 | import type {ActionCellProps} from '.'; |
| 8 | +import actionTranslationsMap from './actionTranslationsMap'; |
8 | 9 |
|
9 | 10 | function DeferredActionCell(actionCellProps: ActionCellProps) { |
10 | 11 | const styles = useThemeStyles(); |
11 | | - const theme = useTheme(); |
| 12 | + const {translate} = useLocalize(); |
12 | 13 | const shouldRender = useDeferredValue(true, false); |
13 | 14 |
|
14 | 15 | 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 | + |
16 | 21 | 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 | + /> |
23 | 31 | ); |
24 | 32 | } |
25 | 33 |
|
| 34 | + // Deferred wrapper intentionally forwards all props to the underlying component |
26 | 35 | // eslint-disable-next-line react/jsx-props-no-spreading |
27 | 36 | return <ActionCell {...actionCellProps} />; |
28 | 37 | } |
|
0 commit comments