2023-05-19 15:22:48 -03:00
|
|
|
import { RequestHandler } from "express";
|
2024-05-28 13:52:27 +02:00
|
|
|
import { getJSONfromString } from "@/src/helpers/stringHelpers";
|
|
|
|
import { getAccountIdForRequest } from "@/src/services/loginService";
|
2024-06-02 18:35:06 +03:00
|
|
|
import { updateChallengeProgress } from "@/src/services/inventoryService";
|
|
|
|
import { IUpdateChallengeProgressRequest } from "@/src/types/requestTypes";
|
2024-05-28 13:52:27 +02:00
|
|
|
|
2024-06-20 11:47:21 +02:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
2024-05-28 13:52:27 +02:00
|
|
|
const updateChallengeProgressController: RequestHandler = async (req, res) => {
|
2024-06-24 12:37:28 +02:00
|
|
|
const payload = getJSONfromString(String(req.body)) as IUpdateChallengeProgressRequest;
|
2024-05-28 13:52:27 +02:00
|
|
|
const accountId = await getAccountIdForRequest(req);
|
2024-06-02 18:35:06 +03:00
|
|
|
|
|
|
|
await updateChallengeProgress(payload, accountId);
|
|
|
|
|
2024-05-28 13:52:27 +02:00
|
|
|
res.status(200).end();
|
2023-05-19 15:22:48 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
export { updateChallengeProgressController };
|