mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-06-20 22:01:45 +00:00
refactor(places): merge KML/KMZ routes into single POST /import/map endpoint
This commit is contained in:
@@ -105,13 +105,9 @@ export const placesApi = {
|
||||
const fd = new FormData(); fd.append('file', file)
|
||||
return apiClient.post(`/trips/${tripId}/places/import/gpx`, fd, { headers: { 'Content-Type': 'multipart/form-data' } }).then(r => r.data)
|
||||
},
|
||||
importKml: (tripId: number | string, file: File) => {
|
||||
importMapFile: (tripId: number | string, file: File) => {
|
||||
const fd = new FormData(); fd.append('file', file)
|
||||
return apiClient.post(`/trips/${tripId}/places/import/kml`, fd, { headers: { 'Content-Type': 'multipart/form-data' } }).then(r => r.data)
|
||||
},
|
||||
importKmz: (tripId: number | string, file: File) => {
|
||||
const fd = new FormData(); fd.append('file', file)
|
||||
return apiClient.post(`/trips/${tripId}/places/import/kmz`, fd, { headers: { 'Content-Type': 'multipart/form-data' } }).then(r => r.data)
|
||||
return apiClient.post(`/trips/${tripId}/places/import/map`, fd, { headers: { 'Content-Type': 'multipart/form-data' } }).then(r => r.data)
|
||||
},
|
||||
importGoogleList: (tripId: number | string, url: string) =>
|
||||
apiClient.post(`/trips/${tripId}/places/import/google-list`, { url }).then(r => r.data),
|
||||
|
||||
@@ -111,9 +111,7 @@ const PlacesSidebar = React.memo(function PlacesSidebar({
|
||||
setKmlKmzSummary(null)
|
||||
|
||||
try {
|
||||
const result = ext === 'kmz'
|
||||
? await placesApi.importKmz(tripId, kmlKmzFile)
|
||||
: await placesApi.importKml(tripId, kmlKmzFile)
|
||||
const result = await placesApi.importMapFile(tripId, kmlKmzFile)
|
||||
|
||||
await loadTrip(tripId)
|
||||
setKmlKmzSummary(result.summary || null)
|
||||
|
||||
Reference in New Issue
Block a user