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
|
|
|
|
|
|
|
const updateChallengeProgressController: RequestHandler = async (req, res) => {
|
2024-06-02 18:35:06 +03:00
|
|
|
const payload: IUpdateChallengeProgressRequest = getJSONfromString(req.body.toString());
|
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 };
|