-
Notifications
You must be signed in to change notification settings - Fork 8
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
1 parent
d4e56cf
commit a5c5a38
Showing
13 changed files
with
157 additions
and
3 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
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
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
3 changes: 3 additions & 0 deletions
3
src/components/pages/ExploreTopProjectsPage/ExploreTopProjectsPage.i18n/en.json
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,3 @@ | ||
{ | ||
"title": "Taskany — Explore — Projects" | ||
} |
17 changes: 17 additions & 0 deletions
17
src/components/pages/ExploreTopProjectsPage/ExploreTopProjectsPage.i18n/index.ts
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,17 @@ | ||
/* eslint-disable */ | ||
// Do not edit, use generator to update | ||
import { i18n, fmt, I18nLangSet } from 'easy-typed-intl'; | ||
import getLang from '../../../../utils/getLang'; | ||
|
||
import ru from './ru.json'; | ||
import en from './en.json'; | ||
|
||
export type I18nKey = keyof typeof ru & keyof typeof en; | ||
type I18nLang = 'ru' | 'en'; | ||
|
||
const keyset: I18nLangSet<I18nKey> = {}; | ||
|
||
keyset['ru'] = ru; | ||
keyset['en'] = en; | ||
|
||
export const tr = i18n<I18nLang, I18nKey>(keyset, fmt, getLang); |
3 changes: 3 additions & 0 deletions
3
src/components/pages/ExploreTopProjectsPage/ExploreTopProjectsPage.i18n/ru.json
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,3 @@ | ||
{ | ||
"title": "Taskany — Обзор — Проекты" | ||
} |
81 changes: 81 additions & 0 deletions
81
src/components/pages/ExploreTopProjectsPage/ExploreTopProjectsPage.tsx
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,81 @@ | ||
import useSWR from 'swr'; | ||
import { nullable } from '@taskany/bricks'; | ||
|
||
import { Project } from '../../../../graphql/@generated/genql'; | ||
import { createFetcher, refreshInterval } from '../../../utils/createFetcher'; | ||
import { declareSsrProps, ExternalPageProps } from '../../../utils/declareSsrProps'; | ||
import { routes } from '../../../hooks/router'; | ||
import { Page, PageContent } from '../../Page'; | ||
import { PageSep } from '../../PageSep'; | ||
import { ExplorePageLayout } from '../../ExplorePageLayout/ExplorePageLayout'; | ||
import { ProjectListItem } from '../../ProjectListItem'; | ||
|
||
import { tr } from './ExploreTopProjectsPage.i18n'; | ||
|
||
const fetcher = createFetcher(() => ({ | ||
topProjects: { | ||
id: true, | ||
title: true, | ||
description: true, | ||
createdAt: true, | ||
activity: { | ||
user: { | ||
id: true, | ||
name: true, | ||
email: true, | ||
image: true, | ||
}, | ||
ghost: { | ||
id: true, | ||
email: true, | ||
}, | ||
}, | ||
}, | ||
})); | ||
|
||
export const getServerSideProps = declareSsrProps( | ||
async ({ user }) => ({ | ||
fallback: { | ||
'explore/projects': await fetcher(user), | ||
}, | ||
}), | ||
{ | ||
private: true, | ||
}, | ||
); | ||
|
||
export const ExploreTopProjectsPage = ({ | ||
user, | ||
locale, | ||
ssrTime, | ||
fallback, | ||
}: ExternalPageProps<Awaited<ReturnType<typeof fetcher>>>) => { | ||
const { data } = useSWR('explore/projects', () => fetcher(user), { | ||
fallback, | ||
refreshInterval, | ||
}); | ||
const projects = data?.topProjects; | ||
|
||
return ( | ||
<Page user={user} locale={locale} ssrTime={ssrTime} title={tr('title')}> | ||
<ExplorePageLayout> | ||
<PageSep /> | ||
|
||
<PageContent> | ||
{projects?.map((project: Project) => | ||
nullable(project, (p) => ( | ||
<ProjectListItem | ||
key={p.id} | ||
href={routes.project(p.id)} | ||
createdAt={p.createdAt} | ||
title={p.title} | ||
description={p.description} | ||
activity={p.activity} | ||
/> | ||
)), | ||
)} | ||
</PageContent> | ||
</ExplorePageLayout> | ||
</Page> | ||
); | ||
}; |
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,5 @@ | ||
import { ExploreTopProjectsPage } from '../../components/pages/ExploreTopProjectsPage/ExploreTopProjectsPage'; | ||
|
||
export { getServerSideProps } from '../../components/pages/ExploreTopProjectsPage/ExploreTopProjectsPage'; | ||
|
||
export default ExploreTopProjectsPage; |