diff --git a/src/index.ts b/src/index.ts index 70917ca..7ce8c0c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -52,7 +52,8 @@ export async function submit( reason: string, photos: Array, timestamp: Date, - contact_details: ContactDetails + contact_details: ContactDetails, + plate: string ) { if (location.address.includes("\n")) { throw new Error("no newlines allowed in address"); @@ -74,7 +75,9 @@ export async function submit( const [date_str, hour] = formatTimestamp(timestamp); - const body = `Samochód ${reason || ""}. Zdjęci${ + const body = `Samochód ${ + reason || "" + }. Numer rejestracyjny samochodu: ${plate} Zdjęci${ photos.length === 1 ? "e" : "a" } wykonane ${date_str} o godz. ${hour} w pobliżu ul. ${ location.address @@ -178,5 +181,11 @@ export async function submit( "--data", `action=save&source=summary&instance=poznan_sm&x=${x}&y=${y}&lon=${x}&lat=${y}&srs=EPSG%3A2177&goto_thanks=`, ]); - console.log(response); + const matches = response.match( + /
  • Numer: ([0-9]+)<\/strong><\/li>/ + ); + if (matches === null) { + throw new Error("Could not extract submission number"); + } + return matches[1]; }