@ -8,17 +8,10 @@ import {
TextField ,
Box ,
Typography ,
Avatar ,
useTheme ,
Divider ,
} from '@mui/material' ;
import {
Business ,
PersonOutline ,
Groups ,
FamilyRestroom ,
Favorite ,
Home ,
PersonAdd ,
ContactPage ,
} from '@mui/icons-material' ;
@ -72,8 +65,6 @@ const InviteForm: React.FC<InviteFormProps> = ({
relationshipType : '' ,
inviterName : 'Oli S-B' , // Current user
} ) ;
const [ selectedRelationship , setSelectedRelationship ] = useState < string > ( '' ) ;
// Handle prefilled contact data
useEffect ( ( ) = > {
if ( prefilledContact ) {
@ -85,35 +76,23 @@ const InviteForm: React.FC<InviteFormProps> = ({
}
} , [ prefilledContact ] ) ;
const getRCardIcon = ( iconName : string ) = > {
const iconMap : Record < string , React.ReactElement > = {
Business : < Business / > ,
PersonOutline : < PersonOutline / > ,
Groups : < Groups / > ,
FamilyRestroom : < FamilyRestroom / > ,
Favorite : < Favorite / > ,
Home : < Home / > ,
} ;
return iconMap [ iconName ] || < PersonOutline / > ;
} ;
const handleSubmit = ( ) = > {
if ( ! formData . inviteeName || ! formData . inviteeEmail || ! selectedRelationship ) {
if ( ! formData . inviteeName || ! formData . inviteeEmail ) {
return ; // TODO: Add validation feedback
}
const selectedRCard = DEFAULT_RCARDS . find ( card = > card . name === selectedRelationship ) ;
const defaultRCard = DEFAULT_RCARDS [ 0 ] ; // Use first relationship as default
if ( selectedRCard && formData . inviteeName && formData . inviteeEmail ) {
if ( formData . inviteeName && formData . inviteeEmail ) {
const inviteData : InviteFormData = {
inviteeName : formData.inviteeName ,
inviteeEmail : formData.inviteeEmail ,
relationshipType : selectedRelationship ,
relationshipType : defaultRCard.name ,
relationshipData : {
name : selected RCard.name || 'Unknown' ,
description : selected RCard.description || 'No description' ,
color : selected RCard.color || '#2563eb' ,
icon : selected RCard.icon || 'PersonOutline' ,
name : default RCard.name || 'Unknown' ,
description : default RCard.description || 'No description' ,
color : default RCard.color || '#2563eb' ,
icon : default RCard.icon || 'PersonOutline' ,
} ,
inviterName : formData.inviterName || 'Current User' ,
} ;
@ -122,14 +101,6 @@ const InviteForm: React.FC<InviteFormProps> = ({
}
} ;
const handleRelationshipSelect = ( relationshipName : string ) = > {
setSelectedRelationship ( relationshipName ) ;
setFormData ( prev = > ( {
. . . prev ,
relationshipType : relationshipName
} ) ) ;
} ;
return (
< Dialog open = { open } onClose = { onClose } maxWidth = "md" fullWidth >
< DialogTitle >
@ -204,56 +175,6 @@ const InviteForm: React.FC<InviteFormProps> = ({
< / Box >
< / Box >
{ /* Relationship Selection */ }
< Box sx = { { mb : 3 } } >
< Typography variant = "h6" gutterBottom >
What ' s your relationship with them ?
< / Typography >
< Box sx = { {
display : 'flex' ,
flexWrap : 'wrap' ,
gap : 1 ,
'@media (max-width: 600px)' : {
flexDirection : 'column'
}
} } >
{ DEFAULT_RCARDS . map ( ( rCard ) = > (
< Button
key = { rCard . name }
variant = { selectedRelationship === rCard . name ? "contained" : "outlined" }
onClick = { ( ) = > handleRelationshipSelect ( rCard . name ) }
startIcon = {
< Avatar
sx = { {
bgcolor : selectedRelationship === rCard . name ? 'white' : rCard . color ,
color : selectedRelationship === rCard . name ? rCard . color : 'white' ,
width : 24 ,
height : 24 ,
'& .MuiSvgIcon-root' : { fontSize : 16 }
} }
>
{ getRCardIcon ( rCard . icon || 'PersonOutline' ) }
< / Avatar >
}
sx = { {
flex : { xs : 'none' , sm : '1 1 auto' } ,
minWidth : 'fit-content' ,
borderRadius : 2 ,
textTransform : 'none' ,
py : 1.5 ,
px : 2 ,
'&:hover' : {
transform : 'translateY(-1px)' ,
boxShadow : theme.shadows [ 4 ] ,
} ,
} }
>
{ rCard . name }
< / Button >
) ) }
< / Box >
< / Box >
< / DialogContent >
@ -264,7 +185,7 @@ const InviteForm: React.FC<InviteFormProps> = ({
< Button
onClick = { handleSubmit }
variant = "contained"
disabled = { ! formData . inviteeName || ! formData . inviteeEmail || ! selectedRelationship }
disabled = { ! formData . inviteeName || ! formData . inviteeEmail }
>
Create Invite
< / Button >