28 lines
948 B
TypeScript
28 lines
948 B
TypeScript
/* eslint-disable */
|
|
import { useExpensesStore } from "src/stores/expense-store";
|
|
import { useTimesheetStore } from "src/stores/timesheet-store";
|
|
import type { Expense } from "src/modules/timesheets/models/expense.models";
|
|
|
|
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) {
|
|
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,
|
|
};
|
|
}; |