import { NextResponse } from 'next/server'
import { createFormation,deleteFormation,getAllFormation } from '@/methods/formationMethods'


export async function POST(request: Request) {
    const body = await request.json()
    const{titre,description,prix} = body

    const result = await createFormation(titre,description,prix)   
    return NextResponse.json(result, { status: 201 })
}

export async function GET(){
    const result = await getAllFormation()
    return NextResponse.json(result, { status: 200 })
}

export async function DELETE(request : Request){
    const body = await request.json()
    const {id } = body
    const result = await deleteFormation(id)

    return NextResponse.json(result,{status : 200})
}
