Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions app/projects/[slug]/project-tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,31 @@ import { uniq } from 'es-toolkit'
import { compareDesc } from 'date-fns'
import { formatMoneyPrecise, formatPercent } from '@/utils/formatting'
import { SimilarProjects } from './similar-projects'
import { useEffect, useState } from 'react'
import { createClient } from '@/db/supabase-browser'

const SIMILARITY_THRESHOLD = 0.6

function useExpiredBids(projectId: string) {
const [expiredBids, setExpiredBids] = useState<BidAndProfile[]>([])
useEffect(() => {
const fetchExpiredBids = async () => {
const supabase = createClient()
const { data, error } = await supabase
.from('bids')
.select('*, profiles(*)')
.eq('project', projectId)
.eq('status', 'declined')
.eq('type', 'donate')
if (data && data.length > 0) {
setExpiredBids(data as BidAndProfile[])
}
}
void fetchExpiredBids()
}, [projectId])
return expiredBids
}

export function ProjectTabs(props: {
project: FullProject
comments: CommentAndProfileAndRxns[]
Expand Down Expand Up @@ -102,6 +124,28 @@ export function ProjectTabs(props: {
),
})
}

const expiredBids = useExpiredBids(project.id)
// Show expired offers for non-funded projects
if (project.stage === 'not funded') {
if (expiredBids.length > 0) {
tabs.push({
name: 'Expired Offers',
id: 'expired-offers',
count: expiredBids.length,
display: (
<Bids
bids={expiredBids}
project={project}
userProfile={userProfile}
userSpendableFunds={0}
userSellableShares={0}
activeAuction={false}
/>
),
})
}
}
if (shareholders) {
tabs.push({
name: 'Shareholders',
Expand Down