From a014cedfbd048befac15950294f5ecb1132cd124 Mon Sep 17 00:00:00 2001 From: ka-lucas Date: Thu, 17 Apr 2025 11:33:06 -0300 Subject: [PATCH] get funcional holiday --- src/stores/holiday.js | 15 +++------------ src/views/Holiday.vue | 3 ++- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/src/stores/holiday.js b/src/stores/holiday.js index c361ea7..40a77bf 100644 --- a/src/stores/holiday.js +++ b/src/stores/holiday.js @@ -30,37 +30,28 @@ export const useHolidayStore = defineStore('holidays', { async fetchHolidays() { const authStore = useAuthStore(); const serviceInstanceId = authStore.getInstance; - if (!serviceInstanceId) { this.error = 'Nenhuma instância de serviço selecionada'; return; } - this.loading = true; this.error = null; - try { console.log('cheguei aqui3'); const response = await api.get('/holiday/', { params: {} }); - this.$patch({ - holidays: response.data, - //total: response.data, + holidays: response.data.holiday_list, // <- CORREÇÃO AQUI! }); - - console.log(response.data); - return response.data; - + console.log(response.data.holiday_list); // Log correto para debug + return response.data.holiday_list; } catch (error) { const status = error?.response?.status; - if (status === 401) { console.warn('Não autorizado. Redirecionando para login...'); router.push('/login'); } - this.error = error?.response?.data?.message || error.message || 'Erro ao buscar feriados'; console.error('Erro ao buscar feriados', error); throw error; diff --git a/src/views/Holiday.vue b/src/views/Holiday.vue index 308cf33..e3ffd80 100644 --- a/src/views/Holiday.vue +++ b/src/views/Holiday.vue @@ -425,7 +425,8 @@ try { loading.value.holidays = true; console.log('cheguei aqui') - const holidaysData = await holidayStore.getHolidays(); + const holidaysData = await holidayStore.fetchHolidays(); + holidays.value = holidaysData; console.log("Dados recebidos da API:", holidaysData);