34 lines
655 B
TypeScript
34 lines
655 B
TypeScript
import getUri from '../lib/ids';
|
|
import { putNewGpx } from './gpx';
|
|
import { put } from './lib';
|
|
|
|
export const emptyTrk: Trk = {
|
|
name: undefined,
|
|
cmt: undefined,
|
|
desc: undefined,
|
|
src: undefined,
|
|
link: undefined,
|
|
number: 0,
|
|
type: undefined,
|
|
extensions: undefined,
|
|
trkseg: undefined,
|
|
};
|
|
|
|
export const putNewTrk = async (id?: IdTrk | IdGpx) => {
|
|
let finalId = { ...id };
|
|
if (!('trk' in finalId)) {
|
|
const gpxId = await putNewGpx(id);
|
|
finalId = { ...gpxId, trk: 0 };
|
|
}
|
|
const uri = getUri('trk', finalId);
|
|
await put(
|
|
uri,
|
|
'trk',
|
|
(trk) => {
|
|
return trk;
|
|
},
|
|
emptyTrk
|
|
);
|
|
return finalId as IdTrk;
|
|
};
|