Skip to content

Commit

Permalink
Merge pull request #32968 from pasyukevich/feature/migrate-PinButton
Browse files Browse the repository at this point in the history
[TS migration] Migrate 'PinButton.js' component to TypeScript
  • Loading branch information
stitesExpensify authored Dec 16, 2023
2 parents 18e9fd2 + 916b33b commit 3ed43ff
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 49 deletions.
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))}
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;

0 comments on commit 3ed43ff

Please sign in to comment.