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}
messageHref={`/user/message?agentProfileId=${agentProfile.id}`}
connectionStatus={connectionStatus}
isAvailable={agentProfile.isAvailable ?? true}
onConnectClick={() => setShowConnectModal(true)}
onUnlinkClick={handleUnlink}
/>

View File

@@ -24,6 +24,7 @@ interface ProfileCardProps {
requestsHref?: string;
pendingRequestCount?: number;
connectionStatus?: ConnectionStatus;
isAvailable?: boolean;
onConnectClick?: () => void; // Callback when Connect button is clicked (for opening modal)
onUnlinkClick?: () => void; // Callback when Unlink button is clicked
}
@@ -43,6 +44,7 @@ export function ProfileCard({
requestsHref,
pendingRequestCount = 0,
connectionStatus,
isAvailable = true,
onConnectClick,
onUnlinkClick,
}: ProfileCardProps) {
@@ -244,6 +246,7 @@ export function ProfileCard({
) : (
<button
onClick={(e) => {
if (!isAvailable) return;
if (!session) {
e.preventDefault();
const returnUrl = encodeURIComponent(pathname);
@@ -252,7 +255,12 @@ export function ProfileCard({
}
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
src="/assets/icons/requests-dark-icon.svg"