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.

improved transfer link modal UX

Steven Tey2f521c9b3647
diff --git a/apps/web/scripts/bulk-update-links.ts b/apps/web/scripts/bulk-update-links.ts
new file mode 100644
index 0000000000..19e91c2d36
--- /dev/null
+++ b/apps/web/scripts/bulk-update-links.ts
@@ -0,0 +1,18 @@
+import prisma from "@/lib/prisma";
+
+import "dotenv-flow/config";
+
+async function main() {
+ const links = await prisma.link.updateMany({
+ where: {
+ domain: "xxx",
+ },
+ data: {
+ publicStats: true,
+ },
+ });
+
+ console.log(links);
+}
+
+main();
diff --git a/apps/web/ui/modals/transfer-link-modal.tsx b/apps/web/ui/modals/transfer-link-modal.tsx
index d85d9c0bf0..3a52b0b72c 100644
--- a/apps/web/ui/modals/transfer-link-modal.tsx
+++ b/apps/web/ui/modals/transfer-link-modal.tsx
@@ -103,13 +103,13 @@ function TransferLinkModal({
<InputSelect
items={
projects
- ? projects
- .filter((project) => project.id !== props.projectId)
- .map((project) => ({
- id: project.id,
- value: project.name,
- image: project.logo || DUB_LOGO,
- }))
+ ? projects.map((project) => ({
+ id: project.id,
+ value: project.name,
+ image: project.logo || DUB_LOGO,
+ disabled: project.id === props.projectId,
+ label: project.id === props.projectId ? "Current" : "",
+ }))
: []
}
selectedItem={selectedProject}
diff --git a/packages/ui/src/input-select.tsx b/packages/ui/src/input-select.tsx
index 31ffa7c33f..a386a4fb93 100644
--- a/packages/ui/src/input-select.tsx
+++ b/packages/ui/src/input-select.tsx
@@ -10,11 +10,14 @@ import {
useRef,
useState,
} from "react";
+import { Badge } from "./badge";
export interface InputSelectItemProps {
id: string;
value: string;
image: string;
+ disabled?: boolean;
+ label?: string;
}
export function InputSelect({
@@ -117,12 +120,13 @@ export function InputSelect({
<Command.Item
key={item.id}
value={item.value}
+ disabled={item.disabled}
onSelect={() => {
setSelectedItem(item);
setInputValue(item.value);
setOpenCommandList(false);
}}
- className="group flex cursor-pointer items-center justify-between rounded-md px-4 py-2 text-sm text-gray-900 hover:bg-gray-100 hover:text-gray-900 active:bg-gray-200 aria-selected:bg-gray-100 aria-selected:text-gray-900"
+ className="group flex cursor-pointer items-center justify-between rounded-md px-4 py-2 text-sm text-gray-900 hover:bg-gray-100 hover:text-gray-900 active:bg-gray-200 aria-disabled:cursor-not-allowed aria-disabled:opacity-75 aria-disabled:hover:bg-white aria-selected:bg-gray-100 aria-selected:text-gray-900"
>
<div className="flex items-center space-x-2">
<img
@@ -131,6 +135,11 @@ export function InputSelect({
className="h-4 w-4 rounded-full"
/>
<p>{item.value}</p>
+ {item.label && (
+ <Badge className="text-xs" variant="neutral">
+ {item.label}
+ </Badge>
+ )}
</div>
<Check className="invisible h-5 w-5 text-gray-500 aria-selected:visible" />
</Command.Item>