@@ -13,6 +13,7 @@ import AvailabilityEditModal from './Availability/AvailabilityEditModal';
1313import { useState } from 'react' ;
1414import { SetUserScheduleSettingsArgs } from 'shared' ;
1515import ExternalLink from '../../../components/ExternalLink' ;
16+ import { useToast } from '../../../hooks/toasts.hooks' ;
1617
1718interface UserScheduleSettingsEditProps {
1819 onSubmit : ( data : ScheduleSettingsPayload ) => Promise < void > ;
@@ -21,17 +22,19 @@ interface UserScheduleSettingsEditProps {
2122
2223const schema = yup . object ( ) . shape ( {
2324 personalGmail : yup . string ( ) . email ( 'Must be an email address' ) . optional ( ) ,
24- personalZoomLink : yup
25- . string ( )
26- . optional ( )
27- . test ( 'zoom-link' , 'Must be a valid zoom link' , ( value ) => value ! . includes ( 'zoom.us/' ) )
25+ personalZoomLink : yup . string ( ) . optional ( )
2826} ) ;
2927
3028const UserScheduleSettingsEdit : React . FC < UserScheduleSettingsEditProps > = ( { onSubmit, defaultValues } ) => {
3129 const [ editAvailabilityOpen , setEditAvailability ] = useState ( false ) ;
3230 const [ availabilities , setAvailabilities ] = useState < number [ ] > ( defaultValues ?. availability || [ ] ) ;
31+ const toast = useToast ( ) ;
3332
3433 const onFormSubmit = ( data : ScheduleSettingsFormInput ) => {
34+ if ( data . personalZoomLink !== '' && ! data . personalZoomLink . startsWith ( 'https://zoom.us/j/' ) ) {
35+ toast . error ( 'Invalid Zoom Link Format. Must start with "https://zoom.us/j/"' ) ;
36+ return ;
37+ }
3538 onSubmit ( { availability : availabilities , ...data } ) ;
3639 } ;
3740
@@ -66,10 +69,8 @@ const UserScheduleSettingsEdit: React.FC<UserScheduleSettingsEditProps> = ({ onS
6669 < Controller
6770 name = "personalGmail"
6871 control = { control }
69- rules = { { required : true } }
7072 render = { ( { field : { onChange, value } } ) => (
7173 < TextField
72- required
7374 id = "email-input"
7475 autoComplete = "off"
7576 onChange = { onChange }
@@ -93,10 +94,8 @@ const UserScheduleSettingsEdit: React.FC<UserScheduleSettingsEditProps> = ({ onS
9394 < Controller
9495 name = "personalZoomLink"
9596 control = { control }
96- rules = { { required : true } }
9797 render = { ( { field : { onChange, value } } ) => (
9898 < TextField
99- required
10099 id = "zoom-link-input"
101100 autoComplete = "off"
102101 onChange = { onChange }
0 commit comments