mirror of
https://github.com/muerwre/orchidmap-front.git
synced 2025-04-25 11:06:40 +07:00
backend: drop and modify
This commit is contained in:
parent
17a929956c
commit
7513f79b93
7 changed files with 81 additions and 2 deletions
|
@ -7,4 +7,7 @@ export const API: { [x: string]: string } = {
|
|||
GET_MAP: `${CLIENT.API_ADDR}/route`,
|
||||
POST_MAP: `${CLIENT.API_ADDR}/route`,
|
||||
GET_ROUTE_LIST: `${CLIENT.API_ADDR}/route/list`,
|
||||
|
||||
DROP_ROUTE: `${CLIENT.API_ADDR}/route`,
|
||||
MODIFY_ROUTE: `${CLIENT.API_ADDR}/route/modify`,
|
||||
};
|
||||
|
|
|
@ -3,9 +3,9 @@ import { delay, SagaIterator } from 'redux-saga';
|
|||
import { takeLatest, select, call, put, takeEvery, race, take } from 'redux-saga/effects';
|
||||
import {
|
||||
checkIframeToken, checkOSRMService,
|
||||
checkUserToken,
|
||||
checkUserToken, dropRoute,
|
||||
getGuestToken, getRouteList,
|
||||
getStoredMap,
|
||||
getStoredMap, modifyRoute,
|
||||
postMap
|
||||
} from '$utils/api';
|
||||
import {
|
||||
|
@ -647,6 +647,20 @@ function* mapsLoadMoreSaga() {
|
|||
yield put(searchSetLoading(false));
|
||||
}
|
||||
|
||||
function* dropRouteSaga({ _id }: ReturnType<typeof ActionCreators.dropRoute>): SagaIterator {
|
||||
const { id, token } = yield select(getUser);
|
||||
const result = yield call(dropRoute, { address: _id, id, token });
|
||||
|
||||
console.log('result', result);
|
||||
}
|
||||
|
||||
function* modifyRouteSaga({ _id, title, is_public }: ReturnType<typeof ActionCreators.modifyRoute>): SagaIterator {
|
||||
const { id, token } = yield select(getUser);
|
||||
const result = yield call(modifyRoute, { address: _id, id, token, title, is_public });
|
||||
|
||||
console.log('result', result);
|
||||
}
|
||||
|
||||
export function* userSaga() {
|
||||
yield takeLatest(REHYDRATE, authCheckSaga);
|
||||
yield takeEvery(ACTIONS.SET_MODE, setModeSaga);
|
||||
|
@ -691,4 +705,7 @@ export function* userSaga() {
|
|||
|
||||
yield takeLatest(ACTIONS.GET_GPX_TRACK, getGPXTrackSaga);
|
||||
yield takeLatest(ACTIONS.MAPS_LOAD_MORE, mapsLoadMoreSaga);
|
||||
|
||||
yield takeLatest(ACTIONS.DROP_ROUTE, dropRouteSaga);
|
||||
yield takeLatest(ACTIONS.MODIFY_ROUTE, modifyRouteSaga);
|
||||
}
|
||||
|
|
|
@ -101,3 +101,14 @@ export const getRouteList = ({
|
|||
export const checkOSRMService = (bounds: LatLngLiteral[]): Promise<boolean> => (
|
||||
CLIENT && CLIENT.OSRM_URL && axios.get(CLIENT.OSRM_TEST_URL(bounds)).then(() => true).catch(() => false)
|
||||
);
|
||||
|
||||
export const dropRoute = ({ address, id, token }: { address: string, id: string, token: string }): AxiosPromise<any> => (
|
||||
axios.delete(API.DROP_ROUTE, { data: { address: '1123123123123', id, token } })
|
||||
);
|
||||
|
||||
export const modifyRoute = (
|
||||
{ address, id, token, title, is_public }:
|
||||
{ address: string, id: string, token: string, title: string, is_public: boolean }
|
||||
): AxiosPromise<any> => (
|
||||
axios.patch(API.DROP_ROUTE, { address, id, token, title, is_public })
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue