import axiosInstance from 'api/axios';
import { ADD_PASSPORT, PASSPORT_ME, SEND_PASSPORT } from 'api/URL';

export interface sendPassportPayload {
  fullName: string;
  birthDate: string;
  passportSerial: string;
  passportPin: string;
  passportFrontImage: string;
  passportBackImage: string;
}

export interface AddPassportPayload {
  fullName: string;
  birthDate: string;
  passportSerial: string;
  passportPin: string;
  passportFrontImage: string;
  passportBackImage: string;
}

export interface myPassport {
  fullName: string;
  passportSeries: string;
  passportPin: string;
  passportFrontImage: string;
  passportBackImage: string;
  address: string;
  phone: string;
  birthDate: string;
  availableLimit: number;
  active: boolean;
}

const passportApi = {
  async sendPassport(payload: sendPassportPayload) {
    const data = await axiosInstance.post(SEND_PASSPORT, payload);
    return data;
  },
  async getPassport(): Promise<myPassport[]> {
    const { data } = await axiosInstance.get<myPassport[]>(PASSPORT_ME);
    return data;
  },
  async addPassport(payload: AddPassportPayload) {
    const data = await axiosInstance.post(ADD_PASSPORT, payload);
    return data;
  },
};

export default passportApi;
