-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from swaponline/transaction-wallet
Transaction wallet issue-#6
- Loading branch information
Showing
11 changed files
with
1,253 additions
and
99 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
import Vue from 'vue' | ||
import Vuex from 'vuex' | ||
import Wallets from './modules/Wallets' | ||
import Transactions from './modules/Transactions' | ||
|
||
Vue.use(Vuex) | ||
|
||
export default new Vuex.Store({ | ||
modules: { | ||
Wallets | ||
Wallets, | ||
Transactions | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import Transaction from '@/api/swap.json' | ||
import { SET_LIST } from '@/store/common/mutations.types' | ||
import { pickCommonMutations } from '@/store/common/mutations' | ||
import { getDate } from '@/utils/date' | ||
|
||
export const MODULE_NAME = 'Transaction' | ||
|
||
export const GET_TRANSACTIONS = 'GET_TRANSACTIONS' | ||
|
||
export default { | ||
state: { | ||
list: [] | ||
}, | ||
getters: { | ||
/** | ||
* [{ | ||
* date: "Today || Yesterday || 'dd.mm.yyyy'", | ||
* list: [] | ||
* }] | ||
*/ | ||
listTransactionsSortByDate({ list }) { | ||
return wallet => { | ||
return list | ||
.filter(el => el.to === wallet || el.from === wallet) | ||
.reduce((newList, el) => { | ||
const nameDay = getDate(el.timestamp) | ||
const day = newList.find(item => item.date === nameDay) | ||
if (day) { | ||
day.list.push(el) | ||
} else { | ||
newList.push({ | ||
date: nameDay, | ||
list: [el] | ||
}) | ||
} | ||
return newList | ||
}, []) | ||
} | ||
} | ||
}, | ||
actions: { | ||
[GET_TRANSACTIONS]({ commit }) { | ||
const list = Transaction.sort((a, b) => b.timestamp - a.timestamp) | ||
commit(SET_LIST, { list }) | ||
} | ||
}, | ||
mutations: { | ||
...pickCommonMutations([SET_LIST]) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.