diff --git a/src/core/components/table/AttendanceTable/Composables/AttendanceSheets.js b/src/core/components/table/AttendanceTable/Composables/AttendanceSheets.js index 32d91c2ef..da308dc6a 100644 --- a/src/core/components/table/AttendanceTable/Composables/AttendanceSheets.js +++ b/src/core/components/table/AttendanceTable/Composables/AttendanceSheets.js @@ -6,7 +6,7 @@ import groupBy from 'lodash/groupBy'; import useVuelidate from '@vuelidate/core'; import { required, requiredIf } from '@vuelidate/validators'; import AttendanceSheets from '@api/AttendanceSheets'; -import { INTER_B2B, DD_MM_YYYY } from '@data/constants'; +import { INTER_B2B, DD_MM_YYYY, GENERATION } from '@data/constants'; import { formatIdentity, sortStrings } from '@helpers/utils'; import CompaniDate from '@helpers/dates/companiDates'; import { NotifyPositive, NotifyNegative, NotifyWarning } from '@components/popup/notify'; @@ -177,6 +177,23 @@ export const useAttendanceSheets = ( } }; + const generateAttendanceSheet = async (attendanceSheetId) => { + try { + modalLoading.value = true; + + await AttendanceSheets.update(attendanceSheetId, { method: GENERATION }); + + NotifyPositive('Feuille d\'émargement générée.'); + await refreshAttendanceSheets(); + } catch (e) { + console.error(e); + if (e.data.statusCode === 403) return NotifyNegative(e.data.message); + NotifyNegative('Erreur lors de la génération de la feuille d\'émargement.'); + } finally { + modalLoading.value = false; + } + }; + const validateAttendanceSheetDeletion = (attendanceSheet) => { if (!canUpdate.value) return NotifyNegative('Impossible de supprimer la feuille d\'émargement.'); @@ -281,6 +298,7 @@ export const useAttendanceSheets = ( openAttendanceSheetEditionModal, updateAttendanceSheet, resetAttendanceSheetEditionModal, + generateAttendanceSheet, // Validations attendanceSheetValidations: v$, }; diff --git a/src/core/components/table/AttendanceTable/index.vue b/src/core/components/table/AttendanceTable/index.vue index f51862d96..06bd67017 100644 --- a/src/core/components/table/AttendanceTable/index.vue +++ b/src/core/components/table/AttendanceTable/index.vue @@ -99,7 +99,12 @@ +