2022-11-08 21:02:06 +00:00
|
|
|
import getUri from '../lib/ids';
|
|
|
|
import { putNewGpx } from './gpx';
|
|
|
|
import { put } from './lib';
|
|
|
|
|
|
|
|
export const emptyRte: Rte = {
|
|
|
|
name: undefined,
|
|
|
|
cmt: undefined,
|
|
|
|
desc: undefined,
|
|
|
|
src: undefined,
|
|
|
|
link: undefined,
|
|
|
|
number: 0,
|
|
|
|
type: undefined,
|
|
|
|
extensions: undefined,
|
|
|
|
rtept: undefined,
|
|
|
|
};
|
|
|
|
|
|
|
|
export const putNewRte = async (id?: IdRte | IdGpx) => {
|
|
|
|
let finalId = { ...id };
|
|
|
|
if (!('rte' in finalId)) {
|
|
|
|
const gpxId = await putNewGpx(id);
|
2022-11-13 19:02:11 +00:00
|
|
|
finalId = { ...gpxId, rte: 0 };
|
2022-11-08 21:02:06 +00:00
|
|
|
}
|
|
|
|
const uri = getUri('rte', finalId);
|
|
|
|
await put(
|
|
|
|
uri,
|
|
|
|
'rte',
|
|
|
|
(rte) => {
|
|
|
|
return rte;
|
|
|
|
},
|
|
|
|
emptyRte
|
|
|
|
);
|
|
|
|
return finalId as IdRte;
|
|
|
|
};
|