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
This commit is contained in:
@@ -1,43 +1,53 @@
|
||||
import { apiRequest } from "@/lib/queryClient";
|
||||
import { Task, InsertTask } from "@shared/schema";
|
||||
|
||||
export interface TasksResponse {
|
||||
tasks: Task[];
|
||||
}
|
||||
|
||||
export interface TaskResponse {
|
||||
task: Task;
|
||||
message?: string;
|
||||
}
|
||||
|
||||
export const taskService = {
|
||||
async getTasks(status?: string): Promise<TasksResponse> {
|
||||
const url = status ? `/api/tasks?status=${status}` : "/api/tasks";
|
||||
const response = await apiRequest("GET", url);
|
||||
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): Promise<TaskResponse> {
|
||||
const response = await apiRequest("GET", `/api/tasks/${id}`);
|
||||
async getTask(id: number) {
|
||||
const response = await fetch(`/api/tasks/${id}`, {
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
});
|
||||
return response.json();
|
||||
},
|
||||
|
||||
async createTask(task: InsertTask & { createdViaVoice?: boolean; voiceTranscription?: string }): Promise<TaskResponse> {
|
||||
const response = await apiRequest("POST", "/api/tasks", task);
|
||||
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: Partial<Task>): Promise<TaskResponse> {
|
||||
const response = await apiRequest("PUT", `/api/tasks/${id}`, updates);
|
||||
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 deleteTask(id: number): Promise<{ message: string }> {
|
||||
const response = await apiRequest("DELETE", `/api/tasks/${id}`);
|
||||
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 completeTask(id: number): Promise<TaskResponse> {
|
||||
return this.updateTask(id, { status: "completed", completedAt: new Date() });
|
||||
async deleteTask(id: number) {
|
||||
const response = await fetch(`/api/tasks/${id}`, {
|
||||
method: 'DELETE',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
});
|
||||
return response.json();
|
||||
},
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user