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

(feat) O3-3094: Removing Warning modal and leveraging workspace promptBeforeClosing functionality #205

Merged
merged 3 commits into from
Apr 23, 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
39 changes: 0 additions & 39 deletions src/components/warning-modal.component.tsx

This file was deleted.

15 changes: 3 additions & 12 deletions src/ohri-form.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import { usePatientData } from './hooks/usePatientData';
import LinearLoader from './components/loaders/linear-loader.component';
import LoadingIcon from './components/loaders/loading.component';
import OHRIFormSidebar from './components/sidebar/ohri-form-sidebar.component';
import WarningModal from './components/warning-modal.component';
import styles from './ohri-form.component.scss';
import { evaluatePostSubmissionExpression } from './utils/post-submission-action-helper';
import MarkdownWrapper from './components/inputs/markdown/markdown-wrapper.component';
Expand Down Expand Up @@ -69,6 +68,7 @@ interface OHRIFormProps {
* Renamed to `encounterUUID`. To be removed in future iterations.
*/
encounterUuid?: string;
markFormAsDirty?: (isDirty: boolean) => void;
}

export interface FormSubmissionHandler {
Expand All @@ -89,6 +89,7 @@ const OHRIForm: React.FC<OHRIFormProps> = ({
formSessionIntent,
meta,
encounterUuid,
markFormAsDirty,
}) => {
const session = useSession();
const currentProvider = session?.currentProvider?.uuid ? session.currentProvider.uuid : null;
Expand All @@ -112,8 +113,6 @@ const OHRIForm: React.FC<OHRIFormProps> = ({
const [isLoadingFormDependencies, setIsLoadingFormDependencies] = useState(true);
const [isSubmitting, setIsSubmitting] = useState(false);
const [pagesWithErrors, setPagesWithErrors] = useState([]);
const [isFormTouched, setIsFormTouched] = useState(false);
const [showWarningModal, setShowWarningModal] = useState(false);
const postSubmissionHandlers = usePostSubmissionAction(refinedFormJson?.postSubmissionActions);
const sessionMode = mode ? mode : encounterUUID || encounterUuid ? 'edit' : 'enter';

Expand Down Expand Up @@ -284,7 +283,7 @@ const OHRIForm: React.FC<OHRIFormProps> = ({
}}>
{(props) => {
useEffect(() => {
setIsFormTouched(props.dirty);
markFormAsDirty?.(props.dirty);
}, [props.dirty]);

return (
Expand All @@ -293,9 +292,6 @@ const OHRIForm: React.FC<OHRIFormProps> = ({
<LoadingIcon />
) : (
<div className={styles.ohriFormContainer}>
{showWarningModal ? (
<WarningModal onCancel={onCancel} onShowWarningModal={setShowWarningModal} t={t} />
) : null}
{isLoadingFormDependencies && (
<div className={styles.loader}>
<LinearLoader />
Expand Down Expand Up @@ -357,11 +353,6 @@ const OHRIForm: React.FC<OHRIFormProps> = ({
<Button
kind="secondary"
onClick={() => {
if (mode !== 'view' && isFormTouched) {
setShowWarningModal(true);
return;
}

onCancel && onCancel();
handleClose && handleClose();
}}>
Expand Down
Loading