Parcourir la source

Create sample custom MI field

master
Immanuel Onyeka il y a 1 an
Parent
révision
84d6807b94
2 fichiers modifiés avec 34 ajouts et 8 suppressions
  1. +20
    -8
      components/new.vue
  2. +14
    -0
      skouter.go

+ 20
- 8
components/new.vue Voir le fichier

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


<section class="form radios"> <section class="form radios">
<h3>Mortgage Insurance</h3> <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>


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


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


function generate() { function generate() {
this.errors = this.validate() 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() { function validate() {


+ 14
- 0
skouter.go Voir le fichier

@@ -863,6 +863,16 @@ func createUser(w http.ResponseWriter, db *sql.DB, r *http.Request) {
json.NewEncoder(w).Encode(user) 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) { func api(w http.ResponseWriter, r *http.Request) {
var args []string var args []string


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


db.Close() db.Close()


Chargement…
Annuler
Enregistrer