create-vendor-admin
unknown
tsx
a year ago
1.1 kB
14
Indexable
import {
createStep,
StepResponse,
} from "@medusajs/framework/workflows-sdk"
import VendorModuleService from "../../../../modules/vendor/service"
import { VENDOR_MODULE } from "../../../../modules/vendor"
type CreateVendorAdminStepInput = {
email: string
first_name?: string
last_name?: string
phone?: string
vendor_id: string
}
const createVendorAdminStep = createStep(
"create-vendor-admin-step",
async (
adminData: CreateVendorAdminStepInput,
{ container }
) => {
const vendorModuleService: VendorModuleService =
container.resolve(VENDOR_MODULE)
const vendorAdmin = await vendorModuleService.createVendorAdmins(
adminData
)
return new StepResponse(
vendorAdmin,
vendorAdmin.id
)
},
async (vendorAdminId, { container }) => {
if (!vendorAdminId) {
return
}
const vendorModuleService: VendorModuleService =
container.resolve(VENDOR_MODULE)
await vendorModuleService.deleteVendorAdmins(vendorAdminId)
}
)
export default createVendorAdminStep
Editor is loading...
Leave a Comment