feat(financials): add compact surface UI and graphing states
This commit is contained in:
@@ -27,7 +27,8 @@ export type GraphingSeriesPoint = {
|
||||
export type GraphingCompanySeries = {
|
||||
ticker: string;
|
||||
companyName: string;
|
||||
status: 'ready' | 'error' | 'no_metric_data';
|
||||
fiscalPack: string | null;
|
||||
status: 'ready' | 'error' | 'no_metric_data' | 'not_meaningful';
|
||||
errorMessage: string | null;
|
||||
unit: FinancialUnit | null;
|
||||
points: GraphingSeriesPoint[];
|
||||
@@ -38,6 +39,7 @@ export type GraphingCompanySeries = {
|
||||
export type GraphingLatestValueRow = {
|
||||
ticker: string;
|
||||
companyName: string;
|
||||
fiscalPack: string | null;
|
||||
status: GraphingCompanySeries['status'];
|
||||
errorMessage: string | null;
|
||||
latestValue: number | null;
|
||||
@@ -86,6 +88,7 @@ function extractCompanySeries(
|
||||
return {
|
||||
ticker: result.ticker,
|
||||
companyName: result.ticker,
|
||||
fiscalPack: null,
|
||||
status: 'error',
|
||||
errorMessage: result.error ?? 'Unable to load financial history',
|
||||
unit: null,
|
||||
@@ -97,6 +100,10 @@ function extractCompanySeries(
|
||||
|
||||
const metricRow = extractMetricRow(result.financials, surface, metric);
|
||||
const periods = [...result.financials.periods].sort(sortPeriods);
|
||||
const notMeaningful = surface !== 'ratios'
|
||||
&& metricRow
|
||||
&& 'resolutionMethod' in metricRow
|
||||
&& metricRow.resolutionMethod === 'not_meaningful';
|
||||
const points = periods.map((period) => ({
|
||||
periodId: period.id,
|
||||
dateKey: period.periodEnd ?? period.filingDate,
|
||||
@@ -113,8 +120,9 @@ function extractCompanySeries(
|
||||
return {
|
||||
ticker: result.financials.company.ticker,
|
||||
companyName: result.financials.company.companyName,
|
||||
status: latestPoint ? 'ready' : 'no_metric_data',
|
||||
errorMessage: latestPoint ? null : 'No data available for the selected metric.',
|
||||
fiscalPack: result.financials.normalization.fiscalPack,
|
||||
status: notMeaningful ? 'not_meaningful' : latestPoint ? 'ready' : 'no_metric_data',
|
||||
errorMessage: notMeaningful ? 'Not meaningful for this pack.' : latestPoint ? null : 'No data available for the selected metric.',
|
||||
unit: metricRow?.unit ?? null,
|
||||
points,
|
||||
latestPoint,
|
||||
@@ -159,6 +167,7 @@ export function buildGraphingComparisonData(input: {
|
||||
const latestRows = companies.map((company) => ({
|
||||
ticker: company.ticker,
|
||||
companyName: company.companyName,
|
||||
fiscalPack: company.fiscalPack,
|
||||
status: company.status,
|
||||
errorMessage: company.errorMessage,
|
||||
latestValue: company.latestPoint?.value ?? null,
|
||||
|
||||
Reference in New Issue
Block a user