vchikalkin 5018560f29 feat(customer): implement banned customer check and enhance customer data handling
- Added `isCustomerBanned` function to determine if a customer is banned based on the `bannedUntil` field.
- Updated the `BaseService` to throw an error if a banned customer attempts to access certain functionalities.
- Enhanced the GraphQL operations to include the `bannedUntil` field in customer queries and mutations, improving data integrity and user experience.
- Integrated the `CheckBanned` component in the layout to manage banned customer states effectively.
2025-08-25 19:15:00 +03:00

69 lines
1.4 KiB
GraphQL

fragment CustomerFields on Customer {
active
bannedUntil
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, $documentId: ID) {
customers(
filters: {
or: [
{ phone: { eq: $phone } }
{ telegramId: { eq: $telegramId } }
{ documentId: { eq: $documentId } }
]
}
) {
...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
}
}