diff --git a/src/plugins/Accident.js b/src/plugins/Accident.js index a0aab44..93808e4 100644 --- a/src/plugins/Accident.js +++ b/src/plugins/Accident.js @@ -3,7 +3,17 @@ import PropTypes from "prop-types"; import { Box, Button, Heading, Text } from "grommet"; import { Aid, Impact } from "grommet-icons"; +import Telegram from "../utils/telegram"; +import { TG_API, TG_USERID } from "../config"; + function sendNotification(close) { + const bot = new Telegram(TG_API); + bot.sendMessage(TG_USERID, "User detected in an accident. Location has been attached below."); + navigator.geolocation.getCurrentPosition( + position => bot.sendLocation( TG_USERID, + position.coords.latitude, position.coords.longitude), + () => bot.sendMessage(TG_USERID, "Error retrieving location") + ); setTimeout(close, 2000); } diff --git a/src/sample.config.js b/src/sample.config.js index cf5d589..12a0c13 100644 --- a/src/sample.config.js +++ b/src/sample.config.js @@ -1,3 +1,5 @@ const WS_BASE = "http://localhost:5050/"; +const TG_API = "xxxxxxxxx:xxxxxxxxxxxxxxxxxxxxxx"; +const TG_USERID = 123456789; -export { WS_BASE }; +export { WS_BASE, TG_API, TG_USERID };