Example #1
0
const onCancelClick = ( state, dispatch ) => () => {
	dispatch( actions.setRSVPTempDetails( {
		tempTitle: selectors.getRSVPTitle( state ),
		tempDescription: selectors.getRSVPDescription( state ),
		tempCapacity: selectors.getRSVPCapacity( state ),
		tempNotGoingResponses: selectors.getRSVPNotGoingResponses( state ),
		tempStartDate: selectors.getRSVPStartDate( state ),
		tempStartDateInput: selectors.getRSVPStartDateInput( state ),
		tempStartDateMoment: selectors.getRSVPStartDateMoment( state ),
		tempEndDate: selectors.getRSVPEndDate( state ),
		tempEndDateInput: selectors.getRSVPEndDateInput( state ),
		tempEndDateMoment: selectors.getRSVPEndDateMoment( state ),
		tempStartTime: selectors.getRSVPStartTime( state ),
		tempEndTime: selectors.getRSVPEndTime( state ),
		tempStartTimeInput: selectors.getRSVPStartTimeInput( state ),
		tempEndTimeInput: selectors.getRSVPEndTimeInput( state ),
	} ) );
	dispatch( actions.setRSVPHasChanges( false ) );
	wpDispatch( 'core/editor' ).clearSelectedBlock();
};
Example #2
0
const getIsInactive = ( state ) => {
	const startDateMoment = selectors.getRSVPStartDateMoment( state );
	const startTime = selectors.getRSVPStartTimeNoSeconds( state );
	const endDateMoment = selectors.getRSVPEndDateMoment( state );
	const endTime = selectors.getRSVPEndTimeNoSeconds( state );

	if ( ! startDateMoment || ! endDateMoment ) {
		return false;
	}

	const startMoment = momentUtil.setTimeInSeconds(
		startDateMoment.clone(),
		time.toSeconds( startTime, time.TIME_FORMAT_HH_MM ),
	);
	const endMoment = momentUtil.setTimeInSeconds(
		endDateMoment.clone(),
		time.toSeconds( endTime, time.TIME_FORMAT_HH_MM ),
	);
	const currentMoment = moment();

	return ! ( currentMoment.isAfter( startMoment ) && currentMoment.isBefore( endMoment ) );
};
Example #3
0
	it( 'should return the end date moment', () => {
		expect( selectors.getRSVPEndDateMoment( state ) )
			.toBe( DEFAULT_STATE.details.endDateMoment );
	} );