From aec8b7201c4e444f7a4c2152609b2dd40fbb2078 Mon Sep 17 00:00:00 2001 From: Eva Decker Date: Sun, 1 Dec 2024 23:08:26 -0500 Subject: [PATCH] Update deletion naming --- convex/forms.ts | 2 +- convex/questFields.ts | 2 +- convex/questions.test.ts | 4 ++-- convex/questions.ts | 2 +- convex/quests.ts | 2 +- convex/topics.test.ts | 4 ++-- convex/topics.ts | 2 +- convex/userQuests.ts | 2 +- src/routes/_authenticated/_home/quests.$questId.index.tsx | 4 ++-- src/routes/_authenticated/admin/forms/index.tsx | 4 ++-- src/routes/_authenticated/admin/quests/index.tsx | 4 ++-- 11 files changed, 16 insertions(+), 16 deletions(-) diff --git a/convex/forms.ts b/convex/forms.ts index d11e76f..ff973df 100644 --- a/convex/forms.ts +++ b/convex/forms.ts @@ -112,7 +112,7 @@ export const undoSoftDelete = userMutation({ }, }); -export const permanentlyDelete = userMutation({ +export const deleteForever = userMutation({ args: { formId: v.id("forms") }, handler: async (ctx, args) => { // TODO: Delete form references in other tables diff --git a/convex/questFields.ts b/convex/questFields.ts index ed6ccbe..2fe3410 100644 --- a/convex/questFields.ts +++ b/convex/questFields.ts @@ -10,7 +10,7 @@ export const getAll = query({ }, }); -export const getManyById = query({ +export const getByIds = query({ args: { fieldIds: v.array(v.id("questFields")) }, handler: async (ctx, args) => { const fields = await Promise.all( diff --git a/convex/questions.test.ts b/convex/questions.test.ts index df7d95d..ca7f7b8 100644 --- a/convex/questions.test.ts +++ b/convex/questions.test.ts @@ -119,7 +119,7 @@ describe("questions", () => { expect(createdQuestion?.topics).toContain(topicId); // Delete the question - await t.mutation(api.questions.permanentlyDelete, { + await t.mutation(api.questions.deleteForever, { questionId, }); @@ -163,7 +163,7 @@ describe("questions", () => { // Attempt to delete the question await expect( - t.mutation(api.questions.permanentlyDelete, { + t.mutation(api.questions.deleteForever, { questionId, }), ).rejects.toThrowError( diff --git a/convex/questions.ts b/convex/questions.ts index 4494556..37ccb6e 100644 --- a/convex/questions.ts +++ b/convex/questions.ts @@ -42,7 +42,7 @@ export const update = mutation({ }, }); -export const permanentlyDelete = mutation({ +export const deleteForever = mutation({ args: { questionId: v.id("questions") }, handler: async (ctx, { questionId }) => { const question = await ctx.db.get(questionId); diff --git a/convex/quests.ts b/convex/quests.ts index 532ba31..76cc00d 100644 --- a/convex/quests.ts +++ b/convex/quests.ts @@ -148,7 +148,7 @@ export const undoSoftDelete = userMutation({ }, }); -export const permanentlyDelete = userMutation({ +export const deleteForever = userMutation({ args: { questId: v.id("quests") }, handler: async (ctx, args) => { // Delete userQuests diff --git a/convex/topics.test.ts b/convex/topics.test.ts index bb44c18..756dde3 100644 --- a/convex/topics.test.ts +++ b/convex/topics.test.ts @@ -53,7 +53,7 @@ describe("topics", () => { expect(createdTopic?.topic).toBe("Immigration"); // Delete the topic - await t.mutation(api.topics.permanentlyDelete, { + await t.mutation(api.topics.deleteForever, { topicId, }); @@ -100,7 +100,7 @@ describe("topics", () => { // Attempt to delete the topic await expect( - t.mutation(api.topics.permanentlyDelete, { + t.mutation(api.topics.deleteForever, { topicId, }), ).rejects.toThrowError("Cannot delete topic with questions"); diff --git a/convex/topics.ts b/convex/topics.ts index 5e9ec3a..ab66fdf 100644 --- a/convex/topics.ts +++ b/convex/topics.ts @@ -33,7 +33,7 @@ export const set = mutation({ }, }); -export const permanentlyDelete = mutation({ +export const deleteForever = mutation({ args: { topicId: v.id("topics") }, handler: async (ctx, { topicId }) => { // If there are any questions with this topic, throw an error diff --git a/convex/userQuests.ts b/convex/userQuests.ts index 15b7fc7..5e24f77 100644 --- a/convex/userQuests.ts +++ b/convex/userQuests.ts @@ -178,7 +178,7 @@ export const setStatus = userMutation({ }, }); -export const permanentlyDelete = userMutation({ +export const deleteForever = userMutation({ args: { questId: v.id("quests") }, returns: v.null(), handler: async (ctx, args) => { diff --git a/src/routes/_authenticated/_home/quests.$questId.index.tsx b/src/routes/_authenticated/_home/quests.$questId.index.tsx index 76ffc6b..c7127cc 100644 --- a/src/routes/_authenticated/_home/quests.$questId.index.tsx +++ b/src/routes/_authenticated/_home/quests.$questId.index.tsx @@ -43,14 +43,14 @@ function QuestDetailRoute() { }); const changeStatus = useMutation(api.userQuests.setStatus); - const permanentlyDelete = useMutation(api.userQuests.permanentlyDelete); + const deleteForever = useMutation(api.userQuests.deleteForever); const handleStatusChange = (status: Status) => { changeStatus({ questId: questId as Id<"quests">, status: status }); }; const handleRemoveQuest = (questId: Id<"quests">, title: string) => { - permanentlyDelete({ questId }).then(() => { + deleteForever({ questId }).then(() => { toast(`Removed ${title} quest`); navigate({ to: "/" }); }); diff --git a/src/routes/_authenticated/admin/forms/index.tsx b/src/routes/_authenticated/admin/forms/index.tsx index eb3e6d6..d70a0e2 100644 --- a/src/routes/_authenticated/admin/forms/index.tsx +++ b/src/routes/_authenticated/admin/forms/index.tsx @@ -163,7 +163,7 @@ const FormTableRow = ({ form }: { form: DataModel["forms"]["document"] }) => { const formUrl = useQuery(api.forms.getURL, { formId: form._id }); const deleteForm = useMutation(api.forms.softDelete); const undeleteForm = useMutation(api.forms.undoSoftDelete); - const permanentlyDeleteForm = useMutation(api.forms.permanentlyDelete); + const deleteForeverForm = useMutation(api.forms.deleteForever); return ( { {/* TODO: Add modal */} permanentlyDeleteForm({ formId: form._id })} + onAction={() => deleteForeverForm({ formId: form._id })} > Permanently Delete diff --git a/src/routes/_authenticated/admin/quests/index.tsx b/src/routes/_authenticated/admin/quests/index.tsx index 1483d91..50f3069 100644 --- a/src/routes/_authenticated/admin/quests/index.tsx +++ b/src/routes/_authenticated/admin/quests/index.tsx @@ -140,7 +140,7 @@ const QuestTableRow = ({ }); const softDelete = useMutation(api.quests.softDelete); const undelete = useMutation(api.quests.undoSoftDelete); - const permanentlyDelete = useMutation(api.quests.permanentlyDelete); + const deleteForever = useMutation(api.quests.deleteForever); const Category = () => { if (!quest.category) return; @@ -193,7 +193,7 @@ const QuestTableRow = ({ Undelete permanentlyDelete({ questId: quest._id })} + onAction={() => deleteForever({ questId: quest._id })} > Permanently Delete