diff --git a/src/modules/timesheet-approval/components/details-dialog.vue b/src/modules/timesheet-approval/components/details-dialog.vue index 1cb8f9f..0c3f08a 100644 --- a/src/modules/timesheet-approval/components/details-dialog.vue +++ b/src/modules/timesheet-approval/components/details-dialog.vue @@ -10,13 +10,18 @@ import DetailsDialogChartExpenses from 'src/modules/timesheet-approval/components/details-dialog-chart-expenses.vue'; import TimesheetWrapper from 'src/modules/timesheets/components/timesheet-wrapper.vue'; import ExpenseDialogList from 'src/modules/timesheets/components/expense-dialog-list.vue'; + import ExpenseDialogForm from 'src/modules/timesheets/components/expense-dialog-form.vue'; import { useTimesheetApprovalApi } from '../composables/use-timesheet-approval-api'; import { useShiftApi } from 'src/modules/timesheets/composables/use-shift-api'; + import { useExpensesStore } from 'src/stores/expense-store'; + import { Expense } from 'src/modules/timesheets/models/expense.models'; + import { date } from 'quasar'; // ========== state ======================================== const { t } = useI18n(); const timesheetStore = useTimesheetStore(); + const expenseStore = useExpensesStore(); const timesheetApprovalApi = useTimesheetApprovalApi(); const shiftApi = useShiftApi(); const isDialogOpen = ref(false); @@ -24,11 +29,14 @@ // ========== computed ======================================== const isApproved = computed(() => timesheetStore.timesheets.every(timesheet => timesheet.is_approved)); + const approveButtonLabel = computed(() => isApproved.value ? t('shared.label.unlock') : t('shared.label.lock') ); + const approveButtonIcon = computed(() => isApproved.value ? 'las la-lock' : 'las la-unlock'); + const hasExpenses = computed(() => timesheetStore.timesheets.some(timesheet => Object.values(timesheet.weekly_expenses).some(hours => hours > 0)) ); @@ -49,6 +57,15 @@ const onClickSaveTimesheets = async () => { await shiftApi.saveShiftChanges(timesheetStore.current_pay_period_overview?.email); + expenseStore.is_showing_create_form = false; + } + + const onClickExpenseCreate = () => { + expenseStore.mode = 'create'; + if (timesheetStore.pay_period) + expenseStore.current_expense = new Expense(timesheetStore.pay_period.period_start); + else + expenseStore.current_expense = new Expense(date.formatDate(new Date(), 'YYYY-MM-DD')); } @@ -118,6 +135,7 @@