From 0518b6b331dd677affb96c0584ce447b0373232b Mon Sep 17 00:00:00 2001 From: Francesco Esposito <33671357+frsposito@users.noreply.github.com> Date: Thu, 22 Aug 2019 17:26:58 +0200 Subject: [PATCH] Add templates --- src/templates.js | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 src/templates.js diff --git a/src/templates.js b/src/templates.js new file mode 100644 index 0000000..01c9c84 --- /dev/null +++ b/src/templates.js @@ -0,0 +1,43 @@ +export const searchCityTemplate = (data) => ( + `========== + *Id*: ${data.id} + *City*: ${data.name} + *Country*: ${data.country}` +); + + +export const welcomeTemplate = (name) => ( + `Welcome *${name}*` +); + + +export const errorTemplate = () => ( + "*Ops*, there's a problem. Check the log." +); + + +export const setLocationTemplate = (location) => ( + `Location setted: ${location}` +); + + +export const weatherTemplate = () => ( + 'Hey, today take the umbrella ☂️' +); + + +export const weatherDetailsTemplate = (data) => { + let msg = `*Information:* + City: ${data.city}\n\n`; + + msg += '*Details*:'; + data.list.forEach((e) => { + msg += ` + 🕓 ${new Date(e.date).toLocaleTimeString()} + ☔ ${e.rain_flag === 'Y' ? 'Yes' : 'No'} + 🌡️ ${e.temperature} + ----`; + }); + + return msg; +};