diff --git a/src/i18n/en-ca/index.ts b/src/i18n/en-ca/index.ts index c733aa2..e01b2c2 100644 --- a/src/i18n/en-ca/index.ts +++ b/src/i18n/en-ca/index.ts @@ -250,7 +250,8 @@ export default { timeSheetValidations: 'Time sheet approvals', }, timesheet: { - //employee's timesheet page + title:'Timesheet', + date_ranges_to:'to', days: ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'], nav_button: { calendar_date_picker:'Calendar', @@ -262,29 +263,38 @@ export default { cancel_button:'Cancel', remote_button: 'Remote work', delete_button: 'Delete', - - delete_confirmation_msg: 'Do you want to delete this shift completly?', - - add_shift:'Add Shift', - edit_shift: 'Edit shift', - delete_shift: 'Delete shift', - - shift_types_label: 'Shift`s Type', - shift_types: { - EMERGENCY: 'Emergency', - EVENING: 'Evening', - HOLIDAY: 'Holiday', - OVERTIME: 'Overtime', - REGULAR: 'Regular', - SICK: 'Sick Leave', - VACATION: 'Vacation', - REMOTE: 'Remote work', - }, - fields: { - start:'Start (HH:mm)', - end:'End (HH:mm)', - header_comment:'Shift`s comment', - textarea_comment: 'Leave a comment here', + shift: { + actions: { + add:'Add Shift', + edit: 'Edit shift', + delete: 'Delete shift', + delete_confirmation_msg: 'Do you want to delete this shift completly?', + }, + types: { + label: 'Shift`s Type', + EMERGENCY: 'Emergency', + EVENING: 'Evening', + HOLIDAY: 'Holiday', + OVERTIME: 'Overtime', + REGULAR: 'Regular', + SICK: 'Sick Leave', + VACATION: 'Vacation', + REMOTE: 'Remote work', + }, + errors: { + not_found:'Shift not found', + overlap:'An overlaps occured between 2 or more shifts', + invalid:'Invalid shift`s entry', + unknown:'Unknown error', + comment_required:'A comment is required', + comment_too_long:'Your comment is too long', + }, + fields: { + start:'Start (HH:mm)', + end:'End (HH:mm)', + header_comment:'Shift`s comment', + textarea_comment: 'Leave a comment here', + }, }, expense: { add_expense:'Add Expense', @@ -292,17 +302,18 @@ export default { date:'Date', empty_list:'No registered expenses', errors: { - date_required_or_invalid:'', - comment_required:'', - comment_too_long:'', - amount_must_be_positive:'', - mileave_must_be_positive:'', - amount_xor_mileage:'', - mileage_required_for_type:'', - amount_required_for_type:'', + date_required_or_invalid:'the date is missing or invalid', + comment_required:'A comment required', + comment_too_long:'Your comment is too long', + amount_must_be_positive:'the amount cannot be under 0$', + mileave_must_be_positive:'the mileage cannot be under 0', + amount_xor_mileage:'you cannot enter an amount and a mileage for the same expense', + mileage_required_for_type:'you need to enter a value for mileage when you enter an expense of that type', + amount_required_for_type:'you need to enter a value for amount when you enter an expense of that type', }, hints: { amount_or_mileage:'Either amount or mileage, not both', + comment_required:'A comment required', }, mileage:'Mileage', open_btn:'List of expenses', @@ -311,10 +322,10 @@ export default { total_mileage:'Total mileage', type:'Type', types: { - PER_DIEM:'', - EXPENSES:'', - MILEAGE:'', - PRIME_GARDE:'', + PER_DIEM:'Per Diem', + EXPENSES:'expense', + MILEAGE:'mileage', + PRIME_GARDE:'on-call allowance', }, }, }, diff --git a/src/i18n/fr-ca/index.ts b/src/i18n/fr-ca/index.ts index 1bdd198..ccf79e3 100644 --- a/src/i18n/fr-ca/index.ts +++ b/src/i18n/fr-ca/index.ts @@ -300,7 +300,8 @@ export default { noDataLabel: 'Je n’ai rien trouvé pour toi', }, timesheet: { - //employee's timesheet page + title:'Carte de temps', + date_ranges_to:'au', days: ['Dimanche','Lundi','Mardi','Mercredi','Jeudi','Vendredi','Samedi'], nav_button: { calendar_date_picker:'Calendrier', @@ -312,26 +313,38 @@ export default { cancel_button:'Annuler', remote_button: 'Télétravail', delete_button: 'Supprimer', - delete_confirmation_msg: 'Voulez-vous supprimer complètement ce quart?', - add_shift:'Ajouter une quart', - edit_shift: 'Modifier un quart', - delete_shift: 'Supprimer un quart', - shift_types_label: 'Type de quart', - shift_types: { - EMERGENCY: 'Urgence', - EVENING: 'Soir', - HOLIDAY: 'Férié', - OVERTIME: 'Supplémentaire', - SICK: 'Absence', - REGULAR: 'Régulier', - VACATION: 'Vacance', - REMOTE: 'Télétravail', - }, - fields: { - start:'Entrée (HH:mm)', - end:'Sortie (HH:mm)', - header_comment:'Commentaire du Quart', - textarea_comment:'Laissez votre commentaire', + shift: { + actions: { + add:'Ajouter un Quart', + edit: 'Modifier un Quart', + delete: 'Supprimer un Quart', + delete_confirmation_msg: 'Voulez-vous complètement supprimer ce quart?', + }, + types: { + label: 'Type de Quart', + EMERGENCY: 'Urgence', + EVENING: 'Soir', + HOLIDAY: 'Férié', + OVERTIME: 'Supplémentaire', + REGULAR: 'Régulier', + SICK: 'Maladie', + VACATION: 'Vacance', + REMOTE: 'Télétravail', + }, + errors: { + not_found:'Aucun quart trouvé', + overlap:'Il y a un chevauchement entre deux ou plusieurs quarts', + invalid:'Entrée du quart invalide', + unknown:'Erreur inconnue', + comment_required:'un commentaire est requis', + comment_too_long:'votre commentaire est trop long', + }, + fields: { + start:'Début (HH:mm)', + end:'Fin (HH:mm)', + header_comment:'Commentaire du Quart', + textarea_comment: 'Laissez votre commentaire ici', + }, }, expense: { add_expense:'Ajouter une dépense', @@ -339,17 +352,18 @@ export default { date:'Date', empty_list:'Aucun dépense enregistrée', errors: { - date_required_or_invalid:'', - comment_required:'', - comment_too_long:'', - amount_must_be_positive:'', - mileave_must_be_positive:'', - amount_xor_mileage:'', - mileage_required_for_type:'', - amount_required_for_type:'', + date_required_or_invalid:'La date est manquante ou invalide', + comment_required:'un commentaire est requis', + comment_too_long:'votre commentaire est trop long', + amount_must_be_positive:'le montant doit être suppérieur à 0$', + mileave_must_be_positive:'le kilométrage doit être suppérieur à 0', + amount_xor_mileage:'Vous ne pouvez pas saisir un montant et un kilométrage pour une même dépense', + mileage_required_for_type:'Vous devez entrer une valeur en kilométrage pour ce type de dépense', + amount_required_for_type:'Vous devez entrer une valeur en montant $ pour ce type de dépense', }, hints: { amount_or_mileage:'Soit dépense ou kilométrage, pas les deux', + comment_required:'un commentaire est requis', }, mileage:'Kilométrage', open_btn:'Liste des Dépenses', @@ -358,10 +372,10 @@ export default { total_mileage:'Kilométrage total', type:'Type', types: { - PER_DIEM:'', - EXPENSES:'', - MILEAGE:'', - PRIME_GARDE:'', + PER_DIEM:'Per diem', + EXPENSES:'dépense', + MILEAGE:'kilométrage', + PRIME_GARDE:'Prime de garde', }, }, }, diff --git a/src/modules/timesheets/components/expenses/timesheet-details-expenses.vue b/src/modules/timesheets/components/expenses/timesheet-details-expenses.vue index 8ba65c3..cda1de1 100644 --- a/src/modules/timesheets/components/expenses/timesheet-details-expenses.vue +++ b/src/modules/timesheets/components/expenses/timesheet-details-expenses.vue @@ -1,10 +1,11 @@ + + + \ No newline at end of file diff --git a/src/modules/timesheets/components/shift/shifts-legend.vue b/src/modules/timesheets/components/shift/shifts-legend.vue index 039abfc..08a568f 100644 --- a/src/modules/timesheets/components/shift/shifts-legend.vue +++ b/src/modules/timesheets/components/shift/shifts-legend.vue @@ -13,13 +13,13 @@ type ShiftLegendItem = { }; const legend: ShiftLegendItem[] = [ - {type:'REGULAR' , color: 'secondary', label_key: 'timesheet.shift_types.REGULAR', text_color: 'grey-8'}, - {type:'EVENING' , color: 'warning' , label_key: 'timesheet.shift_types.EVENING'}, - {type:'EMERGENCY', color: 'amber-10' , label_key: 'timesheet.shift_types.EMERGENCY'}, - {type:'OVERTIME' , color: 'negative' , label_key: 'timesheet.shift_types.OVERTIME'}, - {type:'VACATION' , color: 'purple-10', label_key: 'timesheet.shift_types.VACATION'}, - {type:'HOLIDAY' , color: 'purple-8' , label_key: 'timesheet.shift_types.HOLIDAY'}, - {type:'SICK' , color: 'grey-8' , label_key: 'timesheet.shift_types.SICK'}, + {type:'REGULAR' , color: 'secondary', label_key: 'timesheet.shift.types.REGULAR', text_color: 'grey-8'}, + {type:'EVENING' , color: 'warning' , label_key: 'timesheet.shift.types.EVENING'}, + {type:'EMERGENCY', color: 'amber-10' , label_key: 'timesheet.shift.types.EMERGENCY'}, + {type:'OVERTIME' , color: 'negative' , label_key: 'timesheet.shift.types.OVERTIME'}, + {type:'VACATION' , color: 'purple-10', label_key: 'timesheet.shift.types.VACATION'}, + {type:'HOLIDAY' , color: 'purple-8' , label_key: 'timesheet.shift.types.HOLIDAY'}, + {type:'SICK' , color: 'grey-8' , label_key: 'timesheet.shift.types.SICK'}, ] const shift_type_legend = computed(()=> diff --git a/src/modules/timesheets/pages/timesheet-details-overview.vue b/src/modules/timesheets/pages/timesheet-details-overview.vue index 341842d..08bb5cc 100644 --- a/src/modules/timesheets/pages/timesheet-details-overview.vue +++ b/src/modules/timesheets/pages/timesheet-details-overview.vue @@ -8,10 +8,12 @@ import { date } from 'quasar'; import TimesheetNavigation from '../components/timesheet/timesheet-navigation.vue'; import ShiftsLegend from '../components/shift/shifts-legend.vue'; import TimesheetDetailsShifts from '../components/shift/timesheet-details-shifts.vue'; -import { upsert_shifts_by_date, type ShiftPayload, type UpsertShiftsBody } from '../composables/use-shift-api'; +import { type ShiftPayload } from '../composables/use-shift-api'; import { ExpensesApiError, get_pay_period_expenses, put_pay_period_expenses } from '../composables/use-expense-api'; import type { PayPeriodExpenses } from '../types/timesheet-expenses-list-interface'; import type { TimesheetExpense } from '../types/timesheet-expenses-interface'; +import TimesheetDetailsExpenses from '../components/expenses/timesheet-details-expenses.vue'; +import ShiftCrudDialog from '../components/shift/shift-crud-dialog.vue'; /* eslint-disable */ const { locale, t } = useI18n(); @@ -26,13 +28,13 @@ const expenses_data = ref(null); const notify_error = (err: number) => { const e = err as any; - error_banner.value = (e instanceof ExpensesApiError && t(e.message)) || e?.message || 'Unknown error'; + expenses_error.value = (e instanceof ExpensesApiError && t(e.message)) || e?.message || 'Unknown error'; }; const open_expenses_dialog = async () => { show_expenses_dialog.value = true; is_loading_expenses.value = true; - error_banner.value = null; + expenses_error.value = null; try { const data = await get_pay_period_expenses( @@ -62,7 +64,7 @@ const on_save_expenses = async (payload: { expenses: TimesheetExpense[]; }) => { is_loading_expenses.value = true; - error_banner.value = null; + expenses_error.value = null; try{ const updated = await put_pay_period_expenses( @@ -129,6 +131,10 @@ onMounted( async () => { await loadByDate(date.formatDate(new Date(), 'YYYY-MM-DD' )); }); +const onShiftSaved = async () => { + await timesheet_store.getTimesheetsByPayPeriodAndEmail(auth_store.user.email); +} + type FormMode = 'create' | 'edit' | 'delete'; const is_dialog_open = ref(false); @@ -136,32 +142,16 @@ const form_mode = ref('create'); const selected_date = ref(''); const old_shift_ref = ref(undefined); -const start_time = ref(''); -const end_time = ref(''); -const type = ref(''); -const is_remote = ref(false); -const comment = ref(''); - const open_create_dialog = (iso_date: string) => { form_mode.value = 'create'; selected_date.value = iso_date; old_shift_ref.value = undefined; - start_time.value = ''; - end_time.value = ''; - type.value = ''; - is_remote.value = false; - comment.value = ''; is_dialog_open.value = true; }; const open_edit_dialog = (iso_date: string, shift: any) => { form_mode.value = 'edit'; selected_date.value = iso_date; - start_time.value = shift.start_time, - end_time.value = shift.end_time, - type.value = shift.type, - is_remote.value = shift.is_remote, - comment.value = shift.comment, is_dialog_open.value = true; old_shift_ref.value = { start_time: shift.start_time, @@ -185,65 +175,13 @@ const open_delete_dialog = (iso_date: string, shift: any) => { is_dialog_open.value = true; }; -const build_new_shift_payload = () => { - const base = { - start_time: start_time.value, - end_time: end_time.value, - type: type.value, - is_remote: !!is_remote.value, - }; - const trimmed_comment = (comment.value ?? '').trim(); - return { - ...base, - ...(trimmed_comment.length > 0 ? { comment: trimmed_comment }: {}), - }; -}; -const is_submitting = ref(false); -const error_banner = ref(null); -const conflicts = ref>([]); -const submit_dialog = async () => { - error_banner.value = null; - conflicts.value = []; - is_submitting.value = true; - try { - const email = auth_store.user.email; - const date_iso = selected_date.value; - let body: UpsertShiftsBody; - - if(form_mode.value === 'create') { - body = { new_shift: build_new_shift_payload() }; - } else if (form_mode.value === 'edit') { - body = { old_shift: old_shift_ref.value!, new_shift: build_new_shift_payload() }; - } else { - body = { old_shift: old_shift_ref.value! }; - } - - await upsert_shifts_by_date(email, date_iso, body); - await timesheet_store.getTimesheetsByPayPeriodAndEmail(email); - - close_dialog(); - is_dialog_open.value = false; - } catch (e:any) { - const status = e?.status_code ?? e?.response?.status ?? 500; - if (status === 404) { - error_banner.value = 'Ce quart a été modifié ou supprimé. Rafraichissez la page.'; - } else if (status === 409) { - error_banner.value = 'Chevauchement détecté avec un autre quart'; - } else if (status === 422) { - error_banner.value = 'Certains champs sont invalides. Vérifiez le formulaire.'; - } else { - error_banner.value = e?.message || 'Erreur inconnue'; - } - } finally { - is_submitting.value = false; - } -}; +const expenses_error = ref(null); const close_dialog = () => { - error_banner.value = null; + expenses_error.value = null; is_dialog_open.value = false; }; @@ -257,7 +195,7 @@ const on_request_delete = async ({ date, shift }: { date: string; shift: any })
- {{ $t('pageTitles.timeSheets') }} + {{ $t('timesheet.title') }}
- {{ $t('timesheet.dateRangesTo') }} + {{ $t('timesheet.date_ranges_to') }}
- + @@ -330,8 +267,15 @@ const on_request_delete = async ({ date, shift }: { date: string; shift: any }) + + {{ expenses_error }} + - - - - -
- -
- {{ form_mode === 'create' ? $t('timesheet.add_shift') : form_mode === 'edit' ? $t('timesheet.edit_shift') : $t('timesheet.delete_shift') }} -
- - {{ selected_date }} -
- - -
-
-
- -
-
- -
-
-
- - -
- -
- -
- {{ $t('timesheet.delete_confirmation_msg') }} -
- -
- {{ error_banner }} -
-
Conflits :
-
    -
  • - {{ c.start_time }}–{{ c.end_time }} ({{ c.type }}) -
  • -
-
-
- - - -
- - - -
-
-
+ + \ No newline at end of file