diff --git a/src/i18n/en/index.js b/src/i18n/en/index.js index 0be04003e..558709513 100644 --- a/src/i18n/en/index.js +++ b/src/i18n/en/index.js @@ -835,6 +835,7 @@ export default { workerCreate: 'New worker', department: 'Department', pda: 'PDA', + timeControl: 'Time control', }, list: { name: 'Name', @@ -1201,4 +1202,13 @@ export default { }, iban_tooltip: 'IBAN: ES21 1234 5678 90 0123456789', }, + weekdays: { + sun: 'Sunday', + mon: 'Monday', + tue: 'Tuesday', + wed: 'Wednesday', + thu: 'Thursday', + fri: 'Friday', + sat: 'Saturday', + }, }; diff --git a/src/i18n/es/index.js b/src/i18n/es/index.js index 610c6017f..0a81b7ec5 100644 --- a/src/i18n/es/index.js +++ b/src/i18n/es/index.js @@ -835,6 +835,7 @@ export default { workerCreate: 'Nuevo trabajador', department: 'Departamentos', pda: 'PDA', + timeControl: 'Control de horario', }, list: { name: 'Nombre', @@ -1201,4 +1202,13 @@ export default { }, iban_tooltip: 'IBAN: ES21 1234 5678 90 0123456789', }, + weekdays: { + sun: 'Domingo', + mon: 'Lunes', + tue: 'Martes', + wed: 'Miércoles', + thu: 'Jueves', + fri: 'Viernes', + sat: 'Sábado', + }, }; diff --git a/src/pages/Worker/Card/WorkerTimeControl.vue b/src/pages/Worker/Card/WorkerTimeControl.vue new file mode 100644 index 000000000..306e7bc54 --- /dev/null +++ b/src/pages/Worker/Card/WorkerTimeControl.vue @@ -0,0 +1,146 @@ + + + + + + + +es: + Entrada: Entrada + Intermedio: Intermedio + Salida: Salida + diff --git a/src/router/modules/worker.js b/src/router/modules/worker.js index 1c722afe8..8d7891b40 100644 --- a/src/router/modules/worker.js +++ b/src/router/modules/worker.js @@ -12,7 +12,7 @@ export default { redirect: { name: 'WorkerMain' }, menus: { main: ['WorkerList', 'WorkerDepartment'], - card: ['WorkerNotificationsManager', 'WorkerPda'], + card: ['WorkerNotificationsManager', 'WorkerPda', 'WorkerTimeControl'], departmentCard: ['BasicData'], }, children: [ @@ -85,6 +85,16 @@ export default { }, component: () => import('src/pages/Worker/Card/WorkerPda.vue'), }, + { + name: 'WorkerTimeControl', + path: 'time-control', + meta: { + title: 'timeControl', + icon: 'access_time', + }, + component: () => + import('src/pages/Worker/Card/WorkerTimeControl.vue'), + }, ], }, ], diff --git a/src/stores/useWeekdayStore.js b/src/stores/useWeekdayStore.js new file mode 100644 index 000000000..2d0078c1e --- /dev/null +++ b/src/stores/useWeekdayStore.js @@ -0,0 +1,71 @@ +import { computed, ref, reactive } from 'vue'; +import { useI18n } from 'vue-i18n'; +import { defineStore } from 'pinia'; + +export const useWeekdayStore = defineStore('weekdayStore', () => { + const weekdays = [ + { code: 'sun', name: 'Sunday' }, + { code: 'mon', name: 'Monday' }, + { code: 'tue', name: 'Tuesday' }, + { code: 'wed', name: 'Wednesday' }, + { code: 'thu', name: 'Thursday' }, + { code: 'fri', name: 'Friday' }, + { code: 'sat', name: 'Saturday' }, + ]; + + const localeOrder = { + es: ['mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun'], + en: ['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'], + }; + + const { t, locale } = useI18n(); + const localeWeekdays = ref([]); + const weekdaysMap = reactive({}); + + const initStore = () => { + getWeekdaysMap(); + getLocales(); + console.log('weekdaysMap:: ', weekdaysMap); + }; + + const getWeekdaysMap = () => { + if (Object.keys(weekdaysMap).length > 0) return weekdaysMap; + + weekdays.forEach((day, i) => { + const obj = { + ...day, + index: i, + char: day.name.substr(0, 1), + abr: day.name.substr(0, 3), + locale: t(`weekdays.${day.code}`), + localeChar: t(`weekdays.${day.code}`).substr(0, 1), + localeAbr: t(`weekdays.${day.code}`).substr(0, 3), + }; + weekdaysMap[day.code] = obj; + }); + }; + + const getLocales = () => { + if (localeWeekdays.value.length > 0) return localeWeekdays.value; + for (let code of localeOrder.es) { + console.log('code:: ', code); + localeWeekdays.value.push(weekdaysMap[code]); + } + console.log('localeWeekdays:: ', localeWeekdays.value); + return localeWeekdays.value; + }; + + // const orderLocales = (weekDaysArray) => { + // const order = localeOrder[locale.value] || localeOrder.en; + // const orderedLocales = []; + // for (let code of order) orderedLocales.push(weekDaysArray[code]); + // // return order.map((code) => localeWeekdays.value.find((day) => day.code === code)); + // }; + + return { + initStore, + getLocales, + localeWeekdays, + weekdaysMap, + }; +});