Skouter mortgage estimates. Web application with view written in PHP and Vue, but controller and models in Go.
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 
 
 

122 wiersze
2.6 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 estimates">
  27. <h3>Saved Estimates</h3>
  28. <div class="entry" v-for="e in estimates" v-if="!estimate">
  29. <span @click="() => estimate = e">
  30. {{e.id}} - {{e.property}} - ${{(e.price/100).toLocaleString()}}
  31. </span>
  32. </div>
  33. <div class="details" v-if="estimate">
  34. <label>
  35. #{{estimate.id}} -
  36. {{estimate.transaction}} -
  37. {{estimate.property}} -
  38. ${{(estimate.price / 100).toLocaleString()}}
  39. </label>
  40. <label>Borrowers: {{estimate.borrower.num}}</label>
  41. <label>Credit: {{estimate.borrower.credit}}</label>
  42. <label>Income: {{(estimate.borrower.income/100).toLocaleString()}}</label>
  43. <button @click="() => estimate = null">Cancel</button>
  44. </div>
  45. </section>
  46. </div>
  47. </template>
  48. <script setup>
  49. import { ref, computed, onMounted } from 'vue'
  50. import FeeDialog from "./fee-dialog.vue"
  51. const props = defineProps(['user', 'fees', 'token'])
  52. let edit = ref(null)
  53. let estimates = ref([])
  54. let estimate = ref()
  55. function newFee(fee, isDebit) {
  56. this.edit = null
  57. }
  58. function newType() {
  59. }
  60. function remove() {
  61. }
  62. function getEstimates() {
  63. fetch(`/api/estimates`,
  64. {method: 'GET',
  65. headers: {
  66. "Accept": "application/json",
  67. "Authorization": `Bearer ${props.token}`,
  68. },
  69. }).then(response => {
  70. if (response.ok) { return response.json() } else {
  71. response.text().then(t => console.log(t))
  72. }
  73. }).then (result => {
  74. if (!result || !result.length) return // Exit if token is invalid or no fees are saved
  75. estimates.value = result
  76. // console.log(result)
  77. })
  78. }
  79. function summarize() {
  80. fetch(`/api/estimate/summarize`,
  81. {method: 'POST',
  82. headers: {
  83. "Accept": "application/json",
  84. "Authorization": `Bearer ${props.token}`,
  85. },
  86. body: JSON.stringify(estimate.value),
  87. }).then(response => {
  88. if (response.ok) { return response.json() } else {
  89. response.text().then(t => console.log(t))
  90. }
  91. }).then(result => {
  92. if (!result || !result.length) return // Exit if token is invalid or no fees are saved
  93. console.log('done', result)
  94. })
  95. }
  96. onMounted(() => {
  97. getEstimates()
  98. })
  99. </script>