mirror of
https://github.com/TurTaskProject/TurTaskWeb.git
synced 2025-12-18 13:34:08 +01:00
Add subtasks api in react
This commit is contained in:
parent
d3a8c90c30
commit
f9e1250c56
33
frontend/src/api/SubTaskApi.jsx
Normal file
33
frontend/src/api/SubTaskApi.jsx
Normal file
@ -0,0 +1,33 @@
|
||||
import { axiosInstance } from "./AxiosConfig";
|
||||
|
||||
export const getSubtasks = async (parentTaskId) => {
|
||||
try {
|
||||
const response = await axiosInstance.get(`subtasks?parent_task=${parentTaskId}`);
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error("Error fetching subtasks:", error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
export const addSubtask = async (parentTaskId, text) => {
|
||||
try {
|
||||
const response = await axiosInstance.post("subtasks/", {
|
||||
text,
|
||||
parent_task: parentTaskId,
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error("Error adding subtask:", error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
export const deleteSubtask = async (subtaskId) => {
|
||||
try {
|
||||
await axiosInstance.delete(`subtasks/${subtaskId}/`);
|
||||
} catch (error) {
|
||||
console.error("Error deleting subtask:", error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
Loading…
Reference in New Issue
Block a user