improvement: Some improvements done. some bugs fixed.
This commit is contained in:
@@ -2,14 +2,14 @@
|
||||
|
||||
import type { ReactNode } from 'react';
|
||||
import { useTranslations } from 'next-intl';
|
||||
import { X } from 'lucide-react';
|
||||
import { Trash2 } from 'lucide-react';
|
||||
import { Button } from '@/components/ui/shared/Button';
|
||||
import {
|
||||
ResponsiveDialogOverlay,
|
||||
ResponsiveDialogPanel,
|
||||
} from '@/components/ui/shared/ResponsiveDialog';
|
||||
import type { ProsthesisCatalogEntry } from '@/types/treatment-catalog';
|
||||
import { prosthesisTypeColorFromCatalog } from '@/components/treatment/prosthesisTypeDisplay';
|
||||
import { prosthesisTypeColorFromCatalog, prosthesisTypeFillAccent } from '@/components/treatment/prosthesisTypeDisplay';
|
||||
import {
|
||||
addonLeaves,
|
||||
categoryCodesInCatalog,
|
||||
@@ -151,7 +151,7 @@ export function ProsthesisJobPopover({
|
||||
const back = parentStep(step);
|
||||
|
||||
function openCategory(code: string) {
|
||||
const subs = subcategoriesFor(catalog, code);
|
||||
const subs = subcategoriesFor(catalog, code, scope);
|
||||
const arch = scope === 'arch' ? lockedArch : undefined;
|
||||
if (subs.length > 0) {
|
||||
onStep({ kind: 'subcategory', category: code, arch });
|
||||
@@ -264,7 +264,7 @@ export function ProsthesisJobPopover({
|
||||
} else if (step.kind === 'leaves' && step.subcategory) {
|
||||
selectedNode = { label: subLabel(step.subcategory) };
|
||||
childrenKey = `leaves-${step.category}-${step.subcategory}`;
|
||||
childTiles = leavesFor(catalog, step.category, step.subcategory).map(leafTile);
|
||||
childTiles = leavesFor(catalog, step.category, step.subcategory, scope).map(leafTile);
|
||||
} else {
|
||||
selectedNode = {
|
||||
label: categoryLabel(step.category),
|
||||
@@ -274,7 +274,7 @@ export function ProsthesisJobPopover({
|
||||
const arch = step.arch;
|
||||
const subs =
|
||||
step.kind === 'subcategory'
|
||||
? subcategoriesFor(catalog, step.category).map((sub) => (
|
||||
? subcategoriesFor(catalog, step.category, scope).map((sub) => (
|
||||
<Tile
|
||||
key={sub}
|
||||
label={subLabel(sub)}
|
||||
@@ -293,6 +293,7 @@ export function ProsthesisJobPopover({
|
||||
catalog,
|
||||
step.category,
|
||||
step.kind === 'leaves' ? step.subcategory : undefined,
|
||||
scope,
|
||||
).map(leafTile);
|
||||
childTiles = [...subs, ...leaves];
|
||||
}
|
||||
@@ -384,32 +385,39 @@ export function ProsthesisJobPopover({
|
||||
{jobCodes.map((code) => {
|
||||
const entry = byCode.get(code);
|
||||
const color = prosthesisTypeColorFromCatalog(code, catalog);
|
||||
const trashColor = prosthesisTypeFillAccent(color);
|
||||
return (
|
||||
<span
|
||||
key={code}
|
||||
className="inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-[11px] font-medium"
|
||||
className="inline-flex items-stretch overflow-hidden rounded-[var(--radius-md)] border text-[11px] font-medium"
|
||||
style={{
|
||||
backgroundColor: color,
|
||||
color: CHIP_INK,
|
||||
borderColor: 'rgba(0,0,0,0.16)',
|
||||
}}
|
||||
>
|
||||
<span className="opacity-70">
|
||||
{entry?.category
|
||||
? t(`category_${entry.category}` as never)
|
||||
: t('regionCrown')}
|
||||
<span className="inline-flex items-center gap-1 px-2 py-0.5">
|
||||
<span className="opacity-70">
|
||||
{entry?.category
|
||||
? t(`category_${entry.category}` as never)
|
||||
: t('regionCrown')}
|
||||
</span>
|
||||
{entry?.label ?? code}
|
||||
</span>
|
||||
{entry?.label ?? code}
|
||||
<button
|
||||
type="button"
|
||||
className="rounded-full p-0.5 hover:bg-black/10"
|
||||
className="inline-flex items-center justify-center border-s px-1.5 transition-colors hover:brightness-90"
|
||||
style={{
|
||||
borderColor: trashColor,
|
||||
color: trashColor,
|
||||
}}
|
||||
aria-label={t('removeJob')}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
onRemoveJob(code);
|
||||
}}
|
||||
>
|
||||
<X className="h-3 w-3" aria-hidden />
|
||||
<Trash2 className="lucide-inherit h-3.5 w-3.5" aria-hidden />
|
||||
</button>
|
||||
</span>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user