Files
menassit/client/src/services/taskService.ts
T
ghaddaditw 07fc4fe199 Integrate AI chat, create financial records, and manage tasks efficiently
Implements AIChat.tsx, FinancialRecordForm.tsx, TaskCreateForm.tsx; refactors useVoice.ts, financialService.ts, taskService.ts.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 556aa286-edd2-4cea-8583-f4fc3cfd119b
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/81470e0d-8ae8-4335-9301-cd9a69e670fa/9cb7723a-8921-4263-af37-6daa7845de3e.jpg
2025-05-30 17:51:56 +00:00

53 lines
1.4 KiB
TypeScript

import { apiRequest } from "@/lib/queryClient";
export const taskService = {
async getTasks(status?: string) {
const params = status ? `?status=${status}` : '';
const response = await fetch(`/api/tasks${params}`, {
headers: { 'Content-Type': 'application/json' },
});
return response.json();
},
async getTask(id: number) {
const response = await fetch(`/api/tasks/${id}`, {
headers: { 'Content-Type': 'application/json' },
});
return response.json();
},
async createTask(task: any) {
const response = await fetch('/api/tasks', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(task),
});
return response.json();
},
async updateTask(id: number, updates: any) {
const response = await fetch(`/api/tasks/${id}`, {
method: 'PUT',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(updates),
});
return response.json();
},
async completeTask(id: number) {
const response = await fetch(`/api/tasks/${id}`, {
method: 'PUT',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ status: 'completed' }),
});
return response.json();
},
async deleteTask(id: number) {
const response = await fetch(`/api/tasks/${id}`, {
method: 'DELETE',
headers: { 'Content-Type': 'application/json' },
});
return response.json();
},
};