import { client } from '@operato/graphql';
import gql from 'graphql-tag';
import { showToast } from '../../../shared/utils/alert';
export const getIssueHistoriesByPowerPlantId = async (powerPlantId, fromDate, toDate, pagination) => {
    const response = await client.query({
        query: gql `
      query IssueHistories(
        $powerPlantId: String!
        $fromDate: String!
        $toDate: String!
        $page: Float!
        $limit: Float!
      ) {
        issueHistories(powerPlantId: $powerPlantId, fromDate: $fromDate, toDate: $toDate, page: $page, limit: $limit) {
          id
          inverter_no
          collected_at
          com
          run
          fault
        }

        issueHistorySummary(powerPlantId: $powerPlantId, fromDate: $fromDate, toDate: $toDate) {
          count
          com
          run
        }
      }
    `,
        variables: {
            powerPlantId,
            fromDate,
            toDate,
            page: pagination.page,
            limit: pagination.limit
        }
    });
    if (response.errors) {
        showToast('요청에 실패하였습니다');
        return { status: false, data: { issueHistories: [], issueHistorySummary: {} } };
    }
    return {
        status: true,
        data: {
            issueHistories: response.data.issueHistories,
            issueHistorySummary: response.data.issueHistorySummary
        }
    };
};
//# sourceMappingURL=query.js.map