Add OtomatikSwitch to AjouteTradiksyon and EkriTeks
This commit is contained in:
@@ -4,6 +4,8 @@ import PropTypes from 'prop-types'
|
|||||||
import {MenuItem, Menu, Button} from '@mui/material'
|
import {MenuItem, Menu, Button} from '@mui/material'
|
||||||
import {uniq} from 'lodash'
|
import {uniq} from 'lodash'
|
||||||
|
|
||||||
|
import OtomatikSwitch from './otomatik-switch'
|
||||||
|
|
||||||
const PREFIX = 'AjouteTradiksyon'
|
const PREFIX = 'AjouteTradiksyon'
|
||||||
|
|
||||||
const classes = {
|
const classes = {
|
||||||
@@ -49,7 +51,7 @@ function StyledMenu(props) {
|
|||||||
|
|
||||||
const StyledMenuItem = MenuItem
|
const StyledMenuItem = MenuItem
|
||||||
|
|
||||||
function AjouteTradiksyon({chwaLang, setChwaLang}) {
|
function AjouteTradiksyon({disableSwitch, tradiksyonOtomatik, setTradiksyonOtomatik, canAutoTranslate, chwaLang, setChwaLang}) {
|
||||||
const [anchorElement, setAnchorElement] = useState(null)
|
const [anchorElement, setAnchorElement] = useState(null)
|
||||||
|
|
||||||
const handleClick = event => {
|
const handleClick = event => {
|
||||||
@@ -63,66 +65,75 @@ function AjouteTradiksyon({chwaLang, setChwaLang}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Root style={{textAlign: 'center', marginTop: 20}}>
|
<>
|
||||||
<Button
|
{canAutoTranslate && (
|
||||||
aria-controls='lang-menu'
|
<OtomatikSwitch tradiksyonOtomatik={tradiksyonOtomatik} setTradiksyonOtomatik={setTradiksyonOtomatik} disabled={!chwaLang.includes('fr') || disableSwitch} />
|
||||||
variant='outlined'
|
)}
|
||||||
aria-haspopup='true'
|
<Root style={{textAlign: 'center', marginTop: 20}}>
|
||||||
onClick={handleClick}
|
<Button
|
||||||
>
|
aria-controls='lang-menu'
|
||||||
Ajouter une traduction <br /> 🇫🇷 🇬🇧 🇪🇸 🇩🇪 🇮🇹
|
variant='outlined'
|
||||||
</Button>
|
aria-haspopup='true'
|
||||||
<StyledMenu
|
onClick={handleClick}
|
||||||
keepMounted
|
>
|
||||||
id='lang-menu'
|
Ajouter une traduction <br /> 🇫🇷 🇬🇧 🇪🇸 🇩🇪 🇮🇹
|
||||||
anchorEl={anchorElement}
|
</Button>
|
||||||
open={Boolean(anchorElement)}
|
<StyledMenu
|
||||||
classes={{
|
keepMounted
|
||||||
paper: classes.paper
|
id='lang-menu'
|
||||||
}}
|
anchorEl={anchorElement}
|
||||||
onClose={handleClose}
|
open={Boolean(anchorElement)}
|
||||||
>
|
|
||||||
<StyledMenuItem
|
|
||||||
id='fr'
|
|
||||||
classes={{
|
classes={{
|
||||||
root: classes.root
|
paper: classes.paper
|
||||||
}}
|
}}
|
||||||
onClick={handleClose}
|
onClose={handleClose}
|
||||||
>🇫🇷 Français</StyledMenuItem>
|
>
|
||||||
<StyledMenuItem
|
<StyledMenuItem
|
||||||
id='en'
|
id='fr'
|
||||||
classes={{
|
classes={{
|
||||||
root: classes.root
|
root: classes.root
|
||||||
}}
|
}}
|
||||||
onClick={handleClose}
|
onClick={handleClose}
|
||||||
>🇬🇧 English</StyledMenuItem>
|
>🇫🇷 Français</StyledMenuItem>
|
||||||
<StyledMenuItem
|
<StyledMenuItem
|
||||||
id='es'
|
id='en'
|
||||||
classes={{
|
classes={{
|
||||||
root: classes.root
|
root: classes.root
|
||||||
}}
|
}}
|
||||||
onClick={handleClose}
|
onClick={handleClose}
|
||||||
>🇪🇸 Español</StyledMenuItem>
|
>🇬🇧 English</StyledMenuItem>
|
||||||
<StyledMenuItem
|
<StyledMenuItem
|
||||||
id='de'
|
id='es'
|
||||||
classes={{
|
classes={{
|
||||||
root: classes.root
|
root: classes.root
|
||||||
}}
|
}}
|
||||||
onClick={handleClose}
|
onClick={handleClose}
|
||||||
>🇩🇪 Deutsch</StyledMenuItem>
|
>🇪🇸 Español</StyledMenuItem>
|
||||||
<StyledMenuItem
|
<StyledMenuItem
|
||||||
id='it'
|
id='de'
|
||||||
classes={{
|
classes={{
|
||||||
root: classes.root
|
root: classes.root
|
||||||
}}
|
}}
|
||||||
onClick={handleClose}
|
onClick={handleClose}
|
||||||
>🇮🇹 Italiano</StyledMenuItem>
|
>🇩🇪 Deutsch</StyledMenuItem>
|
||||||
</StyledMenu>
|
<StyledMenuItem
|
||||||
</Root>
|
id='it'
|
||||||
|
classes={{
|
||||||
|
root: classes.root
|
||||||
|
}}
|
||||||
|
onClick={handleClose}
|
||||||
|
>🇮🇹 Italiano</StyledMenuItem>
|
||||||
|
</StyledMenu>
|
||||||
|
</Root>
|
||||||
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
AjouteTradiksyon.propTypes = {
|
AjouteTradiksyon.propTypes = {
|
||||||
|
disableSwitch: PropTypes.bool.isRequired,
|
||||||
|
tradiksyonOtomatik: PropTypes.bool.isRequired,
|
||||||
|
setTradiksyonOtomatik: PropTypes.func.isRequired,
|
||||||
|
canAutoTranslate: PropTypes.bool.isRequired,
|
||||||
chwaLang: PropTypes.array.isRequired,
|
chwaLang: PropTypes.array.isRequired,
|
||||||
setChwaLang: PropTypes.func.isRequired
|
setChwaLang: PropTypes.func.isRequired
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,6 +84,7 @@ function EkriTeks({selectedTeks, setSelectedTeks}) {
|
|||||||
const [loading, setLoading] = useState(false)
|
const [loading, setLoading] = useState(false)
|
||||||
const [currentTeksId, setCurrentTeksId] = useState(null)
|
const [currentTeksId, setCurrentTeksId] = useState(null)
|
||||||
const [open, setOpen] = useState(false)
|
const [open, setOpen] = useState(false)
|
||||||
|
const [tradiksyonOtomatik, setTradiksyonOtomatik] = useState(false)
|
||||||
|
|
||||||
const handleUpdate = useCallback(update => {
|
const handleUpdate = useCallback(update => {
|
||||||
setTeksEkri({...teksEkri, ...update})
|
setTeksEkri({...teksEkri, ...update})
|
||||||
@@ -143,7 +144,8 @@ function EkriTeks({selectedTeks, setSelectedTeks}) {
|
|||||||
italiano: it === '' ? null : it
|
italiano: it === '' ? null : it
|
||||||
},
|
},
|
||||||
user,
|
user,
|
||||||
awtis: awtisResponse.data.awtis.map(id => id)
|
awtis: awtisResponse.data.awtis.map(id => id),
|
||||||
|
tradiksyonOtomatik
|
||||||
}, {
|
}, {
|
||||||
headers
|
headers
|
||||||
})
|
})
|
||||||
@@ -180,7 +182,8 @@ function EkriTeks({selectedTeks, setSelectedTeks}) {
|
|||||||
italiano: it === '' ? null : it
|
italiano: it === '' ? null : it
|
||||||
},
|
},
|
||||||
user,
|
user,
|
||||||
awtis: [awtisResponse.data._id]
|
awtis: [awtisResponse.data._id],
|
||||||
|
tradiksyonOtomatik
|
||||||
}, {
|
}, {
|
||||||
headers
|
headers
|
||||||
})
|
})
|
||||||
@@ -206,6 +209,7 @@ function EkriTeks({selectedTeks, setSelectedTeks}) {
|
|||||||
setTradiksyon({fr: '', en: '', es: '', de: '', it: ''})
|
setTradiksyon({fr: '', en: '', es: '', de: '', it: ''})
|
||||||
setKiChwalang([])
|
setKiChwalang([])
|
||||||
setCurrentTeksId(null)
|
setCurrentTeksId(null)
|
||||||
|
setTradiksyonOtomatik(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -362,7 +366,7 @@ function EkriTeks({selectedTeks, setSelectedTeks}) {
|
|||||||
</FormControl>
|
</FormControl>
|
||||||
))}
|
))}
|
||||||
</form>
|
</form>
|
||||||
<AjouteTradiksyon chwaLang={kiChawLang} setChwaLang={setKiChwalang} />
|
<AjouteTradiksyon disableSwitch={tradiksyon.fr === ''} tradiksyonOtomatik={tradiksyonOtomatik} setTradiksyonOtomatik={setTradiksyonOtomatik} canAutoTranslate={user.canAutoTranslate} chwaLang={kiChawLang} setChwaLang={setKiChwalang} />
|
||||||
<div>
|
<div>
|
||||||
<Button
|
<Button
|
||||||
fullWidth
|
fullWidth
|
||||||
|
|||||||
Reference in New Issue
Block a user