Compare commits
2 Commits
19321e3ea2
...
7768f94122
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7768f94122 | ||
|
|
4830d2a432 |
22
taskncoffee-app/src/api/tasks.service.js
Normal file
22
taskncoffee-app/src/api/tasks.service.js
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
import client from './client';
|
||||||
|
import { API_ENDPOINTS } from './ApiSources';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new task
|
||||||
|
* @param {Object} taskData - Task data
|
||||||
|
* @param {string} taskData.title - Task title
|
||||||
|
* @param {string} taskData.description - Task description
|
||||||
|
* @param {string} taskData.priority - Task priority
|
||||||
|
* @param {string} taskData.status - Task status
|
||||||
|
* @param {string} taskData.due_date - Task due date
|
||||||
|
* @returns {Promise<Object>} Created task data
|
||||||
|
*/
|
||||||
|
export const createTask = async (taskData) => {
|
||||||
|
try {
|
||||||
|
const response = await client.post(API_ENDPOINTS.TASKS.CREATE, taskData);
|
||||||
|
return response.data;
|
||||||
|
} catch (error) {
|
||||||
|
throw error.response?.data || error.message;
|
||||||
|
}
|
||||||
|
};
|
||||||
44
taskncoffee-app/src/api/users.service.js
Normal file
44
taskncoffee-app/src/api/users.service.js
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
import client from './client';
|
||||||
|
import { API_ENDPOINTS } from './ApiSources';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all users
|
||||||
|
* @returns {Promise<Object>} All users data
|
||||||
|
*/
|
||||||
|
export const getUsers = async () => {
|
||||||
|
try {
|
||||||
|
responce = await client.get(API_ENDPOINTS.USERS.LIST);
|
||||||
|
return responce.data;
|
||||||
|
} catch (error) {
|
||||||
|
throw error.response?.data || error.message;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get user by id
|
||||||
|
* @param {number} id - User id
|
||||||
|
* @returns {Promise<Object>} User data
|
||||||
|
*/
|
||||||
|
export const getUserById = async (id) => {
|
||||||
|
try {
|
||||||
|
const response = await client.get(API_ENDPOINTS.USERS.BY_ID(id));
|
||||||
|
return response.data;
|
||||||
|
} catch (error) {
|
||||||
|
throw error.response?.data || error.message;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all user tasks
|
||||||
|
* @param {number} id - User id
|
||||||
|
* @returns {Promise<Object>} All user tasks data
|
||||||
|
*/
|
||||||
|
export const getUserTasks = async (id) => {
|
||||||
|
try {
|
||||||
|
const response = await client.get(API_ENDPOINTS.USERS.TASKS(id));
|
||||||
|
return response.data;
|
||||||
|
} catch (error) {
|
||||||
|
throw error.response?.data || error.message;
|
||||||
|
}
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user