11import React from "react" ;
2- import { UpdateHouseHold } from "." ;
2+ import { UpdateHouseHold } from "./modals/UpdateHouseHold " ;
33import {
4- InputBox , PersonAdd , PersonHelper , ApiHelper , type HouseholdInterface , type PersonInterface , ErrorMessages , Locale
4+ InputBox , PersonHelper , ApiHelper , type HouseholdInterface , type PersonInterface , ErrorMessages , Locale
55} from "@churchapps/apphelper" ;
6+ import { PersonAdd } from "../../components" ;
67import {
78 Table , TableBody , TableCell , TableRow , TextField , FormControl , Select , MenuItem , InputLabel , type SelectChangeEvent
89} from "@mui/material" ;
@@ -17,7 +18,7 @@ interface Props {
1718}
1819
1920export function HouseholdEdit ( props : Props ) {
20- const [ members , setMembers ] = React . useState < PersonInterface [ ] > ( [ ...props . currentMembers ] ) ;
21+ const [ members , setMembers ] = React . useState < PersonInterface [ ] > ( [ ...( props . currentMembers || [ ] ) ] ) ;
2122 const [ showAdd , setShowAdd ] = React . useState ( false ) ;
2223 const [ showUpdateAddressModal , setShowUpdateAddressModal ] = React . useState < boolean > ( false ) ;
2324 const [ text , setText ] = React . useState ( "" ) ;
@@ -67,6 +68,7 @@ export function HouseholdEdit(props: Props) {
6768 const m = [ ...members ] ;
6869 m . push ( addPerson ) ;
6970 setMembers ( m ) ;
71+ setShowAdd ( false ) ;
7072 }
7173
7274 const validate = ( ) => {
@@ -136,7 +138,15 @@ export function HouseholdEdit(props: Props) {
136138
137139 React . useEffect ( ( ) => { setHousehold ( props . household ) ; return ( ) => { setHousehold ( null ) ; } ; } , [ props . household ] ) ;
138140
139- const personAdd = showAdd ? < PersonAdd getPhotoUrl = { PersonHelper . getPhotoUrl } addFunction = { handlePersonAdd } person = { props . currentPerson } showCreatePersonOnNotFound = { true } /> : null ;
141+ const personAdd = showAdd ? (
142+ < div >
143+ < div style = { { display : 'flex' , justifyContent : 'space-between' , alignItems : 'center' , marginBottom : '16px' } } >
144+ < h3 > Add Household Member</ h3 >
145+ < SmallButton icon = "close" onClick = { ( ) => setShowAdd ( false ) } ariaLabel = "Cancel add member" />
146+ </ div >
147+ < PersonAdd getPhotoUrl = { PersonHelper . getPhotoUrl } addFunction = { handlePersonAdd } person = { props . currentPerson } showCreatePersonOnNotFound = { true } />
148+ </ div >
149+ ) : null ;
140150 return (
141151 < >
142152 < UpdateHouseHold show = { showUpdateAddressModal } onHide = { ( ) => setShowUpdateAddressModal ( false ) } handleNo = { handleNo } handleYes = { handleYes } text = { text } />
0 commit comments