-
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.
- Loading branch information
Showing
11 changed files
with
163 additions
and
98 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
76 changes: 76 additions & 0 deletions
76
src/app/dash/[userid]/settings/components/webhook-table.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,76 @@ | ||
import { Table, Button } from '@mantine/core' | ||
import { Table as TableDef, flexRender } from '@tanstack/react-table' | ||
import React from 'react' | ||
import toast from 'react-hot-toast' | ||
import { useTranslation } from 'react-i18next' | ||
import { FetchMyWebHooksQuery, useDeleteAWebHookMutation } from '../../../../../schema/generated' | ||
|
||
type WebhookTableProps = { | ||
table: TableDef<FetchMyWebHooksQuery['me']['webhooks'][0]> | ||
onRowDelete: (id: number) => Promise<any> | ||
} | ||
|
||
function WebhookTable(props: WebhookTableProps) { | ||
const { t } = useTranslation() | ||
const { table, onRowDelete } = props | ||
if (table.getRowModel().rows.length === 0) { | ||
return ( | ||
<div className='my-8'> | ||
<span> | ||
{t('app.menu.search.empty')} | ||
</span> | ||
</div> | ||
) | ||
} | ||
return ( | ||
<Table> | ||
<Table.Thead> | ||
{table.getHeaderGroups().map(headerGroup => ( | ||
<Table.Tr key={headerGroup.id}> | ||
{headerGroup.headers.map(column => ( | ||
// eslint-disable-next-line react/jsx-key | ||
<Table.Th | ||
key={column.id} | ||
> | ||
{flexRender(column.column.columnDef.header, column.getContext())} | ||
</Table.Th> | ||
))} | ||
</Table.Tr> | ||
))} | ||
</Table.Thead> | ||
<Table.Tbody> | ||
{table.getRowModel().rows.map(row => { | ||
return ( | ||
<Table.Tr | ||
key={row.id} | ||
className='with-fade-in' | ||
> | ||
{row.getVisibleCells().map(cell => { | ||
if (cell.column.columnDef.header === 'action') { | ||
return ( | ||
<Table.Td key={cell.id}> | ||
<Button | ||
variant="gradient" | ||
className='bg-gradient-to-br from-orange-400 to-red-500' | ||
onClick={() => { | ||
return onRowDelete(cell.row.getValue('id')) | ||
}} | ||
>{t('app.common.delete')}</Button> | ||
</Table.Td> | ||
) | ||
} | ||
return ( | ||
<Table.Td key={cell.id}> | ||
{flexRender(cell.column.columnDef.cell, cell.getContext())} | ||
</Table.Td> | ||
) | ||
})} | ||
</Table.Tr> | ||
) | ||
})} | ||
</Table.Tbody> | ||
</Table> | ||
) | ||
} | ||
|
||
export default WebhookTable |
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
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
Oops, something went wrong.