Skip to content

Commit dbefb17

Browse files
committed
[refactor] migrate NGO models to BI Table API based on MobX-Lark 2.8
[optimize] update Upstream packages
1 parent fc0e541 commit dbefb17

14 files changed

Lines changed: 687 additions & 595 deletions

File tree

.env

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@ NEXT_PUBLIC_ACTIVITY_TABLE_ID = tblREEMxDOECZZrK
1111
NEXT_PUBLIC_PROJECT_TABLE_ID = tblGnY6Hm0nTSBR9
1212
NEXT_PUBLIC_AWARD_TABLE_ID = tblmYd5V5BMngAp2
1313

14-
NEXT_PUBLIC_STRAPI_API_HOST = https://china-ngo-db.onrender.com/api/
14+
NEXT_PUBLIC_STRAPI_API_HOST = https://test.nomad-home.cn/api/Lark/
15+
NEXT_PUBLIC_NGO_BASE_ID = Kfs0bHJZhaKtJLs3uBTcnynnnNf
16+
NEXT_PUBLIC_NGO_TABLE_ID = tbl3eTvwgMGukhqL
17+
NEXT_PUBLIC_NGO_YEAR_STATISTIC_TABLE_ID = tblNWHacXaiEYC50
18+
NEXT_PUBLIC_NGO_CITY_STATISTIC_TABLE_ID = tblFFyaTEpGAaZNl
19+
NEXT_PUBLIC_NGO_TYPE_STATISTIC_TABLE_ID = tblZeAOFqH6zX6Tr
1520

1621
SMTP_HOST = smtp.feishu.cn
1722
SMTP_PORT = 465

.npmrc

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

README.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,8 @@
2222
## 开始
2323

2424
```bash
25-
npm install
26-
npm run dev
27-
# or
28-
yarn install
29-
yarn dev
25+
pnpm install
26+
pnpm dev
3027
```
3128

3229
可访问 http://localhost:3000.

components/Map/CityStatisticMap.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import systemStore from '../../models/System';
1010
const ChinaMap = dynamic(() => import('./ChinaMap'), { ssr: false });
1111

1212
export interface CityStatisticMapProps {
13-
data: OrganizationStatistic['coverageArea'];
13+
data: OrganizationStatistic['city'];
1414
onChange?: (city: string) => any;
1515
}
1616

@@ -27,7 +27,7 @@ export class CityStatisticMap extends ObservedComponent<CityStatisticMapProps> {
2727

2828
return Object.entries(data)
2929
.map(([city, count]) => {
30-
const point = cityCoordinate[city];
30+
const point = cityCoordinate[city.replace(/(||)$/, '')];
3131

3232
if (point)
3333
return {

components/Organization/Card.tsx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { Organization } from '@open-source-bazaar/china-ngo-database';
21
import { Icon } from 'idea-react';
32
import { observable } from 'mobx';
43
import { observer } from 'mobx-react';
@@ -8,9 +7,11 @@ import { HTMLAttributes } from 'react';
87
import { Button, Card, CardProps, Image } from 'react-bootstrap';
98

109
import { i18n, I18nContext } from '../../models/Translation';
10+
import { Organization } from '../../models/Organization';
1111

1212
export interface OrganizationCardProps
13-
extends Pick<HTMLAttributes<HTMLDivElement>, 'className' | 'style'>,
13+
extends
14+
Pick<HTMLAttributes<HTMLDivElement>, 'className' | 'style'>,
1415
Omit<Organization, 'id'>,
1516
CardProps {
1617
onSwitch?: (filter: Partial<Pick<Organization, 'entityType' | 'coverageArea'>>) => any;
@@ -24,7 +25,7 @@ export class OrganizationCard extends ObservedComponent<OrganizationCardProps, t
2425
accessor showQRC = false;
2526

2627
renderIcon() {
27-
const { website, wechatPublic } = this.observedProps.internetContact || {};
28+
const { website, wechatPublic } = this.observedProps;
2829

2930
return (
3031
<div className="d-flex justify-content-around">
@@ -34,7 +35,7 @@ export class OrganizationCard extends ObservedComponent<OrganizationCardProps, t
3435
</Button>
3536
)} */}
3637
{website && (
37-
<Button title="WWW" size="sm" target="_blank" href={website}>
38+
<Button title="WWW" size="sm" target="_blank" href={website?.toString()}>
3839
<Icon name="globe2" />
3940
</Button>
4041
)}
@@ -53,9 +54,8 @@ export class OrganizationCard extends ObservedComponent<OrganizationCardProps, t
5354
}
5455

5556
render() {
56-
const { name, entityType, services, description, internetContact, onSwitch, ...props } =
57+
const { name, entityType, services, description, wechatPublic, onSwitch, ...props } =
5758
this.props;
58-
const { wechatPublic } = internetContact || {};
5959

6060
return (
6161
<Card
@@ -74,21 +74,21 @@ export class OrganizationCard extends ObservedComponent<OrganizationCardProps, t
7474
/> */}
7575
<Card.Body>
7676
<Card.Title>
77-
{name}
78-
<BadgeBar className="ms-2" list={[{ text: entityType! }]} />
77+
{name + ''}
78+
<BadgeBar className="ms-2" list={[{ text: entityType + '' }]} />
7979
</Card.Title>
8080

8181
{services && (
8282
<BadgeBar
8383
className="justify-content-end"
84-
list={services.map(({ serviceCategory }) => ({ text: serviceCategory! }))}
84+
list={(services as string[]).map(text => ({ text }))}
8585
/>
8686
)}
8787
<Card.Text
8888
className="d-none d-sm-block text-wrap overflow-auto"
8989
style={{ minHeight: '5rem', maxHeight: '10rem' }}
9090
>
91-
{description}
91+
{description?.toString()}
9292
</Card.Text>
9393
</Card.Body>
9494

@@ -99,7 +99,7 @@ export class OrganizationCard extends ObservedComponent<OrganizationCardProps, t
9999
<Image
100100
className="mt-2"
101101
src={`https://open.weixin.qq.com/qr/code?username=${wechatPublic}`}
102-
alt={wechatPublic}
102+
alt={wechatPublic?.toString()}
103103
fluid
104104
/>
105105
)}

components/Organization/Charts.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ import { OrganizationStatistic, sortStatistic } from '../../models/Organization'
66
import { I18nContext } from '../../models/Translation';
77

88
const OrganizationCharts: FC<OrganizationStatistic> = observer(
9-
({ entityType, serviceCategory, coverageArea }) => {
9+
({ entityType, serviceCategory, city }) => {
1010
const { t } = useContext(I18nContext);
1111

1212
const typeList = sortStatistic(entityType),
1313
categoryList = sortStatistic(serviceCategory),
14-
areaList = sortStatistic(coverageArea);
14+
areaList = sortStatistic(city);
1515

1616
return (
1717
<div style={{ minHeight: '70vh' }}>

components/Organization/Landscape.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
import { Organization } from '@open-source-bazaar/china-ngo-database';
21
import { Dialog } from 'idea-react';
32
import { observable } from 'mobx';
43
import { observer } from 'mobx-react';
54
import { Component } from 'react';
65
import { Modal } from 'react-bootstrap';
76
import { splitArray } from 'web-utility';
87

9-
import { OrganizationModel } from '../../models/Organization';
8+
import { Organization, OrganizationModel } from '../../models/Organization';
109
import systemStore from '../../models/System';
1110
import { OrganizationCard } from './Card';
1211
import styles from './LandScape.module.less';
@@ -46,9 +45,9 @@ export class OpenCollaborationLandscape extends Component<OpenCollaborationLands
4645
onClick={() => this.modal.open({ name: name as string })}
4746
>
4847
<div className="text-nowrap" style={{ fontSize: this.itemSize + 'rem' }}>
49-
{name.slice(0, 2)}
48+
{(name + '').slice(0, 2)}
5049
<br />
51-
{name.slice(2, 4)}
50+
{(name + '').slice(2, 4)}
5251
</div>
5352
</li>
5453
);

0 commit comments

Comments
 (0)