feat: add availability status check and disable connect button for unavailable agents

This commit is contained in:
pradeepkumar
2026-05-15 11:28:24 +05:30
parent 9033ad8e64
commit fb14c4d37c
2 changed files with 10 additions and 1 deletions

View File

@@ -388,6 +388,7 @@ export default function AgentProfileView() {
showEditButton={false} showEditButton={false}
messageHref={`/user/message?agentProfileId=${agentProfile.id}`} messageHref={`/user/message?agentProfileId=${agentProfile.id}`}
connectionStatus={connectionStatus} connectionStatus={connectionStatus}
isAvailable={agentProfile.isAvailable ?? true}
onConnectClick={() => setShowConnectModal(true)} onConnectClick={() => setShowConnectModal(true)}
onUnlinkClick={handleUnlink} onUnlinkClick={handleUnlink}
/> />

View File

@@ -24,6 +24,7 @@ interface ProfileCardProps {
requestsHref?: string; requestsHref?: string;
pendingRequestCount?: number; pendingRequestCount?: number;
connectionStatus?: ConnectionStatus; connectionStatus?: ConnectionStatus;
isAvailable?: boolean;
onConnectClick?: () => void; // Callback when Connect button is clicked (for opening modal) onConnectClick?: () => void; // Callback when Connect button is clicked (for opening modal)
onUnlinkClick?: () => void; // Callback when Unlink button is clicked onUnlinkClick?: () => void; // Callback when Unlink button is clicked
} }
@@ -43,6 +44,7 @@ export function ProfileCard({
requestsHref, requestsHref,
pendingRequestCount = 0, pendingRequestCount = 0,
connectionStatus, connectionStatus,
isAvailable = true,
onConnectClick, onConnectClick,
onUnlinkClick, onUnlinkClick,
}: ProfileCardProps) { }: ProfileCardProps) {
@@ -244,6 +246,7 @@ export function ProfileCard({
) : ( ) : (
<button <button
onClick={(e) => { onClick={(e) => {
if (!isAvailable) return;
if (!session) { if (!session) {
e.preventDefault(); e.preventDefault();
const returnUrl = encodeURIComponent(pathname); const returnUrl = encodeURIComponent(pathname);
@@ -252,7 +255,12 @@ export function ProfileCard({
} }
onConnectClick?.(); onConnectClick?.();
}} }}
className="flex items-center gap-2 px-4 py-1.5 bg-[#e58625] text-[#00293d] text-sm font-normal rounded-[15px] border border-[#00293d]/10 hover:bg-[#d47720] transition-colors font-serif cursor-pointer" disabled={!isAvailable}
className={`flex items-center gap-2 px-4 py-1.5 text-sm font-normal rounded-[15px] border border-[#00293d]/10 transition-colors font-serif ${
isAvailable
? 'bg-[#e58625] text-[#00293d] hover:bg-[#d47720] cursor-pointer'
: 'bg-[#00293d] text-white cursor-not-allowed opacity-70'
}`}
> >
<Image <Image
src="/assets/icons/requests-dark-icon.svg" src="/assets/icons/requests-dark-icon.svg"