diff --git a/frontend/src/components/Modal/RiderModalInfo.tsx b/frontend/src/components/Modal/RiderModalInfo.tsx index 6d149fca..63decee1 100644 --- a/frontend/src/components/Modal/RiderModalInfo.tsx +++ b/frontend/src/components/Modal/RiderModalInfo.tsx @@ -4,6 +4,7 @@ import cn from 'classnames'; import { Button, Input, Label } from '../FormElements/FormElements'; import styles from './ridermodal.module.css'; import { ObjectType, Accessibility, Rider } from '../../types/index'; +import { rightArrow } from '../../icons/other'; type ModalFormProps = { onSubmit: (data: ObjectType) => void; @@ -20,8 +21,7 @@ const RiderModalInfo = ({ }: ModalFormProps) => { const { register, formState, handleSubmit, getValues } = useForm({ defaultValues: { - firstName: rider?.firstName ?? '', - lastName: rider?.lastName ?? '', + name: (rider?.firstName ?? '') + (rider?.lastName ?? ''), netid: rider?.email.split('@')[0] ?? '', phoneNumber: rider?.phoneNumber ?? '', needs: rider?.accessibility ?? '', // if no needs, default is undefined @@ -32,8 +32,7 @@ const RiderModalInfo = ({ }); const { errors } = formState; const beforeSubmit = ({ - firstName, - lastName, + name, netid, phoneNumber, needs, @@ -43,6 +42,10 @@ const RiderModalInfo = ({ }: ObjectType) => { const email = netid ? `${netid}@cornell.edu` : undefined; const accessibility = needs; + const nameParts = name.trim().split(/\s+/); + const firstName = + nameParts.length > 1 ? nameParts.slice(0, -1).join(' ') : nameParts[0]; + const lastName = nameParts.length > 1 ? nameParts.slice(-1)[0] : ''; onSubmit({ firstName, lastName, @@ -68,34 +71,18 @@ const RiderModalInfo = ({