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.

Add transfer

Tim Wilson8bc2714a153d
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/links/[...link]/page-client.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/links/[...link]/page-client.tsx
index adeb8ab6cd..94e90187c3 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/links/[...link]/page-client.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/links/[...link]/page-client.tsx
@@ -226,11 +226,12 @@ const Controls = memo(({ link }: { link: ExpandedLinkProps }) => {
openPopover={openPopover}
setOpenPopover={setOpenPopover}
shortcutsEnabled={openPopover}
- options={["move", "id", "archive", "delete"]}
+ options={["id", "move", "archive", "transfer", "delete"]}
onMoveSuccess={(folderId) => {
setValue("folderId", folderId);
reset(getValues(), { keepValues: true, keepDirty: false });
}}
+ onTransferSuccess={() => router.push(`/${slug}/links`)}
onDeleteSuccess={() => router.push(`/${slug}/links`)}
className="h-7 border border-neutral-200"
iconClassName="size-4"
diff --git a/apps/web/ui/links/link-controls.tsx b/apps/web/ui/links/link-controls.tsx
index ca043e8242..61eca9e4f9 100644
--- a/apps/web/ui/links/link-controls.tsx
+++ b/apps/web/ui/links/link-controls.tsx
@@ -51,6 +51,7 @@ export function LinkControls({
shortcutsEnabled,
options = Object.keys(OPTIONS),
onMoveSuccess,
+ onTransferSuccess,
onDeleteSuccess,
className,
iconClassName,
@@ -61,6 +62,7 @@ export function LinkControls({
shortcutsEnabled: boolean;
options?: string[];
onMoveSuccess?: (folderId: string | null) => void;
+ onTransferSuccess?: () => void;
onDeleteSuccess?: () => void;
className?: string;
iconClassName?: string;
@@ -88,6 +90,7 @@ export function LinkControls({
});
const { setShowTransferLinkModal, TransferLinkModal } = useTransferLinkModal({
props: link,
+ onSuccess: onTransferSuccess,
});
const { setShowDeleteLinkModal, DeleteLinkModal } = useDeleteLinkModal({
props: link,
diff --git a/apps/web/ui/modals/transfer-link-modal.tsx b/apps/web/ui/modals/transfer-link-modal.tsx
index c8e85efecf..cd1753c37e 100644
--- a/apps/web/ui/modals/transfer-link-modal.tsx
+++ b/apps/web/ui/modals/transfer-link-modal.tsx
@@ -30,6 +30,7 @@ type TransferLinkModalProps = {
showTransferLinkModal: boolean;
setShowTransferLinkModal: Dispatch<SetStateAction<boolean>>;
props: LinkProps;
+ onSuccess?: () => void;
};
function TransferLinkModal(props: TransferLinkModalProps) {
@@ -47,6 +48,7 @@ function TransferLinkModal(props: TransferLinkModalProps) {
function TransferLinkModalInner({
setShowTransferLinkModal,
props,
+ onSuccess,
}: TransferLinkModalProps) {
const { id } = useWorkspace();
const { workspaces } = useWorkspaces();
@@ -76,6 +78,7 @@ function TransferLinkModalInner({
if (res.ok) {
mutatePrefix("/api/links");
setShowTransferLinkModal(false);
+ onSuccess?.();
return true;
} else {
const error = await res.json();
@@ -141,7 +144,13 @@ function TransferLinkModalInner({
);
}
-export function useTransferLinkModal({ props }: { props: LinkProps }) {
+export function useTransferLinkModal({
+ props,
+ onSuccess,
+}: {
+ props: LinkProps;
+ onSuccess?: () => void;
+}) {
const [showTransferLinkModal, setShowTransferLinkModal] = useState(false);
const TransferLinkModalCallback = useCallback(() => {
@@ -150,6 +159,7 @@ export function useTransferLinkModal({ props }: { props: LinkProps }) {
showTransferLinkModal={showTransferLinkModal}
setShowTransferLinkModal={setShowTransferLinkModal}
props={props}
+ onSuccess={onSuccess}
/>
) : null;
}, [showTransferLinkModal, setShowTransferLinkModal]);