Small fixes
This commit is contained in:
@@ -9,7 +9,7 @@ export default function NotFound() {
|
|||||||
Link Not Found
|
Link Not Found
|
||||||
</h2>
|
</h2>
|
||||||
<p className="mt-2 text-gray-600 dark:text-gray-400">
|
<p className="mt-2 text-gray-600 dark:text-gray-400">
|
||||||
The link you're looking for doesn't exist or has expired.
|
The link you're looking for doesn't exist or has expired.
|
||||||
</p>
|
</p>
|
||||||
<Link
|
<Link
|
||||||
href="/"
|
href="/"
|
||||||
|
|||||||
@@ -238,15 +238,15 @@ export function UrlsDataTable({ data }: UrlsDataTableProps) {
|
|||||||
const [columnVisibility, setColumnVisibility] = React.useState<VisibilityState>({})
|
const [columnVisibility, setColumnVisibility] = React.useState<VisibilityState>({})
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
|
||||||
function handleCopy(string: string) {
|
const handleCopy = React.useCallback((string: string) => {
|
||||||
navigator.clipboard.writeText(string).then(() => {
|
navigator.clipboard.writeText(string).then(() => {
|
||||||
toast.success("URL copied to clipboard")
|
toast.success("URL copied to clipboard")
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
toast.error("Failed to copy URL")
|
toast.error("Failed to copy URL")
|
||||||
})
|
})
|
||||||
}
|
}, [])
|
||||||
|
|
||||||
async function handleDelete(id: string) {
|
const handleDelete = React.useCallback(async (id: string) => {
|
||||||
const res = await deleteUrl(id)
|
const res = await deleteUrl(id)
|
||||||
|
|
||||||
if (res.error) {
|
if (res.error) {
|
||||||
@@ -255,8 +255,9 @@ export function UrlsDataTable({ data }: UrlsDataTableProps) {
|
|||||||
toast.success("URL deleted successfully")
|
toast.success("URL deleted successfully")
|
||||||
router.refresh()
|
router.refresh()
|
||||||
}
|
}
|
||||||
}
|
}, [router])
|
||||||
|
|
||||||
|
const tableColumns = React.useMemo(() => {
|
||||||
const actionRow: ColumnDef<UrlRecord> = {
|
const actionRow: ColumnDef<UrlRecord> = {
|
||||||
id: "actions",
|
id: "actions",
|
||||||
enableHiding: false,
|
enableHiding: false,
|
||||||
@@ -297,7 +298,8 @@ export function UrlsDataTable({ data }: UrlsDataTableProps) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const tableColumns = React.useMemo(() => [...columns, actionRow], [actionRow])
|
return [...columns, actionRow]
|
||||||
|
}, [handleCopy, handleDelete])
|
||||||
|
|
||||||
const table = useReactTable({
|
const table = useReactTable({
|
||||||
data,
|
data,
|
||||||
|
|||||||
Reference in New Issue
Block a user