Skip to content
Open
Show file tree
Hide file tree
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
6 changes: 5 additions & 1 deletion components/work/WorkRightSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ export const WorkRightSidebar = ({ work, metadata }: WorkRightSidebarProps) => {
{hasResearchHubJournalVersions && (
<VersionsSection versions={work.versions || []} currentPaperId={work.id} slug={work.slug} />
)}
<SupportersSection tips={work.tips || []} documentId={work.id} />
<SupportersSection
tips={work.tips || []}
documentId={work.id}
contentType={work.contentType}
/>
<TopicsSection topics={metadata.topics || []} />
{work.doi && <DOISection doi={work.doi} />}
{work.postType !== 'QUESTION' && <LicenseSection license={work.license} />}
Expand Down
15 changes: 10 additions & 5 deletions components/work/components/SupportersSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,30 @@ import { HeartHandshake } from 'lucide-react';
import { Button } from '@/components/ui/Button';
import { ResearchCoinIcon } from '@/components/ui/icons/ResearchCoinIcon';
import { Icon } from '@/components/ui/icons/Icon';
import { Work } from '@/types/work';
import { Work, ContentType } from '@/types/work';
import { TipContentModal } from '@/components/modals/TipContentModal';
import { CurrencyBadge } from '@/components/ui/CurrencyBadge';
import { useCurrencyPreference } from '@/contexts/CurrencyPreferenceContext';

interface SupportersSectionProps {
tips: Tip[];
documentId: number;
contentType: ContentType;
onTip?: () => void;
}

export const SupportersSection: FC<SupportersSectionProps> = ({ tips = [], documentId, onTip }) => {
export const SupportersSection: FC<SupportersSectionProps> = ({
tips = [],
documentId,
contentType,
onTip,
}) => {
const [isModalOpen, setIsModalOpen] = useState(false);
const [showAllSupporters, setShowAllSupporters] = useState(false);
const { showUSD } = useCurrencyPreference();

const hasSupporters = tips && tips.length > 0;
const displayLimit = 5; // Show only top 5 supporters in the sidebar
const displayLimit = 5;
const displayedSupporters = showAllSupporters ? tips : tips.slice(0, displayLimit);
const hasMoreSupporters = tips.length > displayLimit;

Expand Down Expand Up @@ -114,12 +120,11 @@ export const SupportersSection: FC<SupportersSectionProps> = ({ tips = [], docum
</div>
)}

{/* Tip Modal */}
<TipContentModal
isOpen={isModalOpen}
onClose={() => setIsModalOpen(false)}
contentId={documentId}
feedContentType="PAPER"
feedContentType={contentType === 'paper' ? 'PAPER' : 'POST'}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there other types backend can accept here or just paper vs post?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How our backend currently processes it is just paper, "rhcommentmodel" or "researchhubpost". I can update these if you'd like me to to be a bit more concise.

onTipSuccess={handleTipSuccess}
/>
</section>
Expand Down