enabling / disabling editor from url

This commit is contained in:
muerwre 2018-08-29 14:43:21 +07:00
parent b35a063cd7
commit e3e209ff65
5 changed files with 70 additions and 38 deletions

View file

@ -4,25 +4,19 @@ import { API } from '$constants/api';
const report = console.warn;
export const checkUserToken = ({
callback, fallback, id, token
}) => (
axios.get(API.CHECK_TOKEN, {
params: { action: 'check_token', id, token }
})
.then(result => (result && result.data))
.then(data => ({ ...data, id, token }))
.then(callback)
.catch(fallback)
);
export const getGuestToken = ({ callback }) => (
axios.get(API.GET_GUEST, {
params: { action: 'gen_guest_token' }
})
.then(result => (result && result.data))
.then(callback)
.catch(report)
);
export const checkUserToken = ({ id, token }) => axios.get(API.CHECK_TOKEN, {
params: {
id,
token,
action: 'check_token',
}
}).then(result => (result && result.data && { ...result.data, id, token }))
export const getGuestToken = () => axios.get(API.GET_GUEST, {
params: {
action: 'gen_guest_token'
}
}).then(result => (result && result.data));
export const getMergedImage = ({ placement, callback }) => (
axios.get(API.COMPOSE, {
@ -32,12 +26,9 @@ export const getMergedImage = ({ placement, callback }) => (
.catch(report)
);
export const getStoredMap = ({ name, callback }) => (
axios.get(API.GET_MAP, {
params: { name, action: 'load' }
})
.then(result => (result && result.data &&result.data.data))
.then(data => ({ ...data }))
.then(callback)
.catch(report)
)
export const getStoredMap = ({ name }) => axios.get(API.GET_MAP, {
params: {
name,
action: 'load'
}
}).then(result => (result && result.data && result.data.data));

View file

@ -1,2 +1,12 @@
export const getPath = () => (window.location && window.location.pathname &&
window.location.pathname.replace(/^\//, ''));
export const replacePath = url => window.history.replaceState(url, 'Редактирование маршрута', url);
export const getUrlData = () => {
const url = getPath();
const [path, mode] = url.split('/');
return { path, mode };
};