-
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
12 changed files
with
222 additions
and
12 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
8 changes: 6 additions & 2 deletions
8
libs/api/post/data-access/src/lib/helpers/get-user-post-where.input.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
18 changes: 18 additions & 0 deletions
18
libs/api/post/data-access/src/lib/helpers/get-user-published-post-where.input.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,18 @@ | ||
import { UserFindManyPostInput } from '@connectamind/api-post-data-access' | ||
import { Prisma } from '@prisma/client' | ||
|
||
export function getUserPublishedPostWhereInput(authorId: string, input: UserFindManyPostInput): Prisma.PostWhereInput { | ||
const where: Prisma.PostWhereInput = { | ||
prices: { some: {} }, // | ||
} | ||
|
||
if (input.search) { | ||
where.OR = [ | ||
{ id: { contains: input.search, mode: 'insensitive' } }, | ||
{ title: { contains: input.search, mode: 'insensitive' } }, | ||
{ content: { contains: input.search, mode: 'insensitive' } }, | ||
] | ||
} | ||
|
||
return where | ||
} |
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
26 changes: 26 additions & 0 deletions
26
libs/web/dashboard/feature/src/lib/user-published-post-list.feature.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,26 @@ | ||
import { Group } from '@mantine/core' | ||
import { UiPageLimit, UiSearchField } from '@connectamind/web-ui-core' | ||
import { useUserFindManyPublishedPost } from '@connectamind/web-post-data-access' | ||
import { UiDebug, UiDebugModal, UiInfo, UiLoader, UiPage } from '@pubkey-ui/core' | ||
|
||
export function UserPublishedPostListFeature() { | ||
const { items, pagination, query, setSearch } = useUserFindManyPublishedPost() | ||
|
||
return ( | ||
<UiPage | ||
title="Published Posts" | ||
rightAction={ | ||
<Group> | ||
<UiDebugModal data={items} /> | ||
</Group> | ||
} | ||
> | ||
<Group> | ||
<UiSearchField placeholder="Search post" setSearch={setSearch} /> | ||
<UiPageLimit limit={pagination.limit} setLimit={pagination.setLimit} setPage={pagination.setPage} /> | ||
</Group> | ||
|
||
{query.isLoading ? <UiLoader /> : items?.length ? <UiDebug data={items} /> : <UiInfo message="No posts found" />} | ||
</UiPage> | ||
) | ||
} |
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export * from './lib/use-admin-find-many-post' | ||
export * from './lib/use-admin-find-one-post' | ||
export * from './lib/use-user-find-many-post' | ||
export * from './lib/use-user-find-many-published-post' | ||
export * from './lib/use-user-find-one-post' |
32 changes: 32 additions & 0 deletions
32
libs/web/post/data-access/src/lib/use-user-find-many-published-post.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,32 @@ | ||
import { UserFindManyPostInput } from '@connectamind/sdk' | ||
import { useSdk } from '@connectamind/web-core-data-access' | ||
import { useQuery } from '@tanstack/react-query' | ||
import { useState } from 'react' | ||
|
||
export function useUserFindManyPublishedPost(props?: Partial<UserFindManyPostInput>) { | ||
const sdk = useSdk() | ||
const [limit, setLimit] = useState(props?.limit ?? 10) | ||
const [page, setPage] = useState(props?.page ?? 1) | ||
const [search, setSearch] = useState<string>(props?.search ?? '') | ||
|
||
const input: UserFindManyPostInput = { page, limit, search } | ||
const query = useQuery({ | ||
queryKey: ['user', 'find-many-published-post', input], | ||
queryFn: () => sdk.userFindManyPublishedPost({ input }).then((res) => res.data), | ||
}) | ||
const total = query.data?.paging?.meta?.totalCount ?? 0 | ||
const items = query.data?.paging.data ?? [] | ||
|
||
return { | ||
items, | ||
query, | ||
pagination: { | ||
page, | ||
setPage, | ||
limit, | ||
setLimit, | ||
total, | ||
}, | ||
setSearch, | ||
} | ||
} |