Added Dashboard Page ✔️

This commit is contained in:
Manik Maity
2024-11-05 23:42:59 +05:30
parent 69fc67ee02
commit aeb98553d5
5 changed files with 141 additions and 0 deletions

View File

@@ -0,0 +1,52 @@
// PollTableRow.js
import React, { useState } from "react";
import { FaTrashAlt, FaUserEdit } from "react-icons/fa";
function PollTableRow({ poll, index }) {
const [showEditForm, setShowEditForm] = useState(false);
const handleDelete = () => {
const sure = window.confirm("Are you sure you want to delete this poll?");
if (sure) {
// Call the delete poll function here
console.log(`Poll with ID: ${poll._id} has been deleted.`);
}
};
return (
<>
{showEditForm && (
<div className="fixed inset-0 bg-gray-800 bg-opacity-75 flex items-center justify-center z-50">
{/* Poll Edit Form Component would go here */}
</div>
)}
<tr>
<th>{index + 1}</th>
<td className="text-white">{poll.title}</td>
<td className="text-gray-400 whitespace-normal break-words max-w-xs">
{poll.description}
</td>
<td className="text-white">{poll.totalVotes}</td>
<td>
{poll.published ? (
<span className="badge badge-success text-white">Published</span>
) : (
<span className="badge badge-warning text-white">Unpublished</span>
)}
</td>
<td>
<div className="flex gap-2">
<button onClick={() => setShowEditForm(true)} className="btn btn-sm btn-info flex items-center">
<FaUserEdit className="mr-1" /> Edit
</button>
<button onClick={handleDelete} className="btn btn-sm btn-error flex items-center">
<FaTrashAlt className="mr-1" /> Delete
</button>
</div>
</td>
</tr>
</>
);
}
export default PollTableRow;