Created
September 23, 2019 14:18
-
-
Save PamornT/e014d4e92157c04b92e0d9b8ca1ad7e8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let item_json = []; | |
let { response } = tracks; | |
let { items } = response; | |
let key = Object.keys(tracks.response.items); | |
if (key.length > 0) { | |
let bgcolor; | |
items[key[0]].forEach(function(detail) { | |
bgcolor = (detail.delivery_status == 'S') ? '#ABEBC6' : '#EEEEEE'; | |
const item_temp = { | |
"type": "box", | |
"layout": "horizontal", | |
"contents": [ | |
{ | |
"type": "box", | |
"layout": "vertical", | |
"contents": [ | |
{ | |
"type": "box", | |
"layout": "horizontal", | |
"contents": [ | |
{ | |
"type": "text", | |
"text": detail.status_date | |
} | |
] | |
}, | |
{ | |
"type": "box", | |
"layout": "horizontal", | |
"contents": [ | |
{ | |
"type": "spacer", | |
"size": "xxl" | |
}, | |
{ | |
"type": "text", | |
"text": detail.status_description, | |
"size": "sm" | |
} | |
], | |
"spacing": "none", | |
"margin": "md" | |
}, | |
{ | |
"type": "box", | |
"layout": "horizontal", | |
"contents": [ | |
{ | |
"type": "spacer", | |
"size": "xxl" | |
}, | |
{ | |
"type": "text", | |
"text": detail.location, | |
"size": "sm" | |
}, | |
{ | |
"type": "text", | |
"text": detail.postcode, | |
"size": "sm" | |
} | |
], | |
"spacing": "none", | |
"margin": "md" | |
} | |
] | |
} | |
], | |
"backgroundColor": bgcolor, | |
"cornerRadius": "md", | |
"paddingAll": "10px" | |
}; | |
item_json.push(item_temp); | |
}); | |
payload = { | |
"type": "bubble", | |
"size": "giga", | |
"body": { | |
"type": "box", | |
"layout": "vertical", | |
"contents": [ | |
{ | |
"type": "text", | |
"text": key[0], | |
"decoration": "none", | |
"size": "xl", | |
"weight": "bold" | |
}, | |
{ | |
"type": "box", | |
"layout": "vertical", | |
"contents": item_json, | |
"spacing": "sm", | |
"margin": "md" | |
} | |
] | |
} | |
} | |
reply_track(req, payload); | |
} else { | |
reply_notfound(req); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment