Fix delete urls

This commit is contained in:
gidsi 2019-04-03 23:08:08 +02:00
commit e17a4bf627
No known key found for this signature in database
GPG key ID: B47291090A6E5604
5 changed files with 10 additions and 26 deletions

View file

@ -59,7 +59,7 @@ class SpaceApiInput extends React.Component {
.set('Content-Type', 'application/json')
.end((err) => {
if (!err) {
this.spaceApiInput.input.value = '';
this.spaceApiInput.value = '';
this.setState({ open: true });
}
});
@ -78,16 +78,16 @@ class SpaceApiInput extends React.Component {
</p>
<div style={style.formContainer}>
<TextField
hintText={'https://example.com/yourspaceapi.json'}
placeholder={'https://example.com/yourspaceapi.json'}
name={'spaceapi-input'}
onChange={this.handleInputChange}
ref={ref => (this.spaceApiInput = ref)}
inputRef={ref => (this.spaceApiInput = ref)}
style={{ width: '100%', maxWidth: '340px' }}
/>
<FloatingActionButton
style={{ marginLeft: '20px' }}
mini
onTouchTap={this.handleButtonClick}
onClick={this.handleButtonClick}
>
<ContentAdd />
</FloatingActionButton>

View file

@ -42,7 +42,7 @@ export class UrlList extends React.Component {
};
deleteSpaceUrl = (spaceUrl) => {
this.props.deleteSpaceUrl(spaceUrl.url, this.state.secret);
this.props.deleteSpaceUrl(spaceUrl.id, this.state.secret);
};
render() {

View file

@ -35,9 +35,6 @@ export const actions = {
fetchCalendars,
};
const formatDate = date => (date.format('DD.MM.YYYY'));
const formatTime = date => (date.format('HH:mm'));
export default handleActions({
[CALENDARS_FETCHED]: (state, { payload }) => {
const items = flatten(flatten(

View file

@ -4,6 +4,7 @@ import { createAction, handleActions } from 'redux-actions';
import config from '../../api/config';
export const itemStruct = PropTypes.shape({
id: PropTypes.string.isRequired,
url: PropTypes.string.isRequired,
validated: PropTypes.bool.isRequired,
lastUpdated: PropTypes.number.isRequired,
@ -47,14 +48,14 @@ export const validateSpaceUrl = (spaceUrl, secret) => (dispatch) => {
);
};
export const deleteSpaceUrl = (spaceUrl, secret) => (dispatch) => {
export const deleteSpaceUrl = (spaceUrlId, secret) => (dispatch) => {
request
.delete(`${config.api.url}/urls/spaceUrl/${secret}`)
.delete(`${config.api.url}/urls/${spaceUrlId}/${secret}`)
.set('Content-Type', 'application/json')
.end(
(err) => {
if (!err) {
dispatch(deleteSpace(spaceUrl));
dispatch(deleteSpace(spaceUrlId));
}
}
);
@ -83,5 +84,5 @@ export default handleActions({
return newState;
},
[SPACEURL_DELETE]: (state, { payload }) => state.items.filter(ele => ele.url != payload.url),
[SPACEURL_DELETE]: (state, { payload }) => state.items.filter(ele => ele.id !== payload),
}, { items: [] });