Skip to content

Commit

Permalink
Support formatted address input
Browse files Browse the repository at this point in the history
  • Loading branch information
wpf500 committed Nov 12, 2024
1 parent 4fc158b commit 7263a04
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions apps/backend/src/tools/database/import-callout-responses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ function parseValue(
component: CalloutComponentSchema,
value: string
): CalloutResponseAnswer {
value = value.trim();

switch (component.type) {
case CalloutComponentType.INPUT_NUMBER:
return parseFloat(value);
Expand Down Expand Up @@ -131,10 +133,10 @@ function parseValue(
);

case CalloutComponentType.INPUT_ADDRESS:
const [lat, lng] = value.split(",").map((v) => parseFloat(v));
const [lat, lng, ...rest] = value.split(",");
return {
geometry: { location: { lat, lng } },
formatted_address: ""
geometry: { location: { lat: Number(lat), lng: Number(lng) } },
formatted_address: rest.join(",")
} satisfies CalloutResponseAnswerAddress;

case CalloutComponentType.INPUT_FILE:
Expand Down

0 comments on commit 7263a04

Please sign in to comment.