Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

useConfirm modal for reject button

Steven Tey488129986031
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/applications/page-client.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/applications/page-client.tsx
index fafc19f1f2..395f2536a7 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/applications/page-client.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/applications/page-client.tsx
@@ -477,7 +477,7 @@ function RowMenuButton({
setShowRejectModal(true);
}}
>
- Reject partner
+ Reject application
</MenuItem>
</Command.List>
</Command>
diff --git a/apps/web/ui/partners/partner-application-sheet.tsx b/apps/web/ui/partners/partner-application-sheet.tsx
index c7742d369b..ddc28081ca 100644
--- a/apps/web/ui/partners/partner-application-sheet.tsx
+++ b/apps/web/ui/partners/partner-application-sheet.tsx
@@ -4,6 +4,7 @@ import { mutatePrefix } from "@/lib/swr/mutate";
import useProgram from "@/lib/swr/use-program";
import useWorkspace from "@/lib/swr/use-workspace";
import { EnrolledPartnerProps } from "@/lib/types";
+import { useConfirmModal } from "@/ui/modals/confirm-modal";
import { X } from "@/ui/shared/icons";
import { Button, Sheet, useRouterStuff } from "@dub/ui";
import { cn, fetcher } from "@dub/utils";
@@ -322,30 +323,45 @@ function PartnerRejectButton({
}) {
const { id: workspaceId } = useWorkspace();
- const { executeAsync, isPending } = useAction(rejectPartnerAction, {
- onSuccess: async () => {
- await mutatePrefix("/api/partners");
- toast.success("Partner rejected successfully.");
- setIsOpen(false);
+ const { executeAsync: rejectPartner, isPending } = useAction(
+ rejectPartnerAction,
+ {
+ onSuccess: async () => {
+ await mutatePrefix("/api/partners");
+ toast.success("Partner rejected successfully.");
+ setIsOpen(false);
+ },
+ onError({ error }) {
+ toast.error(error.serverError || "Failed to reject partner.");
+ },
},
- onError({ error }) {
- toast.error(error.serverError || "Failed to reject partner.");
+ );
+
+ const { setShowConfirmModal, confirmModal } = useConfirmModal({
+ title: "Reject Application",
+ description: "Are you sure you want to reject this partner application?",
+ confirmText: "Reject",
+ onConfirm: async () => {
+ await rejectPartner({
+ workspaceId: workspaceId!,
+ partnerId: partner.id,
+ });
},
});
return (
- <Button
- type="button"
- variant="secondary"
- text={isPending ? "" : "Reject"}
- loading={isPending}
- onClick={async () => {
- await executeAsync({
- workspaceId: workspaceId!,
- partnerId: partner.id,
- });
- }}
- />
+ <>
+ {confirmModal}
+ <Button
+ type="button"
+ variant="secondary"
+ text={isPending ? "" : "Reject"}
+ loading={isPending}
+ onClick={() => {
+ setShowConfirmModal(true);
+ }}
+ />
+ </>
);
}