Faris Ansari | 888dd60 | 2018-08-26 12:41:02 +0530 | [diff] [blame] | 1 | <template> |
| 2 | <div class="hub-page-container"> |
| 3 | <component :is="current_page"></component> |
| 4 | </div> |
| 5 | </template> |
| 6 | <script> |
| 7 | import Home from './pages/Home.vue'; |
| 8 | import SavedProducts from './pages/SavedProducts.vue'; |
| 9 | import Publish from './pages/Publish.vue'; |
| 10 | import Category from './pages/Category.vue'; |
| 11 | import Search from './pages/Search.vue'; |
| 12 | import PublishedProducts from './pages/PublishedProducts.vue'; |
| 13 | |
| 14 | const route_map = { |
| 15 | 'marketplace/home': Home, |
| 16 | 'marketplace/saved-products': SavedProducts, |
| 17 | 'marketplace/publish': Publish |
| 18 | } |
| 19 | |
| 20 | export default { |
| 21 | data() { |
| 22 | return { |
| 23 | current_page: this.get_current_page() |
| 24 | } |
| 25 | }, |
| 26 | mounted() { |
| 27 | frappe.route.on('change', () => { |
| 28 | this.set_current_page(); |
| 29 | }); |
| 30 | }, |
| 31 | methods: { |
| 32 | set_current_page() { |
| 33 | this.current_page = this.get_current_page(); |
| 34 | }, |
| 35 | get_current_page() { |
| 36 | return route_map[frappe.get_route_str()]; |
| 37 | } |
| 38 | } |
| 39 | } |
| 40 | </script> |