forked from outloudvi/info-pride
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
315 additions
and
195 deletions.
There are no files selected for viewing
This file contains 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,53 @@ | ||
import { useTranslations } from 'next-intl' | ||
import _range from 'lodash/range' | ||
import { Button } from '@mantine/core' | ||
|
||
import { SeriesName } from '#data/stories' | ||
|
||
const SeasonChapterList = ({ | ||
series, | ||
season, | ||
length, | ||
selected, | ||
completion, | ||
onClick, | ||
}: { | ||
series: SeriesName | ||
season: number | ||
length: number | ||
selected: number | null | ||
completion: Record<number, 0 | 1> | ||
onClick: (c: number) => void | ||
}) => { | ||
const $t = useTranslations('stories') | ||
|
||
return ( | ||
<div> | ||
<p> | ||
{$t(`series.${series}`)}{' '} | ||
{$t('season', { | ||
s: season, | ||
})} | ||
</p> | ||
{_range(1, length + 1).map((chapter) => { | ||
const currentSelection = chapter === selected | ||
return ( | ||
<Button | ||
variant="subtle" | ||
compact | ||
color={completion[chapter - 1] ? 'blue' : 'teal'} | ||
key={chapter} | ||
onClick={() => { | ||
onClick(chapter) | ||
}} | ||
disabled={currentSelection} | ||
> | ||
{season}-{chapter} | ||
</Button> | ||
) | ||
})} | ||
</div> | ||
) | ||
} | ||
|
||
export default SeasonChapterList |
This file contains 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 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,7 @@ | ||
import storiesData from '#data/videos/stories.data' | ||
|
||
const getSpecialStories = (locale: string) => { | ||
return storiesData?.[locale]?.special | ||
} | ||
|
||
export default getSpecialStories |
This file contains 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 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,21 @@ | ||
import { StoriesData } from './types' | ||
|
||
const special: StoriesData['special'] = [] | ||
|
||
const data: StoriesData['data'] = { | ||
Hoshimi: {}, | ||
Tokyo: {}, | ||
TRINITYAiLE: {}, | ||
LizNoir: {}, | ||
Mana: {}, | ||
ThreeX: {}, | ||
Big4: {}, | ||
Tsuki: {}, | ||
} | ||
|
||
const _ = { | ||
data, | ||
special, | ||
} | ||
|
||
export default _ |
This file contains 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 en from './en' | ||
import zhHans from './zh-hans' | ||
import type { StoriesData } from './types' | ||
|
||
const _: Record<string, StoriesData> = { | ||
en: en, | ||
'zh-hans': zhHans, | ||
} | ||
|
||
export default _ |
This file contains 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,12 @@ | ||
import type { SeriesName } from '#data/stories' | ||
import { ChapterItem } from '#data/types' | ||
|
||
export type IStoriesData<T> = Record< | ||
SeriesName, | ||
Record<number, Record<number, T>> | ||
> | ||
|
||
export type StoriesData = { | ||
data: IStoriesData<ChapterItem> | ||
special: ChapterItem[] | ||
} |
This file contains 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 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 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 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,41 @@ | ||
import { withSentry } from '@sentry/nextjs' | ||
import type { NextApiRequest, NextApiResponse } from 'next' | ||
|
||
import pickFirstOrOne from '#utils/pickFirstOrOne' | ||
import type { FrontendAPIResponseMapping } from '#utils/useFrontendApi' | ||
import { DEFAULT_LANGUAGE } from '#utils/constants' | ||
import storiesData from '#data/videos/stories.data' | ||
import { SeriesName } from '#data/stories' | ||
|
||
// ?series=hoshimi&season=1&chapter=1 | ||
const eventStories = async ( | ||
req: NextApiRequest, | ||
res: NextApiResponse<FrontendAPIResponseMapping['stories']> | ||
) => { | ||
const q = req.query | ||
const series = q.series | ||
const season = Number.parseInt(String(q.season) ?? '') | ||
const chapter = Number.parseInt(String(q.chapter) ?? '') | ||
const locale = q.locale ? pickFirstOrOne(q.locale) : DEFAULT_LANGUAGE | ||
|
||
if (!series || Number.isNaN(season) || Number.isNaN(chapter)) { | ||
res.status(400).end() | ||
return | ||
} | ||
|
||
const ret = | ||
storiesData?.[locale]?.data?.[series as SeriesName]?.[season]?.[chapter] | ||
if (!ret) { | ||
res.status(404).end() | ||
return | ||
} | ||
res.status(200).json(ret) | ||
} | ||
|
||
export default withSentry(eventStories) | ||
|
||
export const config = { | ||
api: { | ||
externalResolver: true, | ||
}, | ||
} |
Oops, something went wrong.