-
-
Notifications
You must be signed in to change notification settings - Fork 246
feat: allow deleting ses settings #289
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
KMKoushik
wants to merge
1
commit into
main
Choose a base branch
from
codex/add-option-to-delete-ses-settings
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+191
−1
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
93 changes: 93 additions & 0 deletions
93
apps/web/src/app/(dashboard)/admin/delete-ses-configuration.tsx
This file contains hidden or 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,93 @@ | ||
| "use client"; | ||
|
|
||
| import { useState } from "react"; | ||
| import { SesSetting } from "@prisma/client"; | ||
| import { Trash } from "lucide-react"; | ||
|
|
||
| import { Button } from "@usesend/ui/src/button"; | ||
| import { | ||
| Dialog, | ||
| DialogContent, | ||
| DialogDescription, | ||
| DialogFooter, | ||
| DialogHeader, | ||
| DialogTitle, | ||
| DialogTrigger, | ||
| } from "@usesend/ui/src/dialog"; | ||
| import { toast } from "@usesend/ui/src/toaster"; | ||
|
|
||
| import { api } from "~/trpc/react"; | ||
|
|
||
| export default function DeleteSesConfiguration({ | ||
| setting, | ||
| }: { | ||
| setting: SesSetting; | ||
| }) { | ||
| const [open, setOpen] = useState(false); | ||
|
|
||
| const deleteSesSettings = api.admin.deleteSesSettings.useMutation(); | ||
| const utils = api.useUtils(); | ||
|
|
||
| const handleDelete = () => { | ||
| deleteSesSettings.mutate( | ||
| { settingsId: setting.id }, | ||
| { | ||
| onSuccess: () => { | ||
| utils.admin.invalidate(); | ||
| toast.success("SES configuration deleted", { | ||
| description: `${setting.region} has been removed`, | ||
| }); | ||
| setOpen(false); | ||
| }, | ||
| onError: (error) => { | ||
| toast.error("Failed to delete SES configuration", { | ||
| description: error.message, | ||
| }); | ||
| }, | ||
| } | ||
| ); | ||
| }; | ||
|
|
||
| return ( | ||
| <Dialog open={open} onOpenChange={(next) => setOpen(next)}> | ||
| <DialogTrigger asChild> | ||
| <Button | ||
| variant="ghost" | ||
| size="sm" | ||
| className="text-destructive hover:text-destructive" | ||
| > | ||
| <Trash className="h-4 w-4" /> | ||
| </Button> | ||
| </DialogTrigger> | ||
| <DialogContent> | ||
| <DialogHeader> | ||
| <DialogTitle>Delete SES configuration</DialogTitle> | ||
| <DialogDescription> | ||
| This will delete the callback URL, SNS topic, and queues for the{" "} | ||
| <span className="font-semibold">{setting.region}</span> region. | ||
| This action cannot be undone. | ||
| </DialogDescription> | ||
| </DialogHeader> | ||
| <DialogFooter> | ||
| <Button | ||
| type="button" | ||
| variant="ghost" | ||
| onClick={() => setOpen(false)} | ||
| disabled={deleteSesSettings.isPending} | ||
| > | ||
| Cancel | ||
| </Button> | ||
| <Button | ||
| type="button" | ||
| variant="destructive" | ||
| onClick={handleDelete} | ||
| isLoading={deleteSesSettings.isPending} | ||
| showSpinner | ||
| > | ||
| Delete | ||
| </Button> | ||
| </DialogFooter> | ||
| </DialogContent> | ||
| </Dialog> | ||
| ); | ||
| } | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
Avoid Prisma value imports on the client; add an accessible label for the delete button
"use client"component, importingSesSettingas a value (import { SesSetting } from "@prisma/client";) can cause Prisma (a server‑side dependency) to be pulled into the browser bundle depending on TS/compiler settings. Since it’s only used for typing, switch to a type‑only import to keep the client bundle clean:aria-labelor sr‑only text:The mutation wiring, toasts, and pending state handling otherwise look solid.
Also applies to: 21-49, 52-92
🌐 Web query:
💡 Result:
Short answer: If you import @prisma/client (non‑type) from inside a Next.js client component, it becomes part of the client module graph and will be included in the client bundle (so it is not automatically erased/tree‑shaken away). Use type‑only imports (import type ...) or the Prisma browser/lightweight exports to avoid bundling server code. [1][2][3]
Evidence / pointers:
If you want, I can show a small example of the safe patterns (import type / importing Prisma browser enums) and what to avoid.
Avoid Prisma value imports on the client; add an accessible label for the delete button
The concerns in the original review are confirmed:
import typeimports of@prisma/clientin "use client" components are bundled into the client bundle and are not tree-shaken away. Use type-only imports to keep server code out of the browser:aria-labelso screen readers announce its purpose:📝 Committable suggestion
🤖 Prompt for AI Agents