-
Notifications
You must be signed in to change notification settings - Fork 0
/
EditedCard.js
59 lines (52 loc) · 1.97 KB
/
EditedCard.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import { MdDelete } from "react-icons/md";
import axios from "axios";
import { useState } from "react";
const EditedCard = (props) => {
const [vidStatus, setVidStatus] = useState("Pending...");
const data = props.value;
const ytId = props.id;
const refersh = props.refersh;
const setRefersh = props.setRefersh;
const accountType = localStorage.getItem("accountType");
const deleteHandler = async () => {
const formData = new FormData();
try {
formData.append("content", data);
formData.append("ytId", ytId);
await axios.post(`${process.env.REACT_APP_BASE_URL}/deleteEditodVideo`, formData)
.then((result) => {
if (result.data.success) {
setRefersh(!refersh);
}
});
} catch (e) {
console.log("Error in deleting video", e);
}
};
const handleApproval = (status) => {
setVidStatus(status);
};
return (
<div className="w-[30%] h-[75%] mx-auto border border-yellow-500 my-auto">
<div className="h-[75%] w-full border border-green-600">
<video className="h-full w-full" controls src={data}></video>
</div>
<div className="w-full h-[25%] border border-red-500 relative mr-4 ">
{accountType === "Editor" ? (
<div className="w-full h-full flex justify-evenly items-center">
<h2 className="py-1 px-3 bg-yellow-500 rounded-sm text-black">{vidStatus}</h2>
<button className="text-3xl cursor-pointer " onClick={deleteHandler}>
<MdDelete></MdDelete>
</button>
</div>
) : (
<div className="w-full h-full flex justify-evenly items-center">
<button onClick={() => handleApproval("Approved")} className="bg-yellow-500 py-1 px-3 rounded-sm text-black">Approve</button>
<button onClick={deleteHandler} className="bg-yellow-500 py-1 px-3 rounded-sm text-black">Reject</button>
</div>
)}
</div>
</div>
);
};
export default EditedCard;