import { When } from '@cucumber/cucumber' import type { PerausetWorld } from '../support/world.js' When('I create a retreat {string} with slug {string} from {string} to {string}', async function (this: PerausetWorld, name: string, slug: string, startAt: string, endAt: string) { await this.post('/retreats', { slug, name, startAt, endAt, }) }) When('I list retreats', async function (this: PerausetWorld) { await this.get('/retreats') }) When('I update the retreat with name {string} and capacity {int}', async function (this: PerausetWorld, name: string, capacity: number) { const retreatId = (this as any).retreatId await this.put(`/retreats/${retreatId}`, { retreatId, name, capacity, }) }) When('I publish the retreat', async function (this: PerausetWorld) { const retreatId = (this as any).retreatId await this.post(`/retreats/${retreatId}/publish`, { retreatId, }) }) When('I add a person {string} with role {string} to the retreat', async function (this: PerausetWorld, fullName: string, roleType: string) { const retreatId = (this as any).retreatId await this.post(`/retreats/${retreatId}/persons`, { retreatId, fullName, roleType, email: `${fullName.toLowerCase().replace(/\s+/g, '.')}@test.org`, }) }) When('I add a schedule item {string} from {string} to {string} at {string}', async function (this: PerausetWorld, title: string, startsAt: string, endsAt: string, location: string) { const retreatId = (this as any).retreatId await this.post(`/retreats/${retreatId}/schedule`, { retreatId, title, startsAt, endsAt, location, }) }) When('I cancel the retreat', async function (this: PerausetWorld) { const retreatId = (this as any).retreatId await this.post(`/retreats/${retreatId}/cancel`, { retreatId, }) })