generated from idea2app/Next-Bootstrap-ts
-
Notifications
You must be signed in to change notification settings - Fork 6
[add] China NGO Database 2.0 pages #36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
234b008
Initial plan
Copilot ca30930
Add China Public Interest Map foundation with mobx-strapi integration
Copilot 20db4cc
Complete China Public Interest Map implementation with working naviga…
Copilot 81a83e0
Address PR review feedback: Fix .npmrc, restore Base.ts, update navig…
Copilot 0d6041b
Fix major TypeScript issues and implement class-based components as r…
Copilot 0ab732e
Fix getStaticProps serialization and add error handling for API failures
Copilot 11201fc
新增中国公益地图页面 - Add China Public Interest Map Pages
Copilot 23feba1
Complete rewrite of China Public Interest Map components according to…
Copilot 56ffc8a
[refactor] replace Scroll List with Search List for NGO index page
TechQuery 4a83fd2
[add] Organization Charts component
TechQuery e07c205
[optimize] update Upstream packages
TechQuery 68bd527
[refactor] load NGO data by year
TechQuery 69787fd
Translate all hardcoded text and clean up unused i18n keys
Copilot e35e3b5
[fix] some SSG & i18n bugs
TechQuery 6445ea9
[fix] NGO routes compatibility
TechQuery File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
npm test | ||
npm test |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
npm run build | ||
npm run build |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
auto-install-peers = false | ||
auto-install-peers = false | ||
//npm.pkg.github.com/:_authToken=${GH_PAT} | ||
@open-source-bazaar:registry=https://npm.pkg.github.com | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import Link from 'next/link'; | ||
import { FC, ReactNode } from 'react'; | ||
|
||
export const ZodiacSigns = ['🐵', '🐔', '🐶', '🐷', '🐭', '🐮', '🐯', '🐰', '🐲', '🐍', '🐴', '🐐']; | ||
|
||
export interface ZodiacBarProps { | ||
startYear: number; | ||
endYear?: number; | ||
itemOf?: (year: number, zodiac: string) => { link?: string; title?: ReactNode }; | ||
} | ||
|
||
export const ZodiacBar: FC<ZodiacBarProps> = ({ | ||
startYear, | ||
endYear = new Date().getFullYear(), | ||
itemOf, | ||
}) => ( | ||
<ol className="list-inline d-flex flex-wrap justify-content-center gap-3"> | ||
{Array.from({ length: endYear - startYear + 1 }, (_, index) => { | ||
const year = endYear - index; | ||
const zodiac = ZodiacSigns[year % 12]; | ||
const { link = '#', title } = itemOf?.(year, zodiac) || {}; | ||
|
||
return ( | ||
<li key={index} className="list-inline-item border rounded"> | ||
<Link className="d-inline-block p-3 text-decoration-none text-center" href={link}> | ||
<div className="fs-1">{zodiac}</div> | ||
|
||
{title} | ||
</Link> | ||
</li> | ||
); | ||
})} | ||
</ol> | ||
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { OpenReactMap, OpenReactMapProps, TileLayer } from 'open-react-map'; | ||
import { FC } from 'react'; | ||
|
||
const ChinaMap: FC<OpenReactMapProps> = props => ( | ||
<OpenReactMap | ||
{...props} | ||
renderTileLayer={() => <TileLayer vendor="GaoDe" />} | ||
/> | ||
); | ||
export default ChinaMap; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { computed } from 'mobx'; | ||
import { observer } from 'mobx-react'; | ||
import { ObservedComponent } from 'mobx-react-helper'; | ||
import dynamic from 'next/dynamic'; | ||
import { MarkerMeta, OpenReactMapProps } from 'open-react-map'; | ||
|
||
import { OrganizationStatistic } from '../../models/Organization'; | ||
import systemStore from '../../models/System'; | ||
|
||
const ChinaMap = dynamic(() => import('./ChinaMap'), { ssr: false }); | ||
|
||
export interface CityStatisticMapProps { | ||
data: OrganizationStatistic['coverageArea']; | ||
onChange?: (city: string) => any; | ||
} | ||
|
||
@observer | ||
export class CityStatisticMap extends ObservedComponent<CityStatisticMapProps> { | ||
componentDidMount() { | ||
systemStore.getCityCoordinate(); | ||
} | ||
|
||
@computed | ||
get markers() { | ||
const { cityCoordinate } = systemStore, | ||
{ data } = this.observedProps; | ||
|
||
return Object.entries(data) | ||
.map(([city, count]) => { | ||
const point = cityCoordinate[city]; | ||
|
||
if (point) | ||
return { | ||
tooltip: `${city} ${count}`, | ||
position: [point[1], point[0]], | ||
}; | ||
}) | ||
.filter(Boolean) as MarkerMeta[]; | ||
} | ||
|
||
handleChange: OpenReactMapProps['onMarkerClick'] = ({ latlng: { lat, lng } }) => { | ||
const { markers } = this; | ||
const { tooltip } = | ||
markers.find(({ position: p }) => p instanceof Array && lat === p[0] && lng === p[1]) || {}; | ||
const [city] = tooltip?.split(/\s+/) || []; | ||
|
||
this.props.onChange?.(city); | ||
}; | ||
|
||
render() { | ||
const { markers } = this; | ||
|
||
return ( | ||
<ChinaMap | ||
style={{ height: '70vh' }} | ||
center={[34.32, 108.55]} | ||
zoom={4} | ||
markers={markers} | ||
onMarkerClick={this.handleChange} | ||
/> | ||
); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
import { Organization } from '@open-source-bazaar/china-ngo-database'; | ||
import { Icon } from 'idea-react'; | ||
import { observable } from 'mobx'; | ||
import { observer } from 'mobx-react'; | ||
import { ObservedComponent } from 'mobx-react-helper'; | ||
import { BadgeBar } from 'mobx-restful-table'; | ||
import { HTMLAttributes } from 'react'; | ||
import { Button, Card, CardProps, Image } from 'react-bootstrap'; | ||
|
||
import { i18n, I18nContext } from '../../models/Translation'; | ||
|
||
export interface OrganizationCardProps | ||
extends Pick<HTMLAttributes<HTMLDivElement>, 'className' | 'style'>, | ||
Omit<Organization, 'id'>, | ||
CardProps { | ||
onSwitch?: (filter: Partial<Pick<Organization, 'entityType' | 'coverageArea'>>) => any; | ||
} | ||
|
||
@observer | ||
export class OrganizationCard extends ObservedComponent<OrganizationCardProps, typeof i18n> { | ||
static contextType = I18nContext; | ||
|
||
@observable | ||
accessor showQRC = false; | ||
|
||
renderIcon() { | ||
const { website, wechatPublic } = this.observedProps.internetContact || {}; | ||
|
||
return ( | ||
<div className="d-flex justify-content-around"> | ||
{/* {email && ( | ||
<Button title="E-mail" size="sm" variant="warning" href={`mailto:${email}`}> | ||
<Icon name="mailbox2" /> | ||
</Button> | ||
)} */} | ||
{website && ( | ||
<Button title="WWW" size="sm" target="_blank" href={website}> | ||
<Icon name="globe2" /> | ||
</Button> | ||
)} | ||
{wechatPublic && ( | ||
<Button | ||
title="WeChat" | ||
size="sm" | ||
variant="success" | ||
onClick={() => (this.showQRC = !this.showQRC)} | ||
> | ||
<Icon name="chat-fill" /> | ||
</Button> | ||
)} | ||
</div> | ||
); | ||
} | ||
|
||
render() { | ||
const { t } = this.observedContext, | ||
{ name, entityType, services, description, internetContact, onSwitch, ...props } = this.props; | ||
const { wechatPublic } = internetContact || {}; | ||
|
||
return ( | ||
<Card | ||
{...props} | ||
style={{ | ||
...props.style, | ||
contentVisibility: 'auto', | ||
containIntrinsicHeight: '36rem', | ||
}} | ||
> | ||
{/* <Card.Img | ||
variant="top" | ||
className="object-fit-contain" | ||
style={{ height: '30vh' }} | ||
src={logos} | ||
/> */} | ||
<Card.Body> | ||
<Card.Title> | ||
{name} | ||
<BadgeBar className="ms-2" list={[{ text: entityType! }]} /> | ||
</Card.Title> | ||
|
||
{services && ( | ||
<BadgeBar | ||
className="justify-content-end" | ||
list={services.map(({ serviceCategory }) => ({ text: serviceCategory! }))} | ||
/> | ||
)} | ||
<Card.Text | ||
className="d-none d-sm-block text-wrap overflow-auto" | ||
style={{ minHeight: '5rem', maxHeight: '10rem' }} | ||
> | ||
{description} | ||
</Card.Text> | ||
</Card.Body> | ||
|
||
<Card.Footer> | ||
{this.renderIcon()} | ||
|
||
{this.showQRC && ( | ||
<Image | ||
className="mt-2" | ||
src={`https://open.weixin.qq.com/qr/code?username=${wechatPublic}`} | ||
alt={wechatPublic} | ||
fluid | ||
/> | ||
)} | ||
</Card.Footer> | ||
</Card> | ||
); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { BarSeries, PieSeries, SVGCharts, Title, Tooltip, XAxis, YAxis } from 'echarts-jsx'; | ||
import { observer } from 'mobx-react'; | ||
import { FC, useContext } from 'react'; | ||
|
||
import { OrganizationStatistic, sortStatistic } from '../../models/Organization'; | ||
import { I18nContext } from '../../models/Translation'; | ||
|
||
const OrganizationCharts: FC<OrganizationStatistic> = observer( | ||
({ entityType, serviceCategory, coverageArea }) => { | ||
const { t } = useContext(I18nContext); | ||
|
||
const typeList = sortStatistic(entityType), | ||
categoryList = sortStatistic(serviceCategory), | ||
areaList = sortStatistic(coverageArea); | ||
|
||
return ( | ||
<div style={{ minHeight: '70vh' }}> | ||
<SVGCharts> | ||
<Title>{t('NGO_area_distribution')}</Title> | ||
<XAxis type="category" data={areaList.map(([key]) => key)} /> | ||
<YAxis type="value" /> | ||
<BarSeries data={areaList.map(([{}, value]) => value)} /> | ||
<Tooltip /> | ||
</SVGCharts> | ||
|
||
<SVGCharts> | ||
<Title>{t('NGO_service_distribution')}</Title> | ||
<XAxis type="category" data={categoryList.map(([key]) => key)} /> | ||
<YAxis type="value" /> | ||
<BarSeries data={categoryList.map(([{}, value]) => value)} /> | ||
<Tooltip /> | ||
</SVGCharts> | ||
|
||
<SVGCharts className="col-auto"> | ||
<Title>{t('NGO_type_distribution')}</Title> | ||
<PieSeries data={typeList.map(([name, value]) => ({ name, value }))} /> | ||
<Tooltip trigger="item" /> | ||
</SVGCharts> | ||
</div> | ||
); | ||
}, | ||
); | ||
export default OrganizationCharts; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
.groupTitle { | ||
background-color: rgb(52, 112, 159); | ||
} | ||
.listItem { | ||
transition: 0.25ms; | ||
&:hover { | ||
cursor: pointer; | ||
box-shadow: 1px 1px 5px 1px rgba(0, 0, 0, 0.2); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.