"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.QUERY_GET_PROFILE_USER = exports.GET_CROSS_SCHOOL_ACCESS_V3 = exports.GET_SCHOOL_V3 = exports.GET_PERMISSION_DETAIL_USER_V3 = exports.getCampaignNameV3 = exports.querySearchGlobalV3 = exports.getTuitionDebtRecordByUserCodeV3 = exports.getUserInfo = void 0;
const constants_1 = require("../utils/constants");
exports.getUserInfo = `
  query MyQuery($userId: Int) {
    users(where: { id: { _eq: $userId } }) {
      id
      email
      phone_number
      full_name
      school_id
      school {
        educational_levels(where: { deleted_at: { _is_null: true } }) {
          code
        }
        school_name_id
        email
        id
        phone
        name
        school_name {
          name
          group_id
        }
      }
      user_roles(where: { is_active: { _eq: true }, deleted_at: { _is_null: true } }) {
        role_id
        role {
          name
          role_code
        }
      }
    }
  }
`;
exports.getTuitionDebtRecordByUserCodeV3 = `
  query GetTuitionDebtRecordByUserCode($user_code: String, $school_year_id: Int, $school_id: Int) {
    tuition_fee_debt_record(
      order_by: { school_term: {start_at: asc} }
      where: {
        deleted_at: { _is_null: true }
        school_id: { _eq: $school_id }
        user_code: { _eq: $user_code }
        school_term: { school_year_id: { _eq: $school_year_id } }
      }
    ) {
      total_promotion_service
      total_payment
      total_promotion_tuition_policy
      total_promotion_tuition_scholar_ship
      total_promotion_tuition_seniority
      total_promotion_early
      total_promotion_admission
      total_required_service
      total_not_required_service
      total_tuition
      last_period_debt_balance
      last_period_credit_balance
      status
      last_credit_balance
      last_debt_balance
      total_refund
      total_adjustment_refund
      total_adjustment_additional
      id
      is_locked
      status
      school_term {
        school_year {
          name
          code
        }
        name
        code
        coefficient
        id
      }
      profile_student {
        tuition_notice_delivered_emails(order_by: { created_at: desc }) {
          link_pdf_cdn
          tuition_notice_campaign {
            school_term_id
          }
        }
      }
      user_code
    }
    tuition_fee_debt_record_by_month(
      order_by: { school_month: {start_date: asc} }
      where: {
        deleted_at: { _is_null: true }
        school_id: { _eq: $school_id }
        user_code: { _eq: $user_code }
        school_month: { school_term: { school_year_id: { _eq: $school_year_id } } }
      }
    ) {
      total_promotion_service
      total_payment
      total_promotion_tuition_policy
      total_promotion_tuition_scholar_ship
      total_promotion_tuition_seniority
      total_promotion_early
      total_promotion_admission
      total_required_service
      total_not_required_service
      total_tuition
      last_period_debt_balance
      last_period_credit_balance
      status
      last_credit_balance
      last_debt_balance
      total_refund
      total_adjustment_refund
      total_adjustment_additional
      id
      is_locked
      status
      school_month {
        name
      }
      user_code
    }
  }
`;
exports.querySearchGlobalV3 = `
  query QuerySearchGlobal($school_id: Int, $searchValue: String) {
    profile_student(
      where: {
        _or: [
          { user_code: { _eq: $searchValue } }
          { user: { school_id: { _eq: $school_id }, deleted_at: { _is_null: true }, full_name: { _eq: $searchValue } } }
        ]
      }
    ) {
      user_code
      user {
        id
        user_roles(where: { deleted_at: { _is_null: true }, user: { deleted_at: { _is_null: true } } }) {
          role {
            name
            role_code
          }
        }
        classroom_students {
          classroom {
            name
          }
        }
        id
        full_name
      }
    }

    profile_parent(
      where: {
        _or: [
          { user: { email: { _eq: $searchValue } } }
          { user: { full_name: { _eq: $searchValue } } }
          { user: { phone_number: { _eq: $searchValue } } }
        ]
        deleted_at: { _is_null: true }
        user: { school_id: { _eq: $school_id }, deleted_at: { _is_null: true } }
      }
    ) {
      user {
        id
        full_name
        user_roles(where: { deleted_at: { _is_null: true }, user: { deleted_at: { _is_null: true } } }) {
          role {
            name
            role_code
          }
        }
        relationship_users(
          where: {
            deleted_at: { _is_null: true }
            user: { deleted_at: { _is_null: true } }
            userByStudentId: { deleted_at: { _is_null: true } }
          }
        ) {
          userByStudentId {
            full_name
          }
        }
      }
    }

    profile_teacher(
      where: {
        _or: [
          { user_code: { _eq: $searchValue } }
          { user: { email: { _eq: $searchValue } } }
          { user: { full_name: { _eq: $searchValue } } }
          { user: { phone_number: { _eq: $searchValue } } }
        ]
        deleted_at: { _is_null: true }
        user: { school_id: { _eq: $school_id }, deleted_at: { _is_null: true } }
      }
    ) {
      user {
        id
        full_name
        email
        phone_number
        user_roles(where: { deleted_at: { _is_null: true }, user: { deleted_at: { _is_null: true } } }) {
          role {
            name
            role_code
          }
        }
        relationship_users(
          where: {
            deleted_at: { _is_null: true }
            user: { deleted_at: { _is_null: true } }
            userByStudentId: { deleted_at: { _is_null: true } }
          }
        ) {
          userByStudentId {
            full_name
          }
        }
      }
    }
  }
`;
exports.getCampaignNameV3 = `
  query MyQuery($id: Int!) {
    admissions_campaigns_by_pk(id: $id) {
      id
      campaign_name
    }
  }
`;
exports.GET_PERMISSION_DETAIL_USER_V3 = `
  query GetUserPermission($id: Int, $school_id: Int) {
    permission_user:permission_user_permission(
      where: {
        deleted_at: { _is_null: true }
        is_active: { _eq: true }
        school_id: { _eq: $school_id }
        user_id: { _eq: $id }
        permission: { deleted_at: { _is_null: true } }
      }
    ) {
      permission {
        code
        is_action
      }
    }
    permission_role:permission_role_permission(
      where: {
        deleted_at: { _is_null: true }
        is_active: { _eq: true }
        permission: { deleted_at: { _is_null: true } }
        role: {
          school_id: { _eq: $school_id }
          deleted_at: { _is_null: true }
          user_roles: { deleted_at: { _is_null: true }, is_active: { _eq: true }, user_id: { _eq: $id } }
        }
      }
    ) {
      permission {
        code
        is_action
      }
      id
    }
  }
`;
exports.GET_SCHOOL_V3 = `
  query GetSchool($group_id: Int, $school_name_id: Int, $email: String!) {
    school_name(where: { group_id: { _eq: $group_id }, deleted_at: { _is_null: true }, id: { _eq: $school_name_id } }) {
      schools(where: { deleted_at: { _is_null: true } }) {
        id
        name
      }
    }
    school(
      where: {
        users: {
          _or: [{deleted_at: {_is_null: true}}, {login_k12: {_eq: true}}]
          email: {_eq: $email}
        }
      }
    ) {
      id
      name
      school_name {
        id
        group_id
      }
      users(where: {email: {_eq: $email}}) {
        id
      }
    }
    setting_site(where: {deleted_at: { _is_null: true }, key_setting: { _eq: "${constants_1.KEY_QUERY_SETTING}" } }) {
      value_setting
      school_id
    }
  }
`;
exports.GET_CROSS_SCHOOL_ACCESS_V3 = `
  query GetCrossSchoolAccess($userIds: [Int!]) {
    allCoreSharedPermissionCrossSchoolAccesses(
      filter: {
        userId: { in: $userIds }
        deletedAt: { isNull: true }
      }
    ) {
      nodes {
        userId
        schoolId
        coreSharedPublicSchoolBySchoolId {
          id
          rowId
          name
          coreSharedPublicSchoolNameBySchoolNameIdAndSchoolId {
            id
            rowId
            groupId
          }
        }
      }
    }
  }
`;
exports.QUERY_GET_PROFILE_USER = `
  query MyQuery($user_id: Int!) {
      users_by_pk(id: $user_id) {
        avatar
        email
        full_name
        user_avatar {
          size_small
        }
        user_roles(where: {is_active: {_eq: true}, deleted_at: {_is_null: true}}) {
          role_id
          role {
            id
            name
            role_code
            is_admin
            is_master_role
          }
        }
        profile_staff {
          is_quit_job
          user_code
        }
        profile_teacher {
          is_quit_job
          user_code
        }
      }
    }
`;
//# sourceMappingURL=index.js.map