Update TestHomePage.vue

This commit is contained in:
Nukeap committed 2025-02-05 08:46:08 +03:00
1 parent 1e34447b1e
commit c8c465f5cc
1 file changed
+29 -28
+29 -28
View File
@@ -11,11 +11,8 @@
<v-btn color="#00897B1F" class="mr-2 text-teal-darken-1" elevation="0"> <v-btn color="#00897B1F" class="mr-2 text-teal-darken-1" elevation="0">
Тренироваться Тренироваться
</v-btn> </v-btn>
<v-btn color="teal-darken-1" elevation="0"> <v-btn color="teal-darken-1" elevation="0"> Пройти </v-btn>
Пройти
</v-btn>
</template> </template>
</CatalogTest> </CatalogTest>
</v-tabs-window-item> </v-tabs-window-item>
<!-- Вкладка завершенных --> <!-- Вкладка завершенных -->
@@ -50,50 +47,54 @@
</template> </template>
<script> <script>
import CatalogTest from "@/components/testing/CatalogTest.vue"; import CatalogTest from '@/components/testing/CatalogTest.vue';
import { axiosApiInstance } from "@/utils/axios-api"; import { axiosApiInstance } from '@/utils/axios-api';
import { ref, computed, watch } from "vue" import { ref, computed, watch } from 'vue';
export default { export default {
components: { components: {
CatalogTest CatalogTest,
}, },
setup() { setup() {
const activeTab = ref(0); const activeTab = ref(0);
const currentTest = ref('') const currentTest = ref('');
const getAllTests = ref([]) const getAllTests = ref([]);
const getTestById = () => { const getTestById = () => {
let status = activeTab.value == 0 ? '?status=active' : activeTab.value == 1 ? '?status=completed' : '' let status =
axiosApiInstance.get(`/api/tests/gettests/${status}`).then(resp => getAllTests.value = resp.data).finally(() => { activeTab.value == 0 ? '?status=active' : activeTab.value == 1 ? '?status=completed' : '';
axiosApiInstance
.get(`/api/tests/gettests/${status}`)
.then((resp) => (getAllTests.value = resp.data))
.finally(() => {
if (activeTab.value == 0) { if (activeTab.value == 0) {
currentTest.value = getAllTests.value.length currentTest.value = getAllTests.value.length;
}
})
} }
});
};
getTestById() getTestById();
watch (() => activeTab.value, watch(
() => activeTab.value,
() => { () => {
getTestById() getTestById();
} },
) );
const tabs = computed(() => [ const tabs = computed(() => [
{ value: 0, title: `Назначенные (${currentTest.value})`, }, { value: 0, title: `Назначенные (${currentTest.value})` },
{ value: 1, title: 'Завершенные', }, { value: 1, title: 'Завершенные' },
{ value: 2, title: 'Каталог', }, { value: 2, title: 'Каталог' },
]) ]);
return { return {
activeTab, activeTab,
tabs, tabs,
getAllTests, getAllTests,
} };
} },
} };
</script> </script>