2023-07-22 13:36:33 +04:00
|
|
|
'use client'
|
|
|
|
|
|
|
|
|
|
import {useEffect} from 'react'
|
2022-01-24 21:06:52 +04:00
|
|
|
import PropTypes from 'prop-types'
|
2023-07-22 13:36:33 +04:00
|
|
|
import Box from '@mui/material/Box'
|
2024-10-21 09:55:57 +04:00
|
|
|
import Grid from '@mui/material/Grid2'
|
2023-07-22 13:36:33 +04:00
|
|
|
import Typography from '@mui/material/Typography'
|
|
|
|
|
import Tooltip from '@mui/material/Tooltip'
|
|
|
|
|
import {useMediaQuery} from '@mui/material'
|
2023-07-30 00:26:54 +04:00
|
|
|
import Link from 'next/link'
|
|
|
|
|
import slugify from 'slugify'
|
2023-07-22 13:36:33 +04:00
|
|
|
|
2022-01-24 21:06:52 +04:00
|
|
|
import {styled} from '@mui/material/styles'
|
|
|
|
|
import ExplicitIcon from '@mui/icons-material/Explicit'
|
|
|
|
|
|
2022-05-22 00:17:28 +04:00
|
|
|
import {formatJsonString, getAlias} from '../../lib/utils/format'
|
2022-01-24 21:06:52 +04:00
|
|
|
|
2024-04-14 07:06:31 +04:00
|
|
|
import LicenseModal from '../cc/license-modal'
|
2024-04-17 06:58:50 +04:00
|
|
|
import FilesDialog from '../files/files-dialog'
|
2022-01-24 21:06:52 +04:00
|
|
|
import EntegreMizik from './entegre-mizik'
|
|
|
|
|
import OkiMizik from './oki-mizik'
|
2022-12-12 22:31:05 +04:00
|
|
|
import DiferansDialog from './diferans-dialog'
|
2022-01-24 21:06:52 +04:00
|
|
|
|
|
|
|
|
const PREFIX = 'teks'
|
|
|
|
|
|
|
|
|
|
const classes = {
|
2023-07-22 13:56:18 +04:00
|
|
|
container: `${PREFIX}-container`,
|
2022-01-24 21:06:52 +04:00
|
|
|
tooltip: `${PREFIX}-tooltip`,
|
|
|
|
|
text: `${PREFIX}-text`,
|
|
|
|
|
gridText: `${PREFIX}-gridText`,
|
|
|
|
|
grid: `${PREFIX}-grid`,
|
|
|
|
|
koute: `${PREFIX}-koute`,
|
|
|
|
|
vwe: `${PREFIX}-vwe`,
|
2023-07-30 00:26:54 +04:00
|
|
|
pataje: `${PREFIX}-pataje`,
|
|
|
|
|
separation: `${PREFIX}-separation`
|
2022-01-24 21:06:52 +04:00
|
|
|
}
|
|
|
|
|
|
2023-07-30 00:26:54 +04:00
|
|
|
const Root = styled('div')((
|
|
|
|
|
{
|
|
|
|
|
theme
|
|
|
|
|
}
|
|
|
|
|
) => ({
|
2023-07-22 13:56:18 +04:00
|
|
|
[`&.${classes.container}`]: {
|
|
|
|
|
marginTop: '3em',
|
2022-01-24 21:06:52 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
|
|
[`& .${classes.gridText}`]: {
|
|
|
|
|
border: '2px solid grey',
|
|
|
|
|
borderRadius: '5px',
|
|
|
|
|
marginTop: '2em',
|
|
|
|
|
padding: '1em'
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
[`& .${classes.pataje}`]: {
|
2023-07-22 13:56:18 +04:00
|
|
|
position: 'absolute',
|
|
|
|
|
zIndex: 9999
|
2023-07-22 23:39:16 +04:00
|
|
|
},
|
|
|
|
|
|
2023-07-30 00:26:54 +04:00
|
|
|
[`& .${classes.separation}`]: {
|
|
|
|
|
color: 'black',
|
|
|
|
|
[theme.getColorSchemeSelector('dark')]: {
|
|
|
|
|
color: 'white'
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
2023-07-22 23:39:16 +04:00
|
|
|
'@media (max-width: 600px)': {
|
|
|
|
|
marginLeft: '0',
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
'@media (min-width: 600px)': {
|
|
|
|
|
marginLeft: '240px',
|
|
|
|
|
},
|
2022-01-24 21:06:52 +04:00
|
|
|
}))
|
|
|
|
|
|
2022-05-20 02:15:56 +04:00
|
|
|
const langToArray = parole => {
|
2022-01-24 21:06:52 +04:00
|
|
|
const langArray = []
|
|
|
|
|
|
2022-05-20 02:15:56 +04:00
|
|
|
if (parole && parole.traductions) {
|
|
|
|
|
const {francais, anglais, espagnol, allemand, italien} = parole.traductions
|
2022-01-24 21:06:52 +04:00
|
|
|
|
|
|
|
|
if (francais) {
|
|
|
|
|
langArray.push({title: 'Traduction', flag: 'fr', lang: francais})
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-20 02:15:56 +04:00
|
|
|
if (anglais) {
|
|
|
|
|
langArray.push({title: 'Translation', flag: 'en', lang: anglais})
|
2022-01-24 21:06:52 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (espagnol) {
|
|
|
|
|
langArray.push({title: 'Traducción', flag: 'es', lang: espagnol})
|
|
|
|
|
}
|
2022-03-22 07:21:45 +04:00
|
|
|
|
2022-05-20 02:15:56 +04:00
|
|
|
if (allemand) {
|
|
|
|
|
langArray.push({title: 'Übersetzung', flag: 'de', lang: allemand})
|
2022-03-22 07:21:45 +04:00
|
|
|
}
|
|
|
|
|
|
2022-05-20 02:15:56 +04:00
|
|
|
if (italien) {
|
|
|
|
|
langArray.push({title: 'Traduzione', flag: 'it', lang: italien})
|
2022-03-22 07:21:45 +04:00
|
|
|
}
|
2022-01-24 21:06:52 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return langArray
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const alignTeks = (langArray, isMobile) => {
|
|
|
|
|
if (langArray.length > 0 && !isMobile) {
|
|
|
|
|
return 'justify'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (langArray.length > 0 && isMobile) {
|
|
|
|
|
return 'justify'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (langArray.length === 0 && isMobile) {
|
|
|
|
|
return 'justify'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (langArray.length === 0 && !isMobile) {
|
|
|
|
|
return 'center'
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const ExplicitTooltip = Tooltip
|
|
|
|
|
|
2023-07-22 13:56:18 +04:00
|
|
|
export default function Teks({parole}) {
|
|
|
|
|
const isMobile = useMediaQuery('(max-width:600px)')
|
2022-05-20 02:15:56 +04:00
|
|
|
const langArray = langToArray(parole)
|
2023-07-30 00:26:54 +04:00
|
|
|
const enhancedAliases = getAlias(parole.artistes, parole.prioriteArtistes, true)
|
2022-01-24 21:06:52 +04:00
|
|
|
|
2023-07-22 13:56:18 +04:00
|
|
|
useEffect(() => {
|
|
|
|
|
const isBrowser = () => typeof window !== 'undefined'
|
|
|
|
|
if (!isBrowser()) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
window.scrollTo({top: 0, behavior: 'smooth'})
|
|
|
|
|
}, [])
|
|
|
|
|
|
2022-01-24 21:06:52 +04:00
|
|
|
return (
|
2023-07-22 23:39:16 +04:00
|
|
|
<Root className={classes.container}>
|
2023-07-22 13:56:18 +04:00
|
|
|
<Box sx={{textAlign: 'center', marginTop: 1}}>
|
2022-12-12 23:17:59 +04:00
|
|
|
<Typography variant='h4' component='div' display='block' marginBottom={2}>
|
2023-07-30 00:26:54 +04:00
|
|
|
<Typography gutterBottom color='primary' variant='h6' component='div'>
|
|
|
|
|
{enhancedAliases.map(({type, value}) => {
|
|
|
|
|
if (type === 'element') {
|
|
|
|
|
return (
|
2024-01-23 04:38:02 +04:00
|
|
|
<Link key={value} style={{textDecoration: 'none', color: 'inherit'}} href={`/awtis/${slugify(value, {lower: true, remove: /[*#+~.()'"!:@]/g})}`}>{value}</Link>
|
2023-07-30 00:26:54 +04:00
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return <span key={value} className={classes.separation}>{value}</span>
|
|
|
|
|
})}
|
2022-01-24 21:06:52 +04:00
|
|
|
</Typography>
|
2024-04-14 07:13:51 +04:00
|
|
|
<Box display='flex' justifyContent='center' alignItems='center'>
|
|
|
|
|
<Typography variant='h5' component='div'>
|
|
|
|
|
{parole.titre} <small>({parole?.annee})</small>
|
|
|
|
|
</Typography>
|
|
|
|
|
{parole.explicitLyrics && (
|
2022-01-24 21:06:52 +04:00
|
|
|
<ExplicitTooltip
|
|
|
|
|
title='Explicit Lyrics'
|
|
|
|
|
placement='bottom'
|
|
|
|
|
classes={{
|
|
|
|
|
tooltip: classes.tooltip
|
|
|
|
|
}}
|
|
|
|
|
>
|
2024-04-14 07:13:51 +04:00
|
|
|
<ExplicitIcon style={{marginLeft: 10}} color='error' />
|
2022-01-24 21:06:52 +04:00
|
|
|
</ExplicitTooltip>
|
|
|
|
|
)}
|
2024-04-14 07:13:51 +04:00
|
|
|
</Box>
|
2022-01-24 21:06:52 +04:00
|
|
|
</Typography>
|
2022-12-12 23:17:59 +04:00
|
|
|
|
2022-05-20 02:15:56 +04:00
|
|
|
{parole?.user?.data && (
|
2022-01-24 21:06:52 +04:00
|
|
|
<Typography style={{marginBottom: '1.5em'}} display='block' variant='caption'>
|
2022-05-23 18:34:55 +04:00
|
|
|
<i>parole soumise par {parole.user.data.attributes.username}</i>
|
2022-01-24 21:06:52 +04:00
|
|
|
</Typography>
|
|
|
|
|
)}
|
2022-05-22 14:18:30 +04:00
|
|
|
{parole?.userAdmin?.data && !parole.user.data && (
|
2022-05-08 05:26:23 +04:00
|
|
|
<Typography style={{marginBottom: '1.5em'}} display='block' variant='caption'>
|
2022-12-12 22:31:29 +04:00
|
|
|
<i>parole soumise par {parole.userAdmin.data.attributes.firstname}</i>
|
2022-05-08 05:26:23 +04:00
|
|
|
</Typography>
|
|
|
|
|
)}
|
2024-04-14 07:08:24 +04:00
|
|
|
{parole.creativeCommons && (
|
|
|
|
|
<Box sx={{maxWidth: 220, margin: '0 auto', textAlign: 'center'}}>
|
|
|
|
|
<LicenseModal license={parole.creativeCommons.toLowerCase()} />
|
|
|
|
|
</Box>
|
|
|
|
|
)}
|
2024-04-17 06:58:50 +04:00
|
|
|
{parole?.files?.data && (
|
|
|
|
|
<FilesDialog files={parole.files.data} />
|
|
|
|
|
)}
|
2023-03-09 10:39:44 +04:00
|
|
|
{(parole.okiMizikID || parole.streamAudio.length > 0 || parole.gadeEmbed) && (
|
2022-12-12 23:17:59 +04:00
|
|
|
<Box sx={{textAlign: 'center'}}>
|
|
|
|
|
<EntegreMizik parole={parole} isMobile={isMobile} />
|
|
|
|
|
</Box>
|
|
|
|
|
)}
|
|
|
|
|
{parole.okiMizikID && (
|
|
|
|
|
<OkiMizik id={parole.okiMizikID} parole={parole} />
|
|
|
|
|
)}
|
|
|
|
|
{parole?.difference?.length > 0 && (
|
|
|
|
|
<DiferansDialog difference={parole.difference} />
|
|
|
|
|
)}
|
2022-01-24 21:06:52 +04:00
|
|
|
</Box>
|
2023-07-22 23:39:16 +04:00
|
|
|
<Grid container justifyContent='center' spacing={1}>
|
2024-10-21 10:06:16 +04:00
|
|
|
<Grid size={{xs: 12, md: langArray.length > 0 ? 6 : null}}>
|
2023-07-22 13:56:18 +04:00
|
|
|
<Box className={classes.gridText}>
|
|
|
|
|
<Typography align='center' sx={{marginBottom: '0.5em'}} variant='h4'>
|
2022-01-24 21:06:52 +04:00
|
|
|
Transcription
|
|
|
|
|
</Typography>
|
|
|
|
|
<Typography paragraph align={alignTeks(langArray, isMobile)} component='span'>
|
2022-05-20 02:15:56 +04:00
|
|
|
{formatJsonString(parole.transcription)}
|
2022-01-24 21:06:52 +04:00
|
|
|
</Typography>
|
2023-07-22 13:56:18 +04:00
|
|
|
</Box>
|
2022-01-24 21:06:52 +04:00
|
|
|
</Grid>
|
|
|
|
|
{langArray.map(({title, flag, lang}) => (
|
2024-10-21 10:06:16 +04:00
|
|
|
<Grid key={title} size={{xs: 12, md: 6}}>
|
2023-07-22 13:56:18 +04:00
|
|
|
<Box className={classes.gridText}>
|
|
|
|
|
<Typography align='center' sx={{marginBottom: '0.5em'}} variant='h4'>
|
2022-01-24 21:06:52 +04:00
|
|
|
{flag === 'fr' && (
|
|
|
|
|
<span>
|
|
|
|
|
🇫🇷
|
|
|
|
|
</span>
|
|
|
|
|
)}
|
|
|
|
|
{flag === 'en' && (
|
|
|
|
|
<span>
|
|
|
|
|
🇬🇧
|
|
|
|
|
</span>
|
|
|
|
|
)}
|
|
|
|
|
{flag === 'es' && (
|
|
|
|
|
<span>
|
|
|
|
|
🇪🇸
|
|
|
|
|
</span>
|
2022-03-22 07:12:41 +04:00
|
|
|
)}
|
|
|
|
|
{flag === 'de' && (
|
|
|
|
|
<span>
|
|
|
|
|
🇩🇪
|
|
|
|
|
</span>
|
|
|
|
|
)}
|
|
|
|
|
{flag === 'it' && (
|
|
|
|
|
<span>
|
|
|
|
|
🇮🇹
|
|
|
|
|
</span>
|
2022-01-24 21:06:52 +04:00
|
|
|
)} {title}
|
|
|
|
|
</Typography>
|
|
|
|
|
<Typography paragraph align='justify' component='span'>
|
|
|
|
|
{formatJsonString(lang)}
|
|
|
|
|
</Typography>
|
2023-07-22 13:56:18 +04:00
|
|
|
</Box>
|
2022-01-24 21:06:52 +04:00
|
|
|
</Grid>
|
|
|
|
|
))}
|
|
|
|
|
</Grid>
|
|
|
|
|
</Root>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Teks.propTypes = {
|
2022-05-20 02:15:56 +04:00
|
|
|
parole: PropTypes.object.isRequired,
|
2022-01-24 21:06:52 +04:00
|
|
|
}
|