Skip to content

Commit

Permalink
Merge pull request #792 from AI4Bharat/video
Browse files Browse the repository at this point in the history
Show popup when same video link is uploaded
  • Loading branch information
aparna-aa authored Aug 11, 2024
2 parents 9202da1 + ce4fb73 commit 9a8d7ef
Showing 1 changed file with 58 additions and 1 deletion.
59 changes: 58 additions & 1 deletion src/common/CreateVideoDialog.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { Fragment, useEffect } from "react";
import React, { Fragment, useEffect, useState } from "react";
import { useDispatch, useSelector } from "react-redux";
import { MenuProps } from "utils";

Expand Down Expand Up @@ -78,6 +78,14 @@ const CreateVideoDialog = ({
(state) => state.getSupportedLanguages.transcriptionLanguage
);

const videosInProject = useSelector((state)=>state.getProjectVideoList.data)
const [showPopup, setShowPopup] = useState(false);
useEffect(() => {
if (videosInProject.some((video) => video.url === videoLink)) {
setShowPopup(true);
}
}, [videoLink, videosInProject]);

const handleClear = () => {
setLang("");
setVideoLink("");
Expand Down Expand Up @@ -241,6 +249,55 @@ const CreateVideoDialog = ({
onChange={(event) => setVideoLink(event.target.value)}
sx={{ mt: 3 }}
/>
{showPopup && (
<div
style={{
position: 'fixed',
top: 0,
left: 0,
right: 0,
bottom: 0,
backgroundColor: 'rgba(0,0,0,0.5)',
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
zIndex: 9999,
}}
>
<div
style={{
backgroundColor: 'white',
padding: '20px',
borderRadius: '8px',
textAlign: 'center',
position: 'relative',
minWidth: '300px',
}}
>
<p>This video already exists in the project. Do you want to upload it again?</p>
<Button
style={{ marginRight: "10px" }}
// className={classes.projectButton}
onClick={()=>setShowPopup(false)}
variant="contained"
>
Yes
</Button>

<Button
style={{ marginRight: "10px" }}
// className={classes.projectButton}
onClick={()=>{setShowPopup(false)
setVideoLink("")
}}
variant="contained"
>
No
</Button>
</div>
</div>
)}


<FormControl fullWidth sx={{ mt: 3 }}>
<InputLabel id="select-voice">Voice Selection</InputLabel>
Expand Down

0 comments on commit 9a8d7ef

Please sign in to comment.