@@ -24,10 +24,7 @@ import QualityChip from "./QualityChip";
2424import { formatMinuteToReadable , getRandomNumber } from "src/utils/common" ;
2525import SimilarVideoCard from "./SimilarVideoCard" ;
2626import { useDetailModal } from "src/providers/DetailModalProvider" ;
27- import {
28- useGetAppendedVideosQuery ,
29- useGetSimilarVideosQuery ,
30- } from "src/store/slices/discover" ;
27+ import { useGetSimilarVideosQuery } from "src/store/slices/discover" ;
3128import { MEDIA_TYPE } from "src/types/Common" ;
3229import VideoJSPlayer from "./watch/VideoJSPlayer" ;
3330
@@ -47,14 +44,10 @@ const Transition = forwardRef(function Transition(
4744// }
4845
4946export default function DetailModal ( ) {
50- const { detailType, setDetailType } = useDetailModal ( ) ;
51- const { data : detail } = useGetAppendedVideosQuery (
52- { mediaType : detailType . mediaType , id : detailType . id ?? 0 } ,
53- { skip : ! detailType . id }
54- ) ;
47+ const { detail, setDetailType } = useDetailModal ( ) ;
5548 const { data : similarVideos } = useGetSimilarVideosQuery (
56- { mediaType : detailType . mediaType , id : detailType . id ?? 0 } ,
57- { skip : ! detailType . id }
49+ { mediaType : detail . mediaType ?? MEDIA_TYPE . Movie , id : detail . id ?? 0 } ,
50+ { skip : ! detail . id }
5851 ) ;
5952 const playerRef = useRef < Player | null > ( null ) ;
6053 const [ muted , setMuted ] = useState ( true ) ;
@@ -71,14 +64,14 @@ export default function DetailModal() {
7164 }
7265 } , [ ] ) ;
7366
74- if ( detailType . id ) {
67+ if ( detail . mediaDetail ) {
7568 return (
7669 < Dialog
77- id = "detail_dialog"
7870 fullWidth
7971 scroll = "body"
8072 maxWidth = "md"
8173 open = { ! ! detail }
74+ id = "detail_dialog"
8275 TransitionComponent = { Transition }
8376 >
8477 < DialogContent sx = { { p : 0 , bgcolor : "#181818" } } >
@@ -110,7 +103,8 @@ export default function DetailModal() {
110103 {
111104 type : "video/youtube" ,
112105 src : `https://www.youtube.com/watch?v=${
113- detail ?. videos . results [ 0 ] ?. key || "L3oOldViIgY"
106+ detail . mediaDetail ?. videos . results [ 0 ] ?. key ||
107+ "L3oOldViIgY"
114108 } `,
115109 } ,
116110 ] ,
@@ -148,7 +142,7 @@ export default function DetailModal() {
148142 />
149143 < IconButton
150144 onClick = { ( ) => {
151- setDetailType ( { mediaType : MEDIA_TYPE . Movie , id : null } ) ;
145+ setDetailType ( { mediaType : undefined , id : undefined } ) ;
152146 } }
153147 sx = { {
154148 top : 15 ,
@@ -176,7 +170,7 @@ export default function DetailModal() {
176170 } }
177171 >
178172 < MaxLineTypography variant = "h4" maxLine = { 1 } sx = { { mb : 2 } } >
179- { detail ?. title }
173+ { detail . mediaDetail ?. title }
180174 </ MaxLineTypography >
181175 < Stack direction = "row" spacing = { 2 } sx = { { mb : 3 } } >
182176 < PlayButton sx = { { color : "black" , py : 0 } } />
@@ -209,7 +203,7 @@ export default function DetailModal() {
209203 sx = { { color : "success.main" } }
210204 > { `${ getRandomNumber ( 100 ) } % Match` } </ Typography >
211205 < Typography variant = "body2" >
212- { detail ?. release_date . substring ( 0 , 4 ) }
206+ { detail . mediaDetail ?. release_date . substring ( 0 , 4 ) }
213207 </ Typography >
214208 < AgeLimitChip label = { `${ getRandomNumber ( 20 ) } +` } />
215209 < Typography variant = "subtitle2" > { `${ formatMinuteToReadable (
@@ -223,17 +217,17 @@ export default function DetailModal() {
223217 variant = "body1"
224218 sx = { { mt : 2 } }
225219 >
226- { detail ?. overview }
220+ { detail . mediaDetail ?. overview }
227221 </ MaxLineTypography >
228222 </ Grid >
229223 < Grid item xs = { 12 } sm = { 6 } md = { 4 } >
230224 < Typography variant = "body2" sx = { { my : 1 } } >
231- { `Genres : ${ detail ?. genres
225+ { `Genres : ${ detail . mediaDetail ?. genres
232226 . map ( ( g ) => g . name )
233227 . join ( ", " ) } `}
234228 </ Typography >
235229 < Typography variant = "body2" sx = { { my : 1 } } >
236- { `Available in : ${ detail ?. spoken_languages
230+ { `Available in : ${ detail . mediaDetail ?. spoken_languages
237231 . map ( ( l ) => l . name )
238232 . join ( ", " ) } `}
239233 </ Typography >
0 commit comments