Example #1
0
const onConfirmClick = ( state, dispatch ) => () => {
	const payload = {
		title: selectors.getRSVPTempTitle( state ),
		description: selectors.getRSVPTempDescription( state ),
		capacity: selectors.getRSVPTempCapacity( state ),
		notGoingResponses: selectors.getRSVPTempNotGoingResponses( state ),
		startDate: selectors.getRSVPTempStartDate( state ),
		startDateInput: selectors.getRSVPTempStartDateInput( state ),
		startDateMoment: selectors.getRSVPTempStartDateMoment( state ),
		endDate: selectors.getRSVPTempEndDate( state ),
		endDateInput: selectors.getRSVPTempEndDateInput( state ),
		endDateMoment: selectors.getRSVPTempEndDateMoment( state ),
		startTime: selectors.getRSVPTempStartTime( state ),
		endTime: selectors.getRSVPTempEndTime( state ),
		startTimeInput: selectors.getRSVPTempStartTimeInput( state ),
		endTimeInput: selectors.getRSVPTempEndTimeInput( state ),
	};

	if ( ! selectors.getRSVPCreated( state ) ) {
		dispatch( thunks.createRSVP( {
			...payload,
			postId: select( 'core/editor' ).getCurrentPostId(),
		} ) );
	} else {
		dispatch( thunks.updateRSVP( {
			...payload,
			id: selectors.getRSVPId( state ),
		} ) );
	}
};
Example #2
0
const mapStateToProps = ( state ) => {
	const datePickerFormat = globals.tecDateSettings().datepickerFormat
		? momentUtil.toFormat( globals.tecDateSettings().datepickerFormat )
		: 'LL';
	const isDisabled = selectors.getRSVPIsLoading( state )
		|| selectors.getRSVPSettingsOpen( state );

	const startDateMoment = selectors.getRSVPTempStartDateMoment( state );
	const endDateMoment = selectors.getRSVPTempEndDateMoment( state );
	const fromDate = startDateMoment && startDateMoment.toDate();
	const toDate = endDateMoment && endDateMoment.toDate();

	return {
		fromDate,
		fromDateInput: selectors.getRSVPTempStartDateInput( state ),
		fromDateDisabled: isDisabled,
		fromDateFormat: datePickerFormat,
		fromTime: selectors.getRSVPTempStartTimeInput( state ),
		fromTimeDisabled: isDisabled,
		toDate,
		toDateInput: selectors.getRSVPTempEndDateInput( state ),
		toDateDisabled: isDisabled,
		toDateFormat: datePickerFormat,
		toTime: selectors.getRSVPTempEndTimeInput( state ),
		toTimeDisabled: isDisabled,
		state,
	};
};
Example #3
0
	it( 'should return the temp end time input', () => {
		expect( selectors.getRSVPTempEndTimeInput( state ) )
			.toBe( DEFAULT_STATE.tempDetails.endTimeInput );
	} );