feat(FE): Add chart data types to Uniformity API types

This commit is contained in:
rstubryan
2026-01-08 09:47:33 +07:00
parent dbdfd2c50b
commit 3cb6bfcf52
+57
View File
@@ -1,6 +1,62 @@
import { BaseMetadata } from '@/types/api/api-general';
import { BaseApproval } from '@/types/api/approval/approval';
// ==================== CHART DATA TYPES ====================
export type WeightDistributionData = {
weight: number;
count: number;
};
export type StatisticsData = {
mean: number;
standardDeviation: number;
min: number;
max: number;
};
export type WeekBarChartData = {
has_data: boolean;
weight_distribution: WeightDistributionData[];
ideal_range: {
min: number;
max: number;
} | null;
statistics: StatisticsData | null;
};
export type BarChart = {
current_week: number;
all_weeks: Record<string, WeekBarChartData>;
};
export type AvailableWeek = {
week: number;
uniformity_percentage: number;
ideal_count: number;
outside_ideal_count: number;
total_count: number;
has_data: boolean;
};
export type WeekInfo = {
total_weeks: number;
weeks_with_data: number;
current_week_index: number;
has_prev_week: boolean;
has_next_week: boolean;
};
export type GaugeChart = {
current_week: number;
available_weeks: AvailableWeek[];
week_info: WeekInfo;
};
export type ChartData = {
bar_chart: BarChart;
gauge_chart: GaugeChart;
};
// ==================== GET ALL RESPONSE ====================
export type Uniformity = BaseMetadata & {
id: number;
@@ -21,6 +77,7 @@ export type Uniformity = BaseMetadata & {
standard_mean_weight: number | null;
standard_uniformity: number | null;
created_at: string;
chart_data?: ChartData;
created_by: number;
latest_approval?: BaseApproval;
};