feat: abort building of a deco
All checks were successful
Build / build (22) (push) Successful in 36s
Build / build (20) (push) Successful in 51s
Build / build (18) (pull_request) Successful in 40s
Build / build (20) (pull_request) Successful in 52s
Build / build (22) (pull_request) Successful in 1m0s
Build / build (18) (push) Successful in 1m10s

This commit is contained in:
Sainan 2025-03-04 19:38:22 +01:00
parent e279a9369f
commit 4ac0f848ac

View File

@ -9,11 +9,19 @@ export const abortDojoComponentController: RequestHandler = async (req, res) =>
const guild = await getGuildForRequestEx(req, inventory); const guild = await getGuildForRequestEx(req, inventory);
const request = JSON.parse(String(req.body)) as IAbortDojoComponentRequest; const request = JSON.parse(String(req.body)) as IAbortDojoComponentRequest;
// TODO: Move already-contributed credits & items to the clan vault // TODO: Move already-contributed credits & items to the clan vault
guild.DojoComponents.pull({ _id: request.ComponentId }); if (request.DecoId) {
const component = guild.DojoComponents.id(request.ComponentId)!;
const decoIndex = component.Decos!.findIndex(x => x._id.equals(request.DecoId));
component.Decos!.splice(decoIndex, 1);
} else {
guild.DojoComponents.pull({ _id: request.ComponentId });
}
await guild.save(); await guild.save();
res.json(getDojoClient(guild, 0)); res.json(getDojoClient(guild, 0));
}; };
export interface IAbortDojoComponentRequest { interface IAbortDojoComponentRequest {
DecoType?: string;
ComponentId: string; ComponentId: string;
DecoId?: string;
} }