round-summary.component.jsx 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import React from "react";
  2. import withGoogleApiKey from "./with-google-key.component";
  3. // TODO eventually we want this to query and show other players
  4. const RoundSummary = ({ googleApiKey, round, onNext }) => {
  5. const {
  6. roundNum,
  7. selectedPoint,
  8. targetPoint,
  9. score,
  10. totalScore,
  11. } = round;
  12. // TODO determine zoom and center dynamically, or make this a dynamic map
  13. const mapUrl = `https://maps.googleapis.com/maps/api/staticmap?key=${googleApiKey}`;
  14. const size = `&size=600x400`
  15. const zoom = `&zoom=5`;
  16. const centerOnTarget = `&center=${targetPoint.lat},${targetPoint.lng}`;
  17. const targetMarker = `&markers=color:blue|label:T|${targetPoint.lat},${targetPoint.lng}`;
  18. const selectedMarker = selectedPoint ? `&markers=color:red|label:S|${selectedPoint.lat},${selectedPoint.lng}` : ""
  19. return (
  20. <div>
  21. <img
  22. src={mapUrl + size + zoom + centerOnTarget + targetMarker + selectedMarker}
  23. alt={`Map pointing to ${targetPoint.lat},${targetPoint.lng}`}
  24. />
  25. {selectedPoint ? <p>You Selected: {`${selectedPoint.lat},${selectedPoint.lng}`}</p> : <p>Timed out!</p>}
  26. <p>Target: {targetPoint.lat},{targetPoint.lng}</p>
  27. <p>Score For Round {roundNum}: {score}</p>
  28. <p>Running Total Score: {totalScore}</p>
  29. <button
  30. onClick={onNext}>
  31. {roundNum === "5" ? "View Summary" : "Next Round"}
  32. </button>
  33. </div>
  34. );
  35. }
  36. const RoundSummaryWithApiKey = withGoogleApiKey(RoundSummary);
  37. export default RoundSummaryWithApiKey;