Connect CalDAV todos to DB-Items, finish todo component and add it to pipeline items
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import axios, { AxiosError } from 'axios';
|
||||
import { Note, PipelineItem } from '@/types';
|
||||
import { Note } from '@/types';
|
||||
import { toast } from 'vue-sonner';
|
||||
|
||||
const API_URL = '/api/notes';
|
||||
@@ -7,11 +7,11 @@ const API_URL = '/api/notes';
|
||||
export default {
|
||||
/**
|
||||
* Retrieves all notes
|
||||
* @returns Promise<Note<PipelineItem>[] | null>
|
||||
* @returns Promise<Note[] | null>
|
||||
*/
|
||||
async getAllNotes(modelType: string, notableId: number): Promise<Note<PipelineItem>[] | null> {
|
||||
async getNotesForModel(modelType: string, notableId: number): Promise<Note[] | null> {
|
||||
try {
|
||||
const response = await axios.get<Note<PipelineItem>[]>(`${API_URL}/${modelType}/${notableId}`)
|
||||
const response = await axios.get<Note[]>(`${API_URL}/${modelType}/${notableId}`)
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
toast.error('Fehler beim Laden der Notizen', { description: (error as AxiosError).message })
|
||||
|
||||
@@ -21,4 +21,36 @@ export default {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Creates a new pipeline item
|
||||
* @param item
|
||||
* @returns
|
||||
*/
|
||||
async createPipelineItem(item: PipelineItem): Promise<PipelineItem | null> {
|
||||
try {
|
||||
const response = await axios.post(ITEMS_API_URL, item);
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
toast.error('Fehler beim Speichern des Vorgangs', { description: (error as AxiosError).message })
|
||||
console.error(error)
|
||||
return null;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Updates an existing pipeline item
|
||||
* @param item
|
||||
* @returns
|
||||
*/
|
||||
async updatePipelineItem(item: PipelineItem): Promise<PipelineItem | null> {
|
||||
try {
|
||||
const response = await axios.put(ITEMS_API_URL + '/' + item.id, item);
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
toast.error('Fehler beim Speichern des Vorgangs', { description: (error as AxiosError).message })
|
||||
console.error(error)
|
||||
return null;
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,25 @@
|
||||
import axios, { AxiosError } from 'axios';
|
||||
import { Todo } from '@/types';
|
||||
import { toast } from 'vue-sonner';
|
||||
|
||||
const API_URL = '/api/todos';
|
||||
|
||||
export default {
|
||||
/**
|
||||
* Retrieves all notes
|
||||
* @returns Promise<Todo[] | null>
|
||||
*/
|
||||
async getTodosForModel(modelType: string, notableId: number): Promise<Todo[] | null> {
|
||||
try {
|
||||
const response = await axios.get<Todo[]>(`${API_URL}/${modelType}/${notableId}`)
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
toast.error('Fehler beim Laden der Aufgaben', { description: (error as AxiosError).message })
|
||||
console.error(error)
|
||||
}
|
||||
|
||||
return null
|
||||
},
|
||||
|
||||
|
||||
};
|
||||
Reference in New Issue
Block a user