import { factories } from "@strapi/strapi";

const POPULATE = {
  founder: {
    populate: {
      slides: { populate: { bio: true, image_8x9: true } },
    },
  },
  visionaryBeginnings: {
    populate: { bannerImage_3x1: true, mobileBannerImage_1x1: true },
  },
  aboutCompany: {
    populate: { image_1x1: true },
  },
  goldenRules: {
    populate: {
      cards: { populate: { icon_1x1: true } },
    },
  },
  timeline: {
    populate: {
      backgroundImage_3x2: true,
      years: {
        populate: {
          slides: { populate: { image_16x9: true } },
        },
      },
    },
  },
  gallery: {
    populate: {
      images: { populate: { src_3x2: true } },
    },
  },
  pastVentures: {
    populate: {
      ventures: { populate: { image_3x2: true, logo_1x1: true } },
    },
  },
  charitableTrust: {
    populate: {
      aidBulletIcon_1x1: true,
      aidItems: true,
      slides: { populate: { image_16x10: true } },
    },
  },
  philanthropic: {
    populate: {
      activities: { populate: { image_5x3: true } },
    },
  },
  testimonials: {
    populate: {
      testimonials: { populate: { avatar_1x1: true } },
    },
  },
};

export default factories.createCoreController("api::about.about", () => ({
  async find(ctx) {
    const data = await strapi
      .documents("api::about.about")!
      .findFirst({ populate: POPULATE });
    return this.transformResponse(data);
  },
}));
