-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: make fixes requested while review
- Loading branch information
Showing
13 changed files
with
168 additions
and
136 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { useGetListsQuery, useDeleteListMutation } from '@/app/services/ListApi'; | ||
import { EditListForm } from '@/components/ListForms'; | ||
import Modal from '@/components/Modal'; | ||
import { Row } from '@tanstack/react-table'; | ||
import { Edit3, Trash2 } from 'lucide-react'; | ||
import React from 'react' | ||
|
||
interface ActionsColumnProps { | ||
row: Row<any>, | ||
namespaceId: string, | ||
}; | ||
|
||
const ActionsColumn = ({ | ||
row, | ||
namespaceId, | ||
}: ActionsColumnProps) => { | ||
const listId = row.original.id; | ||
|
||
const [ deleteList, { isLoading: isDeleting, error: deletionError } ] = useDeleteListMutation(); | ||
|
||
const deleteListHandler = async (id: string) => { | ||
if (deletionError) { | ||
return <div>Error deleting the list</div> | ||
} | ||
|
||
await deleteList({ namespaceId, listId: id }); | ||
} | ||
|
||
return ( | ||
<div className='flex space-x-4 text-primary items-center'> | ||
{/* <button className='transition-all duration-300 ease-in-out hover:scale-105'><Edit3 size={16} /></button> */} | ||
<Modal | ||
triggerButton={<Edit3 | ||
size={20} | ||
strokeWidth={1.5} | ||
className='text-lime-400 hover:text-lime-500' | ||
/>} | ||
dialogBody={<EditListForm listId={listId}/>} | ||
dialogTitle={"Edit Template"} | ||
dialogDescription={"Edit your template"} | ||
/> | ||
<button | ||
className='transition-all duration-300 ease-in-out hover:scale-105' | ||
onClick={() => deleteListHandler(listId)} | ||
> | ||
<Trash2 strokeWidth={1.5} size={20} className='text-red-400 hover:text-red-500' /> | ||
</button> | ||
</div> | ||
); | ||
} | ||
|
||
export default ActionsColumn |
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
52 changes: 52 additions & 0 deletions
52
frontend/app/dashboard/templates/components/ActionsColumn.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,52 @@ | ||
import { useGetTemplatesQuery, useDeleteTemplateMutation } from '@/app/services/TemplateApi'; | ||
import Modal from '@/components/Modal'; | ||
import { EditTemplateForm } from '@/components/TemplateForms'; | ||
import { Row } from '@tanstack/react-table'; | ||
import { Edit3, ScanEye, Trash2 } from 'lucide-react'; | ||
import React from 'react'; | ||
|
||
interface ActionsColumnProps { | ||
row: Row<any>, | ||
}; | ||
|
||
const ActionsColumn = ({ row }: ActionsColumnProps) => { | ||
const templateId = row.original.id; | ||
|
||
const [ deleteTemplate, { isLoading: isDeleting, error: deletionError } ] = useDeleteTemplateMutation(); | ||
|
||
const deleteTemplateHandler = async (id: string) => { | ||
if (deletionError) { | ||
return <div>Error deleting the list</div> | ||
} | ||
|
||
await deleteTemplate(id); | ||
} | ||
|
||
|
||
return ( | ||
<div className='flex space-x-4 text-primary items-center'> | ||
<button className='transition-all duration-300 ease-in-out hover:scale-105'><ScanEye size={20} /></button> | ||
{/* <button className='transition-all duration-300 ease-in-out hover:scale-105'><Edit3 size={16} /></button> */} | ||
<Modal | ||
triggerButton={<Edit3 | ||
size={20} | ||
strokeWidth={1.5} | ||
className='text-lime-400 transition-all duration-300 ease-in-out hover:scale-105 hover:text-lime-500' | ||
/>} | ||
dialogBody={<EditTemplateForm templateId={templateId}/>} | ||
dialogTitle={"Edit Template"} | ||
dialogDescription={"Edit your template"} | ||
/> | ||
<button | ||
className='transition-all duration-300 ease-in-out hover:scale-105 text-red-400 hover:text-red-500' | ||
onClick={() => { | ||
deleteTemplateHandler(templateId); | ||
}} | ||
> | ||
<Trash2 size={20} strokeWidth={1.5} /> | ||
</button> | ||
</div> | ||
) | ||
} | ||
|
||
export default ActionsColumn |
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.