Two month of work
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
import axios, { AxiosError } from 'axios';
|
||||
import { Note, PipelineItem } from '@/types';
|
||||
import { toast } from 'vue-sonner';
|
||||
|
||||
const API_URL = '/api/notes';
|
||||
|
||||
export default {
|
||||
/**
|
||||
* Retrieves all notes
|
||||
* @returns Promise<Note<PipelineItem>[] | null>
|
||||
*/
|
||||
async getAllNotes(modelType: string, notableId: number): Promise<Note<PipelineItem>[] | null> {
|
||||
try {
|
||||
const response = await axios.get<Note<PipelineItem>[]>(`${API_URL}/${modelType}/${notableId}`)
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
toast.error('Fehler beim Laden der Notizen', { description: (error as AxiosError).message })
|
||||
console.error(error)
|
||||
}
|
||||
|
||||
return null
|
||||
},
|
||||
|
||||
/**
|
||||
* Creates a new note
|
||||
* @param note - The note data to create
|
||||
* @returns Promise<Note>
|
||||
*/
|
||||
async createNote(note: Partial<Note>): Promise<Note> {
|
||||
const response = await axios.post<Note>(API_URL, note);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
/**
|
||||
* Update an existing note
|
||||
* @param note - The Note object to update
|
||||
* @returns
|
||||
*/
|
||||
async updateNote(note: Partial<Note>): Promise<Note> {
|
||||
const response = await axios.put<Note>(`${API_URL}/${note.id}`, note);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
/**
|
||||
* Deletes a note by ID
|
||||
* @param noteId - The id of the note to delete
|
||||
* @returns boolean - True if the note was deleted, false otherwise
|
||||
*/
|
||||
async deleteNote(noteId: number): Promise<boolean> {
|
||||
try {
|
||||
const response = await axios.delete(`${API_URL}/${noteId}`);
|
||||
return true;
|
||||
} catch (error) {
|
||||
toast.error('Fehler beim LÖschen der Notiz', { description: (error as AxiosError).message })
|
||||
console.error(error)
|
||||
return false;
|
||||
}
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,24 @@
|
||||
import axios, { AxiosError } from 'axios';
|
||||
import { Note, PipelineItem } from '@/types';
|
||||
import { toast } from 'vue-sonner';
|
||||
|
||||
const API_URL = '/api/pipeline';
|
||||
const ITEMS_API_URL = '/api/pipelineItems';
|
||||
|
||||
export default {
|
||||
/**
|
||||
* Deletes an item by ID
|
||||
* @param id - The id of the item to delete
|
||||
* @returns boolean - True if the item was deleted, false otherwise
|
||||
*/
|
||||
async deletePipelineItem(id: number): Promise<boolean> {
|
||||
try {
|
||||
const response = await axios.delete(`${ITEMS_API_URL}/${id}`);
|
||||
return true;
|
||||
} catch (error) {
|
||||
toast.error('Fehler beim Löschen des Vorgangs', { description: (error as AxiosError).message })
|
||||
console.error(error)
|
||||
return false;
|
||||
}
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,106 @@
|
||||
// resources/js/services/TimesheetService.ts
|
||||
import axios, { AxiosResponse } from 'axios';
|
||||
import { Timesheet, TimesheetEntry } from '@/types';
|
||||
import { update } from '@/routes/password';
|
||||
|
||||
const API_URL = '/api/timesheets';
|
||||
const ENTRY_API_URL = '/api/timesheet-entries';
|
||||
|
||||
export default {
|
||||
/**
|
||||
* Retrieves all timesheets
|
||||
* @returns Promise<Timesheet[]>
|
||||
*/
|
||||
async getAllTimesheets(): Promise<Timesheet[]> {
|
||||
const response = await axios.get<Timesheet[]>(API_URL);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
/**
|
||||
* Creates a new timesheet
|
||||
* @param timesheet - The timesheet data to create
|
||||
* @returns Promise<Timesheet>
|
||||
*/
|
||||
async createTimesheet(timesheet: Partial<Timesheet>): Promise<Timesheet> {
|
||||
const response = await axios.post<Timesheet>(API_URL, timesheet);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
/**
|
||||
* Update an existing timesheet
|
||||
* @param timesheet - The Timesheet object to update
|
||||
* @returns
|
||||
*/
|
||||
async updateTimesheet(timesheet: Partial<Timesheet>): Promise<Timesheet> {
|
||||
const response = await axios.put<Timesheet>(`${API_URL}/${timesheet.id}`, timesheet);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
/**
|
||||
* Deletes a timesheet by ID
|
||||
* @param timesheetId - The id of the timesheet to delete
|
||||
* @returns Promise<AxiosResponse>
|
||||
*/
|
||||
async deleteTimesheet(timesheetId: number): Promise<AxiosResponse> {
|
||||
const response = await axios.delete(`${API_URL}/${timesheetId}`);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
/**
|
||||
* Retrieves all entries for a specific timesheet
|
||||
* @param timesheetId - The ID of the timesheet
|
||||
* @returns Promise<TimesheetEntry[]>
|
||||
*/
|
||||
async getTimesheetEntries(timesheetId: number): Promise<TimesheetEntry[]> {
|
||||
const response = await axios.get<TimesheetEntry[]>(`${API_URL}/${timesheetId}/entries`);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
/**
|
||||
* Retrieves all timesheet entries
|
||||
* @returns Promise<TimesheetEntry[]>
|
||||
*/
|
||||
async getAllEntries(): Promise<TimesheetEntry[]> {
|
||||
const response = await axios.get<TimesheetEntry[]>(ENTRY_API_URL);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
/**
|
||||
* Creates a new timesheet entry
|
||||
* @param entry - The entry data to create
|
||||
* @returns Promise<TimesheetEntry>
|
||||
*/
|
||||
async createEntry(entry: Partial<TimesheetEntry>): Promise<TimesheetEntry> {
|
||||
const response = await axios.post<TimesheetEntry>(ENTRY_API_URL, entry);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
/**
|
||||
* Updates an existing timesheet entry
|
||||
* @param entry - The TimesheetEntry object to update
|
||||
* @returns Promise<TimesheetEntry>
|
||||
*/
|
||||
async updateEntry(entry: Partial<TimesheetEntry>): Promise<TimesheetEntry> {
|
||||
const response = await axios.put<TimesheetEntry>(`${ENTRY_API_URL}/${entry.id}`, entry);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
/**
|
||||
* Toggles the billed status of a timesheet entry
|
||||
* @param entryId - The ID of the entry to toggle
|
||||
* @returns Promise<TimesheetEntry>
|
||||
*/
|
||||
async toggleBilled(entryId: number): Promise<TimesheetEntry> {
|
||||
const response = await axios.patch<TimesheetEntry>(`${ENTRY_API_URL}/${entryId}/toggle-billed`);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
/**
|
||||
* Deletes a timesheet entry
|
||||
* @param entryId - The ID of the entry to delete
|
||||
* @returns Promise<void>
|
||||
*/
|
||||
async deleteEntry(entryId: number): Promise<void> {
|
||||
await axios.delete(`${ENTRY_API_URL}/${entryId}`);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user