You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

property.js 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. import axios from 'axios';
  2. export default {
  3. namespaced: true,
  4. state: {
  5. property: {
  6. id: 0,
  7. propertyTypeId: 0,
  8. propertyName: '',
  9. unit: '',
  10. addressLine1: '',
  11. addressLine2: '',
  12. addressLine3: '',
  13. suburbId: 0,
  14. cityId: 0,
  15. provinceId: 0,
  16. price: '',
  17. per: '',
  18. description: '',
  19. isSale: false,
  20. propertyUserFields: [],
  21. propertyImages: [],
  22. },
  23. propertyImages: [],
  24. propertyTypes: [],
  25. propertyTypesRes: [],
  26. propertyTypesCom: [],
  27. propertyOverviewFields: [],
  28. propertyFields: [],
  29. properties: [],
  30. },
  31. mutations: {
  32. setProperty(state, property) {
  33. state.property = property;
  34. },
  35. setPropertyImages(state, images) {
  36. state.propertyImages = images;
  37. },
  38. setPropertyTypes(state, types) {
  39. state.propertyTypes = types;
  40. },
  41. setPropertyTypesRes(state, types) {
  42. state.propertyTypesRes = types;
  43. },
  44. setPropertyTypesCom(state, types) {
  45. state.propertyTypesCom = types;
  46. },
  47. setPropertyOverviewFields(state, fields) {
  48. state.propertyOverviewFields = fields;
  49. },
  50. setPropertyFields(state, fields) {
  51. state.propertyFields = fields;
  52. },
  53. updateCurrentProperty(state, property) {
  54. state.property = property;
  55. },
  56. updateSearch(state, propertySearch) {
  57. state.properties = propertySearch;
  58. },
  59. },
  60. getters: {},
  61. actions: {
  62. getProperty({ commit }, id) {
  63. console.log(id);
  64. axios
  65. .get(`http://localhost:57260/Property/Property/${id}`)
  66. .then(result => commit('setProperty', result.data))
  67. .catch(console.error);
  68. },
  69. getPropertyImages({ commit }, id) {
  70. axios
  71. .get(`http://localhost:57260/property/PropertyImage/getpropertyimages/${id}`)
  72. .then(result => commit('setPropertyImages', result.data))
  73. .catch(console.error);
  74. },
  75. getPropertyTypes({ commit }, propertyType) {
  76. axios
  77. .get(`http://localhost:57260/Property/PropertyType/type/${propertyType}`)
  78. .then(result => commit('setPropertyTypes', result.data))
  79. .catch(console.error);
  80. },
  81. getPropertyTypesRes({ commit }) {
  82. axios
  83. .get('http://localhost:57260/Property/PropertyType/type/Residential')
  84. .then(result => commit('setPropertyTypesRes', result.data))
  85. .catch(console.error);
  86. },
  87. getPropertyTypesCom({ commit }) {
  88. axios
  89. .get('http://localhost:57260/Property/PropertyType/type/Commercial')
  90. .then(result => commit('setPropertyTypesCom', result.data))
  91. .catch(console.error);
  92. },
  93. getPropertyOverviewFields({ commit }) {
  94. axios
  95. .get('http://localhost:57260/Property/PropertyFields/Property Overview')
  96. .then(response => commit('setPropertyOverviewFields', response.data));
  97. },
  98. getPropertyFields({ commit }, propertyType) {
  99. axios
  100. .get(`http://localhost:57260/property/propertyfields/Propertytype/${propertyType}`)
  101. .then(response => commit('setPropertyFields', response.data));
  102. },
  103. saveProperty({ commit }, item) {
  104. axios
  105. .post('http://localhost:57260/Property/Property', item)
  106. .then(result => commit('updateCurrentProperty', result.data))
  107. .catch(console.error);
  108. },
  109. searchPropertiesParams({ commit }, item) {
  110. axios
  111. .get(
  112. `http://localhost:57260/Property/Property/Search/${item.type}/${item.propertyType}/${item.province}/${item.city}/${item.suburb}/${item.propType}`,
  113. )
  114. .then(response => commit('updateSearch', response.data))
  115. .catch(console.error);
  116. },
  117. searchPropertiesKeyword({ commit }, item) {
  118. axios
  119. .get(`http://localhost:57260/Property/Property/Search/Keyword/${item.keyword}`)
  120. .then(response => commit('updateSearch', response.data))
  121. .catch(console.error);
  122. },
  123. },
  124. };