From b3cf840f882f43526d855e4b36975cd6998bbd78 Mon Sep 17 00:00:00 2001
From: Immanuel Onyeka <immanuel@onyeka.ca>
Date: Mon, 17 Jul 2023 16:27:36 -0400
Subject: [PATCH] Loop over indices to avoid copying values

---
 components/estimates.vue | 10 ++++++++--
 skouter.go               |  4 ++--
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/components/estimates.vue b/components/estimates.vue
index 24c2ba5..8e18241 100644
--- a/components/estimates.vue
+++ b/components/estimates.vue
@@ -32,8 +32,13 @@
 <section class="inputs estimates">
 <h3>Saved Estimates</h3>
 
-<div class="entry" v-for="e in estimates">
-<span>{{e.id}} - {{e.property}} - ${{e.price/100}}</span>
+<div class="entry" v-for="e in estimates" v-if="!estimate">
+<span @click="() => estimate = e">{{e.id}} - {{e.property}} - ${{e.price/100}}</span>
+</div>
+
+<div class="details" v-if="estimate">
+{{estimate}}
+<label>Name: {{estimate.name}}</label>
 </div>
 
 </section>
@@ -48,6 +53,7 @@ import FeeDialog from "./fee-dialog.vue"
 const props = defineProps(['user', 'fees', 'token'])
 let edit = ref(null)
 let estimates = ref([])
+let estimate = ref()
 
 function newFee(fee, isDebit) {
 	this.edit = null
diff --git a/skouter.go b/skouter.go
index 818f070..8da99c9 100644
--- a/skouter.go
+++ b/skouter.go
@@ -973,8 +973,8 @@ func queryEstimate(db *sql.DB, id int, user int) ( []Estimate, error ) {
 	// Prevents runtime panics
 	if len(estimates) == 0 { return estimates, errors.New("Estimate not found.") }
 	
-	for _, e := range estimates {
-		e.Loans, err = queryLoan(db, e.Id, 0)
+	for i := range estimates {
+		estimates[i].Loans, err = queryLoan(db, estimates[i].Id, 0)
 		if err != nil { return estimates, err }
 	}