|
1 | 1 | import Link from 'next/link'; |
2 | | -import { FC } from 'react'; |
| 2 | +import { FC, useContext } from 'react'; |
3 | 3 | import { Button, Card, Col, Container, Row } from 'react-bootstrap'; |
4 | 4 |
|
| 5 | +import { I18nContext } from '../../models/Translation'; |
5 | 6 | import { ArticleMeta } from '../../pages/api/core'; |
6 | 7 | import { SectionTitle } from './SectionTitle'; |
7 | 8 |
|
8 | 9 | interface UpcomingEventsProps { |
9 | 10 | events: ArticleMeta[]; |
10 | 11 | } |
11 | 12 |
|
12 | | -export const UpcomingEvents: FC<UpcomingEventsProps> = ({ events }) => ( |
13 | | - <div className="py-5 bg-white w-100 m-0"> |
14 | | - <Container> |
15 | | - <SectionTitle>近期活动</SectionTitle> |
| 13 | +export const UpcomingEvents: FC<UpcomingEventsProps> = ({ events }) => { |
| 14 | + const { t } = useContext(I18nContext); |
16 | 15 |
|
17 | | - <Row className="g-4" xs={1} sm={2} md={3}> |
18 | | - {events.map(({ name, meta, path }) => ( |
19 | | - <Col key={name}> |
20 | | - <Card body> |
21 | | - <Card.Title className="text-dark">{name}</Card.Title> |
22 | | - <Card.Text className="text-dark">时间: {meta?.start || 'N/A'}</Card.Text> |
23 | | - <Card.Text className="text-dark">地点: {meta?.address || 'N/A'}</Card.Text> |
| 16 | + return ( |
| 17 | + <div className="py-5 bg-white w-100 m-0"> |
| 18 | + <Container> |
| 19 | + <SectionTitle>{t('upcoming_events')}</SectionTitle> |
24 | 20 |
|
25 | | - <Link href={path || '#'} className="btn btn-primary"> |
26 | | - 查看详情 |
27 | | - </Link> |
28 | | - </Card> |
29 | | - </Col> |
30 | | - ))} |
31 | | - </Row> |
32 | | - <div className="text-center mt-4"> |
33 | | - <Button variant="outline-primary" size="lg" href="/activity"> |
34 | | - 查看全部活动 → |
35 | | - </Button> |
36 | | - </div> |
37 | | - </Container> |
38 | | - </div> |
39 | | -); |
| 21 | + <Row className="g-4" xs={1} sm={2} md={3}> |
| 22 | + {events.map(({ name, meta, path }) => ( |
| 23 | + <Col key={name}> |
| 24 | + <Card body> |
| 25 | + <Card.Title className="text-dark">{name}</Card.Title> |
| 26 | + <Card.Text className="text-dark"> |
| 27 | + {t('activity_time')}: {meta?.start || 'N/A'} |
| 28 | + </Card.Text> |
| 29 | + <Card.Text className="text-dark"> |
| 30 | + {t('activity_location')}: {meta?.address || 'N/A'} |
| 31 | + </Card.Text> |
| 32 | + |
| 33 | + <Link href={path || '#'} className="btn btn-primary"> |
| 34 | + {t('view_details')} |
| 35 | + </Link> |
| 36 | + </Card> |
| 37 | + </Col> |
| 38 | + ))} |
| 39 | + </Row> |
| 40 | + <div className="text-center mt-4"> |
| 41 | + <Button variant="outline-primary" size="lg" href="/activity"> |
| 42 | + {t('view_all_activities')} → |
| 43 | + </Button> |
| 44 | + </div> |
| 45 | + </Container> |
| 46 | + </div> |
| 47 | + ); |
| 48 | +}; |
0 commit comments