torrent source regex added

This commit is contained in:
Daniel Shleifman
2021-06-09 20:38:00 +03:00
parent 388416289e
commit dcc7061c19
5 changed files with 27 additions and 8 deletions

View File

@@ -35,7 +35,7 @@ import {
TorrentIconWrapper,
RightSideContainer,
} from './style'
import { checkImageURL, getMoviePosters } from './helpers'
import { checkImageURL, getMoviePosters, chechTorrentSource } from './helpers'
export default function AddDialog({ handleClose }) {
const { t } = useTranslation()
@@ -44,6 +44,7 @@ export default function AddDialog({ handleClose }) {
const [title, setTitle] = useState('')
const [posterUrl, setPosterUrl] = useState('')
const [isPosterUrlCorrect, setIsPosterUrlCorrect] = useState(false)
const [isTorrentSourceCorrect, setIsTorrentSourceCorrect] = useState(false)
const [posterList, setPosterList] = useState()
const [isUserInteractedWithPoster, setIsUserInteractedWithPoster] = useState(false)
const [isUserInteractedWithTitle, setIsUserInteractedWithTitle] = useState(false)
@@ -102,6 +103,10 @@ export default function AddDialog({ handleClose }) {
})
}, [selectedFile, delayedPosterSearch, torrentSource, posterSearchLanguage, isUserInteractedWithTitle])
useEffect(() => {
setIsTorrentSourceCorrect(chechTorrentSource(torrentSource))
}, [torrentSource])
const handleCapture = files => {
const [file] = files
if (!file) return
@@ -214,7 +219,7 @@ export default function AddDialog({ handleClose }) {
</LeftSide>
<RightSide>
<RightSideContainer isHidden={!torrentSource}>
<RightSideContainer isHidden={!isTorrentSourceCorrect}>
<TextField
onChange={handleTitleChange}
value={title}
@@ -279,7 +284,13 @@ export default function AddDialog({ handleClose }) {
</PosterWrapper>
</RightSideContainer>
<RightSideContainer notificationMessage={t('AddTorrentSourceNotification')} isHidden={torrentSource} />
<RightSideContainer
isError={torrentSource && !isTorrentSourceCorrect}
notificationMessage={
!torrentSource ? t('AddTorrentSourceNotification') : !isTorrentSourceCorrect && t('WrongTorrentSource')
}
isHidden={isTorrentSourceCorrect}
/>
</RightSide>
</Content>