@wikala/spmkt 2.21.3 → 2.22.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,12 @@
1
+ import request from './request'
2
+
3
+ const Affiliate = {
4
+ getReport(id) {
5
+ return request({
6
+ url: '/affiliates/'+ id + '/reports',
7
+ method: 'get'
8
+ })
9
+ }
10
+ }
11
+
12
+ export default Affiliate
package/api.js CHANGED
@@ -9,6 +9,7 @@ import Product from './api/product'
9
9
  import ProductQuestions from './api/product-questions'
10
10
  import ProductReviews from './api/product-reviews'
11
11
  import User from './api/user'
12
+ import Affiliate from './api/affiliate'
12
13
 
13
14
  export {
14
15
  request,
@@ -20,5 +21,6 @@ export {
20
21
  Product,
21
22
  ProductQuestions,
22
23
  ProductReviews,
23
- User
24
+ User,
25
+ Affiliate,
24
26
  }
@@ -30,6 +30,10 @@
30
30
  <b-tab-item :label="$t('account.settings')">
31
31
  <AccountSettings />
32
32
  </b-tab-item>
33
+
34
+ <b-tab-item v-if="user.affiliate && user.affiliate.id" label="Affiliate Report">
35
+ <AffiliateReport />
36
+ </b-tab-item>
33
37
  </b-tabs>
34
38
  </div>
35
39
  </div>
@@ -46,6 +50,7 @@ import Orders from './Orders'
46
50
  import CreditCards from './CreditCards'
47
51
  import AccountSettings from './AccountSettings'
48
52
  import Settings from './Settings'
53
+ import AffiliateReport from './AffiliateReport'
49
54
 
50
55
  export default {
51
56
  name: 'AccountDashboard',
@@ -76,22 +81,23 @@ export default {
76
81
  AddressBook,
77
82
  CreditCards,
78
83
  AccountSettings,
79
- Settings
84
+ Settings,
85
+ AffiliateReport
80
86
  },
81
87
 
82
88
  data() {
83
89
  return {
84
- tabs: ['orders', 'addresses', 'settings'],
90
+ tabs: ['orders', 'addresses', 'settings', 'affiliate-report'],
85
91
  activeTab: 0
86
92
  }
87
93
  },
88
94
 
89
95
  computed: {
90
- ...mapState(['countryList'])
96
+ ...mapState(['countryList', 'user'])
91
97
  },
92
98
 
93
99
  methods: {
94
- ...mapActions(['getCountries']),
100
+ ...mapActions(['getCountries', 'getUser', 'getAffiliateReport']),
95
101
 
96
102
  ordersTabClick(index, e) {
97
103
  if (e.target.parentElement.getAttribute('role') === 'tab' && index === 0) {
@@ -119,6 +125,7 @@ export default {
119
125
  async mounted() {
120
126
  this.switchTabBasedOnUrl()
121
127
  await this.getCountries()
128
+ await this.getUser()
122
129
 
123
130
  window.addEventListener('popstate', () => {
124
131
  console.log('popstate ', this.activeTab, window.location.href)
@@ -1,22 +1,39 @@
1
1
 
2
- import { Address, Countries } from '../../api'
2
+ import { Address, Countries, User, Affiliate } from '../../api'
3
3
 
4
4
  const AccountStore = {
5
5
  state: {
6
+ user: {},
6
7
  addressList: [],
7
- countryList: []
8
+ countryList: [],
9
+ affiliateReport: [],
8
10
  },
9
11
 
10
12
  mutations: {
13
+ setUser(state, user) {
14
+ state.user = user
15
+ },
11
16
  setAddressList(state, addressList) {
12
17
  state.addressList = addressList
13
18
  },
14
19
  setCountryList(state, countryList) {
15
20
  state.countryList = countryList
21
+ },
22
+ setAffiliateReport(state, affiliateReport) {
23
+ state.affiliateReport = affiliateReport
16
24
  }
17
25
  },
18
26
 
19
27
  actions: {
28
+ async getUser({commit}) {
29
+ try {
30
+ let res = await User.get()
31
+ commit('setUser', res.data.data)
32
+ } catch(e) {
33
+ console.log('Cannot get user', e)
34
+ }
35
+ },
36
+
20
37
  getAddresses({ commit, state }) {
21
38
  if (!User.isLogged()) {
22
39
  return true
@@ -32,6 +49,13 @@ const AccountStore = {
32
49
  })
33
50
  },
34
51
 
52
+ async getAffiliateReport({ commit, state }) {
53
+ try {
54
+ let res = await Affiliate.getReport(state.user.affiliate.id);
55
+ commit('setAffiliateReport', res.data.data)
56
+ } catch(e) {}
57
+ },
58
+
35
59
  getCountries({ commit, state }) {
36
60
  Countries.get()
37
61
  .then((response) => {
@@ -0,0 +1,102 @@
1
+ <template>
2
+
3
+
4
+ <div>
5
+
6
+ <div>
7
+ <strong>Total commissions:</strong> {{ summary.commission }} RSD
8
+ </div>
9
+ <div style="margin-bottom: 1rem;">
10
+ <strong>Total sold:</strong> {{ summary.item }} RSD ({{summary.count}} items)
11
+ </div>
12
+
13
+ <b-table v-if="items.length > 0" :data="items" :hoverable="true" class="affiliate-report-table">
14
+ <b-table-column v-slot="props" field="id" label="Order ID" width="75" numeric>
15
+ {{ props.row.order_id }}
16
+ </b-table-column>
17
+
18
+ <b-table-column v-slot="props" field="date" label="Date" width="100">
19
+ {{ new Date(props.row.order_created_at).toLocaleDateString() }}
20
+ </b-table-column>
21
+
22
+ <b-table-column v-slot="props" field="iten" label="Item">
23
+ {{ props.row.item_name }}
24
+ </b-table-column>
25
+
26
+ <b-table-column v-slot="props" field="price" label="Price" width="40" numeric>
27
+ {{ props.row.item_price }}
28
+ </b-table-column>
29
+
30
+ <b-table-column v-slot="props" field="qty" label="Qty" width="40" numeric>
31
+ {{ props.row.item_qty }}
32
+ </b-table-column>
33
+
34
+ <b-table-column v-slot="props" field="discount" label="Discount" width="40" numeric>
35
+ {{ props.row.item_discount }}
36
+ </b-table-column>
37
+
38
+ <b-table-column v-slot="props" field="total" label="Item total" width="40" numeric>
39
+ {{ props.row.item_total }}
40
+ </b-table-column>
41
+
42
+ <b-table-column v-slot="props" field="commission" label="Commission" width="40" numeric>
43
+ {{ props.row.commission_total }}
44
+ </b-table-column>
45
+
46
+ </b-table>
47
+
48
+ <div v-if="items.length === 0">No items</div>
49
+
50
+ </div>
51
+ </template>
52
+
53
+ <script>
54
+
55
+ import { mapState, mapActions } from 'vuex'
56
+
57
+ export default {
58
+ name: 'AffiliateReport',
59
+
60
+ data() {
61
+ return {
62
+ loading: false,
63
+ items: [],
64
+ summary: {
65
+ item: 0,
66
+ commission: 0,
67
+ count: 0,
68
+ }
69
+ }
70
+ },
71
+ computed: {
72
+ ...mapState(['affiliateReport'])
73
+ },
74
+ methods: {
75
+
76
+ ...mapActions(['getAffiliateReport']),
77
+
78
+ orderDetailClose() {
79
+ this.selected = {}
80
+ this.showOrderDetail = false
81
+ },
82
+
83
+ async init() {
84
+ //this.loading = this.$buefy.loading.open()
85
+ if(!this.afiliateReport) {
86
+ const loading = this.$buefy.loading.open({
87
+ container: this.$refs.container
88
+ })
89
+ await this.getAffiliateReport();
90
+ loading.close()
91
+ }
92
+
93
+ this.items = this.affiliateReport.items
94
+ this.summary = this.affiliateReport.total
95
+ }
96
+ },
97
+
98
+ mounted() {
99
+ this.init()
100
+ }
101
+ }
102
+ </script>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wikala/spmkt",
3
- "version": "2.21.3",
3
+ "version": "2.22.1",
4
4
  "private": false,
5
5
  "description": "supermarket",
6
6
  "scripts": {
package/utils/animate.js CHANGED
@@ -1,7 +1,9 @@
1
1
  import 'animate.css'
2
2
 
3
3
  function animateCSS(element, animationName, callback) {
4
- const node = document.querySelector(element)
4
+
5
+ const node = element instanceof HTMLElement ? element : document.querySelector(element)
6
+
5
7
  node.classList.add('animate__animated', 'animate__' + animationName)
6
8
 
7
9
  function handleAnimationEnd() {