Improve changing active shop profile methods to avoid multiple queries.

This commit is contained in:
Patrick Fic
2023-03-02 20:04:54 -08:00
parent 2415b4c2b4
commit 99d3943955
7 changed files with 62 additions and 27 deletions

View File

@@ -1,8 +1,11 @@
import { gql } from "@apollo/client";
export const QUERY_ALL_ASSOCIATIONS = gql`
query QUERY_ALL_ASSOCIATIONS {
associations(order_by: { bodyshop: { shopname: asc } }) {
query QUERY_ALL_ASSOCIATIONS($email: String) {
associations(
where: { useremail: { _eq: $email } }
order_by: { bodyshop: { shopname: asc } }
) {
id
active
bodyshop {
@@ -27,6 +30,30 @@ export const UPDATE_ASSOCIATION = gql`
}
}
`;
export const UPDATE_ACTIVE_ASSOCIATION = gql`
mutation UPDATE_ACTIVE_ASSOCIATION($newActiveAssocId: uuid) {
nweActive: update_associations(
where: { id: { _eq: $newActiveAssocId } }
_set: { active: true }
) {
returning {
id
shopid
active
}
}
inactive: update_associations(
where: { id: { _neq: $newActiveAssocId } }
_set: { active: false }
) {
returning {
id
shopid
active
}
}
}
`;
export const UPDATE_ACTIVE_PROD_LIST_VIEW = gql`
mutation UPDATE_ACTIVE_PROD_LIST_VIEW($assocId: uuid, $view: String) {

View File

@@ -12,6 +12,7 @@ export const QUERY_BODYSHOP = gql`
query QUERY_BODYSHOP {
bodyshops(where: { associations: { active: { _eq: true } } }) {
associations {
id
authlevel
useremail
default_prod_list_view