111 lines
2.7 KiB
TypeScript
111 lines
2.7 KiB
TypeScript
export type GoalStatus = "ACTIVE" | "COMPLETED" | "PAUSED" | "CANCELLED";
|
|
export type GoalPriority = "LOW" | "MEDIUM" | "HIGH";
|
|
export type AutoSaveFrequency = "DAILY" | "WEEKLY" | "MONTHLY";
|
|
|
|
export interface Goal {
|
|
id: string;
|
|
titleRu: string;
|
|
descriptionRu?: string;
|
|
targetAmount: number;
|
|
currentAmount: number;
|
|
targetDate?: string;
|
|
status: GoalStatus;
|
|
priority: GoalPriority;
|
|
icon?: string;
|
|
color?: string;
|
|
autoSaveEnabled: boolean;
|
|
autoSaveAmount?: number;
|
|
autoSaveFrequency?: AutoSaveFrequency;
|
|
createdAt: string;
|
|
updatedAt: string;
|
|
}
|
|
|
|
export interface CreateGoalBody {
|
|
titleRu: string;
|
|
descriptionRu?: string;
|
|
targetAmount: number;
|
|
currentAmount?: number;
|
|
targetDate?: string;
|
|
priority?: GoalPriority;
|
|
icon?: string;
|
|
color?: string;
|
|
autoSaveEnabled?: boolean;
|
|
autoSaveAmount?: number;
|
|
autoSaveFrequency?: AutoSaveFrequency;
|
|
}
|
|
|
|
export interface UpdateGoalBody {
|
|
titleRu?: string;
|
|
descriptionRu?: string;
|
|
targetAmount?: number;
|
|
targetDate?: string;
|
|
status?: GoalStatus;
|
|
priority?: GoalPriority;
|
|
icon?: string;
|
|
color?: string;
|
|
autoSaveEnabled?: boolean;
|
|
autoSaveAmount?: number;
|
|
autoSaveFrequency?: AutoSaveFrequency;
|
|
}
|
|
|
|
export interface GoalFundsBody {
|
|
amount: number;
|
|
note?: string;
|
|
}
|
|
|
|
export interface GoalsSummary {
|
|
totalGoals: number;
|
|
activeGoals: number;
|
|
completedGoals: number;
|
|
totalTargetAmount: number;
|
|
totalCurrentAmount: number;
|
|
overallProgress: number;
|
|
}
|
|
|
|
export interface BaseResponse {
|
|
success: boolean;
|
|
timestamp: string;
|
|
}
|
|
|
|
export interface GoalsListResponse extends BaseResponse {
|
|
data: Goal[];
|
|
}
|
|
|
|
export interface GoalResponse extends BaseResponse {
|
|
data: Goal;
|
|
}
|
|
|
|
export interface GoalsSummaryResponse extends BaseResponse {
|
|
data: GoalsSummary;
|
|
}
|
|
|
|
export interface GoalsInitialState {
|
|
goals: Goal[];
|
|
summary: GoalsSummary | null;
|
|
upcoming: Goal[];
|
|
isLoading: boolean;
|
|
error: string | undefined;
|
|
}
|
|
|
|
export interface GoalsUpdateArgs {
|
|
id: string;
|
|
body: UpdateGoalBody;
|
|
}
|
|
|
|
export interface GoalsFundsArgs {
|
|
id: string;
|
|
body: GoalFundsBody;
|
|
}
|
|
|
|
export type GoalsListApi = (params?: {
|
|
status?: GoalStatus;
|
|
}) => Promise<GoalsListResponse>;
|
|
export type GoalsGetApi = (id: string) => Promise<GoalResponse>;
|
|
export type GoalsCreateApi = (body: CreateGoalBody) => Promise<GoalResponse>;
|
|
export type GoalsUpdateApi = (args: GoalsUpdateArgs) => Promise<GoalResponse>;
|
|
export type GoalsDeleteApi = (id: string) => Promise<void>;
|
|
export type GoalsAddFundsApi = (args: GoalsFundsArgs) => Promise<GoalResponse>;
|
|
export type GoalsWithdrawApi = (args: GoalsFundsArgs) => Promise<GoalResponse>;
|
|
export type GoalsSummaryApi = () => Promise<GoalsSummaryResponse>;
|
|
export type GoalsUpcomingApi = (days?: number) => Promise<GoalsListResponse>;
|