Skip to content

Commit

Permalink
fix: add confirmation before removing an identity
Browse files Browse the repository at this point in the history
  • Loading branch information
beeman committed Dec 18, 2023
1 parent 4cd4d96 commit c8d3eb0
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export function useUserFindManyIdentity() {
showNotificationSuccess('Identity deleted')
})
.catch((res) => {
showNotificationError('Error deleting identity')
showNotificationError(`${res}`, { title: 'Error deleting identity' })
})
.finally(() => query.refetch())
},
Expand Down
20 changes: 19 additions & 1 deletion libs/web/identity/ui/src/lib/identity-ui-admin-table.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { modals } from '@mantine/modals'
import { Identity } from '@pubkey-link/sdk'
import { UiDebugModal } from '@pubkey-link/web/ui/core'
import { ActionIcon, Group, ScrollArea, Stack, Text } from '@mantine/core'
Expand Down Expand Up @@ -42,7 +43,24 @@ export function IdentityUiAdminTable({ deleteIdentity, identities = [] }: AdminI
render: (item) => (
<Group spacing={0} position="right" noWrap>
<UiDebugModal data={item} />
<ActionIcon color="red" onClick={() => deleteIdentity(item)}>
<ActionIcon
color="red"
onClick={() => {
modals.openConfirmModal({
title: 'Delete Identity',
children: (
<div>
<Text>Are you sure you want to delete this identity?</Text>
<Text size="sm" color="dimmed">
{item.providerId}
</Text>
</div>
),
labels: { confirm: 'Delete', cancel: 'Cancel' },
onConfirm: () => deleteIdentity(item),
})
}}
>
<IconTrash size={16} />
</ActionIcon>
</Group>
Expand Down
2 changes: 1 addition & 1 deletion prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ model IdentityChallenge {
ip String
userAgent String
verified Boolean @default(false)
identity Identity @relation(fields: [provider, providerId], references: [provider, providerId])
identity Identity @relation(fields: [provider, providerId], references: [provider, providerId], onDelete: Cascade)
provider IdentityProvider
providerId String
}
Expand Down

0 comments on commit c8d3eb0

Please sign in to comment.