import { client } from '@operato/graphql';
import gql from 'graphql-tag';
import { showToast } from '../../shared/utils/alert';
export const createPowerPlantGroup = async (powerPlantGroupName) => {
    const response = await client.query({
        query: gql `
      mutation CreatePowerPlantGroup($powerPlantGroupName: String!) {
        createPowerPlantGroup(powerPlantGroupName: $powerPlantGroupName) {
          id
          name
        }
      }
    `,
        variables: { powerPlantGroupName }
    });
    if (response.errors) {
        showToast('요청에 실패하였습니다');
        return { status: false, data: [] };
    }
    return {
        status: true,
        data: response.data.createPowerPlantGroup
    };
};
export const deletePowerPlantGroup = async (id) => {
    const response = await client.query({
        query: gql `
      mutation DeletePowerPlantGroup($id: String!) {
        deletePowerPlantGroup(id: $id)
      }
    `,
        variables: { id }
    });
    if (response.errors) {
        showToast('요청에 실패하였습니다');
        return { status: false };
    }
    return {
        status: true
    };
};
export const updatePowerPlantGroup = async (id, powerPlantGroupName) => {
    const response = await client.query({
        query: gql `
      mutation UpdatePowerPlantGroup($id: String!, $powerPlantGroupName: String!) {
        updatePowerPlantGroup(id: $id, powerPlantGroupName: $powerPlantGroupName) {
          id
          name
        }
      }
    `,
        variables: { id, powerPlantGroupName }
    });
    if (response.errors) {
        showToast('요청에 실패하였습니다');
        return { status: false, data: {} };
    }
    return {
        status: true,
        data: response.data.updatePowerPlantGroup
    };
};
export const applyPowerPlantGroup = async (powerPlantGroupId, powerPlantIds) => {
    const response = await client.query({
        query: gql `
      mutation CreatePowerPlantGroupBindings($powerPlantGroupId: String!, $powerPlantIds: [String!]!) {
        createPowerPlantGroupBindings(powerPlantGroupId: $powerPlantGroupId, powerPlantIds: $powerPlantIds)
      }
    `,
        variables: { powerPlantGroupId, powerPlantIds }
    });
    if (response.errors) {
        showToast('요청에 실패하였습니다');
        return { status: false };
    }
    return {
        status: true
    };
};
//# sourceMappingURL=mutation.js.map