Adding a new web api path that returns valid labels and then fetching from that within FlaggableElement. This allows FlaggableElement to fetch all its own data and remove the need to pipe labels through a series of components

This commit is contained in:
Keith Stevens
2023-01-10 20:57:42 +09:00
parent 0968d8add6
commit 747c3501d1
14 changed files with 63 additions and 65 deletions
@@ -23,7 +23,6 @@ const handler = async (req, res) => {
// Fetch the new task.
const task = await oasstApiClient.fetchTask(task_type, token);
const valid_labels = await oasstApiClient.fetch_valid_text();
// Store the task and link it to the user..
const registeredTask = await prisma.registeredTask.create({
@@ -37,9 +36,6 @@ const handler = async (req, res) => {
},
});
// Add the valid labels that can be used to flag messages in this Task
registeredTask["valid_labels"] = valid_labels;
// Send the results to the client.
res.status(200).json(registeredTask);
};
+23
View File
@@ -0,0 +1,23 @@
import { getToken } from "next-auth/jwt";
import { oasstApiClient } from "src/lib/oasst_api_client";
/**
* TODO
*/
const handler = async (req, res) => {
const token = await getToken({ req });
// Return nothing if the user isn't registered.
if (!token) {
res.status(401).end();
return;
}
// Fetch the new task.
const valid_labels = await oasstApiClient.fetch_valid_text();
// Send the results to the client.
res.status(200).json(valid_labels);
};
export default handler;