-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add email receivers to workflow form
Signed-off-by: Ryan Hopper-Lowe <[email protected]>
- Loading branch information
1 parent
a49cac5
commit 0d3b161
Showing
15 changed files
with
300 additions
and
52 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
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
63 changes: 63 additions & 0 deletions
63
ui/admin/app/components/workflow/DeleteWorkflowEmailReceiver.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,63 @@ | ||
import { TrashIcon } from "lucide-react"; | ||
import { useState } from "react"; | ||
import { toast } from "sonner"; | ||
import { mutate } from "swr"; | ||
|
||
import { EmailReceiverApiService } from "~/lib/service/api/emailReceiverApiService"; | ||
|
||
import { Button } from "~/components/ui/button"; | ||
import { | ||
Popover, | ||
PopoverContent, | ||
PopoverTrigger, | ||
} from "~/components/ui/popover"; | ||
import { useAsync } from "~/hooks/useAsync"; | ||
|
||
export function DeleteWorkflowEmailReceiver({ | ||
emailReceiverId, | ||
}: { | ||
emailReceiverId: string; | ||
}) { | ||
const [open, setOpen] = useState(false); | ||
|
||
const deleteEmailReceiver = useAsync( | ||
EmailReceiverApiService.deleteEmailReceiver, | ||
{ | ||
onSuccess: () => { | ||
mutate(EmailReceiverApiService.getEmailReceivers.key()); | ||
}, | ||
onError: () => toast.error(`Something went wrong.`), | ||
} | ||
); | ||
|
||
const handleDelete = async () => { | ||
await deleteEmailReceiver.execute(emailReceiverId); | ||
setOpen(false); | ||
}; | ||
|
||
return ( | ||
<Popover open={open} onOpenChange={setOpen}> | ||
<PopoverTrigger asChild> | ||
<Button variant="ghost" size="icon"> | ||
<TrashIcon /> | ||
</Button> | ||
</PopoverTrigger> | ||
|
||
<PopoverContent> | ||
<p>Are you sure you want to delete this email trigger?</p> | ||
<div className="flex justify-end gap-2"> | ||
<Button variant="ghost" onClick={() => setOpen(false)}> | ||
Cancel | ||
</Button> | ||
<Button | ||
variant="destructive" | ||
onClick={handleDelete} | ||
loading={deleteEmailReceiver.isLoading} | ||
> | ||
Delete | ||
</Button> | ||
</div> | ||
</PopoverContent> | ||
</Popover> | ||
); | ||
} |
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.