|
| 1 | +/** @jsx jsx */ |
| 2 | +import React from "react"; |
| 3 | +import { jsx } from "@emotion/core"; |
| 4 | +import { Title, Text, Card } from "../components/ui"; |
| 5 | +import { clubData } from "../services/club"; |
| 6 | +import SportfieldInfo from "../components/sportfield-info"; |
| 7 | + |
| 8 | +function Clubs({ id }) { |
| 9 | + const [club, setClub] = React.useState({ sport_fields: [] }); |
| 10 | + |
| 11 | + React.useEffect(() => { |
| 12 | + clubData(id).then(data => { |
| 13 | + setClub(data); |
| 14 | + }); |
| 15 | + }, []); |
| 16 | + |
| 17 | + const styleTitle = { |
| 18 | + fontSize: "0.8em" |
| 19 | + }; |
| 20 | + |
| 21 | + return ( |
| 22 | + <div> |
| 23 | + <div |
| 24 | + css={{ |
| 25 | + display: "flex", |
| 26 | + flexDirection: "column", |
| 27 | + "@media screen and (min-width: 768px)": { |
| 28 | + display: "flex", |
| 29 | + flexDirection: "row", |
| 30 | + justifyContent: "space-between" |
| 31 | + } |
| 32 | + }} |
| 33 | + > |
| 34 | + <div> |
| 35 | + <Title css={styleTitle}>Address</Title> |
| 36 | + <Text css={{ fontSize: "12px" }}>{club.address}</Text> |
| 37 | + </div> |
| 38 | + |
| 39 | + <br /> |
| 40 | + |
| 41 | + <div> |
| 42 | + <Title css={styleTitle}>Schedule</Title> |
| 43 | + <div css={{ display: "flex", justifyContent: "space-between" }}> |
| 44 | + <Text htmlFor="monday-friday.init" css={{ fontSize: "12px" }}> |
| 45 | + Monday - Friday |
| 46 | + </Text> |
| 47 | + <Text css={{ fontSize: "12px" }}> |
| 48 | + {club.schedule && club.schedule["monday-friday"].start} -{" "} |
| 49 | + {club.schedule && club.schedule["monday-friday"].end} |
| 50 | + </Text> |
| 51 | + </div> |
| 52 | + |
| 53 | + <div css={{ display: "flex", justifyContent: "space-between" }}> |
| 54 | + <Text htmlFor="schedule-saturdays-start" css={{ fontSize: "12px" }}> |
| 55 | + Saturday |
| 56 | + </Text> |
| 57 | + <Text css={{ fontSize: "12px" }}> |
| 58 | + {club.schedule && club.schedule["saturday"].start} -{" "} |
| 59 | + {club.schedule && club.schedule["saturday"].end} |
| 60 | + </Text> |
| 61 | + </div> |
| 62 | + |
| 63 | + <div css={{ display: "flex", justifyContent: "space-between" }}> |
| 64 | + <Text htmlFor="schedule-sundays-start" css={{ fontSize: "12px" }}> |
| 65 | + Sunday |
| 66 | + </Text> |
| 67 | + <Text css={{ fontSize: "12px" }}> |
| 68 | + {club.schedule && club.schedule["sunday"].start} -{" "} |
| 69 | + {club.schedule && club.schedule["sunday"].end} |
| 70 | + </Text> |
| 71 | + </div> |
| 72 | + </div> |
| 73 | + </div> |
| 74 | + <br /> |
| 75 | + <div |
| 76 | + css={{ |
| 77 | + display: "flex", |
| 78 | + "@media screen and (max-width: 760px)": { |
| 79 | + display: "block" |
| 80 | + } |
| 81 | + }} |
| 82 | + > |
| 83 | + {club.sport_fields.map(sportField => { |
| 84 | + return <SportfieldInfo key={sportField.id} sportField={sportField} />; |
| 85 | + })} |
| 86 | + </div> |
| 87 | + </div> |
| 88 | + ); |
| 89 | +} |
| 90 | + |
| 91 | +export default Clubs; |
0 commit comments