1- // Update PatientContext.tsx to include the reset functionality
21import React , { createContext , useContext , useState } from 'react' ;
32
4- interface PatientContextType {
3+ interface GlobalContextType {
54 showSummary : boolean ;
65 setShowSummary : React . Dispatch < React . SetStateAction < boolean > > ;
76 enterNewPatient : boolean ;
87 setEnterNewPatient : React . Dispatch < React . SetStateAction < boolean > > ;
98 resetFormValues : boolean ;
109 triggerFormReset : ( ) => void ;
10+ isEditing : boolean ;
11+ setIsEditing : React . Dispatch < React . SetStateAction < boolean > > ;
1112}
1213
1314
1415//redux / context issue need to provide default to avoid undefined
1516//if we don't the login errors out
16- const defaultContextValue : PatientContextType = {
17- enterNewPatient : true ,
17+ const defaultContextValue : GlobalContextType = {
18+ enterNewPatient : false ,
1819 setEnterNewPatient : ( ) => {
1920 } , //no-op default
20- showSummary : true ,
21+ showSummary : false ,
2122 setShowSummary : ( ) => {
2223 } , //no-op default
2324 resetFormValues : false ,
2425 triggerFormReset : ( ) => {
2526 } , //no-op default
27+ isEditing : false ,
28+ setIsEditing : ( ) => {
29+ } , //no-op default
2630} ;
2731
2832
29- const PatientContext = createContext < PatientContextType > ( defaultContextValue ) ;
33+ const GlobalContext = createContext < GlobalContextType > ( defaultContextValue ) ;
3034
3135
32- export const PatientProvider : React . FC < { children : React . ReactNode } > = ( { children} ) => {
36+ export const GlobalProvider : React . FC < { children : React . ReactNode } > = ( { children} ) => {
3337 const [ showSummary , setShowSummary ] = useState < boolean > ( false ) ;
3438 const [ enterNewPatient , setEnterNewPatient ] = useState < boolean > ( true ) ;
3539 const [ resetFormValues , setResetFormValues ] = useState < boolean > ( false ) ;
36-
40+ const [ isEditing , setIsEditing ] = useState < boolean > ( false ) ;
3741
3842 const triggerFormReset = ( ) => {
3943 setResetFormValues ( true ) ;
@@ -44,25 +48,27 @@ export const PatientProvider: React.FC<{ children: React.ReactNode }> = ({childr
4448 } ;
4549
4650 return (
47- < PatientContext . Provider
51+ < GlobalContext . Provider
4852 value = { {
4953 showSummary,
5054 setShowSummary,
5155 enterNewPatient,
5256 setEnterNewPatient,
5357 resetFormValues,
54- triggerFormReset
58+ triggerFormReset,
59+ isEditing,
60+ setIsEditing
5561 } }
5662 >
5763 { children }
58- </ PatientContext . Provider >
64+ </ GlobalContext . Provider >
5965 ) ;
6066} ;
6167
62- export const usePatientContext = ( ) => {
63- const context = useContext ( PatientContext ) ;
68+ export const useGlobalContext = ( ) => {
69+ const context = useContext ( GlobalContext ) ;
6470 if ( context === undefined ) {
65- throw new Error ( 'usePatientContext must be used within a PatientProvider ' ) ;
71+ throw new Error ( 'useGlobalContext must be used within a GlobalProvider ' ) ;
6672 }
6773 return context ;
6874} ;
0 commit comments