mirror of
https://github.com/muerwre/orchidmap-front.git
synced 2025-04-25 02:56:41 +07:00
save: fixed dialog
backend: fixed provider storing
This commit is contained in:
parent
17baf8ac15
commit
7cdc1f4f95
5 changed files with 17 additions and 12 deletions
|
@ -13,8 +13,11 @@ module.exports = async (req, res) => {
|
|||
const route = parseRoute(body.route);
|
||||
const stickers = parseStickers(body.stickers);
|
||||
const logo = parseString(body.logo, 16);
|
||||
const provider = parseString(body.provider, 16) || 'DEFAULT';
|
||||
const distance = parseNumber(body.distance, 0, 1000);
|
||||
|
||||
console.log('SAVING PROVIDER?', provider, body.provider);
|
||||
|
||||
if ((!route || route.length <= 0) && (!stickers || stickers.length <= 0)) {
|
||||
return res.send({ success: false, mode: 'empty' });
|
||||
}
|
||||
|
@ -26,7 +29,7 @@ module.exports = async (req, res) => {
|
|||
|
||||
if (exists) {
|
||||
exists.set({
|
||||
title, route, stickers, logo, distance, updated_at: Date.now(),
|
||||
title, route, stickers, logo, distance, updated_at: Date.now(), provider,
|
||||
}).save();
|
||||
|
||||
return res.send({
|
||||
|
@ -35,14 +38,14 @@ module.exports = async (req, res) => {
|
|||
}
|
||||
|
||||
const created = await Route.create({
|
||||
_id: address, title, route, stickers, owner, logo, distance,
|
||||
_id: address, title, route, stickers, owner, logo, distance, provider,
|
||||
});
|
||||
|
||||
await owner.routes.push(created);
|
||||
await owner.save();
|
||||
|
||||
return res.send({
|
||||
success: true, title, address, route, stickers
|
||||
success: true, title, address, route, stickers, provider,
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -46,6 +46,7 @@ export function configureStore() {
|
|||
}
|
||||
|
||||
export const history = createBrowserHistory();
|
||||
export const historyListener = history.listen(location => {
|
||||
export const historyListener = history.listen((location, action) => {
|
||||
if (action === 'REPLACE') return;
|
||||
store.dispatch(locationChanged(location.pathname));
|
||||
});
|
||||
|
|
|
@ -18,7 +18,7 @@ import {
|
|||
setSaveOverwrite, setSaveSuccess, setTitle,
|
||||
setUser
|
||||
} from '$redux/user/actions';
|
||||
import { getUrlData, parseQuery, pushLoaderState, pushNetworkInitError, pushPath } from '$utils/history';
|
||||
import { getUrlData, parseQuery, pushLoaderState, pushNetworkInitError, pushPath, replacePath } from '$utils/history';
|
||||
import { editor } from '$modules/Editor';
|
||||
import { ACTIONS } from '$redux/user/constants';
|
||||
import { MODES } from '$constants/modes';
|
||||
|
@ -265,13 +265,13 @@ function* clearSaga({ type }) {
|
|||
function* sendSaveRequestSaga({ title, address, force }) {
|
||||
if (editor.isEmpty) return yield put(setSaveError(TIPS.SAVE_EMPTY));
|
||||
|
||||
const { route, stickers } = editor.dumpData();
|
||||
const { route, stickers, provider } = editor.dumpData();
|
||||
const { logo, distance } = yield select(getState);
|
||||
const { id, token } = yield select(getUser);
|
||||
|
||||
const { result, timeout, cancel } = yield race({
|
||||
result: postMap({
|
||||
id, token, route, stickers, title, force, address, logo, distance,
|
||||
id, token, route, stickers, title, force, address, logo, distance, provider,
|
||||
}),
|
||||
timeout: delay(10000),
|
||||
cancel: take(ACTIONS.RESET_SAVE_DIALOG),
|
||||
|
@ -295,7 +295,8 @@ function* refreshUserData() {
|
|||
function* setSaveSuccessSaga({ address, title }) {
|
||||
const { id } = yield select(getUser);
|
||||
|
||||
pushPath(`/${address}/edit`);
|
||||
replacePath(`/${address}/edit`);
|
||||
|
||||
yield put(setTitle(title));
|
||||
yield put(setAddress(address));
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ export const getStoredMap = ({ name }) => axios.get(API.GET_MAP, {
|
|||
}).then(result => (result && result.data && result.data.success && result.data));
|
||||
|
||||
export const postMap = ({
|
||||
title, address, route, stickers, id, token, force, logo, distance,
|
||||
title, address, route, stickers, id, token, force, logo, distance, provider,
|
||||
}) => axios.post(API.POST_MAP, {
|
||||
title,
|
||||
address,
|
||||
|
@ -31,6 +31,7 @@ export const postMap = ({
|
|||
force,
|
||||
logo,
|
||||
distance,
|
||||
provider,
|
||||
}).then(result => (result && result.data && result.data));
|
||||
|
||||
export const checkIframeToken = ({ viewer_id, auth_key }) => axios.get(API.IFRAME_LOGIN_VK, {
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
import { history } from '$redux/store';
|
||||
|
||||
export const getPath = () => (window.location && window.location.pathname);
|
||||
export const pushPath = url => {
|
||||
return history.push(url);
|
||||
};
|
||||
export const pushPath = url => history.push(url);
|
||||
export const replacePath = url => history.replace(url);
|
||||
|
||||
export const getUrlData = (url = getPath()) => {
|
||||
const [, path, mode] = url.split('/');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue