import { createApi } from "@reduxjs/toolkit/query/react";
import baseQueryWithReauth from "./baseQuery";

export interface KautilyaPageResponse {
  success: boolean;
  status: number;
  message: string;
  data: {
    hero_sections: {
      id: string;
      background_image_url: string;
      background_image_alt_text: string;
      headline: string;
      subtext: string;
      cta_text: string;
      cta_destination: string;
    };
    our_story: {
      id: string;
      tag: string;
      title: string;
      content: string;
      image_url: string;
    };
    why_choose_us: {
      id: string;
      tag: string;
      title: string;
      description: string;
      cards: Array<{
        id: string;
        title: string;
        description: string;
        image_url: string;
        icon: string;
        display_order: number;
        bullets: Array<{
          id: string;
          text: string;
        }>;
      }>;
    };
    facility_features: {
      id: string;
      title: string;
      description: string;
      features: Array<{
        id: string;
        title: string;
        description: string;
        image_url: string;
        sub_title: string;
        sub_description: string;
        display_order: number;
        points: Array<{
          id: string;
          text: string;
        }>;
      }>;
    };
    visual_tour: {
      id: string;
      title: string;
      description: string;
      categories: Array<{
        id: string;
        name: string;
        display_order: number;
        images: Array<{
          id: string;
          image_url: string;
          title: string;
          subtitle: string;
          display_order: number;
        }>;
      }>;
    };
    daily_experience: {
      id: string;
      title: string;
      description: string;
      items: Array<{
        id: string;
        label: string;
        title: string;
        description: string;
        image_url: string;
        display_order: number;
      }>;
    };
    cta_section: {
      id: string;
      background_image_url: string;
      text: string;
      cta_text: string;
      cta_destination: string;
      description: string;
    };
  };
  errors: any;
  correlation_id: string;
}

export const learningFacilityApi = createApi({
  reducerPath: "learningFacilityApi",
  baseQuery: baseQueryWithReauth,
  tagTypes: ["KautilyaPage"],
  endpoints: (builder) => ({
    getKautilyaPage: builder.query<
      KautilyaPageResponse["data"],
      { }
    >({
      query: ({  }) => ({
        url: "/admin/kautilya-page/get",
     }),
      transformResponse: (response: KautilyaPageResponse) => response.data,
      providesTags: [{ type: "KautilyaPage", id: "LIST" }],
    }),
  }),
});

export const { useGetKautilyaPageQuery } = learningFacilityApi;