bugfix/demo-bugs-fixed #19
@@ -756,18 +756,7 @@ export class AuthService {
|
|||||||
throw new UnauthorizedException('Access denied to this organization');
|
throw new UnauthorizedException('Access denied to this organization');
|
||||||
}
|
}
|
||||||
if (!membership.isOwner && !membership.isActive) {
|
if (!membership.isOwner && !membership.isActive) {
|
||||||
const acceptedInvite = await this.prisma.staffInvitation.findFirst({
|
throw new UnauthorizedException('Your invitation is still pending activation');
|
||||||
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.',
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. Build payload WITH org context
|
// 2. Build payload WITH org context
|
||||||
|
|||||||
@@ -3,35 +3,23 @@
|
|||||||
import { useMemo, useState } from 'react';
|
import { useMemo, useState } from 'react';
|
||||||
import { useAuth } from '@/lib/hooks/useAuth';
|
import { useAuth } from '@/lib/hooks/useAuth';
|
||||||
import { canCreateOrganizationFromCurrentOrg } from '@/components/shared/permissions';
|
import { canCreateOrganizationFromCurrentOrg } from '@/components/shared/permissions';
|
||||||
import { Building2, Mail } from 'lucide-react';
|
import { Building2, Beaker, Mail } from 'lucide-react';
|
||||||
import type { Organization } from '@/types/organization';
|
|
||||||
import { organizationTypeIcon } from '@/components/shared/organizationTypeIcon';
|
|
||||||
import { Input } from '@/components/ui/shared/Input';
|
import { Input } from '@/components/ui/shared/Input';
|
||||||
import { Button } from '@/components/ui/shared/Button';
|
import { Button } from '@/components/ui/shared/Button';
|
||||||
|
|
||||||
export function OrganizationSelectorContent() {
|
export function OrganizationSelectorContent() {
|
||||||
const {
|
const { organizations, selectOrganization, createOrganization, isLoading, error, clearError } = useAuth();
|
||||||
organizations,
|
|
||||||
currentOrganization,
|
|
||||||
selectOrganization,
|
|
||||||
createOrganization,
|
|
||||||
isLoading,
|
|
||||||
error,
|
|
||||||
clearError,
|
|
||||||
} = useAuth();
|
|
||||||
const canCreateOrganization = useMemo(
|
const canCreateOrganization = useMemo(
|
||||||
() => canCreateOrganizationFromCurrentOrg(currentOrganization),
|
() => canUserCreateOrganization(organizations),
|
||||||
[currentOrganization],
|
[organizations],
|
||||||
);
|
);
|
||||||
const [isCreateOpen, setIsCreateOpen] = useState(false);
|
const [isCreateOpen, setIsCreateOpen] = useState(false);
|
||||||
const [organizationName, setOrganizationName] = useState('');
|
const [organizationName, setOrganizationName] = useState('');
|
||||||
const [organizationEmail, setOrganizationEmail] = useState('');
|
const [organizationEmail, setOrganizationEmail] = useState('');
|
||||||
const [organizationType, setOrganizationType] = useState<'CLINIC' | 'LAB'>('CLINIC');
|
const [organizationType, setOrganizationType] = useState<'CLINIC' | 'LAB'>('CLINIC');
|
||||||
|
|
||||||
const renderOrgTypeIcon = (type: Organization['type']) => {
|
const getIcon = (type: string) =>
|
||||||
const Icon = organizationTypeIcon(type);
|
type === 'CLINIC' ? <Building2 className="h-8 w-8 icon-flat" /> : <Beaker className="h-8 w-8 icon-flat" />;
|
||||||
return <Icon className="h-8 w-8 icon-flat" />;
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleCreateOrganization = async () => {
|
const handleCreateOrganization = async () => {
|
||||||
try {
|
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"
|
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">
|
<div className="p-3 bg-primary-soft rounded-[var(--radius-sm)] text-primary">
|
||||||
{renderOrgTypeIcon(org.type)}
|
{getIcon(org.type)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex-1">
|
<div className="flex-1">
|
||||||
|
|||||||
Reference in New Issue
Block a user