Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial translation work #1905

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { type OpenmrsEncounter } from '@openmrs/openmrs-form-engine-lib';
import { fetchLatestEncountersOfTypes } from './helpers';

import styles from '../../styleguide/tiles.scss';
import { useTranslation } from 'react-i18next';

export interface SummaryCardProps {
patientUuid: string;
Expand All @@ -23,6 +24,7 @@ export interface SummaryCardColumn {

export const SummaryCard: React.FC<SummaryCardProps> = ({ patientUuid, columns, headerTitle, maxRowItems }) => {
const [isLoading, setIsLoading] = useState(true);
const { t } = useTranslation();
const [columnEncountersMappings, setColumnEncountersMappings] = useState<
{
column: SummaryCardColumn;
Expand Down Expand Up @@ -98,10 +100,12 @@ export const SummaryCard: React.FC<SummaryCardProps> = ({ patientUuid, columns,
};

function SummaryItem({ column, encounters }) {
const { t } = useTranslation();

return (
<div className={styles.tileBox}>
<div className={styles.tileBoxColumn}>
<span className={styles.tileTitle}> {column.header} </span>
<span className={styles.tileTitle}> {t(column.key, column.header)} </span>
<span className={styles.tileValue}>
{column?.getObsValue ? <LazyCell lazyValue={column?.getObsValue(encounters)} /> : '--'}
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,11 @@ export const EncounterList: React.FC<EncounterListProps> = ({
const headers = useMemo(() => {
if (columns) {
return columns.map((column) => {
return { key: column.key, header: column.header };
return { key: column.key, header: t(column.key, column.header) };
});
}
return [];
}, [columns]);
}, [columns, t]);

const constructPaginatedTableRows = useCallback(
(encounters: OpenmrsEncounter[], currentPage: number, pageSize: number) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { LazyCell } from '../lazy-cell/lazy-cell.component';
import { useLastEncounter } from '../../hooks/useLastEncounter';

import styles from '../../styleguide/tiles.scss';
import { useTranslation } from 'react-i18next';

export interface EncounterTileColumn {
key: string;
Expand Down Expand Up @@ -43,6 +44,7 @@ export const EncounterTile: React.FC<EncounterTileProps> = ({ patientUuid, colum
};

export const EncounterValuesTile: React.FC<EncounterValuesTileProps> = ({ patientUuid, column }) => {
const { t } = useTranslation();
const { lastEncounter, isLoading, error, isValidating } = useLastEncounter(patientUuid, column.encounterUuid);

if (isLoading || isValidating) {
Expand All @@ -63,7 +65,7 @@ export const EncounterValuesTile: React.FC<EncounterValuesTileProps> = ({ patien
return (
<div className={styles.tileBox}>
<div className={styles.tileBoxColumn}>
<span className={styles.tileTitle}> {column.header} </span>
<span className={styles.tileTitle}> {t(column.key, column.header)} </span>
<span className={styles.tileValue}>
<LazyCell lazyValue={column.getObsValue(lastEncounter)} />
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,7 @@ interface PatientTableColumn {
};
}

export const PatientTable: React.FC<PatientTableProps> = ({
columns,
isFetching,
isLoading,
patients,
}) => {
export const PatientTable: React.FC<PatientTableProps> = ({ columns, isFetching, isLoading, patients }) => {
const { t } = useTranslation();
const layout = useLayoutType();
const responsiveSize = isDesktop(layout) ? 'sm' : 'lg';
Expand Down Expand Up @@ -209,7 +204,8 @@ export const PatientTable: React.FC<PatientTableProps> = ({
height: '3rem',
overflow: 'visible',
backgroundColor: 'color',
}}>
}}
>
<TableToolbarContent className={styles.toolbarContent}>
<TableToolbarSearch
className={styles.search}
Expand All @@ -219,7 +215,7 @@ export const PatientTable: React.FC<PatientTableProps> = ({
size="sm"
/>
</TableToolbarContent>
</TableToolbar>
</TableToolbar>
<Table className={styles.table} {...getTableProps()} data-testid="patientsTable">
<TableHead>
<TableRow>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,11 @@ const CurrentPregnancy: React.FC<PatientChartProps> = ({ patientUuid, pTrackerId
/>
</div>

<EncounterListTabsComponent patientUuid={patientUuid} configSchema={motherPreviousVisitConfigSchema} config={config} />
<EncounterListTabsComponent
patientUuid={patientUuid}
configSchema={motherPreviousVisitConfigSchema}
config={config}
/>
</div>
);
};
Expand Down
Loading