import { client } from '@operato/graphql';
import gql from 'graphql-tag';
import { showToast } from '../../shared/utils/alert';
export const getPowerPlantGroups = async () => {
    const response = await client.query({
        query: gql `
      query PowerPlantGroups {
        powerPlantGroups {
          items {
            id
            name
            powerPlantCount
          }
          total
        }
      }
    `
    });
    if (response.errors) {
        showToast('요청에 실패하였습니다');
        return { status: false, data: { items: [], total: 0 } };
    }
    return {
        status: true,
        data: {
            items: response.data.powerPlantGroups.items,
            total: response.data.powerPlantGroups.total
        }
    };
};
export const getPowerPlantListByPowerPlantGroupId = async (powerPlantGroupId) => {
    const response = await client.query({
        query: gql `
      query PowerPlantListByPowerPlantGroupId($powerPlantGroupId: String!) {
        powerPlantListByPowerPlantGroupId(powerPlantGroupId: $powerPlantGroupId) {
          id
          domain {
            id
          }
          powerPlantGroup {
            id
          }
        }
      }
    `,
        variables: { powerPlantGroupId }
    });
    if (response.errors) {
        showToast('요청에 실패하였습니다');
        return { status: false, data: [] };
    }
    return {
        status: true,
        data: response.data.powerPlantListByPowerPlantGroupId
    };
};
//# sourceMappingURL=query.js.map