Skip to content

Commit 9612670

Browse files
CopilotTechQuery
andauthored
[add] China NGO Database 2.0 pages (#36)
Co-authored-by: TechQuery <[email protected]>
1 parent fdae8f3 commit 9612670

30 files changed

+1270
-469
lines changed

.env

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ NEXT_PUBLIC_LOGO = https://github.com/Open-Source-Bazaar.png
55
NEXT_PUBLIC_LARK_API_HOST = https://open.feishu.cn/open-apis/
66
NEXT_PUBLIC_LARK_APP_ID = cli_a8094a652022900d
77
NEXT_PUBLIC_LARK_WIKI_URL = https://open-source-bazaar.feishu.cn/wiki/space/7052192153363054596
8+
9+
NEXT_PUBLIC_STRAPI_API_HOST = https://china-ngo-db.onrender.com/api/

.gitignore

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,7 @@ yarn-debug.log*
2626
yarn-error.log*
2727

2828
# local env files
29-
.env.local
30-
.env.development.local
31-
.env.test.local
32-
.env.production.local
29+
.env*local
3330

3431
# vercel
3532
.vercel

.husky/pre-commit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
npm test
1+
npm test

.husky/pre-push

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
npm run build
1+
npm run build

.npmrc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
auto-install-peers = false
1+
auto-install-peers = false
2+
//npm.pkg.github.com/:_authToken=${GH_PAT}
3+
@open-source-bazaar:registry=https://npm.pkg.github.com

components/Base/ZodiacBar.tsx

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import Link from 'next/link';
2+
import { FC, ReactNode } from 'react';
3+
4+
export const ZodiacSigns = ['🐵', '🐔', '🐶', '🐷', '🐭', '🐮', '🐯', '🐰', '🐲', '🐍', '🐴', '🐐'];
5+
6+
export interface ZodiacBarProps {
7+
startYear: number;
8+
endYear?: number;
9+
itemOf?: (year: number, zodiac: string) => { link?: string; title?: ReactNode };
10+
}
11+
12+
export const ZodiacBar: FC<ZodiacBarProps> = ({
13+
startYear,
14+
endYear = new Date().getFullYear(),
15+
itemOf,
16+
}) => (
17+
<ol className="list-inline d-flex flex-wrap justify-content-center gap-3">
18+
{Array.from({ length: endYear - startYear + 1 }, (_, index) => {
19+
const year = endYear - index;
20+
const zodiac = ZodiacSigns[year % 12];
21+
const { link = '#', title } = itemOf?.(year, zodiac) || {};
22+
23+
return (
24+
<li key={index} className="list-inline-item border rounded">
25+
<Link className="d-inline-block p-3 text-decoration-none text-center" href={link}>
26+
<div className="fs-1">{zodiac}</div>
27+
28+
{title}
29+
</Link>
30+
</li>
31+
);
32+
})}
33+
</ol>
34+
);

components/LarkImage.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,7 @@ export interface LarkImageProps extends Omit<ImageProps, 'src'> {
99
src?: TableCellValue;
1010
}
1111

12-
export const LarkImage: FC<LarkImageProps> = ({
13-
src = DefaultImage,
14-
alt,
15-
...props
16-
}) => (
12+
export const LarkImage: FC<LarkImageProps> = ({ src = DefaultImage, alt, ...props }) => (
1713
<Image
1814
fluid
1915
loading="lazy"

components/Map/ChinaMap.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { OpenReactMap, OpenReactMapProps, TileLayer } from 'open-react-map';
2+
import { FC } from 'react';
3+
4+
const ChinaMap: FC<OpenReactMapProps> = props => (
5+
<OpenReactMap
6+
{...props}
7+
renderTileLayer={() => <TileLayer vendor="GaoDe" />}
8+
/>
9+
);
10+
export default ChinaMap;
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import { computed } from 'mobx';
2+
import { observer } from 'mobx-react';
3+
import { ObservedComponent } from 'mobx-react-helper';
4+
import dynamic from 'next/dynamic';
5+
import { MarkerMeta, OpenReactMapProps } from 'open-react-map';
6+
7+
import { OrganizationStatistic } from '../../models/Organization';
8+
import systemStore from '../../models/System';
9+
10+
const ChinaMap = dynamic(() => import('./ChinaMap'), { ssr: false });
11+
12+
export interface CityStatisticMapProps {
13+
data: OrganizationStatistic['coverageArea'];
14+
onChange?: (city: string) => any;
15+
}
16+
17+
@observer
18+
export class CityStatisticMap extends ObservedComponent<CityStatisticMapProps> {
19+
componentDidMount() {
20+
systemStore.getCityCoordinate();
21+
}
22+
23+
@computed
24+
get markers() {
25+
const { cityCoordinate } = systemStore,
26+
{ data } = this.observedProps;
27+
28+
return Object.entries(data)
29+
.map(([city, count]) => {
30+
const point = cityCoordinate[city];
31+
32+
if (point)
33+
return {
34+
tooltip: `${city} ${count}`,
35+
position: [point[1], point[0]],
36+
};
37+
})
38+
.filter(Boolean) as MarkerMeta[];
39+
}
40+
41+
handleChange: OpenReactMapProps['onMarkerClick'] = ({ latlng: { lat, lng } }) => {
42+
const { markers } = this;
43+
const { tooltip } =
44+
markers.find(({ position: p }) => p instanceof Array && lat === p[0] && lng === p[1]) || {};
45+
const [city] = tooltip?.split(/\s+/) || [];
46+
47+
this.props.onChange?.(city);
48+
};
49+
50+
render() {
51+
const { markers } = this;
52+
53+
return (
54+
<ChinaMap
55+
style={{ height: '70vh' }}
56+
center={[34.32, 108.55]}
57+
zoom={4}
58+
markers={markers}
59+
onMarkerClick={this.handleChange}
60+
/>
61+
);
62+
}
63+
}

components/Navigator/MainNavigator.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,16 @@ const topNavBarMenu = ({ t }: typeof i18n): MenuItem[] => [
4545
{ href: '/license-filter', title: t('license_filter') },
4646
],
4747
},
48+
{
49+
title: t('NGO'),
50+
subs: [
51+
{ href: '/NGO', title: t('China_NGO_DB') },
52+
{
53+
href: 'https://open-source-bazaar.feishu.cn/wiki/VGrMwiweVivWrHkTcvpcJTjjnoY',
54+
title: t('Open_Source_NGO_plan'),
55+
},
56+
],
57+
},
4858
{
4959
title: t('wiki'),
5060
subs: [

0 commit comments

Comments
 (0)