feat(MED-168): move toArray to shared utils

This commit is contained in:
2025-09-19 09:17:23 +03:00
parent 2bdd54e649
commit 08b27b022f
7 changed files with 9 additions and 15 deletions

View File

@@ -9,11 +9,7 @@ import { AnalysisElement, createAnalysisElement, getAnalysisElements } from '~/l
import { createCodes } from '~/lib/services/codes.service'; import { createCodes } from '~/lib/services/codes.service';
import { getLatestPublicMessageListItem } from '~/lib/services/medipost/medipostPublicMessage.service'; import { getLatestPublicMessageListItem } from '~/lib/services/medipost/medipostPublicMessage.service';
import type { ICode } from '~/lib/types/code'; import type { ICode } from '~/lib/types/code';
import { toArray } from '@kit/shared/utils';
function toArray<T>(input?: T | T[] | null): T[] {
if (!input) return [];
return Array.isArray(input) ? input : [input];
}
const WRITE_XML_TO_FILE = false as boolean; const WRITE_XML_TO_FILE = false as boolean;

View File

@@ -148,7 +148,6 @@ const AnalysisLevelBar = ({
// Show appropriate levels based on available norm bounds // Show appropriate levels based on available norm bounds
const hasLowerBound = lower !== null; const hasLowerBound = lower !== null;
const isLowerBoundZero = hasLowerBound && lower === 0; const isLowerBoundZero = hasLowerBound && lower === 0;
console.info('isLowerBoundZero', results.analysisElementOriginalId, { isLowerBoundZero, hasLowerBound, lower });
const hasUpperBound = upper !== null; const hasUpperBound = upper !== null;
// Determine which section the value falls into // Determine which section the value falls into

View File

@@ -1,10 +1,9 @@
'use server'; 'use server';
import { toArray } from '@/lib/utils';
import { getMailer } from '@kit/mailers'; import { getMailer } from '@kit/mailers';
import { enhanceAction } from '@kit/next/actions'; import { enhanceAction } from '@kit/next/actions';
import { getLogger } from '@kit/shared/logger'; import { getLogger } from '@kit/shared/logger';
import { toArray } from '@kit/shared/utils';
import { emailSchema } from '~/lib/validations/email.schema'; import { emailSchema } from '~/lib/validations/email.schema';

View File

@@ -13,7 +13,7 @@ import type {
MedipostOrderResponse, MedipostOrderResponse,
UuringElement, UuringElement,
} from '@/packages/shared/src/types/medipost-analysis'; } from '@/packages/shared/src/types/medipost-analysis';
import { toArray } from '@/lib/utils'; import { toArray } from '@kit/shared/utils';
import type { AnalysisOrder } from '~/lib/types/analysis-order'; import type { AnalysisOrder } from '~/lib/types/analysis-order';
import type { AnalysisResponseElement } from '~/lib/types/analysis-response-element'; import type { AnalysisResponseElement } from '~/lib/types/analysis-response-element';

View File

@@ -14,7 +14,7 @@ import {
import { import {
MaterjalideGrupp, MaterjalideGrupp,
} from '@/lib/types/medipost'; } from '@/lib/types/medipost';
import { toArray } from '@/lib/utils'; import { toArray } from '@kit/shared/utils';
import { uniqBy } from 'lodash'; import { uniqBy } from 'lodash';
import { Tables } from '@kit/supabase/database'; import { Tables } from '@kit/supabase/database';

View File

@@ -9,11 +9,6 @@ export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs)); return twMerge(clsx(inputs));
} }
export function toArray<T>(input?: T | T[] | null): T[] {
if (!input) return [];
return Array.isArray(input) ? input : [input];
}
export function toTitleCase(str?: string) { export function toTitleCase(str?: string) {
return ( return (
str str

View File

@@ -57,3 +57,8 @@ export const getPersonParameters = (personalCode: string) => {
return null; return null;
} }
}; };
export function toArray<T>(input?: T | T[] | null): T[] {
if (!input) return [];
return Array.isArray(input) ? input : [input];
}