diff --git a/backend/src/modules/auth/auth.service.ts b/backend/src/modules/auth/auth.service.ts index 7e3cad7..102e59c 100644 --- a/backend/src/modules/auth/auth.service.ts +++ b/backend/src/modules/auth/auth.service.ts @@ -756,18 +756,7 @@ export class AuthService { throw new UnauthorizedException('Access denied to this organization'); } if (!membership.isOwner && !membership.isActive) { - const acceptedInvite = await this.prisma.staffInvitation.findFirst({ - where: { - membershipId: membership.id, - acceptedAt: { not: null }, - }, - select: { id: true }, - }); - throw new UnauthorizedException( - acceptedInvite - ? 'Your access to this organization has been disabled.' - : 'Your invitation is still pending activation.', - ); + throw new UnauthorizedException('Your invitation is still pending activation'); } // 2. Build payload WITH org context diff --git a/frontend/src/components/ui/organizations/OrganizationSelectorContent.tsx b/frontend/src/components/ui/organizations/OrganizationSelectorContent.tsx index 3283092..b98e5f4 100644 --- a/frontend/src/components/ui/organizations/OrganizationSelectorContent.tsx +++ b/frontend/src/components/ui/organizations/OrganizationSelectorContent.tsx @@ -3,35 +3,23 @@ import { useMemo, useState } from 'react'; import { useAuth } from '@/lib/hooks/useAuth'; import { canCreateOrganizationFromCurrentOrg } from '@/components/shared/permissions'; -import { Building2, Mail } from 'lucide-react'; -import type { Organization } from '@/types/organization'; -import { organizationTypeIcon } from '@/components/shared/organizationTypeIcon'; +import { Building2, Beaker, Mail } from 'lucide-react'; import { Input } from '@/components/ui/shared/Input'; import { Button } from '@/components/ui/shared/Button'; export function OrganizationSelectorContent() { - const { - organizations, - currentOrganization, - selectOrganization, - createOrganization, - isLoading, - error, - clearError, - } = useAuth(); + const { organizations, selectOrganization, createOrganization, isLoading, error, clearError } = useAuth(); const canCreateOrganization = useMemo( - () => canCreateOrganizationFromCurrentOrg(currentOrganization), - [currentOrganization], + () => canUserCreateOrganization(organizations), + [organizations], ); const [isCreateOpen, setIsCreateOpen] = useState(false); const [organizationName, setOrganizationName] = useState(''); const [organizationEmail, setOrganizationEmail] = useState(''); const [organizationType, setOrganizationType] = useState<'CLINIC' | 'LAB'>('CLINIC'); - const renderOrgTypeIcon = (type: Organization['type']) => { - const Icon = organizationTypeIcon(type); - return ; - }; + const getIcon = (type: string) => + type === 'CLINIC' ? : ; const handleCreateOrganization = async () => { try { @@ -162,7 +150,7 @@ export function OrganizationSelectorContent() { className="surface-card p-6 transition-all text-left flex items-center gap-4 hover:border-primary/60" >
- {renderOrgTypeIcon(org.type)} + {getIcon(org.type)}