Skip to content

Commit

Permalink
Merge branch 'release/v5.3.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
demtario committed Oct 31, 2023
2 parents 5c4f6d2 + 342fbb8 commit c2c6630
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 6 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "store-admin",
"version": "5.2.0",
"version": "5.3.0",
"private": true,
"description": "Admin panel for Heseya Store API",
"author": "Heseya",
Expand All @@ -18,7 +18,7 @@
"lint:eslint:fix": "eslint --ext .js,.ts,.vue --fix ./src"
},
"dependencies": {
"@heseya/store-core": "5.2.0",
"@heseya/store-core": "5.3.0",
"@sentry/tracing": "^7.6.0",
"@sentry/vue": "^7.6.0",
"ant-design-vue": "^1.7.8",
Expand Down
60 changes: 60 additions & 0 deletions src/components/modules/products/UpdatePriceButton.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<template>
<icon-button :disabled="loading" @click="onClick">
<template #icon>
<i v-if="!loading" class="bx bx-cloud-upload"></i>
<i v-else class="bx bx-loader-circle"></i>
</template>
{{ $t('uploadText') }}
</icon-button>
</template>

<i18n lang="json">
{
"en": {
"uploadText": "Import prices from XML/CSV file",
"successMessage": "Prices have been imported"
},
"pl": {
"uploadText": "Zaimportuj ceny z pliku XML/CSV",
"successMessage": "Ceny zostały zaimportowane"
}
}
</i18n>

<script lang="ts">
import { sdk } from '@/api'
import { formatApiNotificationError } from '@/utils/errors'
import { defineComponent } from 'vue'
export default defineComponent({
data: () => ({ loading: false }),
methods: {
createUploadInput() {
const el = document.createElement('input')
el.type = 'file'
el.accept = '.xml,.csv'
el.onchange = (e) => {
const file = (e.target as HTMLInputElement).files?.[0]
if (file) this.onUpload(file)
}
return el
},
onClick() {
const el = this.createUploadInput()
el.click()
},
async onUpload(file: File) {
this.loading = true
try {
await sdk.Products.importPrices(file)
this.$toast.success(this.$t('successMessage') as string)
} catch (e: any) {
this.$toast.error(formatApiNotificationError(e))
}
this.loading = false
},
},
})
</script>
4 changes: 4 additions & 0 deletions src/views/products/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
@clear-filters="clearFilters"
>
<template #nav>
<UpdatePriceButton v-if="$accessor.config.env.show_import_prices_btn === '1'" />

<icon-button @click="listView = !listView">
<template #icon>
<i v-if="!listView" class="bx bx-list-ul"></i>
Expand Down Expand Up @@ -92,6 +94,7 @@ import { formatFilters } from '@/utils/utils'
import { ALL_FILTER_VALUE } from '@/consts/filters'
import { TableConfig } from '@/interfaces/CmsTable'
import { XlsxFileConfig } from '@/interfaces/XlsxFileConfig'
import UpdatePriceButton from '@/components/modules/products/UpdatePriceButton.vue'
const LOCAL_STORAGE_KEY = 'products-list-view'
Expand All @@ -104,6 +107,7 @@ export default defineComponent({
ProductsFilter,
PaginatedList,
ProductListItem,
UpdatePriceButton,
},
beforeRouteLeave(to, _from, next) {
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1224,10 +1224,10 @@
dependencies:
"@hapi/hoek" "^9.0.0"

"@heseya/store-core@5.2.0":
version "5.2.0"
resolved "https://registry.yarnpkg.com/@heseya/store-core/-/store-core-5.2.0.tgz#65cdcbf8060b39cbdac22bf6a5b720184bdf32ef"
integrity sha512-KGO/Ek3nmXmLFF3uu5Dri57TboFEFMGEhg2A+kMr/gYcuz2Hz5FhdKN0xs0YPDpMXBXA0XrFc2R0p3xYbO7t8g==
"@heseya/store-core@5.3.0":
version "5.3.0"
resolved "https://registry.yarnpkg.com/@heseya/store-core/-/store-core-5.3.0.tgz#d6f6fa6ed4290cb3f1f54ba036ae8019507be4cc"
integrity sha512-9sAhhmLWCujwbrY03OTRW6HlGY4G4L8V3aYCWOqEl6NXvPWMXBxmOrfoJrVgA3UZwINjrVkkq/87I3lmzSrH4w==
dependencies:
"@types/flat" "^5.0.2"
array-to-tree "^3.3.2"
Expand Down

0 comments on commit c2c6630

Please sign in to comment.