Skip to content

Commit

Permalink
fix import
Browse files Browse the repository at this point in the history
  • Loading branch information
Koryakinaisen committed Dec 19, 2024
1 parent dcd01f7 commit d1f2ba2
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions frontend/src/components/AdminSideBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
style="display: block; margin-bottom: 15px;"
/>
</div>
<button @click="handleImport" class="export-button">
Import
</button>

<button @click="handleExport" class="export-button">
Export
Expand Down Expand Up @@ -61,7 +64,7 @@
</template>

<script>
import {exportData} from "@/services/importExport.js";
import {exportData, importData} from "@/services/importExport.js";
export default {
name: 'AdminSideBar',
Expand All @@ -87,15 +90,20 @@ export default {
reader.onload = (e) => {
try {
const jsonData = JSON.parse(e.target.result);
console.log('Прочитанные данные JSON:', jsonData);
this.uploadedJsonData = jsonData;
// Здесь вы можете добавить отправку данных на сервер, если потребуется
} catch (err) {
console.error('Некорректный JSON файл', err);
}
};
reader.readAsText(file);
},
handleImport() {
if(!this.uploadedJsonData){
this.toast.error("Загрузите JSON файл!")
return
}
importData(this.uploadedJsonData)
},
async handleExport() {
try {
exportData().then((data) => {
Expand Down

0 comments on commit d1f2ba2

Please sign in to comment.