diff --git a/src/components/Search/SearchList/ListItem/ActionCell/DeferredActionCell.tsx b/src/components/Search/SearchList/ListItem/ActionCell/DeferredActionCell.tsx new file mode 100644 index 000000000000..13a85cde7fc1 --- /dev/null +++ b/src/components/Search/SearchList/ListItem/ActionCell/DeferredActionCell.tsx @@ -0,0 +1,39 @@ +import React, {useDeferredValue} from 'react'; +import Button from '@components/Button'; +import useLocalize from '@hooks/useLocalize'; +import useThemeStyles from '@hooks/useThemeStyles'; +import CONST from '@src/CONST'; +import ActionCell from '.'; +import type {ActionCellProps} from '.'; +import actionTranslationsMap from './actionTranslationsMap'; + +function DeferredActionCell(actionCellProps: ActionCellProps) { + const styles = useThemeStyles(); + const {translate} = useLocalize(); + const shouldRender = useDeferredValue(true, false); + + if (!shouldRender) { + const action = actionCellProps.action ?? CONST.SEARCH.ACTION_TYPES.VIEW; + const shouldUseViewAction = action === CONST.SEARCH.ACTION_TYPES.VIEW || action === CONST.SEARCH.ACTION_TYPES.PAID || action === CONST.SEARCH.ACTION_TYPES.DONE; + const isSuccess = !shouldUseViewAction && action !== CONST.SEARCH.ACTION_TYPES.UNDELETE; + const text = shouldUseViewAction ? translate(actionTranslationsMap[CONST.SEARCH.ACTION_TYPES.VIEW]) : translate(actionTranslationsMap[action]); + + return ( +