{{define "assignment_form"}}
<h2>{{if .Assignment}}Edit assignment{{else}}New assignment{{end}}</h2>
<form hx-post="{{if .Assignment}}/assignments/{{.AssignID}}{{else}}/assignments{{end}}" hx-target="#main">
  <input type="hidden" name="company_id" value="{{.CompanyID}}">
  <p><label>Name<br><input name="name" value="{{with .Assignment}}{{.Name}}{{end}}" required></label></p>
  <p><label>Description<br><textarea name="description" rows="3">{{with .Assignment}}{{.Description}}{{end}}</textarea></label></p>
  <p><label>Hourly rate (DKK)<br><input name="hourly_rate" type="number" step="0.01" value="{{with .Assignment}}{{money .HourlyRate}}{{end}}"></label>
     <br><small class="muted">Leave 0 to use the company's default rate.</small></p>
  {{if .Assignment}}
  <p><label>Status<br>
    <select name="status">
      <option value="active" {{if eq .Assignment.Status "active"}}selected{{end}}>active</option>
      <option value="archived" {{if eq .Assignment.Status "archived"}}selected{{end}}>archived</option>
    </select></label></p>
  {{end}}
  <p>
    <button type="submit">Save</button>
    <button type="button"
            hx-get="/main?company_id={{.CompanyID}}{{if .Assignment}}&assignment_id={{.AssignID}}{{end}}"
            hx-target="#main">Cancel</button>
  </p>
</form>
{{end}}
