added PreviewCard prop forcedEnable to overrride disable property

This commit is contained in:
Abhinav-grd 2021-01-26 15:14:56 +05:30
parent 4aaebef0e7
commit 6321874ead
2 changed files with 4 additions and 3 deletions

View file

@ -23,7 +23,7 @@ function CollectionSelector(props) {
collectionLatestFile={item}
>
<Card>
<PreviewCard data={item.file} updateUrl={() => { }}/>
<PreviewCard data={item.file} updateUrl={() => { }} forcedEnable />
<Card.Text className="text-center">{item.collection.name}</Card.Text>
</Card>

View file

@ -8,6 +8,7 @@ interface IProps {
data: file,
updateUrl: (url: string) => void,
onClick?: () => void,
forcedEnable?: boolean,
}
const Cont = styled.div<{ disabled: boolean }>`
@ -41,7 +42,7 @@ const Cont = styled.div<{ disabled: boolean }>`
export default function PreviewCard(props: IProps) {
const [imgSrc, setImgSrc] = useState<string>();
const { data, onClick, updateUrl } = props;
const { data, onClick, updateUrl, forcedEnable } = props;
useEffect(() => {
if (data && !data.msrc) {
@ -62,7 +63,7 @@ export default function PreviewCard(props: IProps) {
}
}
return <Cont onClick={handleClick} disabled={!data?.msrc && !imgSrc}>
return <Cont onClick={handleClick} disabled={!forcedEnable && !data?.msrc && !imgSrc}>
<img src={data?.msrc || imgSrc} />
{data?.metadata.fileType === 1 && <PlayCircleOutline />}
</Cont>;