import { useTimesheetStore } from "src/stores/timesheet-store"; import { useAuthStore } from "src/stores/auth-store"; import type { TimesheetApprovalCSVReportFilters } from "src/modules/timesheet-approval/models/timesheet-approval-csv-report.models"; export const useTimesheetApprovalApi = () => { const timesheet_store = useTimesheetStore(); const auth_store = useAuthStore(); const getPayPeriodOverviewsByDate = async (date_string: string): Promise => { const success = await timesheet_store.getPayPeriodByDateOrYearAndNumber(date_string); if (success) { await timesheet_store.getPayPeriodOverviewsBySupervisorEmail( timesheet_store.pay_period.pay_year, timesheet_store.pay_period.pay_period_no, auth_store.user.email ); } }; const getTimesheetApprovalCSVReport = async ( report_filter_company: boolean[], report_filter_type: boolean[], year?: number, period_number?: number ) => { const [ targo, solucom ] = report_filter_company; const [ shifts, expenses, holiday, vacation ] = report_filter_type; const options = { types: { shifts, expenses, holiday, vacation }, companies: { targo, solucom }, } as TimesheetApprovalCSVReportFilters; await timesheet_store.getPayPeriodReportByYearAndPeriodNumber( year ?? timesheet_store.pay_period.pay_year, period_number ?? timesheet_store.pay_period.pay_period_no, options ); }; return { getPayPeriodOverviewsByDate, getTimesheetApprovalCSVReport, } };