-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add video widget display component in public page (#1837)
* Add video widget model and option card * add video widget service and resource * Add video widget crud and UI component * Fix linting issue * Add video widget display in engagement view * improve service methods return * Use some instead of map includes * remove console log
- Loading branch information
1 parent
10cdc74
commit 13a5eea
Showing
13 changed files
with
168 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,3 +23,5 @@ class WidgetType(IntEnum): | |
PHASES = 3 | ||
SUBSCRIBE = 4 | ||
EVENTS = 5 | ||
Map = 6 | ||
Video = 7 |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
met-web/src/components/engagement/view/widgets/Video/VideoWidgetView.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import React, { useEffect, useState } from 'react'; | ||
import { MetPaper, MetHeader2, MetParagraph } from 'components/common'; | ||
import { Grid, Skeleton, Divider } from '@mui/material'; | ||
import { Widget } from 'models/widget'; | ||
import { useAppDispatch } from 'hooks'; | ||
import { openNotification } from 'services/notificationService/notificationSlice'; | ||
import { VideoWidget } from 'models/videoWidget'; | ||
import { fetchVideoWidgets } from 'services/widgetService/VideoService'; | ||
import ReactPlayer from 'react-player/lazy'; | ||
|
||
interface VideoWidgetProps { | ||
widget: Widget; | ||
} | ||
|
||
const VideoWidgetView = ({ widget }: VideoWidgetProps) => { | ||
const dispatch = useAppDispatch(); | ||
const [videoWidget, setVideoWidget] = useState<VideoWidget | null>(null); | ||
const [isLoading, setIsLoading] = useState(true); | ||
|
||
const fetchVideo = async () => { | ||
try { | ||
const videos = await fetchVideoWidgets(widget.id); | ||
const video = videos[videos.length - 1]; | ||
setVideoWidget(video); | ||
setIsLoading(false); | ||
} catch (error) { | ||
setIsLoading(false); | ||
console.log(error); | ||
dispatch( | ||
openNotification({ | ||
severity: 'error', | ||
text: 'Error occurred while fetching Engagement widgets information', | ||
}), | ||
); | ||
} | ||
}; | ||
|
||
useEffect(() => { | ||
fetchVideo(); | ||
}, [widget]); | ||
|
||
if (isLoading) { | ||
return ( | ||
<MetPaper elevation={1} sx={{ padding: '1em' }}> | ||
<Grid container justifyContent="flex-start" spacing={3}> | ||
<Grid item xs={12}> | ||
<MetHeader2> | ||
<Skeleton variant="rectangular" /> | ||
</MetHeader2> | ||
</Grid> | ||
<Grid item xs={12}> | ||
<Skeleton variant="rectangular" height="20em" /> | ||
</Grid> | ||
</Grid> | ||
</MetPaper> | ||
); | ||
} | ||
|
||
if (!videoWidget) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<> | ||
<MetPaper elevation={1} sx={{ paddingTop: '0.5em', padding: '1em' }}> | ||
<Grid container justifyContent={{ xs: 'center' }} alignItems="center" rowSpacing={2}> | ||
<Grid | ||
item | ||
container | ||
justifyContent={{ xs: 'center', md: 'flex-start' }} | ||
flexDirection={'column'} | ||
xs={12} | ||
paddingBottom={0} | ||
> | ||
<MetHeader2 bold>Video</MetHeader2> | ||
<Divider sx={{ borderWidth: 1, marginTop: 0.5 }} /> | ||
</Grid> | ||
<Grid item xs={12}> | ||
<MetParagraph>{videoWidget.description}</MetParagraph> | ||
</Grid> | ||
<Grid item xs={12}> | ||
<ReactPlayer url={videoWidget.video_url} controls width="100%" /> | ||
</Grid> | ||
</Grid> | ||
</MetPaper> | ||
</> | ||
); | ||
}; | ||
|
||
export default VideoWidgetView; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters