Bladeren bron

Create sample custom MI field

master
Immanuel Onyeka 1 jaar geleden
bovenliggende
commit
84d6807b94
2 gewijzigde bestanden met toevoegingen van 34 en 8 verwijderingen
  1. +20
    -8
      components/new.vue
  2. +14
    -0
      skouter.go

+ 20
- 8
components/new.vue Bestand weergeven

@@ -159,14 +159,13 @@ v-model="estimate.transaction">

<section class="form radios">
<h3>Mortgage Insurance</h3>
<input type="radio" name="transaction_type" value="transaction"
@input="e => estimate.transaction = 0"
selected="estimate.transaction == 0">
<label>1.43% - National MI</label>
<input type="radio" name="transaction_type" value="refinance"
@input="e => estimate.transaction = 1"
selected="estimate.transaction == 1">
<label>0.73% - MGIC</label>
<input type="radio">
<span>
<label>Custom %</label>
<input type="text" :value="estimate.loans[sel].mi"
@input="e => estimate.loans[sel].mi = strip(e)"
selected="estimate.transaction == 0">
</span>
</section>

<section class="form inputs">
@@ -207,6 +206,7 @@ const example = {
pud: true, // Property under development
zip: '',
fees: [],
mi: 0
}

// The default loans on a new estimate
@@ -331,6 +331,18 @@ function setHousingDti(e) {

function generate() {
this.errors = this.validate()
if (this.errors.length) return
fetch(`/api/estimate`,
{
method: 'POST',
body: JSON.stringify( this.estimate ),
headers: {
"Accept": "application/json",
"Authorization": `Bearer ${token}`,
},
}
)
}

function validate() {


+ 14
- 0
skouter.go Bestand weergeven

@@ -863,6 +863,16 @@ func createUser(w http.ResponseWriter, db *sql.DB, r *http.Request) {
json.NewEncoder(w).Encode(user)
}

func createEstimate(w http.ResponseWriter, db *sql.DB, r *http.Request) {
var estimate Estimate
err := json.NewDecoder(r.Body).Decode(&estimate)
if err != nil { http.Error(w, "Invalid fields.", 422); return }

if err != nil { http.Error(w, "Error creating user.", 422); return }

json.NewEncoder(w).Encode(estimate)
}

func api(w http.ResponseWriter, r *http.Request) {
var args []string

@@ -914,6 +924,10 @@ func api(w http.ResponseWriter, r *http.Request) {
r.Method == http.MethodGet &&
guard(r, 1):
getFeesTemp(w, db, r)
case match(p, "/api/estimate", &args) &&
r.Method == http.MethodPost &&
guard(r, 1):
createEstimate(w, db, r)
}

db.Close()


Laden…
Annuleren
Opslaan