Skip to content

Commit 54210de

Browse files
author
aafomin
committed
change currencyStore and converter
1 parent 201678b commit 54210de

File tree

2 files changed

+19
-23
lines changed

2 files changed

+19
-23
lines changed

src/components/Converter/converter.vue

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<v-layout wrap align-center>
44
<v-flex xs10 md4 sm10 offset-sm1>
55
<v-autocomplete
6-
class="converter_select"
6+
class="converter__select"
77
:items="dataArr"
88
v-model="currencyRate"
99
item-text="name"
@@ -13,7 +13,7 @@
1313
></v-autocomplete>
1414
</v-flex>
1515
</v-layout>
16-
<div v-show="currencyRate.name" class="converter_value">
16+
<div v-show="currencyRate.name" class="converter__value">
1717
<v-flex xs10 md4 sm10 offset-sm1>
1818
<v-layout row>
1919
<img src="@/./assets/icons_amount.png" alt="Amount" style="vertical-align: middle">
@@ -39,7 +39,6 @@
3939
</template>
4040
<script>
4141
import { mapActions, mapState } from "vuex";
42-
import names from "../Calendar/constNames.js";
4342
import currentPrice from "./components-converter/current-price-modal.vue";
4443
4544
export default {
@@ -76,33 +75,34 @@ export default {
7675
this.INIT_STATE.then(() => {
7776
this.show = true;
7877
this.dataArr = this.currency;
79-
let date = new Date(Date.parse(this.timeStamp));
80-
this.time = `${date.getDate()} ${
81-
names.monthNameS[date.getMonth()]
82-
} ${date.getFullYear()}`;
78+
this.time = new Date(this.timeStamp).toLocaleString("ru", {
79+
day: "numeric",
80+
month: "long",
81+
year: "numeric"
82+
});
8383
});
84-
},
84+
}
8585
};
8686
</script>
8787
<style lang="scss" scoped>
8888
@media screen and (max-width: 1024px) {
8989
.converter {
9090
text-align: center;
91-
.converter_select {
91+
.converter__select {
9292
margin-left: 2vw;
9393
font-size: 22px;
9494
}
95-
.converter_value {
95+
.converter__value {
9696
font-size: 22px;
9797
}
9898
}
9999
}
100100
@media screen and (max-width: 600px) {
101101
.converter {
102-
.converter_select {
102+
.converter__select {
103103
font-size: 18px;
104104
}
105-
.converter_value {
105+
.converter__value {
106106
font-size: 18px;
107107
}
108108
}

src/store/currencyStore.js

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,27 +18,23 @@ export default {
1818
actions: {
1919
async INIT_STATE({ commit }) {
2020
let url = "https://www.cbr-xml-daily.ru/daily_json.js";
21-
const results = await axios.get(url)
21+
await axios.get(url)
2222
.then(response => {
2323
commit('setDataTime', response.data.Timestamp)
24-
let val = response.data.Valute;
25-
let obj = {};
26-
let arr = [];
27-
Object.keys(val).forEach(key => {
28-
let e = val[key];
29-
obj = {
24+
const data = response.data.Valute;
25+
const arr = Object.keys(data).map(key => {
26+
let e = data[key];
27+
return {
3028
name: e.Name,
3129
value: e.Value,
3230
nominal: e.Nominal
33-
};
34-
arr.push(obj);
35-
});
31+
}
32+
})
3633
arr.sort((a,b) => (a.name > b.name) ? 1 : ((b.name > a.name) ? -1 : 0))
3734
commit('setCurrency', arr);
3835
})
3936
// eslint-disable-next-line
4037
.catch(error => console.error(error))
41-
return results
4238
}
4339
},
4440
getters: {

0 commit comments

Comments
 (0)