-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix tickets-crud that was introduced in issues 242
-Admins and Coordinators will be able to create tickets -Traineess will be able to see tickets assigned to them -Also Admins and Admins can also perform CRUD operations on Tickets
- Loading branch information
1 parent
07b4e1f
commit 40370c5
Showing
99 changed files
with
2,005 additions
and
1,021 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import React from 'react'; | ||
import ActionDropdown from '../components/ActionDropdown'; | ||
|
||
interface ActionDropdownCellProps { | ||
row: { | ||
original: any; | ||
}; | ||
onView: (ticket: any) => void; | ||
onEdit?: (id: string) => void; | ||
onDelete?: (id: string) => void; | ||
canEditDelete: boolean; | ||
} | ||
|
||
function ActionDropdownCell({ | ||
row, | ||
onView, | ||
onEdit, | ||
onDelete, | ||
canEditDelete, | ||
}: ActionDropdownCellProps) { | ||
return ( | ||
<ActionDropdown | ||
onView={() => onView(row.original)} | ||
onEdit={canEditDelete ? () => onEdit?.(row.original.id) : undefined} | ||
onDelete={canEditDelete ? () => onDelete?.(row.original.id) : undefined} | ||
canEditDelete={canEditDelete} | ||
id={row.original.id} | ||
/> | ||
); | ||
} | ||
|
||
export default ActionDropdownCell; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
import React, { useState } from 'react'; | ||
import { | ||
FaEllipsisV, | ||
FaEye, | ||
FaEdit, | ||
FaTrashAlt, | ||
FaClipboard, | ||
} from 'react-icons/fa'; | ||
import { toast } from 'react-toastify'; | ||
|
||
interface ActionDropdownProps { | ||
onView: () => void; | ||
onEdit?: () => void; | ||
onDelete?: () => void; | ||
canEditDelete: boolean; | ||
id?: string; | ||
} | ||
|
||
function ActionDropdown({ | ||
onView, | ||
onEdit, | ||
onDelete, | ||
canEditDelete, | ||
id, | ||
}: ActionDropdownProps) { | ||
const [isOpen, setIsOpen] = useState(false); | ||
|
||
const toggleDropdown = () => setIsOpen(!isOpen); | ||
|
||
const copyToClipboard = (text: any) => { | ||
navigator.clipboard | ||
.writeText(text) | ||
.then(() => { | ||
toast.success('ID copied to clipboard!'); | ||
}) | ||
.catch((err) => { | ||
toast.error(`Failed to copy: ${err}`); | ||
}); | ||
}; | ||
|
||
return ( | ||
<div className="relative"> | ||
<button | ||
type="button" | ||
aria-label="Open actions menu" | ||
className="text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-300" | ||
onClick={toggleDropdown} | ||
> | ||
<FaEllipsisV className="text-2xl" /> | ||
</button> | ||
{isOpen && ( | ||
<div className="fixed z-10 w-48 mt-2 bg-white border border-gray-200 rounded-md shadow-lg right-10 dark:bg-gray-800 dark:border-gray-700"> | ||
<button | ||
type="button" | ||
aria-label="View item" | ||
onClick={() => { | ||
onView(); | ||
setIsOpen(false); | ||
}} | ||
className="flex items-center w-full px-4 py-2 text-sm text-blue-600 hover:bg-blue-100 dark:text-blue-400 dark:hover:bg-blue-700" | ||
> | ||
<FaEye className="mr-2" /> | ||
View | ||
</button> | ||
{canEditDelete && ( | ||
<> | ||
<button | ||
type="button" | ||
aria-label="Edit item" | ||
onClick={() => { | ||
onEdit?.(); | ||
setIsOpen(false); | ||
}} | ||
className="flex items-center w-full px-4 py-2 text-sm text-yellow-600 hover:bg-yellow-100 dark:text-yellow-400 dark:hover:bg-yellow-700" | ||
> | ||
<FaEdit className="mr-2" /> | ||
Edit | ||
</button> | ||
<button | ||
type="button" | ||
aria-label="Delete item" | ||
onClick={() => { | ||
onDelete?.(); | ||
setIsOpen(false); | ||
}} | ||
className="flex items-center w-full px-4 py-2 text-sm text-red-600 hover:bg-red-100 dark:text-red-400 dark:hover:bg-red-700" | ||
> | ||
<FaTrashAlt className="mr-2" /> | ||
Delete | ||
</button> | ||
</> | ||
)} | ||
<button | ||
type="button" | ||
aria-label="Copy ID" | ||
onClick={() => { | ||
copyToClipboard(id); | ||
setIsOpen(false); | ||
}} | ||
className="flex items-center w-full px-4 py-2 text-sm text-gray-600 hover:bg-gray-100 dark:text-gray-400 dark:hover:bg-gray-700" | ||
> | ||
<FaClipboard className="mr-2" /> | ||
Copy ID | ||
</button> | ||
</div> | ||
)} | ||
</div> | ||
); | ||
} | ||
|
||
export default ActionDropdown; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* eslint-disable react/function-component-definition */ | ||
import React, { useState } from 'react'; | ||
import { toast } from 'react-toastify'; | ||
|
||
interface ConfirmationModalProps { | ||
isOpen: boolean; | ||
onConfirm: () => void; | ||
onCancel: () => void; | ||
message: string; | ||
} | ||
|
||
const ConfirmationModal: React.FC<ConfirmationModalProps> = ({ | ||
isOpen, | ||
onConfirm, | ||
onCancel, | ||
message, | ||
}) => { | ||
const [loading, setLoading] = useState(false); | ||
|
||
if (!isOpen) return null; | ||
|
||
const handleConfirm = async () => { | ||
setLoading(true); | ||
try { | ||
onConfirm(); | ||
} catch (error) { | ||
toast.error('Failed to confirm action. Please try again.'); | ||
} finally { | ||
setLoading(false); | ||
} | ||
}; | ||
|
||
return ( | ||
<div className="fixed inset-0 flex items-center justify-center bg-black bg-opacity-50"> | ||
<div className="w-full max-w-sm p-6 bg-white rounded-lg shadow-lg dark:bg-gray-800 dark:shadow-gray-700"> | ||
<h2 className="mb-4 text-2xl font-bold text-gray-900 dark:text-gray-100"> | ||
Confirm Action | ||
</h2> | ||
<p className="mb-4 text-gray-700 dark:text-gray-300">{message}</p> | ||
<div className="flex justify-end space-x-4"> | ||
<button | ||
type="button" | ||
onClick={onCancel} | ||
className="px-4 py-2 text-white bg-gray-500 rounded hover:bg-gray-600 focus:outline-none focus:ring-2 focus:ring-gray-400 dark:bg-gray-600 dark:hover:bg-gray-700 dark:focus:ring-gray-500" | ||
> | ||
Cancel | ||
</button> | ||
<button | ||
onClick={handleConfirm} | ||
type="button" | ||
className={`px-4 py-2 text-white rounded hover:bg-red-600 focus:outline-none focus:ring-2 ${ | ||
loading ? 'bg-red-400 cursor-not-allowed' : 'bg-red-500' | ||
} dark:bg-red-600 dark:hover:bg-red-700 dark:focus:ring-red-500`} | ||
disabled={loading} | ||
> | ||
{loading ? 'Processing...' : 'Confirm'} | ||
</button> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default ConfirmationModal; |
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
Oops, something went wrong.