Vlad Chikalkin 9314cdd1cb
merge branch 'refactor-api' (#23)
* refactor customer api

* refactor slots api

* hooks/customers: use invalidateQueries

* refactor services api

* optimize hooks queryKey

* refactor orders api

* typo refactor hooks

* fix telegramId type (number)

* fix bot with new api

* rename customers masters & clients query

* fix useClientsQuery & useMastersQuery query

* new line after 'use client' & 'use server' directives
2025-05-20 14:27:51 +03:00

60 lines
1.2 KiB
GraphQL

fragment CustomerFields on Customer {
active
documentId
name
phone
photoUrl
role
telegramId
}
mutation CreateCustomer($name: String!, $telegramId: Long, $phone: String) {
createCustomer(data: { name: $name, telegramId: $telegramId, phone: $phone, role: client }) {
documentId
}
}
query GetCustomer($phone: String, $telegramId: Long) {
customers(filters: { or: [{ phone: { eq: $phone } }, { telegramId: { eq: $telegramId } }] }) {
...CustomerFields
}
}
query GetMasters($phone: String, $telegramId: Long, $documentId: ID) {
customers(
filters: {
or: [
{ phone: { eq: $phone } }
{ telegramId: { eq: $telegramId } }
{ documentId: { eq: $documentId } }
]
# and: [{ active: { eq: true } }]
}
) {
documentId
masters {
...CustomerFields
}
}
}
query GetClients($phone: String, $telegramId: Long) {
customers(
filters: {
or: [{ phone: { eq: $phone } }, { telegramId: { eq: $telegramId } }]
# and: [{ active: { eq: true } }]
}
) {
documentId
clients {
...CustomerFields
}
}
}
mutation UpdateCustomer($documentId: ID!, $data: CustomerInput!) {
updateCustomer(documentId: $documentId, data: $data) {
...CustomerFields
}
}