diff --git a/package-lock.json b/package-lock.json index b9f9803..744f787 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,10 +9,12 @@ "version": "0.0.0", "dependencies": { "@mdi/font": "^7.4.47", + "animate.css": "^4.1.1", "apexcharts": "^3.54.1", "axios": "^1.8.4", "dashboard": "file:", "date-fns": "^4.1.0", + "gsap": "^3.12.7", "jwt-decode": "^4.0.0", "npm-check-updates": "^17.1.11", "pdf-parse": "^1.1.1", @@ -818,6 +820,12 @@ "resolved": "https://registry.npmjs.org/@yr/monotone-cubic-spline/-/monotone-cubic-spline-1.0.3.tgz", "integrity": "sha512-FQXkOta0XBSUPHndIKON2Y9JeQz5ZeMqLYZVVK93FliNBFm7LNMIZmY6FrMEB9XPcDbE2bekMbZD6kzDkxwYjA==" }, + "node_modules/animate.css": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/animate.css/-/animate.css-4.1.1.tgz", + "integrity": "sha512-+mRmCTv6SbCmtYJCN4faJMNFVNN5EuCTTprDTAo7YzIGji2KADmakjVA3+8mVDkZ2Bf09vayB35lSQIex2+QaQ==", + "license": "MIT" + }, "node_modules/apexcharts": { "version": "3.54.1", "resolved": "https://registry.npmjs.org/apexcharts/-/apexcharts-3.54.1.tgz", @@ -992,6 +1000,12 @@ "node": "^8.16.0 || ^10.6.0 || >=11.0.0" } }, + "node_modules/gsap": { + "version": "3.12.7", + "resolved": "https://registry.npmjs.org/gsap/-/gsap-3.12.7.tgz", + "integrity": "sha512-V4GsyVamhmKefvcAKaoy0h6si0xX7ogwBoBSs2CTJwt7luW0oZzC0LhdkyuKV8PJAXr7Yaj8pMjCKD4GJ+eEMg==", + "license": "Standard 'no charge' license: https://gsap.com/standard-license. Club GSAP members get more: https://gsap.com/licensing/. Why GreenSock doesn't employ an MIT license: https://gsap.com/why-license/" + }, "node_modules/jwt-decode": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/jwt-decode/-/jwt-decode-4.0.0.tgz", diff --git a/package.json b/package.json index ff4cd4b..70321ab 100644 --- a/package.json +++ b/package.json @@ -10,10 +10,12 @@ }, "dependencies": { "@mdi/font": "^7.4.47", + "animate.css": "^4.1.1", "apexcharts": "^3.54.1", "axios": "^1.8.4", "dashboard": "file:", "date-fns": "^4.1.0", + "gsap": "^3.12.7", "jwt-decode": "^4.0.0", "npm-check-updates": "^17.1.11", "pdf-parse": "^1.1.1", diff --git a/src/components/modals/HolidayModal.vue b/src/components/modals/HolidayModal.vue index 844a3af..84315f1 100644 --- a/src/components/modals/HolidayModal.vue +++ b/src/components/modals/HolidayModal.vue @@ -93,7 +93,9 @@ const loadHolidayData = async () => { estado: holidayData.estado || '', municipio: holidayData.municipio || '', parent_id: authStore.userId, - service_instance_id: authStore.service_instance_id || 2 + service_instance_id: authStore.service_instance_id || 2, + adicional_he: Number(localHoliday.value.adicional_he), // Garante tipo numérico + recorrente: localHoliday.value.recorrente }; } else if (props.holiday) { // Fallback para os dados recebidos via props diff --git a/src/components/modals/HolidayModalCreate.vue b/src/components/modals/HolidayModalCreate.vue index 4f68d6f..199abf5 100644 --- a/src/components/modals/HolidayModalCreate.vue +++ b/src/components/modals/HolidayModalCreate.vue @@ -19,10 +19,34 @@ :rules="[v => !!v || 'Data é obrigatória']" required /> - + - + + + + + + + @@ -30,8 +54,13 @@ Cancelar - + Salvar @@ -64,6 +93,8 @@ const defaultHoliday = { date: '', estado: '', municipio: '', + recorrente: true, + adicional_he: 0, parent_id: authStore.userId, service_instance_id: authStore.service_instance_id || 2 }; @@ -116,25 +147,26 @@ const closeModal = () => { // Salvar o novo feriado const handleSave = async (event) => { - if(form.value.validate()){ - event.preventDefault(); // Impede o comportamento padrão do botão + event.preventDefault(); + + // Valida apenas o formulário (sem verificações extras) + const { valid } = await form.value.validate(); + + if (valid) { // ⚠️ Só depende da validação do formulário try { - const holidayData = { + await holidayStore.createHoliday({ ...localHoliday.value, parent_id: authStore.userId, - service_instance_id: authStore.service_instance_id || 2 - }; + service_instance_id: authStore.service_instance_id + }); - console.log('Criando novo feriado:', holidayData); - - await holidayStore.createHoliday(holidayData); - - emit('save', holidayData); + emit('save'); emit('update:modalValue', false); resetLocalHoliday(); } catch (error) { console.error('Erro ao criar feriado:', error); - }} + } + } }; // Inicialização do componente diff --git a/src/routes/router.js b/src/routes/router.js index 793fde0..e8d121a 100644 --- a/src/routes/router.js +++ b/src/routes/router.js @@ -16,8 +16,19 @@ import Holiday from '../views/Holiday.vue' import Company from '../views/Company.vue' const routes = [ - { path: '/', redirect: '/login' }, - { path: '/login', component: Login }, + { + path: '/', + redirect: '/login' + }, + { + path: '/login', + name: 'login', + component: Login, + meta: { + transition: 'slide', + requiresGuest: true + } + }, { path: '/dashboard', component: Dashboard, diff --git a/src/stores/holiday.js b/src/stores/holiday.js index 9323b59..c6581f0 100644 --- a/src/stores/holiday.js +++ b/src/stores/holiday.js @@ -100,19 +100,31 @@ export const useHolidayStore = defineStore('holidays', { const url = '/holiday/'; this.loading = true; this.error = null; - + try { - const response = await api.post(url, holiday, { + // Garantindo que o objeto holiday tem todos os campos necessários + const holidayData = { + name: holiday.name, + date: holiday.date, + estado: holiday.estado || '', + municipio: holiday.municipio || '', + recorrente: holiday.recorrente !== undefined ? holiday.recorrente : true, + adicional_he: holiday.adicional_he !== undefined ? holiday.adicional_he : 0, + type: holiday.type || '', + service_instance_id: useAuthStore().service_instance_id + }; + + const response = await api.post(url, holidayData, { headers: { 'Content-Type': 'application/json' } }); - + this.holidays.push(response.data); return response.data; } catch (error) { this.error = error?.response?.data?.message || error.message || 'Erro ao criar feriado'; - console.error('Erro ao criar turno', error); + console.error('Erro ao criar feriado', error); throw error; } finally { this.loading = false; @@ -133,6 +145,7 @@ export const useHolidayStore = defineStore('holidays', { date: holiday.date, estado: holiday.estado, municipio: holiday.municipio, + type: holiday.type || '', }); const index = this.holidays.findIndex((s) => s.id === id); diff --git a/src/stores/shift.js b/src/stores/shift.js index f3fe542..2c986a1 100644 --- a/src/stores/shift.js +++ b/src/stores/shift.js @@ -2,7 +2,6 @@ import { defineStore } from 'pinia'; import api from '../services/api'; import router from '../routes/router'; import { useAuthStore } from './auth'; -import { ca } from 'date-fns/locale'; export const useShiftStore = defineStore('shifts', { state: () => ({ diff --git a/src/views/Holiday.vue b/src/views/Holiday.vue index 38cb666..04b4c00 100644 --- a/src/views/Holiday.vue +++ b/src/views/Holiday.vue @@ -1,548 +1,642 @@