The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
fix TS issues
Kiran Ka006aba603f4
diff --git a/apps/web/app/api/tokens/[id]/route.ts b/apps/web/app/api/tokens/[id]/route.tsindex f023a3ba66..97b7a975ea 100644--- a/apps/web/app/api/tokens/[id]/route.ts+++ b/apps/web/app/api/tokens/[id]/route.ts@@ -117,9 +117,6 @@ export const DELETE = withWorkspace(});}- // TODO:- // Send email to user that their token has been deleted-return NextResponse.json({id: token.id,});diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/tokens/page-client.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/tokens/page-client.tsxindex e504efd324..86c75c451b 100644--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/tokens/page-client.tsx+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/tokens/page-client.tsx@@ -24,8 +24,6 @@ export default function TokensPageClient() {token: createdToken || "",});- // TODO:- // Check if there is a better way to display the token after creationconst onTokenCreated = (token: string) => {setCreatedToken(token);setShowTokenCreatedModal(true);@@ -94,12 +92,10 @@ const TokenRow = (token: TokenProps) => {isMachine: token.user.isMachine,scopes: mapScopesToResource(token.scopes),},- onTokenCreated: () => {},});const { DeleteTokenModal, setShowDeleteTokenModal } = useDeleteTokenModal({- token: token as any, // TODO: Fix this- tokenType: "workspace",+ token,});return (diff --git a/apps/web/app/app.dub.co/(dashboard)/settings/tokens/page-client.tsx b/apps/web/app/app.dub.co/(dashboard)/settings/tokens/page-client.tsxindex 2090fa2894..ed137f5a47 100644--- a/apps/web/app/app.dub.co/(dashboard)/settings/tokens/page-client.tsx+++ b/apps/web/app/app.dub.co/(dashboard)/settings/tokens/page-client.tsx@@ -1,5 +1,6 @@"use client";+import { TokenProps } from "@/lib/types";import { useDeleteTokenModal } from "@/ui/modals/delete-token-modal";import {Alert,@@ -11,13 +12,12 @@ import {TokenAvatar,} from "@dub/ui";import { fetcher, timeAgo } from "@dub/utils";-import { Token } from "@prisma/client";import { FolderOpen, Info, MoreVertical, Trash } from "lucide-react";import { useState } from "react";import useSWR from "swr";export default function TokensPageClient() {- const { data: tokens, isLoading } = useSWR<Token[]>(+ const { data: tokens, isLoading } = useSWR<TokenProps[]>("/api/user/tokens",fetcher,);@@ -76,11 +76,11 @@ export default function TokensPageClient() {);}-const TokenRow = (token: Token) => {+const TokenRow = (token: TokenProps) => {const [openPopover, setOpenPopover] = useState(false);+const { DeleteTokenModal, setShowDeleteTokenModal } = useDeleteTokenModal({- token,- tokenType: "user",+ token});return (diff --git a/apps/web/ui/modals/delete-token-modal.tsx b/apps/web/ui/modals/delete-token-modal.tsxindex 07d1fbd617..d01497c65c 100644--- a/apps/web/ui/modals/delete-token-modal.tsx+++ b/apps/web/ui/modals/delete-token-modal.tsx@@ -1,4 +1,5 @@import useWorkspace from "@/lib/swr/use-workspace";+import { TokenProps } from "@/lib/types";import {Badge,Button,@@ -8,7 +9,6 @@ import {useMediaQuery,} from "@dub/ui";import { timeAgo } from "@dub/utils";-import { Token } from "@prisma/client";import {Dispatch,SetStateAction,@@ -23,20 +23,20 @@ function DeleteTokenModal({showDeleteTokenModal,setShowDeleteTokenModal,token,- tokenType,}: {showDeleteTokenModal: boolean;setShowDeleteTokenModal: Dispatch<SetStateAction<boolean>>;- token: Token;- tokenType: "user" | "workspace";+ token: TokenProps;}) {const { isMobile } = useMediaQuery();const { id: workspaceId } = useWorkspace();const [removing, setRemoving] = useState(false);// Determine the endpoint+ const isRestrictedToken = "scopes" in token ? true : false;+const endpoint = useMemo(() => {- if (tokenType === "user") {+ if (!isRestrictedToken) {return {url: `/api/user/tokens?id=${token.id}`,mutate: "/api/user/tokens",@@ -47,7 +47,7 @@ function DeleteTokenModal({mutate: `/api/tokens?workspaceId=${workspaceId}`,};}- }, [tokenType]);+ }, [isRestrictedToken]);return (<Modal@@ -106,13 +106,7 @@ function DeleteTokenModal({);}-export function useDeleteTokenModal({- token,- tokenType,-}: {- token: Token;- tokenType: "user" | "workspace";-}) {+export function useDeleteTokenModal({ token }: { token: TokenProps }) {const [showDeleteTokenModal, setShowDeleteTokenModal] = useState(false);const DeleteTokenModalCallback = useCallback(() => {@@ -121,7 +115,6 @@ export function useDeleteTokenModal({showDeleteTokenModal={showDeleteTokenModal}setShowDeleteTokenModal={setShowDeleteTokenModal}token={token}- tokenType={tokenType}/>);}, [showDeleteTokenModal, setShowDeleteTokenModal]);