Skip to content

Add activity and restaurant detail pages with map, comment box, and edit button#6

Merged
TechQuery merged 8 commits intomainfrom
copilot/add-details-page-with-map
Mar 12, 2026
Merged

Add activity and restaurant detail pages with map, comment box, and edit button#6
TechQuery merged 8 commits intomainfrom
copilot/add-details-page-with-map

Conversation

Copy link
Contributor

Copilot AI commented Mar 12, 2026

PR-6 PR-6 PR-6 Powered by Pull Request Badge

Each activity and restaurant now has a dedicated detail page that surfaces a location map, Giscus comment box, and a GitHub edit button — functionality previously absent from the listing views.

New components

  • components/ChinaMap.tsx — Wraps open-react-map's OpenReactMap with a GaoDe tile layer, matching the HOP reference implementation.

  • components/ChinaMapWrapper.tsx — Minimal 'use client' arrow-function component (FC<Props>) that dynamic-imports ChinaMap with ssr: false (required by Next.js 16, which forbids ssr: false inside server components). Detail pages use <ChinaMapWrapper /> directly.

  • components/CommentBox.tsx — Wraps @giscus/react configured for GoodAction-Hub/GoodAction-data (repo ID: R_kgDORijn4w, category: Polls, mapping: title, strict mode, emit metadata enabled, lang: zh-CN).

New shared module

  • lib/activities.ts — Extracts ACTIVITIES_API_URL, ExternalEventData, ExternalDeadlineItem, transformEvent, and transformItem into a single shared module. Both app/api/data/route.ts and app/activities/[id]/page.tsx import from it, eliminating duplication.

New pages

  • app/activities/[id]/page.tsx — Async server component for activity details. Fetches data server-side using the shared lib/activities.ts module, calls notFound() when no matching record is found, renders full activity metadata + timeline, then conditionally shows the map (when place is set), an Edit on GitHub button pointing to the data repo, and the Giscus comment box.

  • app/restaurants/[id]/page.tsx — Async server component for restaurant details. Fetches data server-side via fetchBitesCatalog(), calls notFound() when no matching record is found, renders name, description, accessibility tags, food types, features, address, and shows the map and Giscus comment box.

Updated listing views

  • components/EventCard.tsx — Added an Info icon link (/activities/{event.id}) on each card to navigate to the activity detail page.

  • app/activities/page.tsx — Activities listing (previously /deadlines), with a new + 发布活动 button linking to the GitHub issue template for submitting new activities.

  • app/restaurants/page.tsx — Restaurants listing (previously /Barrier-Free-Bites), with a new + 发布餐厅 button linking to the GitHub issue template for submitting new restaurants, and an Info icon detail link on each restaurant card.

Route renames & redirects

  • /deadlines renamed to /activities and /Barrier-Free-Bites renamed to /restaurants throughout the entire codebase (nav bar, home page links, back-buttons).
  • next.config.ts — permanent 301 redirects defined with the redirects: async () => [...] inline style for both old top-level paths.

Other changes

  • Added @import "leaflet/dist/leaflet.css" to app/globals.css (required by open-react-map).
  • Added detail.* i18n keys to both en/common.json and zh-CN/common.json.
  • Home page QR code updated to reference a locally-served image at /goodaction-hub-qr.png (served from the same domain for accessibility in mainland China). The PNG file must be placed at public/goodaction-hub-qr.png.
Original prompt

This section details on the original issue you should resolve

<issue_title>GoodActionHub 添加详情页,展开显示地图、评论框</issue_title>
<issue_description>### Task description

  1. 地图组件:https://github.com/FreeCodeCamp-Chengdu/HOP/blob/66e0273c8e162d8bd39ad09fd5305a08b7588f57/pages/activity/%5Bname%5D/index.tsx#L336-L338
  2. 评论组件:https://github.com/FreeCodeCamp-Chengdu/HOP/blob/66e0273c8e162d8bd39ad09fd5305a08b7588f57/components/CommentBox.tsx#L3
  3. 编辑按钮:GitHub 网页版文件编辑链接

Reward currency

TQT $

Reward amount

45

Reward payer

水歌 tech-query@fcc-cd.dev

Task source

https://open-source-bazaar.feishu.cn/record/Ypd9rJV4HeLooWcIDRIcqheanse</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: TechQuery <19969570+TechQuery@users.noreply.github.com>
Copilot AI changed the title [WIP] Add details page with map and comments section Add activity detail page with map, comment box, and edit button Mar 12, 2026
…tivities route, add restaurant detail page

Co-authored-by: TechQuery <19969570+TechQuery@users.noreply.github.com>
Copilot AI changed the title Add activity detail page with map, comment box, and edit button Add activity and restaurant detail pages with map, comment box, and edit button Mar 12, 2026
Copy link
Member

@TechQuery TechQuery left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. 我指出的问题通篇都要改类似的情况
  2. 两个列表页各增加新增入口:
  3. 把微信二维码替换为以下图片:
Image

@TechQuery TechQuery added the feature New feature or request label Mar 12, 2026
… links, new QR code

Co-authored-by: TechQuery <19969570+TechQuery@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Mar 12, 2026

  1. 我指出的问题通篇都要改类似的情况
  2. 两个列表页各增加新增入口:

已全部完成(commit b1ed2ca):

  1. /deadlines/activities/Barrier-Free-Bites/restaurants 通篇替换,含导航栏、主页链接、详情页返回按钮,并添加 next.config.ts 重定向
  2. 活动列表页新增「+ 发布活动」按钮(指向 activity.yml 模板);餐厅列表页新增「+ 发布餐厅」按钮(指向 restaurant.yml 模板)
  3. 微信二维码替换为新图片

Comment on lines -136 to -137
<Pencil className="w-4 h-4" />
{t('detail.editOnGitHub')}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i18n 解决方案不支持服务端渲染吗?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

当前使用的 react-i18next 依赖 useContext hook,只能在客户端组件中调用。由于详情页已转为服务端组件(async Server Component),无法使用 useTranslation(),因此直接内联了中文字符串。
如果需要真正的服务端 i18n,可以引入 i18next 的 Node.js 后端(例如 i18next-fs-backend)并在服务端手动初始化实例,或者考虑 next-intl 等支持 RSC 的方案。目前规模较小,内联字符串是最简单的权宜方案。

…rrow FC wrapper, local QR image

Co-authored-by: TechQuery <19969570+TechQuery@users.noreply.github.com>
@TechQuery TechQuery marked this pull request as ready for review March 12, 2026 12:05
@TechQuery TechQuery merged commit a86effa into main Mar 12, 2026
1 check passed
@TechQuery TechQuery deleted the copilot/add-details-page-with-map branch March 12, 2026 12:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GoodActionHub 添加详情页,展开显示地图、评论框

2 participants