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,60 +1,47 @@
|
||||
import { apiRequest } from "@/lib/queryClient";
|
||||
import { FinancialRecord, InsertFinancialRecord } from "@shared/schema";
|
||||
|
||||
export interface FinancialRecordsResponse {
|
||||
records: FinancialRecord[];
|
||||
}
|
||||
|
||||
export interface FinancialRecordResponse {
|
||||
record: FinancialRecord;
|
||||
message?: string;
|
||||
}
|
||||
|
||||
export interface FinancialSummaryResponse {
|
||||
summary: {
|
||||
income: number;
|
||||
expenses: number;
|
||||
net: number;
|
||||
};
|
||||
period: string;
|
||||
startDate?: string;
|
||||
endDate?: string;
|
||||
}
|
||||
|
||||
export const financialService = {
|
||||
async getRecords(startDate?: string, endDate?: string): Promise<FinancialRecordsResponse> {
|
||||
async getRecords(startDate?: Date, endDate?: Date) {
|
||||
const params = new URLSearchParams();
|
||||
if (startDate) params.append("startDate", startDate);
|
||||
if (endDate) params.append("endDate", endDate);
|
||||
if (startDate) params.append('startDate', startDate.toISOString());
|
||||
if (endDate) params.append('endDate', endDate.toISOString());
|
||||
|
||||
const url = `/api/financial/records${params.toString() ? `?${params.toString()}` : ""}`;
|
||||
const response = await apiRequest("GET", url);
|
||||
const query = params.toString() ? `?${params.toString()}` : '';
|
||||
const response = await fetch(`/api/financial/records${query}`, {
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
});
|
||||
return response.json();
|
||||
},
|
||||
|
||||
async getSummary(period?: "week" | "month" | "year", startDate?: string, endDate?: string): Promise<FinancialSummaryResponse> {
|
||||
const params = new URLSearchParams();
|
||||
if (period) params.append("period", period);
|
||||
if (startDate) params.append("startDate", startDate);
|
||||
if (endDate) params.append("endDate", endDate);
|
||||
|
||||
const url = `/api/financial/summary${params.toString() ? `?${params.toString()}` : ""}`;
|
||||
const response = await apiRequest("GET", url);
|
||||
async getSummary(period?: string) {
|
||||
const params = period ? `?period=${period}` : '';
|
||||
const response = await fetch(`/api/financial/summary${params}`, {
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
});
|
||||
return response.json();
|
||||
},
|
||||
|
||||
async createRecord(record: InsertFinancialRecord & { createdViaVoice?: boolean; voiceTranscription?: string; metadata?: any }): Promise<FinancialRecordResponse> {
|
||||
const response = await apiRequest("POST", "/api/financial/records", record);
|
||||
async createRecord(record: any) {
|
||||
const response = await fetch('/api/financial/records', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(record),
|
||||
});
|
||||
return response.json();
|
||||
},
|
||||
|
||||
async updateRecord(id: number, updates: Partial<FinancialRecord>): Promise<FinancialRecordResponse> {
|
||||
const response = await apiRequest("PUT", `/api/financial/records/${id}`, updates);
|
||||
async updateRecord(id: number, updates: any) {
|
||||
const response = await fetch(`/api/financial/records/${id}`, {
|
||||
method: 'PUT',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(updates),
|
||||
});
|
||||
return response.json();
|
||||
},
|
||||
|
||||
async deleteRecord(id: number): Promise<{ message: string }> {
|
||||
const response = await apiRequest("DELETE", `/api/financial/records/${id}`);
|
||||
async deleteRecord(id: number) {
|
||||
const response = await fetch(`/api/financial/records/${id}`, {
|
||||
method: 'DELETE',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
});
|
||||
return response.json();
|
||||
},
|
||||
};
|
||||
};
|
||||
@@ -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