import { api } from './api';

type GetSchoolsByIdResponse = {
    success: boolean,
    message: string,
    details: {
        docs:  CreateSchoolRequest[],
        pages: 1,
        total: 1
    }
}

type CreateSchoolRequest = {
    id?: string,
    name: string,
    address: string,
    phone: string,
    email: string,
    notes: string,
    status?: boolean
}
type CreateSchoolResponse = {
    success: boolean,
    message: string,
    result: CreateSchoolRequest
}
export const Schools = api.injectEndpoints({
    endpoints: (build) => ({
        CreateSchool: build.mutation<CreateSchoolResponse, CreateSchoolRequest>({
            query: (body) => ({
                url: 'school',
                method: 'POST',
                body,
            }),
            invalidatesTags: ['CreateSchool'],
        }),
        getSchoolss: build.query<GetSchoolsByIdResponse, any>({
            query: (params: any) => ({
                url: `/schools/showall`,
                method: 'GET',
                params,
            }),
            // providesTags: ['getSchool',CreateSchool],
        }),

    }),
});

export const {
    useCreateSchoolMutation
} = Schools;