@@ -13,6 +13,7 @@ import { DateTime } from 'luxon';
1313import styled from 'styled-components' ;
1414import { IChangeEvent , ThemeProps } from '@rjsf/core' ;
1515import { CustomValidator , RJSFValidationError } from '@rjsf/utils' ;
16+ import ALL_INTAKE_ZONES from 'data/intakeZones' ;
1617
1718interface EditProps {
1819 isFormEditMode : boolean ;
@@ -41,10 +42,10 @@ const StyledBtnContainer = styled.div<EditProps>`
4142
4243const StyledForm = styled . section < EditProps > `
4344 overflow: hidden;
44- max-height: ${ ( { isFormEditMode } ) => ( isFormEditMode ? '560px ' : '0px' ) } ;
45+ max-height: ${ ( { isFormEditMode } ) => ( isFormEditMode ? '760px ' : '0px' ) } ;
4546 transition: max-height 0.5s;
4647 padding-left: 4px;
47- max-width: 480px ;
48+ max-width: 680px ;
4849 margin-top: ${ ( { isFormEditMode } ) => ( isFormEditMode ? '24px' : '0px' ) } ;
4950
5051 .datetime-widget {
@@ -160,12 +161,22 @@ const AddIntake: React.FC<Props> = ({
160161 setIsStartDateDisabled ( false ) ;
161162 setFormData ( {
162163 intakeNumber : newIntakeNumber ,
164+ zones : [ ...ALL_INTAKE_ZONES ] ,
165+ allowUnlistedFnLedZones : false ,
163166 } ) ;
164167 } ;
165168
166169 const handleSubmit = ( e ) => {
167- const { startDate, endDate, intakeNumber, description, rollingIntake } =
168- e . formData ;
170+ const {
171+ startDate,
172+ endDate,
173+ intakeNumber,
174+ description,
175+ rollingIntake,
176+ inviteOnlyIntake,
177+ zones,
178+ allowUnlistedFnLedZones,
179+ } = e . formData ;
169180
170181 if ( isIntakeEdit ) {
171182 updateIntake ( {
@@ -176,6 +187,9 @@ const AddIntake: React.FC<Props> = ({
176187 endTime : endDate ,
177188 intakeDescription : description ,
178189 isRollingIntake : rollingIntake ,
190+ intakeZones : zones ,
191+ isAllowUnlistedFnLedZones : allowUnlistedFnLedZones ?? false ,
192+ hiddenIntakeCode : inviteOnlyIntake ? crypto . randomUUID ( ) : null ,
179193 } ,
180194 } ,
181195 onCompleted : ( ) => {
@@ -191,6 +205,9 @@ const AddIntake: React.FC<Props> = ({
191205 endTime : endDate ,
192206 startTime : startDate ,
193207 rollingIntake,
208+ zones,
209+ allowUnlistedFnLedZones : allowUnlistedFnLedZones ?? false ,
210+ hiddenCode : inviteOnlyIntake ? crypto . randomUUID ( ) : null ,
194211 } ,
195212 } ,
196213 onCompleted : ( ) => {
@@ -238,6 +255,10 @@ const AddIntake: React.FC<Props> = ({
238255 errors ?. endDate . addError ( 'End date & time must be entered' ) ;
239256 }
240257
258+ if ( ( ! jsonData ?. zones || jsonData . zones . length === 0 ) && isFormSubmitting ) {
259+ errors ?. zones . addError ( 'At least one zone must be selected' ) ;
260+ }
261+
241262 if ( isEdit && nextIntake && endDateTime >= nextIntakeStartDateTime ) {
242263 errors ?. endDate . addError (
243264 'End date & time must not overlap with the next intake'
@@ -283,6 +304,8 @@ const AddIntake: React.FC<Props> = ({
283304 setIsFormEditMode ( true ) ;
284305 setFormData ( {
285306 intakeNumber : newIntakeNumber ,
307+ zones : [ ...ALL_INTAKE_ZONES ] ,
308+ allowUnlistedFnLedZones : false ,
286309 } ) ;
287310 } }
288311 variant = "secondary"
0 commit comments