mirror of
https://github.com/Radarr/Radarr.git
synced 2026-04-18 21:35:51 -04:00
c8299f7e57
Co-authored-by: Mark McDowall <mark@mcdowall.ca> Remove defaultProps from TypeScript components (cherry picked from commit a90c13e86f798841cb6db038bb6b6d1408a00585) Fix multi-select checkboxes not appearing (cherry picked from commit e199710c15fbfa643a9f71c7a20f70b1722d0df6)
45 lines
1.2 KiB
TypeScript
45 lines
1.2 KiB
TypeScript
import React, { SyntheticEvent, useCallback } from 'react';
|
|
import { useSelect } from 'App/SelectContext';
|
|
import Icon from 'Components/Icon';
|
|
import Link from 'Components/Link/Link';
|
|
import { icons } from 'Helpers/Props';
|
|
import styles from './MovieIndexPosterSelect.css';
|
|
|
|
interface MovieIndexPosterSelectProps {
|
|
movieId: number;
|
|
}
|
|
|
|
function MovieIndexPosterSelect(props: MovieIndexPosterSelectProps) {
|
|
const { movieId } = props;
|
|
const [selectState, selectDispatch] = useSelect();
|
|
const isSelected = selectState.selectedState[movieId];
|
|
|
|
const onSelectPress = useCallback(
|
|
(event: SyntheticEvent<HTMLElement, PointerEvent>) => {
|
|
const shiftKey = event.nativeEvent.shiftKey;
|
|
|
|
selectDispatch({
|
|
type: 'toggleSelected',
|
|
id: movieId,
|
|
isSelected: !isSelected,
|
|
shiftKey,
|
|
});
|
|
},
|
|
[movieId, isSelected, selectDispatch]
|
|
);
|
|
|
|
return (
|
|
<Link className={styles.checkButton} onPress={onSelectPress}>
|
|
<span className={styles.checkContainer}>
|
|
<Icon
|
|
className={isSelected ? styles.selected : styles.unselected}
|
|
name={isSelected ? icons.CHECK_CIRCLE : icons.CIRCLE_OUTLINE}
|
|
size={20}
|
|
/>
|
|
</span>
|
|
</Link>
|
|
);
|
|
}
|
|
|
|
export default MovieIndexPosterSelect;
|