Also refactor mobile UI/UX for timesheet: reduced header bloat, made only shifts scrollable, added left or right swipe to travel between pay periods, showing default 'no data' message when beyond 6-month-back 1-month-forward timesheet scope.
30 lines
1.1 KiB
TypeScript
30 lines
1.1 KiB
TypeScript
/* eslint-disable */
|
|
import { useExpensesStore } from "src/stores/expense-store";
|
|
import { useTimesheetStore } from "src/stores/timesheet-store";
|
|
import { Expense } from "src/modules/timesheets/models/expense.models";
|
|
import { date } from "quasar";
|
|
|
|
export const useExpensesApi = () => {
|
|
const expenses_store = useExpensesStore();
|
|
const timesheet_store = useTimesheetStore();
|
|
|
|
const upsertExpense = async (expense: Expense): Promise<void> => {
|
|
const success = await expenses_store.upsertExpense(expense);
|
|
if (success) {
|
|
expenses_store.current_expense = new Expense(date.formatDate( new Date(), 'YYYY-MM-DD'));
|
|
timesheet_store.getTimesheetsByOptionalEmployeeEmail();
|
|
}
|
|
};
|
|
|
|
const deleteExpenseById = async (expense_id: number): Promise<void> => {
|
|
const success = await expenses_store.deleteExpenseById(expense_id);
|
|
if (success) {
|
|
timesheet_store.getTimesheetsByOptionalEmployeeEmail();
|
|
}
|
|
};
|
|
|
|
return {
|
|
upsertExpense,
|
|
deleteExpenseById,
|
|
};
|
|
}; |