diff --git a/components/DashboardItem.tsx b/components/DashboardItem.tsx index d255c4b..efc1303 100644 --- a/components/DashboardItem.tsx +++ b/components/DashboardItem.tsx @@ -14,12 +14,7 @@ export default function dashboardItem({

{name}

-

- {value < 1000 ? value : (value / 1000).toFixed(1) + "k"} -

-

- {value} -

+

{value || 0}

); diff --git a/components/LinkViews/LinkComponents/LinkActions.tsx b/components/LinkViews/LinkComponents/LinkActions.tsx index 2076932..acd651d 100644 --- a/components/LinkViews/LinkComponents/LinkActions.tsx +++ b/components/LinkViews/LinkComponents/LinkActions.tsx @@ -7,12 +7,12 @@ import usePermissions from "@/hooks/usePermissions"; import DeleteLinkModal from "@/components/ModalContent/DeleteLinkModal"; import { dropdownTriggerer } from "@/lib/client/utils"; import { useTranslation } from "next-i18next"; -import { useUser } from "@/hooks/store/user"; -import { useDeleteLink, useGetLink, useUpdateLink } from "@/hooks/store/links"; +import { useDeleteLink, useGetLink } from "@/hooks/store/links"; import toast from "react-hot-toast"; import LinkModal from "@/components/ModalContent/LinkModal"; import { useRouter } from "next/router"; import clsx from "clsx"; +import usePinLink from "@/lib/client/pinLink"; type Props = { link: LinkIncludingShortenedCollectionAndTags; @@ -27,41 +27,14 @@ export default function LinkActions({ link, className, btnStyle }: Props) { const permissions = usePermissions(link.collection.id as number); const getLink = useGetLink(); + const pinLink = usePinLink(); + const [editLinkModal, setEditLinkModal] = useState(false); const [linkModal, setLinkModal] = useState(false); const [deleteLinkModal, setDeleteLinkModal] = useState(false); - const { data: user = {} } = useUser(); - - const updateLink = useUpdateLink(); const deleteLink = useDeleteLink(); - const pinLink = async () => { - const isAlreadyPinned = link?.pinnedBy && link.pinnedBy[0] ? true : false; - - const load = toast.loading(t("updating")); - - await updateLink.mutateAsync( - { - ...link, - pinnedBy: isAlreadyPinned ? [{ id: undefined }] : [{ id: user.id }], - }, - { - onSettled: (data, error) => { - toast.dismiss(load); - - if (error) { - toast.error(error.message); - } else { - toast.success( - isAlreadyPinned ? t("link_unpinned") : t("link_pinned") - ); - } - }, - } - ); - }; - const updateArchive = async () => { const load = toast.loading(t("sending_request")); @@ -103,7 +76,7 @@ export default function LinkActions({ link, className, btnStyle }: Props) { ) : (
@@ -117,7 +90,7 @@ export default function LinkActions({ link, className, btnStyle }: Props) {