Some functionality added to dashboard gadgets.

This commit is contained in:
2026-07-12 00:28:43 +03:30
parent 83f6003a2b
commit d79aab907c
21 changed files with 557 additions and 412 deletions

View File

@@ -1,6 +1,7 @@
/**
* Shared pastel palette for treatment types, prosthesis types, and dashboard charts.
* Treatment types own the canonical hex values; prosthesis types reuse the same codes.
* Treatment and prosthesis each have dedicated hex maps — prosthesis colors are unique
* within the prosthesis catalog (no duplicate swatches on charts or badges).
*/
export const TREATMENT_TYPE_COLORS: Record<string, string> = {
@@ -19,28 +20,28 @@ export const TREATMENT_TYPE_COLORS: Record<string, string> = {
continue_treatment: '#99f6e4',
};
/** Prosthesis codes mapped to treatment-palette hex values (mapping is arbitrary). */
/** Dedicated prosthesis palette — one distinct pastel per catalog code. */
export const PROSTHESIS_TYPE_COLORS: Record<string, string> = {
pfm_crown: '#cbd5e1',
pfz_crown: '#86efac',
monolithic_zirconia: '#99f6e4',
glass_ceramic_crown: '#fde68a',
full_metal_crown: '#cbd5e1',
pfm_crown: '#e2e8f0',
pfz_crown: '#bbf7d0',
monolithic_zirconia: '#e0f2fe',
glass_ceramic_crown: '#fef08a',
full_metal_crown: '#d4d4d8',
temporary_resin_crown: '#bae6fd',
pmma: '#93c5fd',
peek_crown: '#99f6e4',
veneer_zirconia: '#86efac',
pmma: '#7dd3fc',
peek_crown: '#5eead4',
veneer_zirconia: '#6ee7b7',
veneer_ips_press: '#fed7aa',
veneer_ips_cad: '#fdba74',
soft_structure: '#ddd6fe',
customized_abutment: '#a5b4fc',
prefabricated_abutment: '#93c5fd',
ti_base_abutment: '#bae6fd',
multi_unit_abutment: '#a5b4fc',
zirconia_abutment: '#86efac',
screw_retained: '#c4b5fd',
zirconia_overlay: '#99f6e4',
ips_overlay: '#fde68a',
prefabricated_abutment: '#c7d2fe',
ti_base_abutment: '#bfdbfe',
multi_unit_abutment: '#818cf8',
zirconia_abutment: '#34d399',
screw_retained: '#e9d5ff',
zirconia_overlay: '#2dd4bf',
ips_overlay: '#fef3c7',
smile_design: '#f9a8d4',
mockup: '#fbcfe8',
};
@@ -54,7 +55,12 @@ export const CATALOG_FALLBACK_COLORS = [
'#fbcfe8',
] as const;
/** Ordered palette for charts and rotating unknown catalog codes. */
/** Fallback rotation for unknown prosthesis codes — drawn from the prosthesis palette. */
export const PROSTHESIS_FALLBACK_COLORS: readonly string[] = [
...new Set(Object.values(PROSTHESIS_TYPE_COLORS)),
];
/** Ordered palette for charts and rotating unknown treatment catalog codes. */
export const CATALOG_PALETTE_COLORS: readonly string[] = [
'#fed7aa',
'#fdba74',
@@ -72,12 +78,25 @@ export const CATALOG_PALETTE_COLORS: readonly string[] = [
'#ddd6fe',
'#d9f99d',
'#fbcfe8',
...PROSTHESIS_FALLBACK_COLORS.filter(
(color) =>
![
'#fed7aa',
'#fdba74',
'#bae6fd',
'#f9a8d4',
'#ddd6fe',
'#fbcfe8',
'#a5b4fc',
].includes(color),
),
];
export function resolveCatalogTypeColor(
code: string,
colorMap: Record<string, string>,
index = 0,
fallbackColors: readonly string[] = CATALOG_FALLBACK_COLORS,
): string {
return colorMap[code] ?? CATALOG_FALLBACK_COLORS[index % CATALOG_FALLBACK_COLORS.length];
return colorMap[code] ?? fallbackColors[index % fallbackColors.length];
}

View File

@@ -1,12 +1,13 @@
import type { CSSProperties } from 'react';
import {
PROSTHESIS_FALLBACK_COLORS,
PROSTHESIS_TYPE_COLORS,
resolveCatalogTypeColor,
} from '@/components/ui/treatment/catalog-type-colors';
/**
* Prosthesis-type colors for lab-facing surfaces (Tasks list, Cases detail group
* headers / badges). Uses the same hex palette as treatment types.
* headers / badges). Uses a dedicated pastel map (unique per prosthesis code).
*
* Clinic-facing dispatch flows intentionally do NOT use these colors.
*/
@@ -15,7 +16,7 @@ import {
const BADGE_INK = '#14253d';
export function prosthesisTypeColor(code: string, index = 0): string {
return resolveCatalogTypeColor(code, PROSTHESIS_TYPE_COLORS, index);
return resolveCatalogTypeColor(code, PROSTHESIS_TYPE_COLORS, index, PROSTHESIS_FALLBACK_COLORS);
}
/** Filled swatch (small indicator dots). */