From c5c0e8b358a26ef4404cf3167a3cd2976a11d583 Mon Sep 17 00:00:00 2001 From: Matthieu Haineault Date: Thu, 25 Sep 2025 09:05:03 -0400 Subject: [PATCH] refactor(types): refactoring of shifts, expenses, timesheet types, interfaces and defaults values. --- quasar.config.ts | 2 +- src/i18n/en-ca/index.ts | 1 + src/i18n/fr-ca/index.ts | 1 + src/modules/shared/composables/use-toggle.ts | 17 + ...sheet-approval-employee-expenses-chart.vue | 2 +- ...t-approval-employee-details-shifts-row.vue | 9 +- ...sheet-approval-employee-details-shifts.vue | 3 +- ...l-pay-period-employee-details-interface.ts | 8 +- .../components/expenses/expense-form.vue | 185 ++++++++ .../components/expenses/expense-list.vue | 98 ++++ .../expense-supervisor-comment.vue} | 0 .../expenses/timesheet-details-expenses.vue | 436 ++++-------------- ...der.vue => detailed-shift-list-header.vue} | 0 ...ts-row.vue => detailed-shift-list-row.vue} | 12 +- ...ils-shifts.vue => detailed-shift-list.vue} | 17 +- .../components/shift/shift-crud-dialog.vue | 69 +-- .../components/shift/shifts-legend.vue | 8 +- .../timesheet/timesheet-save-payload.vue | 8 +- .../composables/{ => api}/use-expense-api.ts | 89 ++-- .../composables/{ => api}/use-shift-api.ts | 40 +- .../{ => api}/use-timesheet-api.ts | 17 +- .../composables/use-expense-draft.ts | 36 ++ .../composables/use-expense-form.ts | 21 + .../composables/use-expense-items.ts | 55 +++ .../timesheets/constants/expense.constants.ts | 3 + .../timesheets/constants/shift.constants.ts | 2 + .../pages/timesheet-details-overview.vue | 286 ++++-------- .../timesheets/services/timesheet-services.ts | 4 +- src/modules/timesheets/timesheet-constants.ts | 1 - .../types/expense-validation.interface.ts | 34 ++ .../timesheets/types/expense.defaults.ts | 0 .../timesheets/types/expense.interfaces.ts | 47 ++ src/modules/timesheets/types/expense.types.ts | 29 ++ .../timesheets/types/shift.defaults.ts | 11 + .../timesheets/types/shift.interfaces.ts | 44 ++ src/modules/timesheets/types/shift.types.ts | 30 ++ .../types/timesheet-details-interface.ts | 83 ---- .../types/timesheet-expenses-interface.ts | 21 - .../timesheet-expenses-list-interface.ts | 14 - .../timesheets/types/timesheet-interface.ts | 28 -- ...t-pay-period-details-overview-interface.ts | 11 - .../types/timesheet-shift-interface.ts | 19 - .../timesheet-shifts-payload-interface.ts | 12 - .../timesheets/types/timesheet.defaults.ts | 39 ++ .../timesheets/types/timesheet.interfaces.ts | 54 +++ .../timesheets/types/timesheet.types.ts | 29 ++ src/modules/timesheets/types/ui.types.ts | 6 + src/modules/timesheets/utils/expense.util.ts | 76 +++ ...s-validators.ts => expenses-validators.ts} | 52 +-- src/modules/timesheets/utils/shift.util.ts | 19 + .../timesheets/utils/timesheet-format.util.ts | 17 + src/stores/expense-store.ts | 88 ++++ src/stores/shift-store.ts | 50 ++ src/stores/timesheet-store.ts | 38 +- src/utils/with-loading.util.ts | 10 + 55 files changed, 1354 insertions(+), 937 deletions(-) create mode 100644 src/modules/shared/composables/use-toggle.ts create mode 100644 src/modules/timesheets/components/expenses/expense-form.vue create mode 100644 src/modules/timesheets/components/expenses/expense-list.vue rename src/modules/timesheets/components/{shift/shift-comment.vue => expenses/expense-supervisor-comment.vue} (100%) rename src/modules/timesheets/components/shift/{timesheet-details-shifts-row-header.vue => detailed-shift-list-header.vue} (100%) rename src/modules/timesheets/components/shift/{timesheet-details-shifts-row.vue => detailed-shift-list-row.vue} (92%) rename src/modules/timesheets/components/shift/{timesheet-details-shifts.vue => detailed-shift-list.vue} (85%) rename src/modules/timesheets/composables/{ => api}/use-expense-api.ts (65%) rename src/modules/timesheets/composables/{ => api}/use-shift-api.ts (83%) rename src/modules/timesheets/composables/{ => api}/use-timesheet-api.ts (81%) create mode 100644 src/modules/timesheets/composables/use-expense-draft.ts create mode 100644 src/modules/timesheets/composables/use-expense-form.ts create mode 100644 src/modules/timesheets/composables/use-expense-items.ts create mode 100644 src/modules/timesheets/constants/expense.constants.ts create mode 100644 src/modules/timesheets/constants/shift.constants.ts delete mode 100644 src/modules/timesheets/timesheet-constants.ts create mode 100644 src/modules/timesheets/types/expense-validation.interface.ts create mode 100644 src/modules/timesheets/types/expense.defaults.ts create mode 100644 src/modules/timesheets/types/expense.interfaces.ts create mode 100644 src/modules/timesheets/types/expense.types.ts create mode 100644 src/modules/timesheets/types/shift.defaults.ts create mode 100644 src/modules/timesheets/types/shift.interfaces.ts create mode 100644 src/modules/timesheets/types/shift.types.ts delete mode 100644 src/modules/timesheets/types/timesheet-details-interface.ts delete mode 100644 src/modules/timesheets/types/timesheet-expenses-interface.ts delete mode 100644 src/modules/timesheets/types/timesheet-expenses-list-interface.ts delete mode 100644 src/modules/timesheets/types/timesheet-interface.ts delete mode 100644 src/modules/timesheets/types/timesheet-pay-period-details-overview-interface.ts delete mode 100644 src/modules/timesheets/types/timesheet-shift-interface.ts delete mode 100644 src/modules/timesheets/types/timesheet-shifts-payload-interface.ts create mode 100644 src/modules/timesheets/types/timesheet.defaults.ts create mode 100644 src/modules/timesheets/types/timesheet.interfaces.ts create mode 100644 src/modules/timesheets/types/timesheet.types.ts create mode 100644 src/modules/timesheets/types/ui.types.ts create mode 100644 src/modules/timesheets/utils/expense.util.ts rename src/modules/timesheets/utils/{timesheet-expenses-validators.ts => expenses-validators.ts} (73%) create mode 100644 src/modules/timesheets/utils/shift.util.ts create mode 100644 src/modules/timesheets/utils/timesheet-format.util.ts create mode 100644 src/stores/expense-store.ts create mode 100644 src/stores/shift-store.ts create mode 100644 src/utils/with-loading.util.ts diff --git a/quasar.config.ts b/quasar.config.ts index 4d94787..3821349 100644 --- a/quasar.config.ts +++ b/quasar.config.ts @@ -106,7 +106,7 @@ export default defineConfig((ctx) => { color: 'primary', avatar: 'https://cdn.quasar.dev/img/boy-avatar.png', }, - dark: false, + dark: "auto", }, // iconSet: 'material-icons', // Quasar icon set diff --git a/src/i18n/en-ca/index.ts b/src/i18n/en-ca/index.ts index 2697fe5..15683c6 100644 --- a/src/i18n/en-ca/index.ts +++ b/src/i18n/en-ca/index.ts @@ -179,6 +179,7 @@ export default { hints: { amount_or_mileage:"Either amount or mileage, not both", comment_required:"A comment required", + attach_file:"Attach File" }, mileage:"mileage", open_btn:"list of expenses", diff --git a/src/i18n/fr-ca/index.ts b/src/i18n/fr-ca/index.ts index 4a5a9ba..0471595 100644 --- a/src/i18n/fr-ca/index.ts +++ b/src/i18n/fr-ca/index.ts @@ -179,6 +179,7 @@ export default { hints: { amount_or_mileage:"Soit dépense ou kilométrage, pas les deux", comment_required:"un commentaire est requis", + attach_file:"Pièce jointe" }, mileage:"Kilométrage", open_btn:"Liste des Dépenses", diff --git a/src/modules/shared/composables/use-toggle.ts b/src/modules/shared/composables/use-toggle.ts new file mode 100644 index 0000000..64a026c --- /dev/null +++ b/src/modules/shared/composables/use-toggle.ts @@ -0,0 +1,17 @@ +import { ref } from "vue"; + +//date picker state +export const useToggle = (initial = false) => { + const state = ref(initial); + + const setTrue = () => { state.value = true; }; + const setFalse = () => { state.value = false; }; + const toggle = () => { state.value = !state.value; }; + + return { + state, + setTrue, + setFalse, + toggle + }; +}; \ No newline at end of file diff --git a/src/modules/timesheet-approval/components/graphs/timesheet-approval-employee-expenses-chart.vue b/src/modules/timesheet-approval/components/graphs/timesheet-approval-employee-expenses-chart.vue index 4090ea9..db49823 100644 --- a/src/modules/timesheet-approval/components/graphs/timesheet-approval-employee-expenses-chart.vue +++ b/src/modules/timesheet-approval/components/graphs/timesheet-approval-employee-expenses-chart.vue @@ -5,7 +5,7 @@ import { useQuasar } from 'quasar'; import { Chart as ChartJS, Title, Tooltip, Legend, BarElement, CategoryScale, LinearScale, TimeScale, type ChartData, type ChartDataset } from 'chart.js'; import type { PayPeriodEmployeeDetails } from 'src/modules/timesheet-approval/types/timesheet-approval-pay-period-employee-details-interface'; - import type { Expense } from 'src/modules/timesheets/types/timesheet-details-interface'; + import type { Expense } from 'src/modules/timesheets/types/expense.interfaces'; const { t } = useI18n(); const $q = useQuasar(); diff --git a/src/modules/timesheet-approval/components/timesheet-approval-employee-details-shifts-row.vue b/src/modules/timesheet-approval/components/timesheet-approval-employee-details-shifts-row.vue index 2eca764..1372023 100644 --- a/src/modules/timesheet-approval/components/timesheet-approval-employee-details-shifts-row.vue +++ b/src/modules/timesheet-approval/components/timesheet-approval-employee-details-shifts-row.vue @@ -1,6 +1,7 @@ + + \ No newline at end of file diff --git a/src/modules/timesheets/components/expenses/expense-list.vue b/src/modules/timesheets/components/expenses/expense-list.vue new file mode 100644 index 0000000..b16b310 --- /dev/null +++ b/src/modules/timesheets/components/expenses/expense-list.vue @@ -0,0 +1,98 @@ + + + \ No newline at end of file diff --git a/src/modules/timesheets/components/shift/shift-comment.vue b/src/modules/timesheets/components/expenses/expense-supervisor-comment.vue similarity index 100% rename from src/modules/timesheets/components/shift/shift-comment.vue rename to src/modules/timesheets/components/expenses/expense-supervisor-comment.vue diff --git a/src/modules/timesheets/components/expenses/timesheet-details-expenses.vue b/src/modules/timesheets/components/expenses/timesheet-details-expenses.vue index f2c7690..f229af9 100644 --- a/src/modules/timesheets/components/expenses/timesheet-details-expenses.vue +++ b/src/modules/timesheets/components/expenses/timesheet-details-expenses.vue @@ -1,159 +1,115 @@ -