import { request } from '@umijs/max';

export const _getStationList = async (): Promise<API.DefaultObjectResponse> => {
  return request('/api/v1/admin/setting/station/all', {
    method: 'get',
  });
};
export const _uploadStationImage = async (options: {
  filename: File;
  stationId: string;
}): Promise<API.DefaultObjectResponse> => {
  const { filename, stationId } = options;
  const formData = new FormData();
  formData.append('filename', filename);
  formData.append('stationId', stationId);
  return request('/api/v1/admin/setting/upload/station/image', {
    method: 'put',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data',
    },
  });
};

export const _updateConnectorStatus = async (options: {
  connectorId: string;
  status: string;
}): Promise<API.DefaultObjectResponse> => {
  const { connectorId, status } = options;
  return request(`/api/v1/admin/setting/station/connector/status`, {
    method: 'put',
    data: { status, connectorId },
  });
};

export const _updateStationPrice = async (options: {
  stationId: string;
  price: number;
}): Promise<API.DefaultObjectResponse> => {
  const { stationId, price } = options;
  return request(`/api/v1/admin/setting/price`, {
    method: 'put',
    data: { price, stationId },
  });
};

export const _syncData = async (): Promise<API.DefaultObjectResponse> => {
  return request('/api/v1/admin/setting/sync', {
    method: 'put',
  });
};
