Skouter mortgage estimates. Web application with view written in PHP and Vue, but controller and models in Go.
 
 
 
 
 
 

81 行
1.4 KiB

  1. <template>
  2. <div class="page">
  3. <h2>Estimates</h2>
  4. <section class="form inputs">
  5. <h3>Default Fees</h3>
  6. <div
  7. v-for="(fee, indx) in fees"
  8. :key="fee.name + indx" class="fee"
  9. >
  10. <label @click="() => edit = fee">
  11. ${{fee.amount/100}}{{ fee.perc ? ` ${fee.perc}%` : ''}} - {{fee.name}}<br>
  12. {{fee.type}}
  13. </label>
  14. <img width="21" height="21" src="/assets/image/icon/x-red.svg"
  15. @click="() => remove(indx, 1)">
  16. </div>
  17. <button @click="() => edit = {}">New Fee</button>
  18. </section>
  19. <fee-dialog v-if="edit"
  20. :heading="'Fee'"
  21. :initial="edit"
  22. :price="0"
  23. @close="() => edit = null"
  24. @save="newFee"
  25. />
  26. <section class="inputs">
  27. <h3>Saved Estimates</h3>
  28. </section>
  29. </div>
  30. </template>
  31. <script setup>
  32. import { ref, computed, onMounted } from 'vue'
  33. import FeeDialog from "./fee-dialog.vue"
  34. const props = defineProps(['user', 'fees'])
  35. let edit = ref(null)
  36. function newFee(fee, isDebit) {
  37. this.edit = null
  38. }
  39. function newType() {
  40. }
  41. function remove() {
  42. }
  43. function getEstimates() {
  44. const token = getCookie("skouter")
  45. return fetch(`/api/estimates`,
  46. {method: 'GET',
  47. headers: {
  48. "Accept": "application/json",
  49. "Authorization": `Bearer ${token}`,
  50. },
  51. }).then(response => {
  52. if (response.ok) { return response.json() }
  53. }).then (result => {
  54. if (!result || !result.length) return // Exit if token is invalid or no fees are saved
  55. this.fees = result
  56. })
  57. }
  58. onMounted(() => {
  59. // getEstimates()
  60. })
  61. </script>