import { createAsset } from "../invokers/assets";
import { createPlatform } from "../invokers/platform";
import { IPrivateResolverContext } from "../../handlers/private";

export default {
  createPlatform: async (obj, args, { groups }: IPrivateResolverContext) => {
    if (groups.indexOf("platform_managment") === -1) {
      return false;
    }

    args.input.icon = await createAsset.execute({
      dir: "PLATFORM_ICON",
      ...args.input.icon,
    });

    await createPlatform.execute(args.input);

    return true;
  },
};
