apiVersion: scaffolder.backstage.io/v1beta3
kind: Template
metadata:
  name: order-chicken-burger
  title: Order Chicken Burger
  description: Create an order for a chicken burger with customizable size, sauces, and toppings.
spec:
  owner: kitchen-team
  type: main
  parameters:
    - title: Chicken Burger Order Configuration
      required:
        - size
      properties:
        size:
          type: string
          title: Size
          description: Choose the size of the chicken burger.
          enum:
            - small
            - medium
            - large
        sauces:
          type: array
          title: Sauces
          description: Choose sauces for the chicken burger.
          items:
            type: string
            enum:
              - mayonnaise
              - ketchup
              - barbecue
              - honey mustard
            enumNames:
              - Mayonnaise
              - Ketchup
              - Barbecue
              - Honey Mustard

          uniqueItems: true
          ui:widget: checkboxes    
        toppings:
          type: array
          title: Toppings
          description: Choose toppings for the chicken burger.
          items:
            type: string
            enum:
              - lettuce
              - tomato
              - onion
              - cheese
            enumNames:
              - Lettuce
              - Tomato
              - Onion
              - Cheese
          uniqueItems: true
          ui:widget: checkboxes
  steps:
    - id: submit-order
      name: Submit Order
      action: http:backstage:request
      input:
        method: 'POST'
        path: '/proxy/log-forwarding'
        headers:
          content-type: 'application/json'
        body:
          event:
            action: submit-order
            attributes:
              menu-item: chickeburger
              size: ${{ parameters.size }}
              sauces: ${{ parameters.sauces }}
              extras: ${{ parameters.extras }}

  output:
    orderResponse: '{{ steps["submit-order"].output.body }}'
    orderStatusCode: '{{ steps["submit-order"].output.code }}'
    orderHeaders: '{{ steps["submit-order"].output.headers }}'