Skip to content

Commit

Permalink
Make 'share link' button optional when creating document
Browse files Browse the repository at this point in the history
  • Loading branch information
alexlipovka committed Dec 10, 2024
1 parent 8545c1b commit 23eeecf
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 21 deletions.
47 changes: 26 additions & 21 deletions src/containers/DocumentsList/ChooseDocumentToCreateModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ interface Props extends ModalProps {
context?: string;
onCancel: () => void;
openNewTab?: boolean;
displayShareButton?: boolean;
}

export const ChooseDocumentToCreateModal = (props: Props) => {
const { subjectType, patient, encounter, onCancel, context, openNewTab } = props;
const { subjectType, patient, encounter, onCancel, context, openNewTab, displayShareButton = true } = props;
const [questionnaireId, setQuestionnaireId] = useState();
const location = useLocation();
const navigate = useNavigate();
Expand Down Expand Up @@ -53,26 +54,30 @@ export const ChooseDocumentToCreateModal = (props: Props) => {
<Button key="back" onClick={onCloseModal}>
<Trans>Cancel</Trans>
</Button>,
<Button
key="share-link"
disabled={!questionnaireId}
onClick={() => {
const questionnaireParams = _.compact([
`patient=${patient.id}`,
`questionnaire=${questionnaireId}`,
encounter?.id ? `encounter=${encounter.id}` : null,
]);
navigator.clipboard.writeText(
`${window.location.origin}/questionnaire?${questionnaireParams.join('&')}`,
);
notification.success({
message: t`The link was copied to clipboard`,
});
onCloseModal();
}}
>
<Trans>Share link</Trans>
</Button>,
...(displayShareButton
? [
<Button
key="share-link"
disabled={!questionnaireId}
onClick={() => {
const questionnaireParams = _.compact([
`patient=${patient.id}`,
`questionnaire=${questionnaireId}`,
encounter?.id ? `encounter=${encounter.id}` : null,
]);
navigator.clipboard.writeText(
`${window.location.origin}/questionnaire?${questionnaireParams.join('&')}`,
);
notification.success({
message: t`The link was copied to clipboard`,
});
onCloseModal();
}}
>
<Trans>Share link</Trans>
</Button>,
]
: []),
<Button
key="create"
disabled={!questionnaireId}
Expand Down
1 change: 1 addition & 0 deletions src/containers/EncounterDetails/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export interface EncounterDetailsProps {
hideControls?: boolean;
documentTypes?: Array<DocumentType>;
openNewTab?: boolean;
displayShareButton?: boolean;
}

export function useEncounterDetails(props: EncounterDetailsProps) {
Expand Down
1 change: 1 addition & 0 deletions src/containers/EncounterDetails/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ export const EncounterDetails = (props: EncounterDetailsProps) => {
encounter={encounter}
context={modalOpened.context}
openNewTab={props.openNewTab}
displayShareButton={props.displayShareButton}
/>

{showScriber ||
Expand Down
2 changes: 2 additions & 0 deletions src/containers/PatientDetails/PatientDocuments/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ interface Props {
title?: string;
context?: string;
openNewTab?: boolean;
displayShareButton?: boolean;
}

export const PatientDocuments = (props: Props) => {
Expand All @@ -39,6 +40,7 @@ export const PatientDocuments = (props: Props) => {
subjectType="Patient"
context={props.context}
openNewTab={props.openNewTab}
displayShareButton={props.displayShareButton}
/>
</div>
)}
Expand Down

0 comments on commit 23eeecf

Please sign in to comment.