Closes #712 a bit unsure about the inbox messages, but otherwise it should be working Reviewed-on: #1025
28 lines
1.1 KiB
TypeScript
28 lines
1.1 KiB
TypeScript
import { getJSONfromString } from "@/src/helpers/stringHelpers";
|
|
import { getInventory } from "@/src/services/inventoryService";
|
|
import { getAccountIdForRequest } from "@/src/services/loginService";
|
|
import { IIncentiveState } from "@/src/types/inventoryTypes/inventoryTypes";
|
|
import { RequestHandler } from "express";
|
|
|
|
export const startCollectibleEntryController: RequestHandler = async (req, res) => {
|
|
const accountId = await getAccountIdForRequest(req);
|
|
const inventory = await getInventory(accountId);
|
|
const request = getJSONfromString<IStartCollectibleEntryRequest>(String(req.body));
|
|
inventory.CollectibleSeries ??= [];
|
|
inventory.CollectibleSeries.push({
|
|
CollectibleType: request.target,
|
|
Count: 0,
|
|
Tracking: "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
|
|
ReqScans: request.reqScans,
|
|
IncentiveStates: request.other
|
|
});
|
|
await inventory.save();
|
|
res.status(200).end();
|
|
};
|
|
|
|
interface IStartCollectibleEntryRequest {
|
|
target: string;
|
|
reqScans: number;
|
|
other: IIncentiveState[];
|
|
}
|