feat(medusa): Add endpoints specific to DiscountConditions (#1355)

This commit is contained in:
Oliver Windall Juhl authored and GitHub committed 2022-05-13 12:42:23 +02:00
1 parent a69b52e031
commit 9ca45ea492
20 files changed
+1433 -159

No files matched your search

@@ -13,6 +13,7 @@ import faker from "faker"
import { Connection } from "typeorm"
export type DiscuntConditionFactoryData = {
id?: string
rule_id: string
type: DiscountConditionType
operator: DiscountConditionOperator
@@ -93,11 +94,17 @@ export const simpleDiscountConditionFactory = async (
resources = data.customer_groups
}
const condToSave = manager.create(DiscountCondition, {
const toCreate = {
type: data.type,
operator: data.operator,
discount_rule_id: data.rule_id,
})
}
if (data.id) {
toCreate["id"] = data.id
}
const condToSave = manager.create(DiscountCondition, toCreate)
const { conditionTable, resourceKey } = getJoinTableResourceIdentifiers(
data.type