Skip to content
This repository has been archived by the owner on Sep 24, 2024. It is now read-only.

Commit

Permalink
feat: add promotion statuses to the homepage
Browse files Browse the repository at this point in the history
  • Loading branch information
marcomontalbano committed Mar 11, 2024
1 parent db7b8c4 commit 2977d48
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 9 deletions.
7 changes: 7 additions & 0 deletions packages/app/src/data/filters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,10 @@ export const filtersInstructions: FiltersInstructions = [
}
}
]

export const predicateWhitelist = [
'starts_at_lteq',
'expires_at_gteq',
'disabled_at_null',
'starts_at_gt'
]
5 changes: 3 additions & 2 deletions packages/app/src/pages/FiltersPage.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import type { PageProps } from '#components/Routes'
import { filtersInstructions } from '#data/filters'
import { filtersInstructions, predicateWhitelist } from '#data/filters'
import { appRoutes } from '#data/routes'
import { PageLayout, useResourceFilters } from '@commercelayer/app-elements'
import { useLocation } from 'wouter'

function Page(props: PageProps<typeof appRoutes.filters>): JSX.Element {
const [, setLocation] = useLocation()
const { FiltersForm, adapters } = useResourceFilters({
instructions: filtersInstructions
instructions: filtersInstructions,
predicateWhitelist
})

return (
Expand Down
13 changes: 8 additions & 5 deletions packages/app/src/pages/HomePage.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { filtersInstructions } from '#data/filters'
import { filtersInstructions, predicateWhitelist } from '#data/filters'
import { presets } from '#data/lists'
import { appRoutes } from '#data/routes'
import {
HomePageLayout,
Icon,
List,
ListItem,
RadialProgress,
Spacer,
StatusIcon,
Text,
Expand All @@ -19,8 +21,9 @@ function HomePage(): JSX.Element {
const search = useSearch()
const [, setLocation] = useLocation()

const { SearchWithNav } = useResourceFilters({
instructions: filtersInstructions
const { SearchWithNav, adapters } = useResourceFilters({
instructions: filtersInstructions,
predicateWhitelist
})

return (
Expand Down Expand Up @@ -51,7 +54,7 @@ function HomePage(): JSX.Element {
) : undefined
}
>
{/* <Link
<Link
href={appRoutes.promotionList.makePath(
{},
adapters.adaptFormValuesToUrlQuery({
Expand Down Expand Up @@ -102,7 +105,7 @@ function HomePage(): JSX.Element {
<Text weight='semibold'>{presets.disabled.viewTitle} </Text>
<StatusIcon name='caretRight' />
</ListItem>
</Link> */}
</Link>

<Link asChild href={appRoutes.promotionList.makePath({})}>
<ListItem
Expand Down
5 changes: 3 additions & 2 deletions packages/app/src/pages/PromotionListPage.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ListEmptyState } from '#components/ListEmptyState'
import { ListItemPromotion } from '#components/ListItemPromotion'
import type { PageProps } from '#components/Routes'
import { filtersInstructions } from '#data/filters'
import { filtersInstructions, predicateWhitelist } from '#data/filters'
import { appRoutes } from '#data/routes'
import {
PageLayout,
Expand All @@ -22,7 +22,8 @@ function Page(props: PageProps<typeof appRoutes.promotionList>): JSX.Element {

const { SearchWithNav, FilteredList, viewTitle, hasActiveFilter } =
useResourceFilters({
instructions: filtersInstructions
instructions: filtersInstructions,
predicateWhitelist
})

const hideFiltersNav = !(viewTitle == null)
Expand Down

0 comments on commit 2977d48

Please sign in to comment.