import { baseAPI } from '@/shared/api/base-api';

import { LoginParams, LoginResponse } from '../model/contracts/login.contract';

export const authenticationApi = baseAPI.injectEndpoints({
  endpoints: (builder) => ({
    login: builder.query<LoginResponse, LoginParams>({
      query: (data) => {
        return {
          method: 'POST',
          body: {
            type: data.type,
            phoneNumber: data.phoneNumber,
            cardNumber: data.cardNumber,
          },
          url: '/auth/login',
        };
      },
    }),
  }),
});

export const { useLazyLoginQuery } = authenticationApi;
