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

Make 'share link' button optional when creating document #406

Merged
merged 1 commit into from
Dec 11, 2024
Merged
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
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
Loading