From cad6fbaa6ce2645de009b4d36a94135f17d9b715 Mon Sep 17 00:00:00 2001 From: rameen Date: Wed, 17 Jun 2026 15:27:00 +0330 Subject: [PATCH 1/3] fix tailwinds modul not issue. --- frontend/package-lock.json | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 0ca90ec..08070aa 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -76,7 +76,6 @@ "integrity": "sha512-CGOfOJqWjg2qW/Mb6zNsDm+u5vFQ8DxXfbM09z69p5Z6+mE1ikP2jUXw+j42Pf1XTYED2Rni5f95npYeuwMDQA==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@babel/code-frame": "^7.29.0", "@babel/generator": "^7.29.0", @@ -1622,7 +1621,6 @@ "integrity": "sha512-ilcTH/UniCkMdtexkoCN0bI7pMcJDvmQFPvuPvmEaYA/NSfFTAgdUSLAoVjaRJm7+6PvcM+q1zYOwS4wTYMF9w==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "csstype": "^3.2.2" } @@ -1682,7 +1680,6 @@ "integrity": "sha512-XZzOmihLIr8AD1b9hL9ccNMzEMWt/dE2u7NyTY9jJG6YNiNthaD5XtUHVF2uCXZ15ng+z2hT3MVuxnUYhq6k1g==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@typescript-eslint/scope-manager": "8.57.0", "@typescript-eslint/types": "8.57.0", @@ -2208,7 +2205,6 @@ "integrity": "sha512-UVJyE9MttOsBQIDKw1skb9nAwQuR5wuGD3+82K6JgJlm/Y+KI92oNsMNGZCYdDsVtRHSak0pcV5Dno5+4jh9sw==", "dev": true, "license": "MIT", - "peer": true, "bin": { "acorn": "bin/acorn" }, @@ -2512,7 +2508,6 @@ "integrity": "sha512-Ixm8tFfoKKIPYdCCKYTsqv+Fd4IJ0DQqMyEimo+pxUOMUR9cVPlwTrFt9Avu+3cb6Zp3mAzl+t1MrG2fxxKsxw==", "devOptional": true, "license": "MIT", - "peer": true, "dependencies": { "@babel/types": "^7.26.0" } @@ -2580,7 +2575,6 @@ } ], "license": "MIT", - "peer": true, "dependencies": { "baseline-browser-mapping": "^2.9.0", "caniuse-lite": "^1.0.30001759", @@ -3164,7 +3158,6 @@ "integrity": "sha512-XoMjdBOwe/esVgEvLmNsD3IRHkm7fbKIUGvrleloJXUZgDHig2IPWNniv+GwjyJXzuNqVjlr5+4yVUZjycJwfQ==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@eslint-community/eslint-utils": "^4.8.0", "@eslint-community/regexpp": "^4.12.1", @@ -3350,7 +3343,6 @@ "integrity": "sha512-whOE1HFo/qJDyX4SnXzP4N6zOWn79WhnCUY/iDR0mPfQZO8wcYE4JClzI2oZrhBnnMUCBCHZhO6VQyoBU95mZA==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@rtsao/scc": "^1.1.0", "array-includes": "^3.1.9", @@ -5621,7 +5613,6 @@ "resolved": "https://registry.npmmirror.com/react/-/react-19.2.3.tgz", "integrity": "sha512-Ku/hhYbVjOQnXDZFv2+RibmLFGwFdeeKHFcOTlrt7xplBnya5OGn/hIRDsqDiSUcfORsDC7MPxwork8jBwsIWA==", "license": "MIT", - "peer": true, "engines": { "node": ">=0.10.0" } @@ -5631,7 +5622,6 @@ "resolved": "https://registry.npmmirror.com/react-dom/-/react-dom-19.2.3.tgz", "integrity": "sha512-yELu4WmLPw5Mr/lmeEpox5rw3RETacE++JgHqQzd2dg+YbJuat3jH4ingc+WPZhxaoFzdv9y33G+F7Nl5O0GBg==", "license": "MIT", - "peer": true, "dependencies": { "scheduler": "^0.27.0" }, @@ -5644,7 +5634,6 @@ "resolved": "https://registry.npmmirror.com/react-hook-form/-/react-hook-form-7.71.2.tgz", "integrity": "sha512-1CHvcDYzuRUNOflt4MOq3ZM46AronNJtQ1S7tnX6YN4y72qhgiUItpacZUAQ0TyWYci3yz1X+rXaSxiuEm86PA==", "license": "MIT", - "peer": true, "engines": { "node": ">=18.0.0" }, @@ -6337,7 +6326,6 @@ "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=12" }, @@ -6500,7 +6488,6 @@ "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", "dev": true, "license": "Apache-2.0", - "peer": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -6775,7 +6762,6 @@ "resolved": "https://registry.npmmirror.com/zod/-/zod-4.3.6.tgz", "integrity": "sha512-rftlrkhHZOcjDwkGlnUtZZkvaPHCsDATp4pGpuOOMDaTdDDXF91wuVDJoWoPsKX/3YPQ5fHuF3STjcYyKr+Qhg==", "license": "MIT", - "peer": true, "funding": { "url": "https://github.com/sponsors/colinhacks" } -- 2.53.0.windows.1 From 4e2a9765bc96acdafd0f592549958fe14acae4cf Mon Sep 17 00:00:00 2001 From: rameen Date: Sun, 21 Jun 2026 13:24:15 +0330 Subject: [PATCH 2/3] backend api service for Count incoming pending connection requests for sidebar badge. --- .../organization/organization.controller.ts | 8 +++++++ .../organization/organization.service.ts | 23 +++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/backend/src/modules/organization/organization.controller.ts b/backend/src/modules/organization/organization.controller.ts index 7e56c60..7f0fc68 100644 --- a/backend/src/modules/organization/organization.controller.ts +++ b/backend/src/modules/organization/organization.controller.ts @@ -64,6 +64,14 @@ export class OrganizationController { return this.organizationService.searchCounterpartOrganizations(req.user.id, organizationId, q); } + @Get('connections/pending-count') + @UseGuards(JwtAuthGuard) + @ApiOperation({ summary: 'Count incoming pending connection requests for sidebar badge' }) + countPendingConnections(@Req() req: { user: { id: string; organizationId?: string } }) { + const organizationId = this.organizationService.getOrganizationIdFromUser(req.user); + return this.organizationService.countIncomingPendingConnections(req.user.id, organizationId); + } + @Get('connections') @UseGuards(JwtAuthGuard) @ApiOperation({ summary: 'List counterpart connections for current organization' }) diff --git a/backend/src/modules/organization/organization.service.ts b/backend/src/modules/organization/organization.service.ts index 5198d77..6945d09 100644 --- a/backend/src/modules/organization/organization.service.ts +++ b/backend/src/modules/organization/organization.service.ts @@ -160,6 +160,29 @@ export class OrganizationService { }; } + /** Lightweight count for sidebar badge — incoming PENDING requests only. */ + async countIncomingPendingConnections(userId: string, organizationId: string) { + const actor = await this.getActorMembership(userId, organizationId); + if (!actor || !this.canEditOrganizations(actor)) { + throw new ForbiddenException('You do not have permission to manage organizations'); + } + + const links = await this.prisma.organizationLink.findMany({ + where: { + status: LinkStatus.PENDING, + OR: [{ organizationAId: organizationId }, { organizationBId: organizationId }], + }, + select: { sharedDataTypes: true }, + }); + + const count = links.filter((link) => { + const requesterOrgId = this.getRequesterOrganizationId(link.sharedDataTypes); + return requesterOrgId !== null && requesterOrgId !== organizationId; + }).length; + + return { success: true, data: { count } }; + } + async listInvitationHistory(userId: string, organizationId: string) { const actor = await this.getActorMembership(userId, organizationId); if (!actor || !this.canEditOrganizations(actor)) { -- 2.53.0.windows.1 From 2f99abbb9e59870760967e55b8c3fb5f12d6e246 Mon Sep 17 00:00:00 2001 From: rameen Date: Sun, 21 Jun 2026 13:26:55 +0330 Subject: [PATCH 3/3] front end feature to showing pending connection request in sidebar. --- .../app/(dashboard)/organizations/page.tsx | 2 + frontend/src/components/ui/shared/Sidebar.tsx | 14 +++++- frontend/src/lib/api/organization.ts | 5 ++ .../lib/hooks/usePendingConnectionsCount.ts | 48 +++++++++++++++++++ 4 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 frontend/src/lib/hooks/usePendingConnectionsCount.ts diff --git a/frontend/src/app/(dashboard)/organizations/page.tsx b/frontend/src/app/(dashboard)/organizations/page.tsx index b3c9ddb..df889a0 100644 --- a/frontend/src/app/(dashboard)/organizations/page.tsx +++ b/frontend/src/app/(dashboard)/organizations/page.tsx @@ -4,6 +4,7 @@ import { useEffect, useState } from 'react'; import { useToast } from '@/lib/hooks/useToast'; import { Check, Trash2, UserPlus, X } from 'lucide-react'; import { useAuth } from '@/lib/hooks/useAuth'; +import { notifyPendingConnectionsChanged } from '@/lib/hooks/usePendingConnectionsCount'; import { useOrganizationInviteLinkCopy } from '@/lib/hooks/useOrganizationInviteLinkCopy'; import { organizationApi, @@ -246,6 +247,7 @@ export default function OrganizationsPage() { toast.showSuccess( action === 'ACCEPT' ? 'Connection request accepted.' : 'Connection request declined.', ); + notifyPendingConnectionsChanged(); await loadList(); } catch (e) { toast.showError(formatApiMessage(e)); diff --git a/frontend/src/components/ui/shared/Sidebar.tsx b/frontend/src/components/ui/shared/Sidebar.tsx index 80bc7f8..7738326 100644 --- a/frontend/src/components/ui/shared/Sidebar.tsx +++ b/frontend/src/components/ui/shared/Sidebar.tsx @@ -13,6 +13,7 @@ import { CreditCard, } from 'lucide-react'; import { useAuth } from '@/lib/hooks/useAuth'; +import { usePendingConnectionsCount } from '@/lib/hooks/usePendingConnectionsCount'; import { canAccessAppointmentsSection, canViewTab } from '@/components/shared/permissions'; import { counterpartOrganizationType, @@ -32,6 +33,7 @@ const menu = [ function Sidebar() { const pathname = usePathname(); const { currentOrganization } = useAuth(); + const pendingConnectionsCount = usePendingConnectionsCount(); const counterpartLabel = currentOrganization?.type === 'LAB' ? 'Clinics' : 'Labs'; const organizationsTabIcon = organizationTypeIcon( counterpartOrganizationType(currentOrganization?.type), @@ -75,6 +77,8 @@ function Sidebar() { {visibleMenu.map((item) => { const Icon = item.icon; const isActive = pathname === item.path; + const showPendingBadge = + item.path === '/organizations' && pendingConnectionsCount > 0; return ( - {item.name} + {item.name} + {showPendingBadge && ( + + {pendingConnectionsCount} + + )} ); })} diff --git a/frontend/src/lib/api/organization.ts b/frontend/src/lib/api/organization.ts index 7c940ce..0e54cd8 100644 --- a/frontend/src/lib/api/organization.ts +++ b/frontend/src/lib/api/organization.ts @@ -46,6 +46,11 @@ export const organizationApi = { return response.data; }, + pendingIncomingCount: async (): Promise<{ success: boolean; data: { count: number } }> => { + const response = await apiClient.get('/organizations/connections/pending-count'); + return response.data; + }, + listInvitations: async (): Promise<{ success: boolean; data: { items: OrganizationInvitationHistoryItemDto[] }; diff --git a/frontend/src/lib/hooks/usePendingConnectionsCount.ts b/frontend/src/lib/hooks/usePendingConnectionsCount.ts new file mode 100644 index 0000000..4be203b --- /dev/null +++ b/frontend/src/lib/hooks/usePendingConnectionsCount.ts @@ -0,0 +1,48 @@ +'use client'; + +import { useCallback, useEffect, useState } from 'react'; +import { usePathname } from 'next/navigation'; +import { canViewTab } from '@/components/shared/permissions'; +import { organizationApi } from '@/lib/api/organization'; +import { useAuth } from '@/lib/hooks/useAuth'; + +/** Tell the sidebar badge to refetch after accept/decline on the organizations page. */ +export function notifyPendingConnectionsChanged() { + window.dispatchEvent(new Event('pending-connections-changed')); +} + +/** + * Sidebar-only: fetches GET /organizations/connections/pending-count. + * Independent from the organizations tab list API. + */ +export function usePendingConnectionsCount(): number { + const pathname = usePathname(); + const { currentOrganization } = useAuth(); + const [count, setCount] = useState(0); + + const fetchCount = useCallback(async () => { + if (!currentOrganization?.id || !canViewTab(currentOrganization, 'TAB_ORGANIZATIONS_READ')) { + setCount(0); + return; + } + + try { + const res = await organizationApi.pendingIncomingCount(); + setCount(res.data.count); + } catch { + setCount(0); + } + }, [currentOrganization]); + + useEffect(() => { + void fetchCount(); + }, [fetchCount, pathname]); + + useEffect(() => { + const onChanged = () => void fetchCount(); + window.addEventListener('pending-connections-changed', onChanged); + return () => window.removeEventListener('pending-connections-changed', onChanged); + }, [fetchCount]); + + return count; +} -- 2.53.0.windows.1