- Implemented Form301 component for displaying OSHA Form 301 equivalent, including employee and case information. - Created Osha component to manage OSHA recordkeeping, including tabs for 300 Log, 300A Summary, Hours & rates, and Submit to OSHA. - Added functionality for printing and downloading CSV files for OSHA submissions. - Integrated loading and error handling states for data fetching.
13 lines
604 B
TypeScript
13 lines
604 B
TypeScript
/** Round axis ticks (0, 5, 10… / 0, 0.5, 1…) covering 0..max, about `count` of them. */
|
|
export function niceTicks(max: number, count = 4): number[] {
|
|
if (!(max > 0)) return [0, 1]
|
|
const raw = max / count
|
|
const magnitude = 10 ** Math.floor(Math.log10(raw))
|
|
const step = [1, 2, 2.5, 5, 10].map((m) => m * magnitude).find((s) => s >= raw) ?? raw
|
|
const ticks: number[] = []
|
|
for (let v = 0; v <= max + step * 0.999; v += step) ticks.push(Math.round(v * 1000) / 1000)
|
|
return ticks
|
|
}
|
|
|
|
export const formatNumber = (value: number) => value.toLocaleString('en-US', { maximumFractionDigits: 2 })
|