-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- pass typed prisma queries to list component, and use typed model in render function - example of wrapper for list component - list search example - env validation
- Loading branch information
1 parent
e204128
commit a9c0df3
Showing
17 changed files
with
222 additions
and
103 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
import { ScrollArea } from '@mantine/core'; | ||
import { Link } from '@tanstack/react-router'; | ||
|
||
import ListSkeleton from '~client/form/lib/skeleton'; | ||
import type { RouteFullPaths } from '~client/routes/-sidebar'; | ||
import { ZSList, type ZSListProps } from '~zenstack-ui/list/list'; | ||
|
||
interface ListWrapperProps<T> extends ZSListProps<T> { | ||
route: RouteFullPaths | ||
itemId?: number | string | ||
search?: string | ||
} | ||
|
||
function ListWrapper<T extends Record<string, any>>({ itemId, search, route, ...zsListProps }: ListWrapperProps<T>) { | ||
return ( | ||
<ScrollArea className="list-scrollarea"> | ||
<ZSList<T> | ||
{...zsListProps} | ||
|
||
// Defaults | ||
skeleton={zsListProps.skeleton ?? <ListSkeleton />} | ||
noResults={zsListProps.noResults ?? <p className="text-gray-500">No results found</p>} | ||
|
||
// Render | ||
render={(item: T, id: string | number) => ( | ||
<Link | ||
key={id} | ||
to={route} | ||
params={{ id: id.toString() }} | ||
className="list-item" | ||
data-selected={id === itemId} | ||
search={search} | ||
> | ||
{zsListProps.render(item, id)} | ||
</Link> | ||
)} | ||
/> | ||
</ScrollArea> | ||
); | ||
} | ||
|
||
export default ListWrapper; |
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
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 @@ | ||
// Tanstack Router generic search params | ||
export interface SearchParams { | ||
search: string | undefined | ||
} | ||
export const validateSearch = (search: SearchParams): SearchParams => ({ search: search.search || undefined }); |
Oops, something went wrong.