diff --git a/src/modules/timesheets/components/timesheet/timesheet-navigation.vue b/src/modules/timesheets/components/timesheet/timesheet-navigation.vue new file mode 100644 index 0000000..2183ed9 --- /dev/null +++ b/src/modules/timesheets/components/timesheet/timesheet-navigation.vue @@ -0,0 +1,104 @@ + + + \ No newline at end of file diff --git a/src/modules/timesheets/components/timesheet/timesheet-shift-form.vue b/src/modules/timesheets/components/timesheet/timesheet-shift-form.vue index 8f2946c..bef6a3a 100644 --- a/src/modules/timesheets/components/timesheet/timesheet-shift-form.vue +++ b/src/modules/timesheets/components/timesheet/timesheet-shift-form.vue @@ -2,8 +2,13 @@ - \ No newline at end of file diff --git a/src/modules/timesheets/services/timesheet-services.ts b/src/modules/timesheets/services/timesheet-services.ts index 1b5803b..d96bef5 100644 --- a/src/modules/timesheets/services/timesheet-services.ts +++ b/src/modules/timesheets/services/timesheet-services.ts @@ -1,9 +1,18 @@ import { api } from "src/boot/axios"; import type {Timesheet} from "src/modules/timesheets/types/timesheet-interface"; +import type { CreateShiftPayload, CreateWeekShiftPayload } from "../types/timesheet-shift-interface"; export const timesheetTempService = { + //GET getTimesheetsByEmail: async ( email: string, offset = 0): Promise => { const response = await api.get(`/timesheets/${encodeURIComponent(email)}`, {params: offset ? { offset } : undefined}); return response.data as Timesheet; }, + + //POST + createTimesheetShifts: async ( email: string, shifts: CreateShiftPayload[], offset = 0): Promise => { + const payload: CreateWeekShiftPayload = { shifts }; + const response = await api.post(`/timesheets/shifts/${encodeURIComponent(email)}`, payload, { params: offset ? { offset }: undefined }); + return response.data as Timesheet; + } }; \ No newline at end of file diff --git a/src/modules/timesheets/types/timesheet-interface.ts b/src/modules/timesheets/types/timesheet-interface.ts index 9986fbd..8fa1a02 100644 --- a/src/modules/timesheets/types/timesheet-interface.ts +++ b/src/modules/timesheets/types/timesheet-interface.ts @@ -16,7 +16,6 @@ type Shifts = { is_approved: boolean; } - type Expenses = { bank_type: string; date: string; diff --git a/src/modules/timesheets/types/timesheet-shift-interface.ts b/src/modules/timesheets/types/timesheet-shift-interface.ts index 474b532..1811d97 100644 --- a/src/modules/timesheets/types/timesheet-shift-interface.ts +++ b/src/modules/timesheets/types/timesheet-shift-interface.ts @@ -1,4 +1,16 @@ -export interface Shift { +export type CreateShiftPayload = { + date: string; + type: string; + start_time: string; + end_time: string; + description?: string; +}; + +export type CreateWeekShiftPayload = { + shifts: CreateShiftPayload[]; +} + +export type Shift = { is_approved: boolean; start: string; end: string; diff --git a/src/stores/timesheet-store.ts b/src/stores/timesheet-store.ts index 1ef2b28..143a67c 100644 --- a/src/stores/timesheet-store.ts +++ b/src/stores/timesheet-store.ts @@ -1,12 +1,13 @@ import { defineStore } from 'pinia'; import { ref } from 'vue'; import { timesheetApprovalService } from 'src/modules/timesheet-approval/services/services-timesheet-approval'; +import { timesheetTempService } from 'src/modules/timesheets/services/timesheet-services'; import type { PayPeriod } from 'src/modules/shared/types/pay-period-interface'; import type { PayPeriodOverviewEmployee } from "src/modules/timesheet-approval/types/timesheet-approval-pay-period-overview-employee-interface"; import type { PayPeriodEmployeeDetails } from 'src/modules/timesheet-approval/types/timesheet-approval-pay-period-employee-details-interface'; import type { PayPeriodReportFilters } from 'src/modules/timesheet-approval/types/timesheet-approval-pay-period-report-interface'; import type { Timesheet } from 'src/modules/timesheets/types/timesheet-interface'; -import { timesheetTempService } from 'src/modules/timesheets/services/timesheet-services'; +import type { CreateShiftPayload } from 'src/modules/timesheets/types/timesheet-shift-interface'; const default_pay_period: PayPeriod = { pay_period_no: -1, @@ -113,6 +114,18 @@ export const useTimesheetStore = defineStore('timesheet', () => { is_loading.value = false; } } + //employee timesheet + const createTimesheetShifts = async (employee_email: string, shifts: CreateShiftPayload[], offset = 0) => { + is_loading.value = true; + try{ + const timesheet = await timesheetTempService.createTimesheetShifts(employee_email, shifts, offset); + current_timesheet.value = timesheet; + } catch (err) { + console.error('createTimesheetShifts error: ', err); + } finally { + is_loading.value = false; + } + }; const getTimesheetsByPayPeriodAndEmail = async (employee_email: string) => { is_loading.value = true; @@ -159,6 +172,7 @@ export const useTimesheetStore = defineStore('timesheet', () => { is_loading, getPayPeriodByDate, getTimesheetByEmail, + createTimesheetShifts, getPayPeriodByYearAndPeriodNumber, getTimesheetApprovalPayPeriodEmployeeOverviews, getTimesheetsByPayPeriodAndEmail,