2018-08-25 16:24:49 +00:00
|
|
|
<template>
|
|
|
|
<div
|
|
|
|
class="marketplace-page"
|
|
|
|
:data-page-name="page_name"
|
|
|
|
>
|
|
|
|
<search-input
|
|
|
|
:placeholder="search_placeholder"
|
|
|
|
:on_search="set_search_route"
|
|
|
|
v-model="search_value"
|
2018-08-26 14:30:42 +00:00
|
|
|
/>
|
2018-08-25 16:24:49 +00:00
|
|
|
|
2018-09-03 14:09:19 +00:00
|
|
|
<div v-if="show_skeleton">
|
|
|
|
<section-header>
|
|
|
|
<h4 class="hub-skeleton">Explore Explore Explore</h4>
|
|
|
|
</section-header>
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-md-3 col-sm-4 col-xs-6 hub-card-container" v-for="(f, $index) in [1, 2, 3, 4, 5, 6, 7]" :key="$index">
|
|
|
|
<div class="hub-skeleton" style="height: 262px; width: 100%; margin-bottom: 25px;"></div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div v-else v-for="section in sections" :key="section.title">
|
2018-08-26 14:30:42 +00:00
|
|
|
|
|
|
|
<section-header>
|
2018-08-25 16:24:49 +00:00
|
|
|
<h4>{{ section.title }}</h4>
|
2018-08-30 06:46:08 +00:00
|
|
|
<p v-if="section.expandable" :data-route="'marketplace/category/' + section.title">{{ 'See All' }}</p>
|
2018-08-26 14:30:42 +00:00
|
|
|
</section-header>
|
2018-08-25 16:24:49 +00:00
|
|
|
|
|
|
|
<item-cards-container
|
|
|
|
:container_name="section.title"
|
|
|
|
:items="section.items"
|
|
|
|
:item_id_fieldname="item_id_fieldname"
|
|
|
|
:on_click="go_to_item_details_page"
|
2018-08-26 14:30:42 +00:00
|
|
|
/>
|
2018-08-25 16:24:49 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
name: 'home-page',
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
page_name: frappe.get_route()[1],
|
2018-08-27 08:41:48 +00:00
|
|
|
item_id_fieldname: 'name',
|
2018-08-25 16:24:49 +00:00
|
|
|
search_value: '',
|
|
|
|
|
|
|
|
sections: [],
|
2018-09-03 14:09:19 +00:00
|
|
|
show_skeleton: true,
|
2018-08-25 16:24:49 +00:00
|
|
|
|
|
|
|
// Constants
|
|
|
|
search_placeholder: __('Search for anything ...'),
|
|
|
|
};
|
|
|
|
},
|
|
|
|
created() {
|
|
|
|
// refreshed
|
|
|
|
this.search_value = '';
|
|
|
|
this.get_items();
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
get_items() {
|
2018-09-11 12:08:31 +00:00
|
|
|
hub.call('get_data_for_homepage', frappe.defaults ? {
|
2018-08-25 16:24:49 +00:00
|
|
|
country: frappe.defaults.get_user_default('country')
|
2018-09-11 12:08:31 +00:00
|
|
|
} : null)
|
2018-08-25 16:24:49 +00:00
|
|
|
.then((data) => {
|
2018-09-03 14:09:19 +00:00
|
|
|
this.show_skeleton = false;
|
|
|
|
|
2018-08-25 16:24:49 +00:00
|
|
|
this.sections.push({
|
|
|
|
title: __('Explore'),
|
|
|
|
items: data.random_items
|
|
|
|
});
|
|
|
|
if (data.items_by_country.length) {
|
|
|
|
this.sections.push({
|
|
|
|
title: __('Near you'),
|
|
|
|
items: data.items_by_country
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
const category_items = data.category_items;
|
|
|
|
|
|
|
|
if (category_items) {
|
|
|
|
Object.keys(category_items).map(category => {
|
|
|
|
const items = category_items[category];
|
|
|
|
|
|
|
|
this.sections.push({
|
|
|
|
title: __(category),
|
2018-08-30 06:46:08 +00:00
|
|
|
expandable: true,
|
2018-08-25 16:24:49 +00:00
|
|
|
items
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
2018-08-27 08:41:48 +00:00
|
|
|
go_to_item_details_page(hub_item_name) {
|
|
|
|
frappe.set_route(`marketplace/item/${hub_item_name}`);
|
2018-08-25 16:24:49 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
set_search_route() {
|
|
|
|
frappe.set_route('marketplace', 'search', this.search_value);
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped></style>
|