|
|
@ -5,6 +5,7 @@ import { ChevronsDown, ChevronsUp } from 'lucide-react'; |
|
|
|
|
|
|
|
|
|
|
|
type TeamActivityItemProps = { |
|
|
|
type TeamActivityItemProps = { |
|
|
|
onTopicClick?: (activity: TeamStreamActivity) => void; |
|
|
|
onTopicClick?: (activity: TeamStreamActivity) => void; |
|
|
|
|
|
|
|
teamId: string; |
|
|
|
user: { |
|
|
|
user: { |
|
|
|
activities: TeamStreamActivity[]; |
|
|
|
activities: TeamStreamActivity[]; |
|
|
|
_id: string; |
|
|
|
_id: string; |
|
|
@ -15,7 +16,7 @@ type TeamActivityItemProps = { |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
export function TeamActivityItem(props: TeamActivityItemProps) { |
|
|
|
export function TeamActivityItem(props: TeamActivityItemProps) { |
|
|
|
const { user, onTopicClick } = props; |
|
|
|
const { user, onTopicClick, teamId } = props; |
|
|
|
const { activities } = user; |
|
|
|
const { activities } = user; |
|
|
|
|
|
|
|
|
|
|
|
const [showAll, setShowAll] = useState(false); |
|
|
|
const [showAll, setShowAll] = useState(false); |
|
|
@ -42,7 +43,7 @@ export function TeamActivityItem(props: TeamActivityItemProps) { |
|
|
|
<a |
|
|
|
<a |
|
|
|
className="font-medium underline transition-colors hover:cursor-pointer hover:text-black" |
|
|
|
className="font-medium underline transition-colors hover:cursor-pointer hover:text-black" |
|
|
|
target="_blank" |
|
|
|
target="_blank" |
|
|
|
href={resourceUrl} |
|
|
|
href={`${resourceUrl}?t=${teamId}`} |
|
|
|
> |
|
|
|
> |
|
|
|
{resourceTitle} |
|
|
|
{resourceTitle} |
|
|
|
</a> |
|
|
|
</a> |
|
|
@ -51,7 +52,7 @@ export function TeamActivityItem(props: TeamActivityItemProps) { |
|
|
|
|
|
|
|
|
|
|
|
const timeAgo = (date: string | Date) => ( |
|
|
|
const timeAgo = (date: string | Date) => ( |
|
|
|
<span className="ml-1 text-xs text-gray-400"> |
|
|
|
<span className="ml-1 text-xs text-gray-400"> |
|
|
|
{getRelativeTimeString(new Date(date).toISOString())} |
|
|
|
{getRelativeTimeString(new Date(date).toISOString(), true)} |
|
|
|
</span> |
|
|
|
</span> |
|
|
|
); |
|
|
|
); |
|
|
|
const userAvatar = user.avatar |
|
|
|
const userAvatar = user.avatar |
|
|
@ -77,7 +78,7 @@ export function TeamActivityItem(props: TeamActivityItemProps) { |
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<li |
|
|
|
<li |
|
|
|
key={user._id} |
|
|
|
key={user._id} |
|
|
|
className="flex items-center flex-wrap gap-1 rounded-md border px-2 py-2.5 text-sm" |
|
|
|
className="flex flex-wrap items-center gap-1 rounded-md border px-2 py-2.5 text-sm" |
|
|
|
> |
|
|
|
> |
|
|
|
{actionType === 'in_progress' && ( |
|
|
|
{actionType === 'in_progress' && ( |
|
|
|
<> |
|
|
|
<> |
|
|
@ -122,13 +123,13 @@ export function TeamActivityItem(props: TeamActivityItemProps) { |
|
|
|
const activityLimit = showAll ? activities.length : 5; |
|
|
|
const activityLimit = showAll ? activities.length : 5; |
|
|
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<li key={user._id} className="rounded-md border overflow-hidden"> |
|
|
|
<li key={user._id} className="overflow-hidden rounded-md border"> |
|
|
|
<h3 className="flex flex-wrap items-center gap-1 bg-gray-100 px-2 py-2.5 text-sm"> |
|
|
|
<h3 className="flex flex-wrap items-center gap-1 bg-gray-100 px-2 py-2.5 text-sm"> |
|
|
|
{username} has {activities.length} updates in {uniqueResourcesCount}{' '} |
|
|
|
{username} has {activities.length} updates in {uniqueResourcesCount}{' '} |
|
|
|
resource(s) |
|
|
|
resource(s) |
|
|
|
</h3> |
|
|
|
</h3> |
|
|
|
<div className="py-3"> |
|
|
|
<div className="py-3"> |
|
|
|
<ul className="flex flex-col gap-2 ml-2 sm:ml-[36px]"> |
|
|
|
<ul className="ml-2 flex flex-col gap-2 sm:ml-[36px]"> |
|
|
|
{activities.slice(0, activityLimit).map((activity) => { |
|
|
|
{activities.slice(0, activityLimit).map((activity) => { |
|
|
|
const { actionType, topicIds } = activity; |
|
|
|
const { actionType, topicIds } = activity; |
|
|
|
const topicCount = topicIds?.length || 0; |
|
|
|
const topicCount = topicIds?.length || 0; |
|
|
@ -173,7 +174,7 @@ export function TeamActivityItem(props: TeamActivityItemProps) { |
|
|
|
|
|
|
|
|
|
|
|
{activities.length > 5 && ( |
|
|
|
{activities.length > 5 && ( |
|
|
|
<button |
|
|
|
<button |
|
|
|
className="mt-3 flex items-center gap-2 rounded-md border border-gray-300 p-1 text-xs uppercase tracking-wide text-gray-600 transition-colors hover:border-black hover:bg-black hover:text-white" |
|
|
|
className="ml-2 mt-3 flex items-center gap-2 rounded-md border border-gray-300 p-1 text-xs uppercase tracking-wide text-gray-600 transition-colors hover:border-black hover:bg-black hover:text-white sm:ml-[36px]" |
|
|
|
onClick={() => setShowAll(!showAll)} |
|
|
|
onClick={() => setShowAll(!showAll)} |
|
|
|
> |
|
|
|
> |
|
|
|
{showAll ? ( |
|
|
|
{showAll ? ( |
|
|
|