- Infinite loop carousels for Similar Artworks & Trending rails
- Mouse wheel horizontal scrolling on both carousels
- Author avatar shown on hover in RailCard (similar + trending)
- Removed "View" badge from RailCard hover overlay
- Added `id` to Meilisearch filterable attributes
- Auto-prepend Scout prefix in meilisearch:configure-index command
- Added author name + avatar to Similar Artworks API response
- Added avatar_url to ArtworkListResource author object
- Added direct /art/{id}/{slug} URL to ArtworkListResource
- Fixed race condition: Similar Artworks no longer briefly shows trending items
- Fixed user_profiles eager load (user_id primary key, not id)
- Bumped /api/art/{id}/similar rate limit to 300/min
- Removed decorative heart icons from tag pills
- Moved ReactionBar under artwork description
43 lines
1.2 KiB
JavaScript
43 lines
1.2 KiB
JavaScript
import React, { useEffect, useState } from 'react'
|
|
import axios from 'axios'
|
|
import ReactionBar from '../comments/ReactionBar'
|
|
|
|
/**
|
|
* Loads and displays reactions for a single artwork.
|
|
*
|
|
* Props:
|
|
* artworkId number
|
|
* isLoggedIn boolean
|
|
*/
|
|
export default function ArtworkReactions({ artworkId, isLoggedIn = false }) {
|
|
const [totals, setTotals] = useState(null)
|
|
const [loading, setLoading] = useState(true)
|
|
|
|
useEffect(() => {
|
|
if (!artworkId) return
|
|
axios
|
|
.get(`/api/artworks/${artworkId}/reactions`)
|
|
.then(({ data }) => setTotals(data.totals ?? {}))
|
|
.catch(() => setTotals({}))
|
|
.finally(() => setLoading(false))
|
|
}, [artworkId])
|
|
|
|
if (loading) return null
|
|
|
|
if (!totals || Object.values(totals).every((r) => r.count === 0) && !isLoggedIn) {
|
|
return null
|
|
}
|
|
|
|
return (
|
|
<section className="rounded-2xl border border-white/[0.06] bg-white/[0.03] px-5 py-4">
|
|
<h2 className="mb-3 text-xs font-semibold uppercase tracking-wider text-white/30">Reactions</h2>
|
|
<ReactionBar
|
|
entityType="artwork"
|
|
entityId={artworkId}
|
|
initialTotals={totals}
|
|
isLoggedIn={isLoggedIn}
|
|
/>
|
|
</section>
|
|
)
|
|
}
|