Skip to content

Commit

Permalink
feat: posts sorting and ordering, refactor fab
Browse files Browse the repository at this point in the history
  • Loading branch information
Innei committed Aug 17, 2023
1 parent 24f7396 commit 6580fbd
Show file tree
Hide file tree
Showing 15 changed files with 655 additions and 117 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"@mx-space/api-client": "1.5.1",
"@radix-ui/react-dialog": "1.0.4",
"@sentry/nextjs": "7.64.0",
"@radix-ui/react-select": "1.2.2",
"@sentry/webpack-plugin": "2.6.2",
"@tanstack/react-query": "4.32.6",
"@tanstack/react-query-devtools": "4.32.6",
Expand Down Expand Up @@ -119,4 +120,4 @@
"budgetPercentIncreaseRed": 20,
"showDetails": true
}
}
}
210 changes: 210 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 11 additions & 4 deletions src/app/posts/page.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { NormalContainer } from '~/components/layout/container/Normal'
import { BottomToUpTransitionView } from '~/components/ui/transition/BottomToUpTransitionView'
import { PostsSortingFab } from '~/components/widgets/post/fab/PostsSortingFab'
import { PostTagsFAB } from '~/components/widgets/post/fab/PostTagsFAB'
import { PostItem } from '~/components/widgets/post/PostItem'
import { PostPagination } from '~/components/widgets/post/PostPagination'
import { PostTagsFAB } from '~/components/widgets/post/PostTagsFAB'
import { NothingFound } from '~/components/widgets/shared/NothingFound'
import { SearchFAB } from '~/components/widgets/shared/SearchFAB'
import { apiClient } from '~/lib/request'
Expand All @@ -11,6 +12,8 @@ interface Props {
searchParams: {
page?: string
size?: string
sortBy?: string
orderBy?: string
}
}

Expand All @@ -19,11 +22,14 @@ export const metadata = {
}

export default async (props: Props) => {
const { page, size } = props?.searchParams || {}
const { page, size, orderBy, sortBy } = props?.searchParams || {}
const nextPage = page ? parseInt(page) : 1
const nextSize = size ? parseInt(size) : 10

const { $serialized } = await apiClient.post.getList(nextPage, nextSize)
const { $serialized } = await apiClient.post.getList(nextPage, nextSize, {
sortBy: sortBy as any,
sortOrder: orderBy === 'desc' ? -1 : 1,
})
const { data, pagination } = $serialized

if (!data?.length) {
Expand All @@ -47,8 +53,9 @@ export default async (props: Props) => {
</ul>

<PostPagination pagination={pagination} />
<PostTagsFAB />

<PostsSortingFab />
<PostTagsFAB />
<SearchFAB />
</NormalContainer>
)
Expand Down
2 changes: 1 addition & 1 deletion src/components/layout/header/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const headerMenuConfig: IHeaderMenu[] = [
subMenu: [],
},
{
title: '水文',
title: '文稿',
path: '/posts',
type: 'Post',
subMenu: [],
Expand Down
9 changes: 6 additions & 3 deletions src/components/layout/root/Root.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { ClientOnly } from '~/components/common/ClientOnly'
import { BackToTopFAB, FABContainer } from '~/components/ui/fab'

import { Content } from '../content/Content'
Expand All @@ -11,9 +12,11 @@ export const Root: Component = ({ children }) => {
<Content>{children}</Content>

<Footer />
<FABContainer>
<BackToTopFAB />
</FABContainer>
<ClientOnly>
<FABContainer>
<BackToTopFAB />
</FABContainer>
</ClientOnly>
</>
)
}
Loading

1 comment on commit 6580fbd

@vercel
Copy link

@vercel vercel bot commented on 6580fbd Aug 17, 2023

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

shiro – ./

springtide.vercel.app
shiro-innei.vercel.app
shiro-git-main-innei.vercel.app
innei.in

Please sign in to comment.