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 3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
auto-install-peers = false | ||
auto-install-peers = false | ||
@open-source-bazaar:registry=https://npm.pkg.github.com | ||
TechQuery marked this conversation as resolved.
Show resolved
Hide resolved
|
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
TechQuery marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
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,81 @@ | ||
import { observer } from 'mobx-react'; | ||
import { FC, useContext } from 'react'; | ||
import { Badge,Card, Col, Row } from 'react-bootstrap'; | ||
|
||
import { Organization } from '../../models/Organization'; | ||
import { I18nContext } from '../../models/Translation'; | ||
|
||
export interface ChinaPublicInterestLandscapeProps { | ||
tagMap: Record<string, Organization[]>; | ||
} | ||
|
||
export const ChinaPublicInterestLandscape: FC<ChinaPublicInterestLandscapeProps> = observer( | ||
({ tagMap }) => { | ||
const { t } = useContext(I18nContext); | ||
|
||
const tagEntries = Object.entries(tagMap).sort(([, a], [, b]) => b.length - a.length); | ||
|
||
return ( | ||
<div> | ||
{tagEntries.length === 0 && ( | ||
<Card> | ||
<Card.Body className="text-center py-5"> | ||
<Card.Title>{t('no_data_available')}</Card.Title> | ||
<Card.Text>{t('landscape_data_loading_message')}</Card.Text> | ||
</Card.Body> | ||
</Card> | ||
)} | ||
|
||
{tagEntries.map(([tag, organizations]) => ( | ||
<Card key={tag} className="mb-4"> | ||
<Card.Header className="d-flex justify-content-between align-items-center"> | ||
<h5 className="mb-0">{tag}</h5> | ||
<Badge bg="primary">{organizations.length} {t('organizations')}</Badge> | ||
</Card.Header> | ||
<Card.Body> | ||
<Row className="g-3"> | ||
{organizations.map(org => ( | ||
<Col key={org.id} md={6} lg={4}> | ||
<Card className="h-100"> | ||
<Card.Body> | ||
<Card.Title className="h6">{org.name}</Card.Title> | ||
{org.description && ( | ||
<Card.Text className="small text-muted"> | ||
{org.description.length > 100 | ||
? `${org.description.substring(0, 100)}...` | ||
: org.description} | ||
</Card.Text> | ||
)} | ||
<div className="mt-2"> | ||
{org.city && ( | ||
<Badge bg="secondary" className="me-1"> | ||
{org.city} | ||
</Badge> | ||
)} | ||
{org.type && ( | ||
<Badge bg="info" className="me-1"> | ||
{org.type} | ||
</Badge> | ||
)} | ||
</div> | ||
{org.website && ( | ||
<Card.Link | ||
href={org.website} | ||
target="_blank" | ||
className="small" | ||
> | ||
{t('visit_website')} | ||
</Card.Link> | ||
)} | ||
</Card.Body> | ||
</Card> | ||
</Col> | ||
))} | ||
</Row> | ||
</Card.Body> | ||
</Card> | ||
))} | ||
</div> | ||
); | ||
}, | ||
); |
TechQuery marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
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,91 @@ | ||
import { observer } from 'mobx-react'; | ||
import { FC, useContext } from 'react'; | ||
import { Badge,Card, Col, Row } from 'react-bootstrap'; | ||
|
||
import { OrganizationModel, OrganizationStatistic } from '../../models/Organization'; | ||
import { I18nContext } from '../../models/Translation'; | ||
|
||
export interface ChinaPublicInterestMapProps extends OrganizationStatistic { | ||
store: OrganizationModel; | ||
} | ||
|
||
export const ChinaPublicInterestMap: FC<ChinaPublicInterestMapProps> = observer( | ||
({ store, year, city, type, tag }) => { | ||
const { t } = useContext(I18nContext); | ||
|
||
return ( | ||
<div> | ||
<Row className="g-4"> | ||
<Col md={6} lg={3}> | ||
<Card> | ||
<Card.Body> | ||
<Card.Title>{t('by_year')}</Card.Title> | ||
<div> | ||
{year.slice(0, 5).map(item => ( | ||
<Badge key={item.label} bg="primary" className="me-2 mb-2"> | ||
{item.label}: {item.count} | ||
</Badge> | ||
))} | ||
</div> | ||
</Card.Body> | ||
</Card> | ||
</Col> | ||
|
||
<Col md={6} lg={3}> | ||
<Card> | ||
<Card.Body> | ||
<Card.Title>{t('by_city')}</Card.Title> | ||
<div> | ||
{city.slice(0, 5).map(item => ( | ||
<Badge key={item.label} bg="success" className="me-2 mb-2"> | ||
{item.label}: {item.count} | ||
</Badge> | ||
))} | ||
</div> | ||
</Card.Body> | ||
</Card> | ||
</Col> | ||
|
||
<Col md={6} lg={3}> | ||
<Card> | ||
<Card.Body> | ||
<Card.Title>{t('by_type')}</Card.Title> | ||
<div> | ||
{type.slice(0, 5).map(item => ( | ||
<Badge key={item.label} bg="info" className="me-2 mb-2"> | ||
{item.label}: {item.count} | ||
</Badge> | ||
))} | ||
</div> | ||
</Card.Body> | ||
</Card> | ||
</Col> | ||
|
||
<Col md={6} lg={3}> | ||
<Card> | ||
<Card.Body> | ||
<Card.Title>{t('by_tag')}</Card.Title> | ||
<div> | ||
{tag.slice(0, 5).map(item => ( | ||
<Badge key={item.label} bg="warning" className="me-2 mb-2"> | ||
{item.label}: {item.count} | ||
</Badge> | ||
))} | ||
</div> | ||
</Card.Body> | ||
</Card> | ||
</Col> | ||
</Row> | ||
|
||
<Card className="mt-4"> | ||
<Card.Body> | ||
<Card.Title>{t('about_china_public_interest_map')}</Card.Title> | ||
<Card.Text> | ||
{t('china_public_interest_map_description')} | ||
</Card.Text> | ||
</Card.Body> | ||
</Card> | ||
</div> | ||
); | ||
}, | ||
); |
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,99 @@ | ||
import { observable } from 'mobx'; | ||
import { HTTPClient } from 'koajax'; | ||
import { StrapiListModel, Base } from 'mobx-strapi'; | ||
|
||
// Define the organization data structure similar to China NGO database | ||
export interface Organization extends Base { | ||
name: string; | ||
description?: string; | ||
type?: string; | ||
city?: string; | ||
province?: string; | ||
tags?: string[]; | ||
website?: string; | ||
logo?: { | ||
data?: { | ||
attributes: { | ||
url: string; | ||
}; | ||
}; | ||
}; | ||
year?: number; | ||
} | ||
TechQuery marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
export interface OrganizationStatistic { | ||
year: Array<{ label: string; count: number }>; | ||
city: Array<{ label: string; count: number }>; | ||
type: Array<{ label: string; count: number }>; | ||
tag: Array<{ label: string; count: number }>; | ||
TechQuery marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
} | ||
|
||
// Strapi client configuration | ||
const strapiClient = new HTTPClient({ | ||
baseURI: 'https://china-ngo-db.onrender.com/api/', | ||
responseType: 'json', | ||
}); | ||
TechQuery marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
export class OrganizationModel extends StrapiListModel<Organization> { | ||
baseURI = '/organizations'; | ||
TechQuery marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
client = strapiClient; | ||
|
||
@observable | ||
accessor tagMap: Record<string, Organization[]> = {}; | ||
|
||
async groupAllByTags(): Promise<Record<string, Organization[]>> { | ||
try { | ||
const allData = await this.getAll(); | ||
const tagMap: Record<string, Organization[]> = {}; | ||
|
||
for (const org of allData) { | ||
const tags = org.tags || []; | ||
for (const tag of tags) { | ||
if (!tagMap[tag]) { | ||
tagMap[tag] = []; | ||
} | ||
tagMap[tag].push(org); | ||
} | ||
} | ||
|
||
this.tagMap = tagMap; | ||
return tagMap; | ||
} catch (error) { | ||
console.error('Failed to fetch organizations:', error); | ||
return {}; | ||
} | ||
TechQuery marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
} | ||
} | ||
|
||
export class OrganizationStatisticModel { | ||
private client: HTTPClient<any>; | ||
private collection: string; | ||
|
||
constructor(baseId: string, collectionId: string) { | ||
this.client = new HTTPClient({ | ||
baseURI: 'https://china-ngo-db.onrender.com/api/', | ||
responseType: 'json', | ||
}); | ||
this.collection = collectionId; | ||
} | ||
|
||
async countAll(): Promise<Array<{ label: string; count: number }>> { | ||
try { | ||
// This would need to be adapted based on the actual Strapi API structure | ||
const response = await this.client.get(`${this.collection}`); | ||
// Handle potential different response structures | ||
const data = response.body?.data || response.body || []; | ||
return Array.isArray(data) ? data : []; | ||
} catch (error) { | ||
console.error(`Failed to fetch statistics for ${this.collection}:`, error); | ||
return []; | ||
} | ||
} | ||
} | ||
TechQuery marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
// Mock constants for now - these would be configured based on the actual Strapi setup | ||
export const COMMUNITY_BASE_ID = 'community'; | ||
export const OSC_YEAR_STATISTIC_TABLE_ID = 'organization-year-stats'; | ||
export const OSC_CITY_STATISTIC_TABLE_ID = 'organization-city-stats'; | ||
export const OSC_TYPE_STATISTIC_TABLE_ID = 'organization-type-stats'; | ||
export const OSC_TAG_STATISTIC_TABLE_ID = 'organization-tag-stats'; |
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
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.