Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<div align="center">

[![Better Stack Badge](https://uptime.betterstack.com/status-badges/v1/monitor/vz4h.svg)](https://uptime.betterstack.com/?utm_source=status_badge)
[![Build CN Image](https://github.com/FurryConsChina/website/actions/workflows/build-cn-image.yml/badge.svg)](https://github.com/FurryConsChina/website/actions/workflows/build-cn-image.yml)
[![Deploy to CN Production](https://github.com/FurryConsChina/website/actions/workflows/deploy-prod-cn.yml/badge.svg)](https://github.com/FurryConsChina/website/actions/workflows/deploy-prod-cn.yml)
[![RelativeCI](https://badges.relative-ci.com/badges/tUU1QJHvaWj6oY0ysuih?branch=main&style=flat)](https://app.relative-ci.com/projects/tUU1QJHvaWj6oY0ysuih)

</div>
Expand Down
2 changes: 1 addition & 1 deletion README.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<div align="center">

[![Better Stack Badge](https://uptime.betterstack.com/status-badges/v1/monitor/vz4h.svg)](https://uptime.betterstack.com/?utm_source=status_badge)
[![Build CN Image](https://github.com/FurryConsChina/website/actions/workflows/build-cn-image.yml/badge.svg)](https://github.com/FurryConsChina/website/actions/workflows/build-cn-image.yml)
[![Deploy to CN Production](https://github.com/FurryConsChina/website/actions/workflows/deploy-prod-cn.yml/badge.svg)](https://github.com/FurryConsChina/website/actions/workflows/deploy-prod-cn.yml)
[![RelativeCI](https://badges.relative-ci.com/badges/tUU1QJHvaWj6oY0ysuih?branch=main&style=flat)](https://app.relative-ci.com/projects/tUU1QJHvaWj6oY0ysuih)

</div>
Expand Down
4 changes: 2 additions & 2 deletions src/components/SimpleEventCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import Link from "next/link";
import dayjs from "dayjs";
import "dayjs/locale/zh-cn";
import "dayjs/locale/zh-tw";
import { EventItem } from "@/types/event";
import { SimpleEventItem } from "@/types/event";
import { useTranslation } from "next-i18next";
import { getDayjsLocale } from "@/utils/locale";

function SimpleEventCard({ event }: { event: EventItem }) {
function SimpleEventCard({ event }: { event: SimpleEventItem }) {
const { t, i18n } = useTranslation();
const dateFormat = t("date.monthDay") || "MM月DD日";
const dayjsLocale = getDayjsLocale(i18n.language);
Expand Down
30 changes: 23 additions & 7 deletions src/pages/[organization]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { serverSideTranslations } from "next-i18next/serverSideTranslations";
import { useTranslation } from "next-i18next";
import { OrganizationsAPI } from "@/api/organizations";
import * as z from "zod/v4";
import { EventItem } from "@/types/event";
import { EventCardItem } from "@/types/event";
import { OrganizationSchema, Organization } from "@/types/organization";
import { FeatureSchema } from "@/types/feature";
import { keywordGenerator, organizationDetailDescriptionGenerator, OrganizationPageMeta } from "@/utils/meta";
Expand All @@ -36,7 +36,7 @@ import axios, { AxiosError } from "axios";

dayjs.extend(relativeTime);

export default function OrganizationDetail(props: { events: EventItem[]; organization: Organization }) {
export default function OrganizationDetail(props: { events: EventCardItem[]; organization: Organization }) {
const { t, i18n } = useTranslation();
const { organization, events } = props;
const dayjsLocale = getDayjsLocale(i18n.language);
Expand Down Expand Up @@ -302,15 +302,31 @@ export async function getServerSideProps(context: GetServerSidePropsContext) {
const data = await OrganizationsAPI.getOrganizationDetail(reqParamsParseResult.organization);

const validOrganization = data.organization;
const validEvents =
const validEvents: EventCardItem[] =
data.events
?.map((e) => ({
...e,
id: e.id,
slug: e.slug,
name: e.name,
startAt: e.startAt,
endAt: e.endAt,
scale: e.scale,
type: e.type,
locationType: e.locationType,
address: e.address,
region: e.region ? { localName: e.region.localName } : null,
organization: {
name: validOrganization?.name,
slug: validOrganization?.slug,
logoUrl: validOrganization?.logoUrl,
slug: validOrganization?.slug || "",
name: validOrganization?.name || "",
},
features: e.features ? { self: e.features.self ?? null } : null,
commonFeatures: e.commonFeatures
? e.commonFeatures.map((f) => ({ name: f.name }))
: null,
thumbnail: e.thumbnail ?? null,
media: e.media?.images
? { images: e.media.images.map((img) => ({ url: img.url })) }
: null,
}))
.sort((a, b) => {
if (a.startAt && b.startAt) {
Expand Down
14 changes: 10 additions & 4 deletions src/pages/organization.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import { sendTrack } from "@/utils/track";
import { serverSideTranslations } from "next-i18next/serverSideTranslations";
import { useTranslation } from "next-i18next";
import { OrganizationsAPI } from "@/api/organizations";
import { Organization } from "@/types/organization";
import { OrganizationListItem } from "@/types/organization";
import { OrganizationPageMeta } from "@/utils/meta";
import { currentSupportLocale } from "@/utils/locale";
import { breadcrumbGenerator } from "@/utils/structuredData";

export default function OrganizationPage({ organizations }: { organizations: Organization[] }) {
export default function OrganizationPage({ organizations }: { organizations: OrganizationListItem[] }) {
const groupByStatusOrganizations = groupBy(organizations, (o) => o.status);
const { t } = useTranslation();

Expand All @@ -37,7 +37,7 @@ export default function OrganizationPage({ organizations }: { organizations: Org
);
}

function OrganizationItem({ organization }: { organization: Organization }) {
function OrganizationItem({ organization }: { organization: OrganizationListItem }) {
const { t } = useTranslation();

return (
Expand Down Expand Up @@ -95,7 +95,13 @@ export async function getStaticProps({ locale }: { locale: string }) {

return {
props: {
organizations: organizations.records,
organizations: organizations.records.map((organization) => ({
id: organization.id,
slug: organization.slug,
name: organization.name,
status: organization.status,
logoUrl: organization.logoUrl,
})),
headMetas: {
title: OrganizationPageMeta[locale as currentSupportLocale].title,
des: OrganizationPageMeta[locale as currentSupportLocale].description(organizations.total),
Expand Down
16 changes: 13 additions & 3 deletions src/pages/years.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import SimpleEventCard from "@/components/SimpleEventCard";
import { serverSideTranslations } from "next-i18next/serverSideTranslations";
import { useTranslation } from "next-i18next";
import { EventsAPI } from "@/api/events";
import { EventItem } from "@/types/event";
import { SimpleEventItem } from "@/types/event";
import { monthNumberFormatter } from "@/utils/locale";
import { YearPageMeta } from "@/utils/meta";
import { currentSupportLocale } from "@/utils/locale";
import { breadcrumbGenerator } from "@/utils/structuredData";

export default function Years({ events }: { events: EventItem[] }) {
export default function Years({ events }: { events: SimpleEventItem[] }) {
const groupByYearEvents = eventGroupByYear(events, "asc");
Comment on lines +12 to 13
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Search for eventGroupByYear and eventGroupByMonth function definitions and usages
rg -n "eventGroupByYear|eventGroupByMonth" --type=ts --type=tsx -C 3

Repository: FurryConsChina/website

Length of output: 93


🏁 Script executed:

#!/bin/bash
# Search for eventGroupByYear and eventGroupByMonth function definitions and usages
rg -n "eventGroupByYear|eventGroupByMonth" --type=ts -C 3

Repository: FurryConsChina/website

Length of output: 2353


🏁 Script executed:

#!/bin/bash
# Search for EventListable interface and SimpleEventItem type definitions
rg -n "interface EventListable|type SimpleEventItem|interface SimpleEventItem" --type=ts -C 5

Repository: FurryConsChina/website

Length of output: 574


🏁 Script executed:

#!/bin/bash
# Search for EventListable interface definition more specifically
rg -n "interface EventListable|type EventListable" --type=ts -A 10

Repository: FurryConsChina/website

Length of output: 699


SimpleEventItem 不满足 eventGroupByYeareventGroupByMonth 的类型约束。

这两个函数要求泛型参数 T extends EventListable,但 SimpleEventItem 缺少 EventListable 所需的 scale: string 属性。虽然函数内部只访问 startAt 属性,但类型签名要求不匹配会导致类型错误。需要:

  1. SimpleEventItem 添加 scale 属性,或
  2. 修改函数签名以接受更宽泛的类型(如 { startAt: string | null }),或
  3. SimpleEventItem 创建单独的分组函数
🤖 Prompt for AI Agents
In `@src/pages/years.tsx` around lines 12 - 13, The type error occurs because
SimpleEventItem does not satisfy the generic constraint T extends EventListable
required by eventGroupByYear and eventGroupByMonth (EventListable requires a
scale: string), so update the types to match: either add a scale: string
property to the SimpleEventItem type/interface, or loosen the grouping
functions' generic constraint to accept items with at least startAt (e.g. change
EventListable constraint to require { startAt: string | null }), or implement a
dedicated grouping function for SimpleEventItem; reference the SimpleEventItem
type and the eventGroupByYear/eventGroupByMonth function signatures when making
the change.


const { t, i18n } = useTranslation();
Expand Down Expand Up @@ -76,10 +76,20 @@ export async function getStaticProps({ locale }: { locale: string }) {
current: "1",
pageSize: "999",
});
const slimEvents: SimpleEventItem[] = events.records.map((event) => ({
id: event.id,
slug: event.slug,
name: event.name,
startAt: event.startAt,
endAt: event.endAt,
scale: event.scale,
region: event.region ? { localName: event.region.localName } : null,
organization: event.organization ? { slug: event.organization.slug, name: event.organization.name } : null,
}));

return {
props: {
events: events.records,
events: slimEvents,
headMetas: {
title: YearPageMeta[locale as currentSupportLocale].title,
des: YearPageMeta[locale as currentSupportLocale].description(12, events.total || 0),
Expand Down
11 changes: 11 additions & 0 deletions src/types/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,3 +182,14 @@ export type EventCardItem = {
thumbnail?: string | null;
media?: { images?: { url: string }[] } | null;
};

export type SimpleEventItem = {
id: string;
slug: string;
name: string;
startAt: string | null;
endAt: string | null;
scale: string;
region: { localName: string | null } | null;
organization: { slug: string; name: string } | null;
};
8 changes: 8 additions & 0 deletions src/types/organization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,11 @@ export const OrganizationSchema = z.object({
});

export type Organization = z.infer<typeof OrganizationSchema>;

export type OrganizationListItem = {
id: string;
slug: string;
name: string;
status: string;
logoUrl: string | null;
};