| 1 |
import React from 'react'; |
| 2 |
|
| 3 |
const RoastDisplay = ({ roast, location, loading }) => { |
| 4 |
const getLocationString = () => { |
| 5 |
if (!location) return ''; |
| 6 |
|
| 7 |
let parts = []; |
| 8 |
if (location.city) parts.push(location.city); |
| 9 |
if (location.state) parts.push(location.state); |
| 10 |
if (location.country) parts.push(location.country); |
| 11 |
|
| 12 |
return parts.join(', '); |
| 13 |
}; |
| 14 |
|
| 15 |
return ( |
| 16 |
<> |
| 17 |
<div className="roast-box"> |
| 18 |
{loading ? ( |
| 19 |
<div className="loading-spinner"> |
| 20 |
<span className="loading"></span> |
| 21 |
</div> |
| 22 |
) : roast ? ( |
| 23 |
<p className="roast-text">{roast}</p> |
| 24 |
) : ( |
| 25 |
<p className="roast-text"> |
| 26 |
Ready to get roasted? Hit the button if you can handle it... |
| 27 |
</p> |
| 28 |
)} |
| 29 |
</div> |
| 30 |
|
| 31 |
{location && ( |
| 32 |
<div className="location-display"> |
| 33 |
📍 {getLocationString()} |
| 34 |
</div> |
| 35 |
)} |
| 36 |
</> |
| 37 |
); |
| 38 |
}; |
| 39 |
|
| 40 |
export default RoastDisplay; |