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.
 
 
 
 
 
 

120 wiersze
2.5 KiB

  1. <template>
  2. <form>
  3. <div>
  4. <label>Given name</label><input required type="text" name="gname"/>
  5. </div>
  6. <div>
  7. <label>Surname</label><input required type="text" name="sname"/>
  8. </div>
  9. <div>
  10. <label>Email</label><input type="email" name="email"/>
  11. </div>
  12. <div>
  13. <label>Password</label><input requried type="password" name="pass"/>
  14. </div>
  15. <div>
  16. <label>Country</label>
  17. <select name="country">
  18. <option value="USA">USA</option>
  19. <option value="Canada">Canada</option>
  20. </select>
  21. </div>
  22. <div class="address-entry">
  23. <label for="">Address</label>
  24. <input type="text" @input="searchLocation" :value="address.full">
  25. <dropdown v-if="addresses && addresses.length"
  26. :entries="addresses.map(a => ({text: a.full_address, value: a}))"
  27. @select="setAddress"
  28. >
  29. </dropdown>
  30. </div>
  31. <div><label>NMLS ID</label><input type="text" name="nmls"/></div>
  32. <div><span class="error">{{error}}</span></div>
  33. <div>
  34. <button class="btn" @click="submit" type="button">Continue</button>
  35. </div>
  36. </form>
  37. </template>
  38. <script setup>
  39. import { ref } from "vue"
  40. import Dropdown from "./dropdown.vue"
  41. const error = ref('')
  42. const addresses = ref([])
  43. const user = ref({})
  44. const address = ref({})
  45. const locationsId = ref(null)
  46. function searchLocation(e) {
  47. address.value.full = e.target.value
  48. clearTimeout(locationsId.value)
  49. locationsId.value = setTimeout(getLocations, 1000, e)
  50. }
  51. function getLocations(e) {
  52. let prefix = "https://api.mapbox.com/search/searchbox/v1/suggest?"
  53. let search = e.target.value
  54. let key = encodeURIComponent(process.env.MAPBOX_API_KEY)
  55. if (!search) return
  56. fetch(`${prefix}q=${search}&proximity=ip&access_token=${key}&session_token=1`
  57. ).then(resp => resp.json()).then(entries => {
  58. if (!entries?.suggestions) {
  59. addresses.value = null
  60. return
  61. }
  62. addresses.value = entries.suggestions.filter(e => e.full_address)
  63. })
  64. }
  65. function setAddress(a) {
  66. address.value = {
  67. id: address.value.id,
  68. full: a.full_address,
  69. street: a.address,
  70. city: a.context?.place.name ?? '',
  71. region: a.context?.region?.name ?? '',
  72. country: a.context?.country?.name ?? '',
  73. zip: a.context?.postcode?.name ?? '',
  74. }
  75. addresses.value = null
  76. }
  77. function submit() {
  78. }
  79. </script>
  80. <style scoped>
  81. form > div {
  82. display: flex;
  83. max-width: 350px;
  84. justify-content: space-between;
  85. margin: 10px;
  86. position: relative;
  87. }
  88. button {
  89. margin: auto;
  90. min-width: 90px;
  91. display: block;
  92. }
  93. span.error {
  94. margin: 10px auto;
  95. color: darkred;
  96. }
  97. </style>