Skip to content

Commit

Permalink
Update deletion naming
Browse files Browse the repository at this point in the history
  • Loading branch information
evadecker committed Dec 2, 2024
1 parent a34a819 commit aec8b72
Show file tree
Hide file tree
Showing 11 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion convex/forms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion convex/questFields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions convex/questions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});

Expand Down Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion convex/questions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion convex/quests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions convex/topics.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});

Expand Down Expand Up @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion convex/topics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion convex/userQuests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
4 changes: 2 additions & 2 deletions src/routes/_authenticated/_home/quests.$questId.index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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: "/" });
});
Expand Down
4 changes: 2 additions & 2 deletions src/routes/_authenticated/admin/forms/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<TableRow
Expand Down Expand Up @@ -204,7 +204,7 @@ const FormTableRow = ({ form }: { form: DataModel["forms"]["document"] }) => {
</MenuItem>
{/* TODO: Add modal */}
<MenuItem
onAction={() => permanentlyDeleteForm({ formId: form._id })}
onAction={() => deleteForeverForm({ formId: form._id })}
>
Permanently Delete
</MenuItem>
Expand Down
4 changes: 2 additions & 2 deletions src/routes/_authenticated/admin/quests/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -193,7 +193,7 @@ const QuestTableRow = ({
Undelete
</MenuItem>
<MenuItem
onAction={() => permanentlyDelete({ questId: quest._id })}
onAction={() => deleteForever({ questId: quest._id })}
>
Permanently Delete
</MenuItem>
Expand Down

0 comments on commit aec8b72

Please sign in to comment.