Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 0 additions & 49 deletions src/components/PinButton.js

This file was deleted.

43 changes: 43 additions & 0 deletions src/components/PinButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import React from 'react';
import useLocalize from '@hooks/useLocalize';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import * as ReportActions from '@userActions/Report';
import * as Session from '@userActions/Session';
import CONST from '@src/CONST';
import type {Report} from '@src/types/onyx';
import Icon from './Icon';
import * as Expensicons from './Icon/Expensicons';
import PressableWithFeedback from './Pressable/PressableWithFeedback';
import Tooltip from './Tooltip';

type PinButtonProps = {
/** Report to pin */
report: Report;
};

function PinButton({report}: PinButtonProps) {
const theme = useTheme();
const styles = useThemeStyles();
const {translate} = useLocalize();

return (
<Tooltip text={report.isPinned ? translate('common.unPin') : translate('common.pin')}>
<PressableWithFeedback
onPress={Session.checkIfActionIsAllowed(() => ReportActions.togglePinnedState(report.reportID, report.isPinned ?? false))}
Comment thread
pasyukevich marked this conversation as resolved.
Outdated
style={styles.touchableButtonImage}
accessibilityLabel={report.isPinned ? translate('common.unPin') : translate('common.pin')}
role={CONST.ROLE.BUTTON}
>
<Icon
src={Expensicons.Pin}
fill={report.isPinned ? theme.heading : theme.icon}
/>
</PressableWithFeedback>
</Tooltip>
);
}

PinButton.displayName = 'PinButton';

export default PinButton;