Skip to content

Commit

Permalink
Add closing button
Browse files Browse the repository at this point in the history
  • Loading branch information
IanPhilips committed Nov 14, 2024
1 parent 5af14f5 commit 5ecc3c0
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
1 change: 1 addition & 0 deletions backend/shared/src/supabase/search-contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ function getSearchContractWhereSQL(args: {
// Include an extra day to capture markets that close on the first of the month. Add 7 hours to shift UTC time zone to PT.
'closing-this-month': `close_time > now() AND close_time < (date_trunc('month', now()) + interval '1 month' + interval '1 day' + interval '7 hours') AND resolution_time IS NULL`,
'closing-next-month': `close_time > ((date_trunc('month', now()) + interval '1 month') + interval '1 day' + interval '7 hours') AND close_time < (date_trunc('month', now()) + interval '2 month' + interval '1 day' + interval '7 hours') AND resolution_time IS NULL`,
closing: `close_time > now() AND close_time < now() + interval '1 month' + interval '1 day' + interval '7 hours' AND resolution_time IS NULL`,
resolved: 'resolution_time IS NOT NULL',
all: '',
}
Expand Down
1 change: 1 addition & 0 deletions common/src/api/market-search-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const searchProps = z
z.literal('open'),
z.literal('closing-this-month'),
z.literal('closing-next-month'),
z.literal('closing'),
z.literal('closed'),
z.literal('resolved'),
z.literal('all'),
Expand Down
28 changes: 25 additions & 3 deletions web/components/search/contract-filters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,9 @@ export function ContractFilters(props: {
onClick={() => {
if (sort === 'score') {
selectSort('freshness-score')
} else {
selectSort('score')
}
selectSort('score')
}}
>
Best
Expand All @@ -190,8 +191,9 @@ export function ContractFilters(props: {
onClick={() => {
if (sort === 'freshness-score') {
selectSort('score')
} else {
selectSort('freshness-score')
}
selectSort('freshness-score')
}}
>
Hot
Expand All @@ -208,8 +210,9 @@ export function ContractFilters(props: {
onClick={() => {
if (sort === 'newest') {
selectSort('score')
} else {
selectSort('newest')
}
selectSort('newest')
}}
>
New
Expand All @@ -230,6 +233,25 @@ export function ContractFilters(props: {
{getLabelFromValue(SORTS, sortValue)}
</FilterPill>
))}
<button
key="closing"
className={clsx(
'flex h-6 cursor-pointer select-none flex-row items-center whitespace-nowrap rounded-full px-2 text-sm outline-none transition-colors',
filter == 'closing'
? 'hover:bg-primary-600 focus-visible:bg-primary-600 bg-primary-500 text-white'
: 'bg-ink-200 text-ink-600 dark:bg-ink-300',
className
)}
onClick={() => {
if (filter === 'closing') {
selectFilter('open')
} else {
selectFilter('closing')
}
}}
>
Closing
</button>
{initialTopics && !topicSlug && (
<TopicDropdownPill
initialTopics={initialTopics}
Expand Down
1 change: 1 addition & 0 deletions web/components/supabase-search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export const FILTERS = [
{ label: 'Open', value: 'open' },
{ label: 'Closing this month', value: 'closing-this-month' },
{ label: 'Closing next month', value: 'closing-next-month' },
{ label: 'Closing in 30 days', value: 'closing' },
{ label: 'Closed', value: 'closed' },
{ label: 'Resolved', value: 'resolved' },
] as const
Expand Down

0 comments on commit 5ecc3c0

Please sign in to comment.