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.

Merge branch 'main' into links-dashboard

Tim Wilson636648698da3
diff --cc apps/web/app/app.dub.co/(dashboard)/[slug]/page-client.tsx
index 78b74e5efc,fe3dc8972e..c02325ed3e
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/page-client.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/page-client.tsx
@@@ -1,14 -1,13 +1,17 @@@
"use client";
import useWorkspace from "@/lib/swr/use-workspace";
+import { SearchBox } from "@/ui/links/link-filters";
+import LinkSort from "@/ui/links/link-sort";
import LinksContainer from "@/ui/links/links-container";
+import { useLinkFilters } from "@/ui/links/use-link-filters";
import { useAddEditLinkModal } from "@/ui/modals/add-edit-link-modal";
+ import { useExportLinksModal } from "@/ui/modals/export-links-modal";
import { ThreeDots } from "@/ui/shared/icons";
import {
+ AnimatedSizeContainer,
+ Button,
+ Filter,
IconMenu,
MaxWidthWrapper,
Popover,
@@@ -16,10 -15,16 +19,17 @@@
TooltipContent,
useRouterStuff,
} from "@dub/ui";
- import { cn } from "@dub/utils";
- import { FilePlus2, Sheet } from "lucide-react";
+ import { CloudUpload, Download } from "@dub/ui/src/icons";
+ import { Sheet } from "lucide-react";
import { useRouter } from "next/navigation";
- import { Suspense, useState } from "react";
+ import {
+ Dispatch,
+ ReactNode,
+ SetStateAction,
++ Suspense,
+ useEffect,
+ useState,
+ } from "react";
export default function WorkspaceLinksClient() {
const { AddEditLinkModal, AddEditLinkButton } = useAddEditLinkModal();
@@@ -36,37 -38,14 +46,37 @@@
<h1 className="text-2xl font-semibold tracking-tight text-black">
Links
</h1>
- <div className="flex gap-2">
- <AddEditLinkButton />
+ <div className="flex space-x-2">
+ <div className="w-72 max-w-full">
+ <SearchBox />
+ </div>
+ <Filter.Select
+ filters={filters}
+ onSelect={onSelect}
+ onRemove={onRemove}
+ />
+ <div className="grow-0">
+ <Suspense>
+ <LinkSort />
+ </Suspense>
+ </div>
+ <div className="grow-0">
+ <AddEditLinkButton />
+ </div>
- <AddLinkOptions />
+ <MoreLinkOptions />
</div>
</div>
+ <Filter.List
+ filters={filters}
+ activeFilters={activeFilters}
+ onRemove={onRemove}
+ onRemoveAll={onRemoveAll}
+ />
</MaxWidthWrapper>
</div>
- <LinksContainer AddEditLinkButton={AddEditLinkButton} />
+ <div className="mt-3">
+ <LinksContainer AddEditLinkButton={AddEditLinkButton} />
+ </div>
</>
);
}
diff --cc apps/web/ui/analytics/events/events-table.tsx
index c19dd8f673,588ff2ce45..987656e89a
--- a/apps/web/ui/analytics/events/events-table.tsx
+++ b/apps/web/ui/analytics/events/events-table.tsx
@@@ -33,8 -43,9 +33,6 @@@ import EmptyState from "./empty-state"
import ExportButton from "./export-button";
import usePagination from "./use-pagination";
- const PAGE_SIZE = 100;
-const tableCellClassName =
- "border-r border-b border-gray-200 px-4 py-2.5 text-left text-sm leading-6 whitespace-nowrap";
--
type EventType = "clicks" | "leads" | "sales";
type Datum =
@@@ -390,8 -406,6 +389,8 @@@ export default function EventsTable()
const defaultData = useMemo(() => [], []);
- const { pagination, setPagination } = usePagination(PAGE_SIZE);
++ const { pagination, setPagination } = usePagination();
+
const { queryString: originalQueryString, totalEvents } =
useContext(AnalyticsContext);
diff --cc apps/web/ui/analytics/events/use-pagination.ts
index ef745a5b5b,0368499003..6092fd53d8
--- a/apps/web/ui/analytics/events/use-pagination.ts
+++ b/apps/web/ui/analytics/events/use-pagination.ts
@@@ -4,34 -5,33 +4,48 @@@ import { useEffect, useMemo } from "rea
export default function usePagination(pageSize: number) {
const { searchParams, queryParams } = useRouterStuff();
- const offset = useMemo(
- () => parseInt(searchParams.get("offset") || "0") || 0,
- [searchParams.get("offset")],
- const [pagination, setPagination] = useState<PaginationState>({
- pageIndex: 0,
++ const page = useMemo(
++ () => parseInt(searchParams.get("page") || "0") || 0,
++ [searchParams.get("page")],
+ );
+
+ const { pagination, setPagination } = useTablePagination({
pageSize,
- offset,
- onOffsetChange: (offset) => {
++ page,
++ onPageChange: (p) => {
+ queryParams(
- offset === 0
- ? { del: "offset" }
++ p === 0
++ ? { del: "page" }
+ : {
+ set: {
- offset: offset.toString(),
++ page: p.toString(),
+ },
+ },
+ );
+ },
});
// Update state when URL parameter changes
useEffect(() => {
+ const page = parseInt(searchParams.get("page") || "0") || 0;
setPagination((p) => ({
...p,
- pageIndex: Math.floor(offset / p.pageSize),
+ pageIndex: page,
}));
- }, [offset]);
+ }, [searchParams.get("page")]);
+
+ // Update URL parameter when state changes
+ useEffect(() => {
- const page = pagination.pageIndex;
+ queryParams(
- page === 0
++ pagination.pageIndex === 0
+ ? { del: "page" }
+ : {
+ set: {
- page: page.toString(),
++ page: pagination.pageIndex.toString(),
+ },
+ },
+ );
+ }, [pagination]);
return { pagination, setPagination };
}
diff --cc apps/web/ui/links/link-sort.tsx
index a7a129bdc3,b55a4ee284..6e1adae7bb
--- a/apps/web/ui/links/link-sort.tsx
+++ b/apps/web/ui/links/link-sort.tsx
@@@ -61,29 -61,24 +61,25 @@@ export default function LinkSort()
openPopover={openPopover}
setOpenPopover={setOpenPopover}
>
- <button
+ <Button
+ variant="secondary"
onClick={() => setOpenPopover(!openPopover)}
- className="hover:bg-white"
- text={
- <span className="flex items-center gap-3">
- <span>{sort ? selectedSort.display : "Sort"}</span>
- <ChevronDown
- className={cn(
- "h-4 w-4 text-gray-400",
- openPopover ? "rotate-180 transform" : "",
- )}
- />
- </span>
- }
- icon={
- sort ? (
- <SortDesc className="h-4 w-4" />
- ) : (
- <Sort className="h-4 w-4 shrink-0" />
- )
- }
- />
+ className={cn(
+ "group flex h-10 w-full cursor-pointer appearance-none items-center gap-x-2 truncate rounded-md border px-3 text-sm outline-none transition-all lg:w-48",
+ "border-gray-200 bg-white text-gray-900 placeholder-gray-400",
+ "focus-visible:border-gray-500 data-[state=open]:border-gray-500 data-[state=open]:ring-4 data-[state=open]:ring-gray-200",
+ )}
+ >
+ {sort ? (
+ <SortDesc className="h-4 w-4" />
+ ) : (
+ <Sort className="h-4 w-4 shrink-0" />
+ )}
+ <span className="flex-1 overflow-hidden text-ellipsis whitespace-nowrap text-left text-gray-900">
+ {sort ? selectedSort.display : "Sort by"}
+ </span>
+ <ChevronDown className="h-4 w-4 flex-shrink-0 text-gray-400 transition-transform duration-75 group-data-[state=open]:rotate-180" />
- </button>
++ </Button>
</Popover>
);
}
diff --cc packages/ui/src/icons/nucleo/index.ts
index a059badf89,f7764a5936..f7039aad91
--- a/packages/ui/src/icons/nucleo/index.ts
+++ b/packages/ui/src/icons/nucleo/index.ts
@@@ -11,15 -28,24 +28,26 @@@ export * from "./hexadecagon-star"
export * from "./hyperlink";
export * from "./invoice-dollar";
export * from "./key";
+ export * from "./lines-y";
+ export * from "./magnifier";
export * from "./mobile-phone";
export * from "./office-building";
+ export * from "./paintbrush";
+ export * from "./pen-writing";
export * from "./qrcode";
+ export * from "./receipt2";
export * from "./referred-via";
+ export * from "./refresh2";
+ export * from "./shield-check";
export * from "./sliders";
+ export * from "./stars2";
export * from "./tablet";
export * from "./tag";
+export * from "./trash";
export * from "./tv";
+export * from "./user";
+ export * from "./users";
+ export * from "./users6";
export * from "./watch";
export * from "./window";
+ export * from "./window-settings";
diff --cc packages/ui/src/index.tsx
index 2c16ff87a4,00e5f797ea..d1834792f0
--- a/packages/ui/src/index.tsx
+++ b/packages/ui/src/index.tsx
@@@ -17,8 -17,8 +17,9 @@@ export * from "./label"
export * from "./modal";
export * from "./popover";
export * from "./radio-group";
+ export * from "./status-badge";
export * from "./switch";
+export * from "./table";
export * from "./tooltip";
// hooks