Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
thalia
ThaliApp
Commits
38e3d9cb
Commit
38e3d9cb
authored
May 30, 2019
by
Sébastiaan Versteeg
Browse files
Merge branch 'fix/events-fields-saving' into 'master'
Fix events field saving See merge request
!266
parents
98e21f0e
6455c5f2
Changes
3
Hide whitespace changes
Inline
Side-by-side
__tests__/sagas/registration.spec.js
View file @
38e3d9cb
...
...
@@ -10,6 +10,8 @@ import * as eventActions from '../../app/actions/event';
import
{
tokenSelector
}
from
'
../../app/selectors/session
'
;
import
{
currentEventSelector
}
from
'
../../app/selectors/events
'
;
const
{
ServerError
}
=
jest
.
requireActual
(
'
../../app/utils/url
'
);
jest
.
mock
(
'
react-native-snackbar
'
,
()
=>
({
LENGTH_LONG
:
100
,
show
:
jest
.
fn
(),
...
...
@@ -32,7 +34,8 @@ describe('event selector', () => {
});
describe
(
'
registration saga
'
,
()
=>
{
const
error
=
new
Error
(
'
error
'
);
const
errorResponse
=
{
status
:
500
};
const
error
=
new
ServerError
(
'
Invalid status code: 500
'
,
errorResponse
);
beforeEach
(()
=>
{
apiRequest
.
mockReset
();
...
...
app/sagas/registration.js
View file @
38e3d9cb
...
...
@@ -34,7 +34,7 @@ const register = function* register(action) {
const
registration
=
yield
call
(
apiRequest
,
`events/
${
event
}
/registrations`
,
data
);
yield
put
(
eventActions
.
event
(
event
,
false
));
if
(
registration
.
fields
)
{
if
(
registration
.
fields
&&
Object
.
keys
(
registration
.
fields
).
length
>
0
)
{
yield
put
(
registrationActions
.
retrieveFields
(
registration
.
pk
));
}
Snackbar
.
show
({
title
:
t
(
'
Registration successful!
'
)
});
...
...
@@ -53,7 +53,9 @@ const update = function* update(action) {
const
body
=
{};
Object
.
keys
(
fields
).
forEach
((
key
)
=>
{
body
[
`fields[
${
key
}
]`
]
=
fields
[
key
];
if
(
fields
[
key
]
!==
undefined
&&
fields
[
key
]
!==
''
)
{
body
[
`fields[
${
key
}
]`
]
=
fields
[
key
];
}
});
const
data
=
{
...
...
@@ -72,8 +74,12 @@ const update = function* update(action) {
yield
delay
(
50
);
Snackbar
.
show
({
title
:
t
(
'
Successfully updated registration
'
)
});
}
catch
(
error
)
{
Sentry
.
captureException
(
error
);
yield
put
(
registrationActions
.
failure
());
if
(
error
.
response
.
status
===
400
)
{
Snackbar
.
show
({
title
:
'
The field values are not correct
'
});
}
else
{
Sentry
.
captureException
(
error
);
yield
put
(
registrationActions
.
failure
());
}
}
};
...
...
app/ui/screens/events/RegistrationScreen.js
View file @
38e3d9cb
...
...
@@ -66,6 +66,11 @@ class RegistrationScreen extends Component {
reason
:
this
.
props
.
t
(
'
This field is required.
'
),
};
}
}
else
if
(
field
.
type
===
'
integer
'
&&
!
(
value
===
''
||
value
===
null
)
&&
!
value
.
match
(
/^-
?\d
+$/
))
{
return
{
isValid
:
false
,
reason
:
this
.
props
.
t
(
'
This field must be an integer.
'
),
};
}
return
{
isValid
:
true
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment