@cranberry-money/shared-types
Version:
Shared TypeScript type definitions for Blueberry platform
96 lines • 2.59 kB
TypeScript
import type * as React from 'react';
export interface BaseQueryParams {
page?: number;
page_size?: number;
order_by?: string;
}
export interface WithDateRange {
start_date?: string;
end_date?: string;
[key: string]: unknown;
}
export type WithNumericRange<T extends string> = {
[K in `min_${T}` | `max_${T}`]?: number;
} & {
[key: string]: unknown;
};
export type WithUuidReference<T extends string> = {
[K in `${T}_uuid` | `${T}`]?: string;
} & {
[key: string]: unknown;
};
export interface WithSearch {
search?: string;
[key: string]: unknown;
}
export interface WithStatusFilter<T extends string = string> {
status?: T;
[key: string]: unknown;
}
export interface BaseEntity {
uuid: string;
createdAt?: string;
updatedAt?: string;
}
export interface WithLoadingState {
isLoading?: boolean;
isSubmitting?: boolean;
isError?: boolean;
error?: Error | string | null;
}
export interface WithRefreshActions {
onRefresh?: () => void;
onRetry?: () => void;
}
export interface BaseDialogProps {
isOpen: boolean;
onClose: () => void;
title?: string;
}
export interface WithSearchCapability {
searchQuery: string;
onSearch: (query: string) => void;
onClearSearch?: () => void;
}
export interface BasePanelProps<TItem, TFilters> extends WithLoadingState, WithRefreshActions {
items: TItem[];
filters: TFilters;
onFilterUpdate: (filters: Partial<TFilters>) => void;
}
export interface BaseChartProps<TData> {
data: TData;
isLoading?: boolean;
error?: Error | string | null;
}
export interface BaseFormProps<TForm, TErrors = Record<string, string[]>> {
form: TForm;
errors?: TErrors;
isSubmitting?: boolean;
onChange: (e: React.ChangeEvent<HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement>) => void;
onSubmit: (e: React.FormEvent) => void | Promise<void>;
}
export interface FormPropsWithValidation<TForm, TValidation> extends BaseFormProps<TForm> {
validation?: TValidation;
}
export interface ValidationResult {
isValid: boolean;
message?: string;
}
export interface FieldValidation extends ValidationResult {
isEmpty: boolean;
}
export interface FormValidation {
isFormValid: boolean;
fields?: Record<string, ValidationResult>;
}
export interface BaseOperationResponse {
uuid: string;
message?: string;
}
export interface ApiErrorResponse {
detail?: string;
errors?: Record<string, string[]>;
message?: string;
statusCode?: number;
}
//# sourceMappingURL=base-patterns.d.ts.map