Skip to content

Commit

Permalink
chore(boards): toast on delete
Browse files Browse the repository at this point in the history
  • Loading branch information
oyvindgrutle committed Jul 4, 2024
1 parent 68be8d6 commit 746c533
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions next-tavla/app/(admin)/boards/components/Column/Delete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import sheep from 'assets/illustrations/Sheep.png'
import Image from 'next/image'
import { SubmitButton } from 'components/Form/SubmitButton'
import { OverflowMenuItem } from '@entur/menu'
import { useToast } from '@entur/alert'

function Delete({
board,
Expand All @@ -23,9 +24,16 @@ function Delete({
board: TBoard
type?: 'icon' | 'button' | 'action'
}) {
const [state, action] = useFormState(deleteBoardAction, undefined)
const { addToast } = useToast()

const [state, deleteBoard] = useFormState(deleteBoardAction, undefined)
const { isOpen, open, close } = useModalWithValue('delete', board.id ?? '')

const submit = async (data: FormData) => {
deleteBoard(data)
addToast('Tavle slettet!')
}

return (
<>
<Tooltip content="Slett tavle" placement="bottom">
Expand Down Expand Up @@ -55,7 +63,7 @@ function Delete({
til.
</Paragraph>

<form action={action} onSubmit={close} className="w-full">
<form action={submit} onSubmit={close} className="w-full">
<HiddenInput id="bid" value={board.id} />
<FormError {...getFormFeedbackForField('general', state)} />
<SubmitButton
Expand Down

0 comments on commit 746c533

Please sign in to comment.