feat: Add PageContainer
diff --git a/erpnext/public/js/hub/PageContainer.vue b/erpnext/public/js/hub/PageContainer.vue
new file mode 100644
index 0000000..456da9a
--- /dev/null
+++ b/erpnext/public/js/hub/PageContainer.vue
@@ -0,0 +1,40 @@
+<template>
+ <div class="hub-page-container">
+ <component :is="current_page"></component>
+ </div>
+</template>
+<script>
+import Home from './pages/Home.vue';
+import SavedProducts from './pages/SavedProducts.vue';
+import Publish from './pages/Publish.vue';
+import Category from './pages/Category.vue';
+import Search from './pages/Search.vue';
+import PublishedProducts from './pages/PublishedProducts.vue';
+
+const route_map = {
+ 'marketplace/home': Home,
+ 'marketplace/saved-products': SavedProducts,
+ 'marketplace/publish': Publish
+}
+
+export default {
+ data() {
+ return {
+ current_page: this.get_current_page()
+ }
+ },
+ mounted() {
+ frappe.route.on('change', () => {
+ this.set_current_page();
+ });
+ },
+ methods: {
+ set_current_page() {
+ this.current_page = this.get_current_page();
+ },
+ get_current_page() {
+ return route_map[frappe.get_route_str()];
+ }
+ }
+}
+</script>
diff --git a/erpnext/public/js/hub/marketplace.js b/erpnext/public/js/hub/marketplace.js
index 98e84e0..931c5f9 100644
--- a/erpnext/public/js/hub/marketplace.js
+++ b/erpnext/public/js/hub/marketplace.js
@@ -8,6 +8,7 @@
import './pages/buying_messages';
import './pages/not_found';
+import PageContainer from './PageContainer.vue';
import Home from './pages/Home.vue';
import SavedProducts from './pages/SavedProducts.vue';
import Publish from './pages/Publish.vue';
@@ -147,6 +148,13 @@
make_body() {
this.$body = this.$parent.find('.layout-main-section');
+ // this.$page_container = $('<div class="hub-page-container">').appendTo(this.$body);
+
+ // new Vue({
+ // el: '.hub-page-container',
+ // render: h => h(PageContainer)
+ // });
+
erpnext.hub.on('seller-registered', () => {
this.registered = 1;
this.make_sidebar_nav_buttons();
diff --git a/erpnext/public/js/hub/pages/home.js b/erpnext/public/js/hub/pages/home.js
deleted file mode 100644
index b011e7e..0000000
--- a/erpnext/public/js/hub/pages/home.js
+++ /dev/null
@@ -1,60 +0,0 @@
-import SubPage from './subpage';
-import { make_search_bar } from '../components/search_bar';
-import { get_item_card_container_html } from '../components/items_container';
-import { get_item_card_html } from '../components/item_card';
-
-erpnext.hub.Home = class Home extends SubPage {
- make_wrapper() {
- super.make_wrapper();
-
- make_search_bar({
- wrapper: this.$wrapper,
- on_search: keyword => {
- frappe.set_route('marketplace', 'search', keyword);
- }
- });
- }
-
- refresh() {
- this.get_items_and_render();
- }
-
- get_items_and_render() {
- this.$wrapper.find('.hub-items-container').empty();
- this.get_data()
- .then(data => {
- this.render(data);
- });
- }
-
- get_data() {
- return hub.call('get_data_for_homepage', { country: frappe.defaults.get_user_default('country') });
- }
-
- render(data) {
- let html = get_item_card_container_html(data.random_items, __('Explore'));
- this.$wrapper.append(html);
-
- if (data.items_by_country.length) {
- html = get_item_card_container_html(data.items_by_country, __('Near You'));
- this.$wrapper.append(html);
- }
-
- const category_items = data.category_items;
-
- if (category_items) {
- Object.keys(category_items).map(category => {
- const items = category_items[category];
- const see_all_link = `<p data-route="marketplace/category/${category}">See All</p>`;
-
- html = get_item_card_container_html(
- items,
- __(category),
- get_item_card_html,
- see_all_link
- );
- this.$wrapper.append(html);
- });
- }
- }
-}