Skip to content

⚡️⚡️⚡️ Self-hosted collaborative bookmark manager to collect, read, annotate, and fully preserve what matters, all in one place.

change routes and add todos

Isaac Wiseda0533ac3656
diff --git a/components/ModalContent/BulkEditLinksModal.tsx b/components/ModalContent/BulkEditLinksModal.tsx
index 9aff5fea..5896f6b9 100644
--- a/components/ModalContent/BulkEditLinksModal.tsx
+++ b/components/ModalContent/BulkEditLinksModal.tsx
@@ -13,6 +13,7 @@ type Props = {
onClose: Function;
};
+// TODO: Make this work
export default function EditLinkModal({ onClose }: Props) {
const { updateLink, updateLinksById } = useLinkStore();
const [submitLoader, setSubmitLoader] = useState(false);
diff --git a/lib/api/controllers/links/bulk/updateLinksById.ts b/lib/api/controllers/links/bulk/updateLinksById.ts
index bdc2e2d3..76ca3467 100644
--- a/lib/api/controllers/links/bulk/updateLinksById.ts
+++ b/lib/api/controllers/links/bulk/updateLinksById.ts
@@ -3,6 +3,7 @@ import { prisma } from "@/lib/api/db";
import getPermission from "@/lib/api/getPermission";
import { UsersAndCollections } from "@prisma/client";
+// Need to fix this
export default async function updateLinksById(userId: number, linkIds: number[], data: LinkIncludingShortenedCollectionAndTags) {
if (!linkIds || linkIds.length === 0) {
return { response: "Please choose valid links.", status: 401 };
diff --git a/pages/api/v1/links/index.ts b/pages/api/v1/links/index.ts
index 58a352ae..8e58bac8 100644
--- a/pages/api/v1/links/index.ts
+++ b/pages/api/v1/links/index.ts
@@ -3,6 +3,8 @@ import getLinks from "@/lib/api/controllers/links/getLinks";
import postLink from "@/lib/api/controllers/links/postLink";
import { LinkRequestQuery } from "@/types/global";
import verifyUser from "@/lib/api/verifyUser";
+import deleteLinksById from "@/lib/api/controllers/links/bulk/deleteLinksById";
+import updateLinksById from "@/lib/api/controllers/links/bulk/updateLinksById";
export default async function links(req: NextApiRequest, res: NextApiResponse) {
const user = await verifyUser({ req, res });
@@ -39,5 +41,15 @@ export default async function links(req: NextApiRequest, res: NextApiResponse) {
return res.status(newlink.status).json({
response: newlink.response,
});
+ } else if (req.method === "PUT") {
+ const updated = await updateLinksById(user.id, req.body.linkIds, req.body.data);
+ return res.status(updated.status).json({
+ response: updated.response,
+ });
+ } else if (req.method === "DELETE") {
+ const deleted = await deleteLinksById(user.id, req.body.linkIds);
+ return res.status(deleted.status).json({
+ response: deleted.response,
+ });
}
}
diff --git a/store/links.ts b/store/links.ts
index 89c4f699..00fda9db 100644
--- a/store/links.ts
+++ b/store/links.ts
@@ -129,7 +129,7 @@ const useLinkStore = create<LinkStore>()((set) => ({
return { ok: response.ok, data: data.response };
},
updateLinksById: async (linkIds, data) => {
- const response = await fetch("/api/v1/links/bulk", {
+ const response = await fetch("/api/v1/links", {
body: JSON.stringify({ linkIds, data }),
headers: {
"Content-Type": "application/json",
@@ -172,7 +172,7 @@ const useLinkStore = create<LinkStore>()((set) => ({
return { ok: response.ok, data: data.response };
},
deleteLinksById: async (linkIds: number[]) => {
- const response = await fetch("/api/v1/links/bulk", {
+ const response = await fetch("/api/v1/links", {
body: JSON.stringify({ linkIds }),
headers: {
"Content-Type": "application/json",