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
6455c5f2
Verified
Commit
6455c5f2
authored
May 30, 2019
by
Sébastiaan Versteeg
Browse files
Fix events field saving
parent
929eca3c
Changes
3
Hide whitespace changes
Inline
Side-by-side
__tests__/sagas/registration.spec.js
View file @
6455c5f2
...
...
@@ -9,6 +9,8 @@ import { apiRequest } from '../../app/utils/url';
import
*
as
eventActions
from
'
../../app/actions/event
'
;
import
{
tokenSelector
}
from
'
../../app/selectors/session
'
;
const
{
ServerError
}
=
jest
.
requireActual
(
'
../../app/utils/url
'
);
jest
.
mock
(
'
react-native-snackbar
'
,
()
=>
({
LENGTH_LONG
:
100
,
show
:
jest
.
fn
(),
...
...
@@ -31,7 +33,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 @
6455c5f2
...
...
@@ -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
:
'
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
:
'
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 @
6455c5f2
...
...
@@ -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