Skip to content

Commit

Permalink
passing fn around
Browse files Browse the repository at this point in the history
  • Loading branch information
mark-prins committed Feb 25, 2025
1 parent b15e940 commit e047bfc
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ import {
TableProvider,
TooltipTextCell,
useColumns,
useTranslation,
} from '@openmsupply-client/common';
import {
CustomerIndicatorInfoFragment,
IndicatorColumnFragment,
} from '../../api';
import { indicatorColumnNameToLocaleKey } from '../../../utils';
import { indicatorColumnNameToLocal } from '../../../utils';

interface CustomerIndicatorInfoProps {
columns: IndicatorColumnFragment[];
Expand All @@ -24,6 +25,7 @@ const CustomerIndicatorInfo = ({
columns,
customerInfos,
}: CustomerIndicatorInfoProps) => {
const t = useTranslation();
const columnDefinitions: ColumnDescription<CustomerIndicatorInfoFragment>[] =
[
[
Expand All @@ -40,7 +42,7 @@ const CustomerIndicatorInfo = ({
columns.forEach(({ name, id }) => {
columnDefinitions.push({
key: name,
label: indicatorColumnNameToLocaleKey(name),
label: indicatorColumnNameToLocal(name, t),
sortable: false,
accessor: ({ rowData }) => {
const indicator = rowData?.indicatorInformation?.find(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
} from '../../api';
import { useDraftIndicatorValue } from './hooks';
import { CustomerIndicatorInfoView } from './CustomerIndicatorInfo';
import { indicatorColumnNameToLocaleKey } from '../../../utils';
import { indicatorColumnNameToLocal } from '../../../utils';

interface IndicatorLineEditProps {
requisitionNumber: number;
Expand Down Expand Up @@ -95,7 +95,7 @@ const InputWithLabel = ({
<InputWithLabelRow
Input={inputComponent}
labelWidth={LABEL_WIDTH}
label={t(indicatorColumnNameToLocaleKey(data.name))}
label={indicatorColumnNameToLocal(data.name, t)}
sx={{ marginBottom: 1 }}
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
IndicatorLineRowFragment,
IndicatorLineWithColumnsFragment,
} from '../../../RequestRequisition/api';
import { indicatorColumnNameToLocaleKey } from '../../../utils';
import { indicatorColumnNameToLocal } from '../../../utils';

interface IndicatorLineEditProps {
requisitionNumber: number;
Expand Down Expand Up @@ -92,7 +92,7 @@ const InputWithLabel = ({
<InputWithLabelRow
Input={inputComponent}
labelWidth={LABEL_WIDTH}
label={indicatorColumnNameToLocaleKey(data.name)}
label={indicatorColumnNameToLocal(data.name, t)}
sx={{ marginBottom: 1 }}
/>
);
Expand Down
13 changes: 8 additions & 5 deletions client/packages/requisitions/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,16 @@ enum IndicatorColumnName {
Value = 'Value',
}

export const indicatorColumnNameToLocaleKey = (
columnName: string
): LocaleKey => {
export const indicatorColumnNameToLocal = (
columnName: string,
t: TypedTFunction<LocaleKey>
) => {
switch (columnName) {
case IndicatorColumnName.Comment:
return 'label.comment';
return t('label.comment');
case IndicatorColumnName.Value:
return t('label.value');
default:
return 'label.value';
return columnName;
}
};

0 comments on commit e047bfc

Please sign in to comment.