Skip to content

Commit

Permalink
Fixups
Browse files Browse the repository at this point in the history
  • Loading branch information
denniskigen committed Aug 20, 2024
1 parent f91b7cc commit 245d57a
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 70 deletions.
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
import React, { forwardRef } from 'react';
import React, { forwardRef, useEffect, useImperativeHandle, useRef } from 'react';
import { useConfig } from '@openmrs/esm-framework';
import { type ConfigObject } from '../config-schema';
import styles from './print-identifier-sticker-content.scss';
import IdentifierSticker from './print-identifier-sticker.component';
import { useImperativeHandle } from 'react';
import { useRef } from 'react';
import { useEffect } from 'react';
import styles from './print-identifier-sticker-content.scss';

interface PrintIdentifierStickerContentProps {
numberOfLabelRowsPerPage: number;
numberOfLabelColumns: number;
labels: Array<{}>;
numberOfLabelColumns: number;
numberOfLabelRowsPerPage: number;
patient: fhir.Patient;
}

const PrintIdentifierStickerContent = forwardRef<HTMLDivElement, PrintIdentifierStickerContentProps>(
({ numberOfLabelRowsPerPage, numberOfLabelColumns, labels, patient }, ref) => {
({ labels, numberOfLabelColumns, numberOfLabelRowsPerPage, patient }, ref) => {
const { printIdentifierStickerWidth, printIdentifierStickerHeight, printIdentifierStickerPaperSize } =
useConfig<ConfigObject>();
const divRef = useRef<HTMLDivElement>();
Expand All @@ -32,10 +29,10 @@ const PrintIdentifierStickerContent = forwardRef<HTMLDivElement, PrintIdentifier
style.setProperty('--omrs-print-label-sticker-width', printIdentifierStickerWidth);
}
}, [
printIdentifierStickerPaperSize,
numberOfLabelColumns,
numberOfLabelRowsPerPage,
printIdentifierStickerHeight,
printIdentifierStickerPaperSize,
printIdentifierStickerWidth,
]);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import React, { useCallback, useEffect, useRef, useState } from 'react';
import React, { useCallback, useRef, useState } from 'react';
import classNames from 'classnames';
import { useTranslation } from 'react-i18next';
import { useReactToPrint, type UseReactToPrintOptions } from 'react-to-print';
import { Button, InlineLoading, ModalBody, ModalFooter, ModalHeader } from '@carbon/react';
import { Button, InlineLoading, ModalBody, ModalFooter, ModalHeader, NumberInput, Stack } from '@carbon/react';
import { getPatientName, showSnackbar, useConfig, getCoreTranslation } from '@openmrs/esm-framework';
import { type ConfigObject } from '../config-schema';
import styles from './print-identifier-sticker.scss';
import { NumberInput } from '@carbon/react';
import IdentifierSticker from './print-identifier-sticker.component';
import PrintIdentifierStickerContent from './print-identifier-sticker-content.component';
import styles from './print-identifier-sticker.scss';

interface PrintIdentifierStickerModalProps {
closeModal: () => void;
Expand Down Expand Up @@ -61,69 +61,75 @@ const PrintIdentifierStickerModal: React.FC<PrintIdentifierStickerModalProps> =
closeModal={closeModal}
title={getCoreTranslation('printIdentifierSticker', 'Print identifier sticker')}
/>
<ModalBody>
<NumberInput
id="numberOfColumnsInput"
label={t('numberOfLabelColumns', 'Number of patient Id sticker columns')}
min={1}
onChange={(event: React.ChangeEvent<HTMLInputElement>) =>
setNumberOfLabelColumns(parseInt(event.target.value || '1'))
}
value={numberOfLabelColumns}
hideSteppers={true}
/>
<NumberInput
id="numberOfRowsPerPageInput"
label={t('numberOfLabelRowsPerPage', 'Number of patient Id sticker rows per page')}
min={1}
onChange={(event: React.ChangeEvent<HTMLInputElement>) =>
setNumberOfLabelRowsPerPage(parseInt(event.target.value || '1'))
}
value={numberOfLabelRowsPerPage}
hideSteppers={true}
/>
<NumberInput
id="numberOfLabels"
label={t('numberOfLabels', 'Number of Patient Id Stickers')}
min={1}
onChange={(event: React.ChangeEvent<HTMLInputElement>) =>
setNumberOfLabels(parseInt(event.target.value || '1'))
}
value={numberOfLabels}
hideSteppers={true}
/>
<div className={styles.stickerContent}>
<IdentifierSticker patient={patient} />
<span>
<Button kind="ghost" onClick={() => setIsPreviewVisible(!isPreviewVisible)}>
{!isPreviewVisible ? t('preview', 'Preview') : t('hidePreview', 'Hide Preview')}
</Button>
</span>
</div>
<ModalBody hasScrollingContent>
<Stack gap={5}>
<NumberInput
hideSteppers
id="numberOfColumnsInput"
label={t('numberOfLabelColumns', 'No. of patient ID sticker columns')}
min={1}
onChange={(event: React.ChangeEvent<HTMLInputElement>) =>
setNumberOfLabelColumns(parseInt(event.target.value || '1'))
}
value={numberOfLabelColumns}
/>
<NumberInput
hideSteppers
id="numberOfRowsPerPageInput"
label={t('numberOfLabelRowsPerPage', 'No. of patient ID sticker rows per page')}
min={1}
onChange={(event: React.ChangeEvent<HTMLInputElement>) =>
setNumberOfLabelRowsPerPage(parseInt(event.target.value || '1'))
}
value={numberOfLabelRowsPerPage}
/>
<NumberInput
hideSteppers
id="numberOfLabels"
label={t('numberOfLabels', 'No. of patient ID stickers')}
min={1}
onChange={(event: React.ChangeEvent<HTMLInputElement>) =>
setNumberOfLabels(parseInt(event.target.value || '1'))
}
value={numberOfLabels}
/>
<div className={styles.stickerContent}>
<IdentifierSticker patient={patient} />
<span>
<Button kind="ghost" onClick={() => setIsPreviewVisible(!isPreviewVisible)}>
{!isPreviewVisible ? t('showPreview', 'Show preview') : t('hidePreview', 'Hide preview')}
</Button>
</span>
</div>
<div
className={classNames(styles.previewContainer, {
[styles.hideResultsPreview]: !isPreviewVisible,
})}
>
<div ref={contentToPrintRef}>
<PrintIdentifierStickerContent
labels={labels}
numberOfLabelColumns={numberOfLabelColumns}
numberOfLabelRowsPerPage={numberOfLabelRowsPerPage}
patient={patient}
ref={contentToPrintRef}
/>
</div>
</div>
</Stack>
</ModalBody>
<ModalFooter>
<Button kind="secondary" onClick={closeModal}>
{getCoreTranslation('cancel', 'Cancel')}
</Button>
<Button className={styles.button} disabled={isPrinting} onClick={() => handlePrint()} kind="primary">
<Button className={styles.button} disabled={isPrinting} onClick={handlePrint} kind="primary">
{isPrinting ? (
<InlineLoading className={styles.loader} description={getCoreTranslation('printing', 'Printing') + '...'} />
) : (
getCoreTranslation('print', 'Print')
)}
</Button>
</ModalFooter>
<div className={`${styles.previewContainer} ${!isPreviewVisible ? styles.hideResultsPreview : ''}`}>
<div ref={contentToPrintRef}>
<PrintIdentifierStickerContent
ref={contentToPrintRef}
numberOfLabelRowsPerPage={numberOfLabelRowsPerPage}
numberOfLabelColumns={numberOfLabelColumns}
labels={labels}
patient={patient}
/>
</div>
</div>
</>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
max-height: 10rem;
overflow-y: scroll;
background-color: white;
width: 96%;
width: 100%;
border: 1px solid $ui-03;
margin-left: auto;
margin-right: auto;
Expand Down
10 changes: 5 additions & 5 deletions packages/esm-patient-banner-app/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
"countyDistrict": "District",
"district": "District",
"dob": "DOB",
"hidePreview": "Hide Preview",
"numberOfLabelColumns": "Number of patient Id sticker columns",
"numberOfLabelRowsPerPage": "Number of patient Id sticker rows per page",
"numberOfLabels": "Number of patient Id stickers",
"hidePreview": "Hide preview",
"numberOfLabelColumns": "No. of patient ID sticker columns",
"numberOfLabelRowsPerPage": "No. of patient ID sticker rows per page",
"numberOfLabels": "No. of patient ID stickers",
"patientIdentifierSticker": "Patient identifier sticker",
"postalCode": "Postal code",
"preview": "Preview",
"showPreview": "Show preview",
"state": "State",
"stateProvince": "State"
}

0 comments on commit 245d57a

Please sign in to comment.