From be7aaf0e250c86b22bb35286c1dade81444a5144 Mon Sep 17 00:00:00 2001 From: Ilya Date: Wed, 2 Oct 2024 01:07:17 +0300 Subject: [PATCH] fixing achievement pic upload (#249) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Изменения ## Детали реализации ## Check-List - [ ] Вы проверили свой код перед отправкой запроса? - [ ] Вы написали тесты к реализованным функциям? - [ ] Вы не забыли применить форматирование `black` и `isort` для _Back-End_ или `Prettier` для _Front-End_? --- .../admin/achievement/AchievementListView.vue | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/views/admin/achievement/AchievementListView.vue b/src/views/admin/achievement/AchievementListView.vue index 8dbb577..e122c1f 100644 --- a/src/views/admin/achievement/AchievementListView.vue +++ b/src/views/admin/achievement/AchievementListView.vue @@ -16,7 +16,7 @@ toolbar.setup({ title: 'Управление достижениями', backUrl: const achievements = ref([]); const newName = ref(''); const newDescription = ref(''); -const newPic = ref(undefined); +const newPic = ref(undefined); const created = ref(undefined); onMounted(async () => { @@ -29,11 +29,12 @@ onMounted(async () => { async function createAchievement( new_name: string, new_description: string, - new_pic: File[] | undefined + new_pic: File | undefined ) { - console.log(new_pic, new_pic?.length); - if (new_pic === undefined || new_pic.length !== 1) return; + console.log(new_pic); + if (new_pic === undefined) return; const new_pic_str = new_pic.toString(); + console.log(new_pic_str); const promise = apiClient.POST('/achievement/achievement', { body: { @@ -88,11 +89,10 @@ async function createAchievement( prepend-icon="md:image" accept="image/png" :rules="[ - (value: File[]) => { + (value: File) => { return ( !value || - value.length == 1 || - value[0].size < 200000 || + value.size < 200000 || 'Размер изображения не должен превышать 200 KB!' ); },