import { client } from '@operato/graphql';
import gql from 'graphql-tag';
import { showToast } from '../../shared/utils/alert';
export const QUERY_POWER_BILL_SUMMARY_BY_YEAR = `
  powerBillSummaryByYear(powerPlantId: $powerPlantId, year: $year) {
    yearMonth
    usageLight
    usageLightFee
    usageMid
    usageMidFee
    usageMax
    usageMaxFee
    totalFee
  }
`;
export const QUERY_EXPECTED_SOLAR_SAVING_FEE_BY_DATE = `
  expectedSolarSavingFeeByDate(powerPlantId: $powerPlantId, startDate: $startDate, endDate: $endDate, groupBy: $groupBy) {
    date
    value
  }
`;
export const QUERY_POWER_BILL_SUMMARY_BY_DATE = `
  powerBillSummaryByDate(powerPlantId: $powerPlantId, startDate: $startDate, endDate: $endDate) {
    usageLight
    usageMid
    usageMax
    totalUsage
  }
`;
export const getExpectedSolarSavingFeeByDate = async (powerPlantId, startDate, endDate, groupBy = 'YYYY-MM-DD') => {
    const response = await client.query({
        query: gql `
      query ExpectedSolarSavingFeeByDate(
        $powerPlantId: String!,
        $startDate: String!,
        $endDate: String!,
        $groupBy: String!
      ) {
        ${QUERY_EXPECTED_SOLAR_SAVING_FEE_BY_DATE}
      }
    `,
        variables: { powerPlantId, startDate, endDate, groupBy }
    });
    if (response.errors) {
        showToast('요청에 실패하였습니다');
        return [];
    }
    return response.data.expectedSolarSavingFeeByDate;
};
export const getPowerBillSummaryByDate = async (powerPlantId, startDate, endDate) => {
    const response = await client.query({
        query: gql `
      query PowerBillSummaryByDate($powerPlantId: String!, $startDate: String!, $endDate: String!) {
        ${QUERY_POWER_BILL_SUMMARY_BY_DATE}
      }
    `,
        variables: { powerPlantId, startDate, endDate }
    });
    if (response.errors) {
        showToast('요청에 실패하였습니다');
        return { usageLight: 0, usageMid: 0, usageMax: 0, totalUsage: 0 };
    }
    return response.data.powerBillSummaryByDate;
};
//# sourceMappingURL=query.js.map