feat: individual discounts migration
feat: loyalty panel routing chore: rename promo-codes module to loyalty
This commit is contained in:
parent
576979f14f
commit
07f15db851
14 changed files with 183 additions and 55 deletions
|
|
@ -8,10 +8,10 @@ const currency = require('./currency.resolver')
|
|||
const customer = require('./customer.resolver')
|
||||
const funding = require('./funding.resolver')
|
||||
const log = require('./log.resolver')
|
||||
const loyalty = require('./loyalty.resolver')
|
||||
const machine = require('./machine.resolver')
|
||||
const notification = require('./notification.resolver')
|
||||
const pairing = require('./pairing.resolver')
|
||||
const promo = require('./promo.resolver')
|
||||
const rates = require('./rates.resolver')
|
||||
const scalar = require('./scalar.resolver')
|
||||
const settings = require('./settings.resolver')
|
||||
|
|
@ -29,10 +29,10 @@ const resolvers = [
|
|||
customer,
|
||||
funding,
|
||||
log,
|
||||
loyalty,
|
||||
machine,
|
||||
notification,
|
||||
pairing,
|
||||
promo,
|
||||
rates,
|
||||
scalar,
|
||||
settings,
|
||||
|
|
|
|||
16
lib/new-admin/graphql/resolvers/loyalty.resolver.js
Normal file
16
lib/new-admin/graphql/resolvers/loyalty.resolver.js
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
const loyalty = require('../../../loyalty')
|
||||
|
||||
const resolvers = {
|
||||
Query: {
|
||||
promoCodes: () => loyalty.getAvailablePromoCodes(),
|
||||
individualDiscounts: () => loyalty.getAvailableIndividualDiscounts()
|
||||
},
|
||||
Mutation: {
|
||||
createPromoCode: (...[, { code, discount }]) => loyalty.createPromoCode(code, discount),
|
||||
deletePromoCode: (...[, { codeId }]) => loyalty.deletePromoCode(codeId),
|
||||
createIndividualDiscount: (...[, { identificationType, value, discount }]) => loyalty.createIndividualDiscount(identificationType, value, discount),
|
||||
deleteIndividualDiscount: (...[, { discountId }]) => loyalty.deleteIndividualDiscount(discountId)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = resolvers
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
const promoCodeManager = require('../../../promo-codes')
|
||||
|
||||
const resolvers = {
|
||||
Query: {
|
||||
promoCodes: () => promoCodeManager.getAvailablePromoCodes()
|
||||
},
|
||||
Mutation: {
|
||||
createPromoCode: (...[, { code, discount }]) => promoCodeManager.createPromoCode(code, discount),
|
||||
deletePromoCode: (...[, { codeId }]) => promoCodeManager.deletePromoCode(codeId)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = resolvers
|
||||
|
|
@ -8,10 +8,10 @@ const currency = require('./currency.type')
|
|||
const customer = require('./customer.type')
|
||||
const funding = require('./funding.type')
|
||||
const log = require('./log.type')
|
||||
const loyalty = require('./loyalty.type')
|
||||
const machine = require('./machine.type')
|
||||
const notification = require('./notification.type')
|
||||
const pairing = require('./pairing.type')
|
||||
const promo = require('./promo.type')
|
||||
const rates = require('./rates.type')
|
||||
const scalar = require('./scalar.type')
|
||||
const settings = require('./settings.type')
|
||||
|
|
@ -29,10 +29,10 @@ const types = [
|
|||
customer,
|
||||
funding,
|
||||
log,
|
||||
loyalty,
|
||||
machine,
|
||||
notification,
|
||||
pairing,
|
||||
promo,
|
||||
rates,
|
||||
scalar,
|
||||
settings,
|
||||
|
|
|
|||
35
lib/new-admin/graphql/types/loyalty.type.js
Normal file
35
lib/new-admin/graphql/types/loyalty.type.js
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
const { gql } = require('apollo-server-express')
|
||||
|
||||
const typeDef = gql`
|
||||
type IndividualDiscount {
|
||||
id: ID!
|
||||
identificationType: DiscountIdentificationType
|
||||
value: String!
|
||||
discount: Int
|
||||
}
|
||||
|
||||
enum DiscountIdentificationType {
|
||||
phone
|
||||
idCard
|
||||
}
|
||||
|
||||
type PromoCode {
|
||||
id: ID!
|
||||
code: String!
|
||||
discount: Int
|
||||
}
|
||||
|
||||
type Query {
|
||||
promoCodes: [PromoCode] @auth
|
||||
individualDiscounts: [IndividualDiscount] @auth
|
||||
}
|
||||
|
||||
type Mutation {
|
||||
createPromoCode(code: String!, discount: Int!): PromoCode @auth
|
||||
deletePromoCode(codeId: ID!): PromoCode @auth
|
||||
createIndividualDiscount(identificationType: DiscountIdentificationType!, value: String!, discount: Int!): IndividualDiscount @auth
|
||||
deleteIndividualDiscount(discountId: ID!): IndividualDiscount @auth
|
||||
}
|
||||
`
|
||||
|
||||
module.exports = typeDef
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
const { gql } = require('apollo-server-express')
|
||||
|
||||
const typeDef = gql`
|
||||
type PromoCode {
|
||||
id: ID!
|
||||
code: String!
|
||||
discount: Int
|
||||
}
|
||||
|
||||
type Query {
|
||||
promoCodes: [PromoCode] @auth
|
||||
}
|
||||
|
||||
type Mutation {
|
||||
createPromoCode(code: String!, discount: Int!): PromoCode @auth
|
||||
deletePromoCode(codeId: ID!): PromoCode @auth
|
||||
}
|
||||
`
|
||||
|
||||
module.exports = typeDef
|
||||
Loading…
Add table
Add a link
Reference in a new issue