import { factories } from "@strapi/strapi";

const POPULATE = {
  hero: { populate: { mobileBackgroundImage_9x16: true, desktopBackgroundImage_2x1: true } },
  about: { populate: { paragraphs: true } },
  productRange: {
    populate: {
      categories: {
        populate: {
          banners: { populate: { image_2x1: true, mobileImage_4x5: true } },
        },
      },
    },
  },
  stats: { populate: { stats: { populate: { vector_9x8: true } } } },
  process: {
    populate: {
      image_3x2: true,
      steps: {
        populate: {
          image_3x2: true,
        },
      },
    },
  },
};

export default factories.createCoreController("api::safl.safl", () => ({
  async find(ctx) {
    const data = await strapi
      .documents("api::safl.safl")!
      .findFirst({ populate: POPULATE });

    return this.transformResponse(data);
  },
}));
