refactor(work-orders): address SH-114 review naming and utils placement

This commit is contained in:
arthur.bassi 2026-08-19 09:28:32 -03:00
parent 1485903898
commit 0182345ba3
5 changed files with 27 additions and 23 deletions

View file

@ -49,41 +49,45 @@ export function WizardFieldSelectOptions({
No matches
</Text>
) : (
options.map((o) => (
options.map((option) => (
<button
key={o.key}
key={option.key}
type="button"
disabled={o.disabled}
title={o.title}
disabled={option.disabled}
title={option.title}
onClick={() => {
if (o.disabled) return;
onPick(o.key);
if (option.disabled) return;
onPick(option.key);
}}
className={
o.disabled
option.disabled
? "flex w-full cursor-not-allowed items-center gap-2 rounded px-2 py-1.5 opacity-50"
: "flex w-full items-center gap-2 rounded px-2 py-1.5 transition-colors hover:bg-[#F9FAFB]"
}
>
{o.left != null && <span className="flex shrink-0 items-center">{o.left}</span>}
{option.left != null && (
<span className="flex shrink-0 items-center">{option.left}</span>
)}
<span className="min-w-0 flex-1 text-left">
<span
className="block truncate text-[12px]"
style={{ color: "var(--color-text-primary)" }}
>
{o.label}
{option.label}
</span>
{Boolean(o.description) && (
{Boolean(option.description) && (
<span
className="mt-0.5 block truncate text-[11px]"
style={{ color: "var(--color-text-muted)" }}
>
{o.description}
{option.description}
</span>
)}
</span>
{o.right != null && <span className="flex shrink-0 items-center">{o.right}</span>}
{value === o.key && (
{option.right != null && (
<span className="flex shrink-0 items-center">{option.right}</span>
)}
{value === option.key && (
<Check size={10} className="shrink-0" style={{ color: "var(--color-primary)" }} />
)}
</button>

View file

@ -116,12 +116,12 @@ function WizardVendorDetail({
}
function buildWizardStatusOptions(closabilityGaps: string[]) {
return ALL_WIZARD_STATUSES.map((s) => {
const isCompletedBlocked = s === "Completed" && closabilityGaps.length > 0;
return ALL_WIZARD_STATUSES.map((status) => {
const isCompletedBlocked = status === "Completed" && closabilityGaps.length > 0;
return {
key: s,
label: s,
left: <ColorDot color={WIZARD_STATUS_DOTS[s]} />,
key: status,
label: status,
left: <ColorDot color={WIZARD_STATUS_DOTS[status]} />,
disabled: isCompletedBlocked,
title: isCompletedBlocked ? formatClosabilityMissingTitle(closabilityGaps) : undefined,
};
@ -262,9 +262,9 @@ export function WizardStepVendorTime({
search={false}
icon={<ColorDot color={statusDotColor} />}
options={buildWizardStatusOptions(closabilityGaps)}
onPick={(s) => {
if (s === "Completed" && closabilityGaps.length > 0) return;
onUpdate("status", s as WizardWOStatus);
onPick={(status) => {
if (status === "Completed" && closabilityGaps.length > 0) return;
onUpdate("status", status as WizardWOStatus);
}}
/>
</div>

View file

@ -3,7 +3,7 @@ import {
readDetailDocStatus,
readDetailMediaCount,
readDetailWoType,
} from "@/domain/work-orders/mappers/read-detail-closability-fields";
} from "@/domain/work-orders/utils/read-detail-closability-fields";
import type {
EmployeeOption,
LocationOption,

View file

@ -1,5 +1,5 @@
import { describe, expect, it } from "vitest";
import { readDetailWoType } from "@/domain/work-orders/mappers/read-detail-closability-fields";
import { readDetailWoType } from "@/domain/work-orders/utils/read-detail-closability-fields";
import type { WorkOrderDetail } from "@/domain/work-orders/types/work-order-detail";
import { EMPTY_WIZARD_DRAFT } from "@/domain/work-orders/types/work-order-wizard";
import type { WoClosabilityInput } from "@/domain/work-orders/utils/wo-closability";