bugfix/demo-bugs-fixed #19
@@ -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
|
||||
|
||||
@@ -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 <Icon className="h-8 w-8 icon-flat" />;
|
||||
};
|
||||
const getIcon = (type: string) =>
|
||||
type === 'CLINIC' ? <Building2 className="h-8 w-8 icon-flat" /> : <Beaker className="h-8 w-8 icon-flat" />;
|
||||
|
||||
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"
|
||||
>
|
||||
<div className="p-3 bg-primary-soft rounded-[var(--radius-sm)] text-primary">
|
||||
{renderOrgTypeIcon(org.type)}
|
||||
{getIcon(org.type)}
|
||||
</div>
|
||||
|
||||
<div className="flex-1">
|
||||
|
||||
Reference in New Issue
Block a user