Merge pull request #219 from medusajs/hotfix/claim-items

hotfix: create claim item w/o tags/images
This commit is contained in:
Sebastian Rindom
2021-03-26 14:37:49 +01:00
committed by GitHub
+26 -18
View File
@@ -83,27 +83,35 @@ class ClaimItemService extends BaseService {
) )
} }
const claimTagRepo = manager.getCustomRepository(this.claimTagRepository_) let tagsToAdd = []
const tagsToAdd = await Promise.all( if (tags && tags.length) {
tags.map(async t => { const claimTagRepo = manager.getCustomRepository(
const normalized = t.trim().toLowerCase() this.claimTagRepository_
const existing = await claimTagRepo.findOne({ )
where: { value: normalized }, tagsToAdd = await Promise.all(
tags.map(async t => {
const normalized = t.trim().toLowerCase()
const existing = await claimTagRepo.findOne({
where: { value: normalized },
})
if (existing) {
return existing
}
return claimTagRepo.create({ value: normalized })
}) })
if (existing) { )
return existing }
}
return claimTagRepo.create({ value: normalized }) let imagesToAdd = []
if (images && images.length) {
const claimImgRepo = manager.getCustomRepository(
this.claimImageRepository_
)
imagesToAdd = images.map(url => {
return claimImgRepo.create({ url })
}) })
) }
const claimImgRepo = manager.getCustomRepository(
this.claimImageRepository_
)
const imagesToAdd = images.map(url => {
return claimImgRepo.create({ url })
})
const created = ciRepo.create({ const created = ciRepo.create({
...rest, ...rest,