nsarrazin HF Staff commited on
Commit
152a297
·
unverified ·
1 Parent(s): a329d39

fix(tool): fix unfeature functionality

Browse files
src/routes/tools/[toolId]/+page.server.ts CHANGED
@@ -118,23 +118,23 @@ export const actions: Actions = {
118
  return fail(403, { error: true, message: "Permission denied" });
119
  }
120
 
121
- const assistant = await collections.assistants.findOne({
122
- _id: new ObjectId(params.assistantId),
123
  });
124
 
125
- if (!assistant) {
126
- return fail(404, { error: true, message: "Assistant not found" });
127
  }
128
 
129
- const result = await collections.assistants.updateOne(
130
- { _id: assistant._id },
131
  { $set: { featured: false } }
132
  );
133
 
134
  if (result.modifiedCount === 0) {
135
- return fail(500, { error: true, message: "Failed to unfeature assistant" });
136
  }
137
 
138
- return { from: "unfeature", ok: true, message: "Assistant unfeatured" };
139
  },
140
  };
 
118
  return fail(403, { error: true, message: "Permission denied" });
119
  }
120
 
121
+ const tool = await collections.tools.findOne({
122
+ _id: new ObjectId(params.toolId),
123
  });
124
 
125
+ if (!tool) {
126
+ return fail(404, { error: true, message: "Tool not found" });
127
  }
128
 
129
+ const result = await collections.tools.updateOne(
130
+ { _id: tool._id },
131
  { $set: { featured: false } }
132
  );
133
 
134
  if (result.modifiedCount === 0) {
135
+ return fail(500, { error: true, message: "Failed to unfeature tool" });
136
  }
137
 
138
+ return { from: "unfeature", ok: true, message: "Tool unfeatured" };
139
  },
140
  };