mirror of
https://github.com/ichsankurnia/hats-app.git
synced 2026-12-05 10:56:28 +00:00
Add HoverCard and UI/status tweaks
Introduce a reusable HoverCard component (components/ui/hover-card.tsx) and integrate it into the client grid to show a status summary with badges. Import the cn helper and BadgeStatus in ClientGrid, add a status pill trigger with animated indicator, and switch displayed client reference from end_user_name to client.name. In ManageTeam, include id in draftData, replace BadgeStatus rendering with a Badge variant and adjust the edit button colors to teal; the same teal edit-button color change was applied to UpdateTimelineStatus. Remove an unnecessary comment line in the task page. These changes improve status visibility and unify UI affordances.
This commit is contained in:
@@ -18,6 +18,11 @@ import { useState } from 'react';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import FormClient from './FormClient';
|
||||
import { ConfirmDeleteWithInput } from '@/components/modal/ConfirmDeleteWithInput';
|
||||
import {
|
||||
HoverCard, HoverCardContent, HoverCardTrigger,
|
||||
} from "@/components/ui/hover-card"
|
||||
import { cn } from '@/lib/utils';
|
||||
import BadgeStatus from '@/components/ui/badge-status';
|
||||
|
||||
export default function ClientGrid({ clients }: { clients: IClient[] }) {
|
||||
const router = useRouter();
|
||||
@@ -70,10 +75,44 @@ export default function ClientGrid({ clients }: { clients: IClient[] }) {
|
||||
className="w-full h-full object-cover group-hover:scale-110 transition-transform duration-500"
|
||||
/>
|
||||
<div className="absolute inset-0 bg-linear-to-t from-black/80 via-black/40 to-transparent" />
|
||||
<div className="absolute top-3 right-3 z-20">
|
||||
<HoverCard openDelay={10} closeDelay={100}>
|
||||
<HoverCardTrigger>
|
||||
<div className="group/pill flex items-center gap-2 bg-black/40 hover:bg-black/60 backdrop-blur-md border border-white/20 rounded-full py-1 px-3 transition-all duration-300 cursor-help hover:scale-105 active:scale-95 shadow-xl">
|
||||
<div className="relative flex items-center justify-center">
|
||||
{client.status_name.toLowerCase() === 'active' &&
|
||||
<span className="absolute inset-0 rounded-full bg-green-400 animate-ping opacity-40 scale-150" />
|
||||
}
|
||||
<div className={cn(
|
||||
"w-2.5 h-2.5 rounded-full ring-2 ring-black/40 relative z-10",
|
||||
client.status_name.toLowerCase() === 'active' ? 'bg-green-400' : 'bg-orange-400'
|
||||
)} />
|
||||
</div>
|
||||
<span className="text-[10px] font-black text-white/90 uppercase tracking-widest whitespace-nowrap">
|
||||
{client.status_name}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
</HoverCardTrigger>
|
||||
<HoverCardContent side="bottom" align='end' className="flex flex-col gap-0.5 text-sm">
|
||||
<div className="font-semibold">Status Summary</div>
|
||||
<div className="text-xs text-muted-foreground">This is status summary information from WO or IM related to this client.</div>
|
||||
<div className='flex flex-col mt-4 gap-2.5 text-xs'>
|
||||
{client.project_status_summary.map((item, key) =>
|
||||
<div className='flex justify-between items-center gap-2' key={key}>
|
||||
<BadgeStatus status={item.project_status} />
|
||||
<div className='font-bold'>{item.total}</div>
|
||||
</div>
|
||||
)}
|
||||
<div></div>
|
||||
</div>
|
||||
</HoverCardContent>
|
||||
</HoverCard>
|
||||
</div>
|
||||
<div className="absolute bottom-4 left-4 right-4 flex items-end justify-between">
|
||||
<div className="text-white">
|
||||
<h3 className="font-bold text-lg leading-tight">{client.name}</h3>
|
||||
<p className="text-xs opacity-80">{client.end_user_name}</p>
|
||||
{/* <p className="text-xs opacity-80">{client.end_user_name}</p> */}
|
||||
</div>
|
||||
<Link href={`/task/client-detail/${client.id}`}>
|
||||
<Button size="icon" variant="secondary" className="h-8 w-8 rounded-full opacity-0 group-hover:opacity-100 transition-opacity">
|
||||
@@ -110,7 +149,7 @@ export default function ClientGrid({ clients }: { clients: IClient[] }) {
|
||||
<>
|
||||
A dedicated team of{" "}
|
||||
<span className="font-bold text-foreground">{userCount} experts</span> is handling{" "}
|
||||
<span className="font-bold text-foreground">{woCount} work order{woCount! > 1 ? 's' : ''}</span>{" "}to ensure successful delivery for <span className="italic">{client.end_user_name}</span>.
|
||||
<span className="font-bold text-foreground">{woCount} work order{woCount! > 1 ? 's' : ''}</span>{" "}to ensure successful delivery for <span className="italic">{client.name}</span>.
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
|
||||
@@ -64,6 +64,7 @@ export function ManageTeam({ assignmentId, onClose }: { assignmentId: number, on
|
||||
setEditingId(row.id);
|
||||
|
||||
setDraftData({
|
||||
id: row.id,
|
||||
start_date: row.start_date,
|
||||
end_date: row.end_date,
|
||||
status: row.status,
|
||||
@@ -204,7 +205,7 @@ export function ManageTeam({ assignmentId, onClose }: { assignmentId: number, on
|
||||
</SelectContent>
|
||||
</Select>
|
||||
:
|
||||
<BadgeStatus status={row.status} />
|
||||
<Badge variant={row.status === "ACTIVE" ? 'statusActive' : "destructive"} className='inline-block lowercase first-letter:uppercase' >{row.status}</Badge>
|
||||
}
|
||||
</TableCell>
|
||||
|
||||
@@ -222,7 +223,7 @@ export function ManageTeam({ assignmentId, onClose }: { assignmentId: number, on
|
||||
:
|
||||
!isOtherRowEditing && (
|
||||
<>
|
||||
<Button variant="outline" className="h-8 w-8 text-blue-600 hover:text-blue-700 hover:bg-blue-100" onClick={() => handleEdit(row)}>
|
||||
<Button variant="outline" className="h-8 w-8 text-teal-600 hover:text-teal-700 hover:bg-teal-100" onClick={() => handleEdit(row)}>
|
||||
<Edit2 className="size-3.5" />
|
||||
</Button>
|
||||
<Button variant="outline" className="h-8 w-8 text-red-600 hover:text-red-700 hover:bg-red-100" onClick={() => setDeletedId(row.id)}>
|
||||
|
||||
@@ -177,7 +177,7 @@ const UpdateTimelineStatus: FC<Props> = ({ assignmentId, onClose }) => {
|
||||
</>
|
||||
:
|
||||
!isOtherRowEditing &&
|
||||
<Button variant="outline" className="h-8 w-8 text-blue-600 hover:text-blue-700 hover:bg-blue-100" onClick={() => handleEdit(row)}>
|
||||
<Button variant="outline" className="h-8 w-8 text-teal-600 hover:text-teal-700 hover:bg-teal-100" onClick={() => handleEdit(row)}>
|
||||
<Edit2 className="size-3.5" />
|
||||
</Button>
|
||||
|
||||
|
||||
@@ -30,7 +30,6 @@ export default async function ClientsPage({ searchParams }: Props) {
|
||||
return (
|
||||
<div className="flex-1 space-y-8 p-6 sm:p-8 pt-6">
|
||||
|
||||
{/* The Shell manages the Search Input, Tabs, and "Add Client" Modal */}
|
||||
<HomeTask currentView={view} />
|
||||
|
||||
{/* Render the correct view based on the URL */}
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
"use client"
|
||||
|
||||
import * as React from "react"
|
||||
import { HoverCard as HoverCardPrimitive } from "radix-ui"
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
function HoverCard({
|
||||
...props
|
||||
}: React.ComponentProps<typeof HoverCardPrimitive.Root>) {
|
||||
return <HoverCardPrimitive.Root data-slot="hover-card" {...props} />
|
||||
}
|
||||
|
||||
function HoverCardTrigger({
|
||||
...props
|
||||
}: React.ComponentProps<typeof HoverCardPrimitive.Trigger>) {
|
||||
return (
|
||||
<HoverCardPrimitive.Trigger data-slot="hover-card-trigger" {...props} />
|
||||
)
|
||||
}
|
||||
|
||||
function HoverCardContent({
|
||||
className,
|
||||
align = "center",
|
||||
sideOffset = 4,
|
||||
...props
|
||||
}: React.ComponentProps<typeof HoverCardPrimitive.Content>) {
|
||||
return (
|
||||
<HoverCardPrimitive.Portal data-slot="hover-card-portal">
|
||||
<HoverCardPrimitive.Content
|
||||
data-slot="hover-card-content"
|
||||
align={align}
|
||||
sideOffset={sideOffset}
|
||||
className={cn(
|
||||
"z-50 w-64 origin-(--radix-hover-card-content-transform-origin) rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-hidden data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
</HoverCardPrimitive.Portal>
|
||||
)
|
||||
}
|
||||
|
||||
export { HoverCard, HoverCardTrigger, HoverCardContent }
|
||||
Reference in New Issue
Block a user