import { gql } from "@apollo/client";

export const QUERY_ALL_ASSOCIATIONS = gql`
  query QUERY_ALL_ASSOCIATIONS {
    associations(order_by: { bodyshop: { shopname: asc } }) {
      id
      active
      bodyshop {
        shopname
      }
    }
  }
`;

export const UPDATE_ASSOCIATION = gql`
  mutation UPDATE_ASSOCIATION($assocId: uuid, $assocActive: Boolean) {
    update_associations(
      where: { id: { _eq: $assocId } }
      _set: { active: $assocActive }
    ) {
      returning {
        id
        active
        authlevel
        default_prod_list_view
      }
    }
  }
`;

export const UPDATE_ACTIVE_PROD_LIST_VIEW = gql`
  mutation UPDATE_ACTIVE_PROD_LIST_VIEW($assocId: uuid, $view: String) {
    update_associations(
      where: { id: { _eq: $assocId } }
      _set: { default_prod_list_view: $view }
    ) {
      returning {
        id
        default_prod_list_view
      }
    }
  }
`;
