File size: 896 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
import type { TimeframeOption } from '../types';
/**
* Get available timeframes for report building
*/
export const getAvailableTimeframes = (
translate: ( key: string, args?: Record< string, unknown > ) => string
): TimeframeOption[] => [
{ label: translate( 'Last 30 days' ), value: '30_days' },
{ label: translate( 'Last 7 days' ), value: '7_days' },
{ label: translate( 'Last 24 hours' ), value: '24_hours' },
{ label: translate( 'Custom range' ), value: 'custom' },
];
/**
* Get display text for a specific timeframe value
*/
export const getTimeframeText = (
timeframe: string,
translate: ( key: string, args?: Record< string, unknown > ) => string
): string => {
const availableTimeframes = getAvailableTimeframes( translate );
const matchingTimeframe = availableTimeframes.find( ( option ) => option.value === timeframe );
return matchingTimeframe?.label || timeframe;
};
|