fix(burst): show actual pipe diameters
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
export type PipeDiameterMap = Record<string, number | null | undefined>;
|
||||
|
||||
export const getPipeDiameterDisplay = (
|
||||
pipeIds: string[] | undefined,
|
||||
diameters: PipeDiameterMap | undefined,
|
||||
loading = false,
|
||||
): string => {
|
||||
if (loading) {
|
||||
return "查询中...";
|
||||
}
|
||||
|
||||
if (!pipeIds?.length) {
|
||||
return "N/A";
|
||||
}
|
||||
|
||||
const values = pipeIds.map((pipeId) => {
|
||||
const diameter = diameters?.[pipeId];
|
||||
const displayValue =
|
||||
typeof diameter === "number" && Number.isFinite(diameter)
|
||||
? `${diameter} mm`
|
||||
: "N/A";
|
||||
|
||||
return pipeIds.length === 1 ? displayValue : `${pipeId}: ${displayValue}`;
|
||||
});
|
||||
|
||||
return values.join(";");
|
||||
};
|
||||
Reference in New Issue
Block a user