Commit c48908ef authored by Petter Goksøyr Åsen's avatar Petter Goksøyr Åsen
Browse files

patron-client: drop last step in regristration

parent 335501cf
......@@ -92,7 +92,8 @@ KeepMyHistory.propTypes = {
personalInformation: PropTypes.object.isRequired,
personalAttributes: PropTypes.object.isRequired,
postProfileSettingsSuccess: PropTypes.bool,
historySize: PropTypes.number.isRequired
historySize: PropTypes.number.isRequired,
intl: PropTypes.object.isRequired
}
export const messages = defineMessages({
......
......@@ -105,7 +105,7 @@ class PaymentResponse extends React.Component {
if (this.props.isSavingPayment || this.props.isRequestingLoansAndReservations) {
return (
<div style={{textAlign: 'center'}}>
<span data-automation-id="is_searching" className="loading-spinner"></span>
<span data-automation-id="is_searching" className="loading-spinner" />
</div>
)
}
......
......@@ -6,7 +6,6 @@ import { injectIntl, intlShape, defineMessages, FormattedMessage } from 'react-i
import FormPartOne from './forms/RegistrationFormPartOne'
import FormPartTwo from './forms/RegistrationFormPartTwo'
import FormPartThree from './forms/RegistrationFormPartThree'
import FormPartFour from './forms/RegistrationFormPartFour'
class Register extends React.Component {
......@@ -15,7 +14,6 @@ class Register extends React.Component {
this.props.dispatch(destroy('registrationPartOne'))
this.props.dispatch(destroy('registrationPartTwo'))
this.props.dispatch(destroy('registrationPartThree'))
this.props.dispatch(destroy('registrationPartFour'))
return (
<div data-automation-id="registration_success_modal" className="default-form">
......@@ -64,8 +62,7 @@ class Register extends React.Component {
{(this.props.stepNumber === 1 || this.props.stepNumber === 2) && <FormPartOne /> }
{this.props.stepNumber === 2 && <FormPartTwo /> }
{this.props.stepNumber === 3 && <FormPartThree /> }
{this.props.stepNumber === 4 && <FormPartFour /> }
{this.props.stepNumber === 5 && this.renderSuccess() }
{this.props.stepNumber === 4 && this.renderSuccess() }
</div>
</section>
)
......
......@@ -588,7 +588,7 @@ class UserLoans extends React.Component {
if (this.props.isRequestingLoansAndReservations) {
return <div style={{textAlign: 'center'}}>
<span data-automation-id="is_searching" className="loading-spinner"></span>
<span data-automation-id="is_searching" className="loading-spinner" />
</div>
} else if (this.props.loansAndReservationError) {
return <FormattedMessage {...messages.loansAndReservationError} />
......
import PropTypes from 'prop-types'
import React from 'react'
import { reduxForm } from 'redux-form'
import { bindActionCreators } from 'redux'
import { connect } from 'react-redux'
import { injectIntl, intlShape, defineMessages, FormattedMessage } from 'react-intl'
import * as RegistrationActions from '../../actions/RegistrationActions'
const formName = 'registrationPartFour'
class RegistrationFormPartFour extends React.Component {
constructor (props) {
super(props)
this.handleComplete = this.handleComplete.bind(this)
}
handleComplete () {
this.props.registrationActions.postRegistration()
}
render () {
const { handleSubmit } = this.props
return (
<div className="default-form" onSubmit={handleSubmit(this.handleComplete)}>
<form>
<div style={{ textAlign: 'center', padding: '1em' }}>
<h1><FormattedMessage {...messages.thanks} /></h1>
<button className="blue-btn" type="submit">
<FormattedMessage {...messages.submit} />
</button>
</div>
</form>
</div>
)
}
}
export const messages = defineMessages({
submit: {
id: 'RegistrationFormPartFour.submit',
description: 'The submit button text',
defaultMessage: 'Complete registration'
},
thanks: {
id: 'RegistrationFormPartFour.thanks',
description: 'Thank you text',
defaultMessage: 'Thanks! We now have all the information we need.'
}
})
RegistrationFormPartFour.propTypes = {
dispatch: PropTypes.func.isRequired,
handleSubmit: PropTypes.func.isRequired,
fields: PropTypes.object.isRequired,
intl: intlShape.isRequired,
registrationActions: PropTypes.object.isRequired
}
function mapStateToProps (state) {
return {
fields: state.form.registrationPartFour ? state.form.registrationPartFour : {}
}
}
function mapDispatchToProps (dispatch) {
return {
dispatch: dispatch,
registrationActions: bindActionCreators(RegistrationActions, dispatch)
}
}
const intlRegistrationFormPartFour = injectIntl(RegistrationFormPartFour)
export { intlRegistrationFormPartFour as RegistrationFormPartFour }
export default connect(
mapStateToProps,
mapDispatchToProps
)(reduxForm({
form: formName,
destroyOnUnmount: false
})(intlRegistrationFormPartFour))
......@@ -20,11 +20,13 @@ class RegistrationFormPartThree extends React.Component {
handleNo (event) {
this.props.change('keepHistory', false)
this.props.registrationActions.historySet()
this.props.registrationActions.postRegistration()
}
handleYes (event) {
this.props.change('keepHistory', true)
this.props.registrationActions.historySet()
this.props.registrationActions.postRegistration()
}
render () {
......
......@@ -200,8 +200,6 @@ export default {
'RegistrationFormPartTwo.repeatPin': 'Gjenta PIN-kode',
'RegistrationFormPartTwo.yesOption': 'Ja',
'RegistrationFormPartTwo.zipcode': 'Postnummer',
'RegistrationFormPartFour.thanks': 'Takk! Nå har vi alt vi trenger.',
'RegistrationFormPartFour.submit': 'Fullfør registreringen',
'RemoteReservationModal.button': 'OK',
'RemoteReservationModal.cancel': 'Avbryt',
'RemoteReservationModal.genericReservationError': 'Bestillingen feilet.\nVennligst kontakt biblioteket for mer informasjon.',
......@@ -364,6 +362,7 @@ export default {
'UserLoans.renewAllLoans': 'Forleng alle lån',
'UserLoans.reservations': 'Reserveringer',
'UserLoans.resumeReservation': 'Gjenoppta',
'UserLoans.sendPaymentReceiptEmailRequired': 'Epost er påkrevd',
'UserLoans.suspendReservation': 'Sett på vent',
'UserLoans.title': 'Tittel',
'UserLoans.tooManyRenewals': 'Kan ikke forlenges flere ganger',
......
......@@ -62,7 +62,7 @@ export default function registration (state = initialState, action) {
isSuccess: action.payload.isSuccess,
username: action.payload.username,
categoryCode: action.payload.categoryCode,
stepNumber: 5
stepNumber: 4
}
case REGISTRATION_FAILURE:
return {
......@@ -80,8 +80,7 @@ export default function registration (state = initialState, action) {
}
case REGISTRATION_HISTORY_SET:
return {
...state,
stepNumber: 4
...state
}
default:
return state
......
/* eslint-env mocha */
import expect from 'expect'
import loan from '../../src/frontend/reducers/loan'
import * as types from '../../src/frontend/constants/ActionTypes'
describe('reducers', () => {
describe('loan', () => {
it('should handle initial state', () => {
expect(
loan(undefined, {})
).toEqual({
isRequestingExtendLoan: false,
isRequestingExtendAllLoans: false,
extendLoanError: false,
hasRequestedRenewAll: false
})
})
it(`should handle ${types.REQUEST_EXTEND_ALL_LOANS}`, () => {
expect(
loan({}, {
type: types.REQUEST_EXTEND_ALL_LOANS
})
).toEqual({
extendLoanError: false,
isRequestingExtendAllLoans: true,
hasRequestedRenewAll: true
})
})
it(`should handle ${types.REQUEST_EXTEND_LOAN}`, () => {
expect(
loan({}, {
type: types.REQUEST_EXTEND_LOAN
})
).toEqual({
isRequestingExtendLoan: true,
extendLoanError: false
})
})
it(`should handle ${types.EXTEND_LOAN_SUCCESS}`, () => {
expect(
loan({}, {
type: types.EXTEND_LOAN_SUCCESS
})
).toEqual({
isRequestingExtendLoan: false,
extendLoanError: false
})
})
it(`should handle ${types.EXTEND_LOAN_FAILURE}`, () => {
expect(
loan({}, {
type: types.EXTEND_LOAN_FAILURE,
payload: {
message: 'error', checkoutId: 'checkoutId'
},
error: true
})
).toEqual({
isRequestingExtendLoan: false,
extendLoanError: true
})
})
})
})
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment