Final work to add torrents categories

This commit is contained in:
LIAUD Corentin
2024-03-24 16:10:49 +01:00
parent 28e24de557
commit a7417a221a
11 changed files with 73 additions and 60 deletions

View File

@@ -26,12 +26,13 @@ export default function AddDialog({
title: originalTitle,
name: originalName,
poster: originalPoster,
category: originalCategory,
}) {
const { t } = useTranslation()
const isEditMode = !!originalHash
const [torrentSource, setTorrentSource] = useState(originalHash || '')
const [title, setTitle] = useState(originalTitle || '')
const [category, setCategory] = useState('Unknown')
const [category, setCategory] = useState(originalCategory || '')
const [originalTorrentTitle, setOriginalTorrentTitle] = useState('')
const [parsedTitle, setParsedTitle] = useState('')
const [posterUrl, setPosterUrl] = useState(originalPoster || '')
@@ -248,7 +249,6 @@ export default function AddDialog({
setTorrentSource={setTorrentSource}
/>
)}
<RightSideComponent
originalTorrentTitle={originalTorrentTitle}
setTitle={setTitle}

View File

@@ -69,6 +69,8 @@ export default function RightSideComponent({
setIsUserInteractedWithPoster(true)
}
const torrentCategories = ['Movies', 'Series', 'Music', 'Other', 'Unknown']
return (
<RightSide>
<RightSideContainer isHidden={!isTorrentSourceCorrect || (isHashAlreadyExists && !isEditMode)}>
@@ -113,26 +115,6 @@ export default function RightSideComponent({
),
}}
/>
<FormControl fullWidth>
<InputLabel id='torrent-category-select-label'>Torrent category</InputLabel>
<Select
labelId='torrent-category-select-label'
id='torrent-category-select'
value={category}
label='Torrent category'
margin='dense'
onChange={handleCategoryChange}
variant='outlined'
fullWidth
>
<MenuItem value='Films'>Films</MenuItem>
<MenuItem value='Series'>Series</MenuItem>
<MenuItem value='Music'>Music</MenuItem>
<MenuItem value='Other'>Other</MenuItem>
<MenuItem value='Unknown'>Unknown</MenuItem>
</Select>
</FormControl>
</>
) : (
<TextField
@@ -156,6 +138,25 @@ export default function RightSideComponent({
fullWidth
/>
<FormControl fullWidth>
<InputLabel id='torrent-category-select-label'>Torrent category</InputLabel>
<Select
labelId='torrent-category-select-label'
id='torrent-category-select'
value={category}
label='Torrent category'
margin='dense'
onChange={handleCategoryChange}
variant='outlined'
fullWidth
defaultValue='Unknown'
>
{torrentCategories.map(category => (
<MenuItem value={category}>{category}</MenuItem>
))}
</Select>
</FormControl>
<PosterWrapper>
<Poster poster={+isPosterUrlCorrect}>
{isPosterUrlCorrect ? <img src={posterUrl} alt='poster' /> : <NoImageIcon />}

View File

@@ -185,7 +185,14 @@ const Torrent = ({ torrent }) => {
</Dialog>
{isEditDialogOpen && (
<AddDialog hash={hash} title={title} name={name} poster={poster} handleClose={handleCloseEditDialog} />
<AddDialog
hash={hash}
title={title}
name={name}
poster={poster}
handleClose={handleCloseEditDialog}
category={category}
/>
)}
</>
)