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.

Update transfer-link-modal.tsx

Steven Tey50d537775b49
diff --git a/apps/web/ui/modals/transfer-link-modal.tsx b/apps/web/ui/modals/transfer-link-modal.tsx
index 589243ee81..ce886d6cb9 100644
--- a/apps/web/ui/modals/transfer-link-modal.tsx
+++ b/apps/web/ui/modals/transfer-link-modal.tsx
@@ -53,6 +53,18 @@ function TransferLinkModal({
"Content-Type": "application/json",
},
body: JSON.stringify({ newWorkspaceId }),
+ }).then(async (res) => {
+ if (res.ok) {
+ mutate(
+ (key) => typeof key === "string" && key.startsWith("/api/links"),
+ undefined,
+ { revalidate: true },
+ );
+ setShowTransferLinkModal(false);
+ return true;
+ } else {
+ throw new Error((await res.json()).message);
+ }
});
};
@@ -69,21 +81,7 @@ function TransferLinkModal({
setTransferring(true);
toast.promise(transferLink(props.id, selectedWorkspace.id), {
loading: "Transferring link...",
- success: async (response) => {
- if (!response.ok) {
- const { error } = await response.json();
- return `Failed to transfer link. ${error.message}`;
- }
-
- mutate(
- (key) =>
- typeof key === "string" && key.startsWith("/api/links"),
- undefined,
- { revalidate: true },
- );
- setShowTransferLinkModal(false);
- return "Successfully transferred link.";
- },
+ success: "Successfully transferred link.",
error: "Failed to transfer link.",
});
}