fix: make /packages/medusa/src/services/gift-card.js pass eslint (#533)
This commit is contained in:
1 parent
751d1edd62
commit
06ee5df9a0
2 files changed
+11
-9
No files matched your search
@@ -9,7 +9,6 @@
|
|||||||
/packages/medusa/src/services/event-bus.js
|
/packages/medusa/src/services/event-bus.js
|
||||||
/packages/medusa/src/services/fulfillment-provider.js
|
/packages/medusa/src/services/fulfillment-provider.js
|
||||||
/packages/medusa/src/services/fulfillment.js
|
/packages/medusa/src/services/fulfillment.js
|
||||||
/packages/medusa/src/services/gift-card.js
|
|
||||||
/packages/medusa/src/services/idempotency-key.js
|
/packages/medusa/src/services/idempotency-key.js
|
||||||
/packages/medusa/src/services/inventory.js
|
/packages/medusa/src/services/inventory.js
|
||||||
/packages/medusa/src/services/line-item.js
|
/packages/medusa/src/services/line-item.js
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { Brackets } from "typeorm"
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides layer to manipulate gift cards.
|
* Provides layer to manipulate gift cards.
|
||||||
* @implements BaseService
|
* @extends BaseService
|
||||||
*/
|
*/
|
||||||
class GiftCardService extends BaseService {
|
class GiftCardService extends BaseService {
|
||||||
static Events = {
|
static Events = {
|
||||||
@@ -101,7 +101,7 @@ class GiftCardService extends BaseService {
|
|||||||
.select(["gift_card.id"])
|
.select(["gift_card.id"])
|
||||||
.where(where)
|
.where(where)
|
||||||
.andWhere(
|
.andWhere(
|
||||||
new Brackets(qb => {
|
new Brackets((qb) => {
|
||||||
return qb
|
return qb
|
||||||
.where(`gift_card.code ILIKE :q`, { q: `%${q}%` })
|
.where(`gift_card.code ILIKE :q`, { q: `%${q}%` })
|
||||||
.orWhere(`display_id::varchar(255) ILIKE :dId`, { dId: `${q}` })
|
.orWhere(`display_id::varchar(255) ILIKE :dId`, { dId: `${q}` })
|
||||||
@@ -111,14 +111,14 @@ class GiftCardService extends BaseService {
|
|||||||
|
|
||||||
return giftCardRepo.findWithRelations(
|
return giftCardRepo.findWithRelations(
|
||||||
rels,
|
rels,
|
||||||
raw.map(i => i.id)
|
raw.map((i) => i.id)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
return giftCardRepo.findWithRelations(rels, query)
|
return giftCardRepo.findWithRelations(rels, query)
|
||||||
}
|
}
|
||||||
|
|
||||||
async createTransaction(data) {
|
async createTransaction(data) {
|
||||||
return this.atomicPhase_(async manager => {
|
return this.atomicPhase_(async (manager) => {
|
||||||
const gctRepo = manager.getCustomRepository(this.giftCardTransactionRepo_)
|
const gctRepo = manager.getCustomRepository(this.giftCardTransactionRepo_)
|
||||||
const created = gctRepo.create(data)
|
const created = gctRepo.create(data)
|
||||||
const saved = await gctRepo.save(created)
|
const saved = await gctRepo.save(created)
|
||||||
@@ -132,7 +132,7 @@ class GiftCardService extends BaseService {
|
|||||||
* @return {Promise<GiftCard>} the result of the create operation
|
* @return {Promise<GiftCard>} the result of the create operation
|
||||||
*/
|
*/
|
||||||
async create(giftCard) {
|
async create(giftCard) {
|
||||||
return this.atomicPhase_(async manager => {
|
return this.atomicPhase_(async (manager) => {
|
||||||
const giftCardRepo = manager.getCustomRepository(this.giftCardRepository_)
|
const giftCardRepo = manager.getCustomRepository(this.giftCardRepository_)
|
||||||
|
|
||||||
if (!giftCard.region_id) {
|
if (!giftCard.region_id) {
|
||||||
@@ -169,6 +169,7 @@ class GiftCardService extends BaseService {
|
|||||||
/**
|
/**
|
||||||
* Gets a gift card by id.
|
* Gets a gift card by id.
|
||||||
* @param {string} giftCardId - id of gift card to retrieve
|
* @param {string} giftCardId - id of gift card to retrieve
|
||||||
|
* @param {object} config - optional values to include with gift card query
|
||||||
* @return {Promise<GiftCard>} the gift card
|
* @return {Promise<GiftCard>} the gift card
|
||||||
*/
|
*/
|
||||||
async retrieve(giftCardId, config = {}) {
|
async retrieve(giftCardId, config = {}) {
|
||||||
@@ -244,7 +245,7 @@ class GiftCardService extends BaseService {
|
|||||||
* @return {Promise} the result of the update operation
|
* @return {Promise} the result of the update operation
|
||||||
*/
|
*/
|
||||||
async update(giftCardId, update) {
|
async update(giftCardId, update) {
|
||||||
return this.atomicPhase_(async manager => {
|
return this.atomicPhase_(async (manager) => {
|
||||||
const giftCardRepo = manager.getCustomRepository(this.giftCardRepository_)
|
const giftCardRepo = manager.getCustomRepository(this.giftCardRepository_)
|
||||||
|
|
||||||
const giftCard = await this.retrieve(giftCardId)
|
const giftCard = await this.retrieve(giftCardId)
|
||||||
@@ -285,12 +286,14 @@ class GiftCardService extends BaseService {
|
|||||||
* @return {Promise} the result of the delete operation
|
* @return {Promise} the result of the delete operation
|
||||||
*/
|
*/
|
||||||
async delete(giftCardId) {
|
async delete(giftCardId) {
|
||||||
return this.atomicPhase_(async manager => {
|
return this.atomicPhase_(async (manager) => {
|
||||||
const giftCardRepo = manager.getCustomRepository(this.giftCardRepository_)
|
const giftCardRepo = manager.getCustomRepository(this.giftCardRepository_)
|
||||||
|
|
||||||
const giftCard = await giftCardRepo.findOne({ where: { id: giftCardId } })
|
const giftCard = await giftCardRepo.findOne({ where: { id: giftCardId } })
|
||||||
|
|
||||||
if (!giftCard) return Promise.resolve()
|
if (!giftCard) {
|
||||||
|
return Promise.resolve()
|
||||||
|
}
|
||||||
|
|
||||||
await giftCardRepo.softRemove(giftCard)
|
await giftCardRepo.softRemove(giftCard)
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user