chore(): Reorganize modules (#7210)
**What** Move all modules to the modules directory
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
import { CampaignBudgetType } from "@medusajs/utils"
|
||||
|
||||
export const defaultCampaignsData = [
|
||||
{
|
||||
id: "campaign-id-1",
|
||||
name: "campaign 1",
|
||||
description: "test description",
|
||||
currency: "USD",
|
||||
campaign_identifier: "test-1",
|
||||
starts_at: new Date("01/01/2023"),
|
||||
ends_at: new Date("01/01/2024"),
|
||||
budget: {
|
||||
type: CampaignBudgetType.SPEND,
|
||||
limit: 1000,
|
||||
used: 0,
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "campaign-id-2",
|
||||
name: "campaign 1",
|
||||
description: "test description",
|
||||
currency: "USD",
|
||||
campaign_identifier: "test-2",
|
||||
starts_at: new Date("01/01/2023"),
|
||||
ends_at: new Date("01/01/2024"),
|
||||
budget: {
|
||||
type: CampaignBudgetType.USAGE,
|
||||
limit: 1000,
|
||||
used: 0,
|
||||
},
|
||||
},
|
||||
]
|
||||
@@ -0,0 +1,23 @@
|
||||
import { CreateCampaignDTO } from "@medusajs/types"
|
||||
import { SqlEntityManager } from "@mikro-orm/postgresql"
|
||||
import { Campaign } from "@models"
|
||||
import { defaultCampaignsData } from "./data"
|
||||
|
||||
export * from "./data"
|
||||
|
||||
export async function createCampaigns(
|
||||
manager: SqlEntityManager,
|
||||
campaignsData: CreateCampaignDTO[] = defaultCampaignsData
|
||||
): Promise<Campaign[]> {
|
||||
const campaigns: Campaign[] = []
|
||||
|
||||
for (let campaignData of campaignsData) {
|
||||
let campaign = manager.create(Campaign, campaignData)
|
||||
|
||||
manager.persist(campaign)
|
||||
|
||||
await manager.flush()
|
||||
}
|
||||
|
||||
return campaigns
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import { PromotionType } from "@medusajs/utils"
|
||||
|
||||
export const defaultPromotionsData = [
|
||||
{
|
||||
id: "promotion-id-1",
|
||||
code: "PROMOTION_1",
|
||||
type: PromotionType.STANDARD,
|
||||
},
|
||||
{
|
||||
id: "promotion-id-2",
|
||||
code: "PROMOTION_2",
|
||||
type: PromotionType.STANDARD,
|
||||
},
|
||||
]
|
||||
@@ -0,0 +1,23 @@
|
||||
import { CreatePromotionDTO } from "@medusajs/types"
|
||||
import { SqlEntityManager } from "@mikro-orm/postgresql"
|
||||
import { Promotion } from "@models"
|
||||
import { defaultPromotionsData } from "./data"
|
||||
|
||||
export * from "./data"
|
||||
|
||||
export async function createPromotions(
|
||||
manager: SqlEntityManager,
|
||||
promotionsData: CreatePromotionDTO[] = defaultPromotionsData
|
||||
): Promise<Promotion[]> {
|
||||
const promotions: Promotion[] = []
|
||||
|
||||
for (let promotionData of promotionsData) {
|
||||
let promotion = manager.create(Promotion, promotionData)
|
||||
|
||||
manager.persist(promotion)
|
||||
await manager.flush()
|
||||
promotions.push(promotion)
|
||||
}
|
||||
|
||||
return promotions
|
||||
}
|
||||
Reference in New Issue
Block a user