Skip to content

Commit

Permalink
Improve state handling
Browse files Browse the repository at this point in the history
  • Loading branch information
arkadiuszbachorski committed Dec 3, 2024
1 parent 41ceb1d commit 9ec7d85
Show file tree
Hide file tree
Showing 25 changed files with 433 additions and 1,501 deletions.
2 changes: 2 additions & 0 deletions main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ const router = createRouter({
entityName="page"
/>
),
defaultPendingMs: 300,
defaultPendingMinMs: 200,
})

declare module '@tanstack/react-router' {
Expand Down
27 changes: 14 additions & 13 deletions modules/notifications/NotificationsTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import {
DataTable,
DataTableBasicView,
type DataTableProps,
} from '@stanfordspezi/spezi-web-design-system/components/DataTable'
import { parseNilLocalizedText } from '@/modules/firebase/localizedText'
import { type UserMessage } from '@/modules/firebase/models'
Expand Down Expand Up @@ -36,12 +36,14 @@ const columns = [
}),
]

interface NotificationsTableProps {
interface NotificationsTableProps
extends Omit<DataTableProps<UserMessage>, 'data'> {
notifications: UserMessage[]
}

export const NotificationsTable = ({
notifications,
...props
}: NotificationsTableProps) => (
<DataTable
columns={columns}
Expand All @@ -57,18 +59,17 @@ export const NotificationsTable = ({
initialState={{
columnFilters: [{ id: columnIds.isRead, value: false }],
}}
{...props}
>
{(props) => (
<DataTableBasicView {...props}>
{(rows) =>
rows.map((row) => {
const notification = row.original
return (
<Notification key={notification.id} notification={notification} />
)
})
}
</DataTableBasicView>
{({ rows }) => (
<div>
{rows.map((row) => {
const notification = row.original
return (
<Notification key={notification.id} notification={notification} />
)
})}
</div>
)}
</DataTable>
)
Loading

0 comments on commit 9ec7d85

Please sign in to comment.