Refactor organization and user management components/tests for simplification and improved clarity
- Removed unused properties (`slug`, `is_active`, etc.) in organization and user-related components and test data. - Simplified function data typing by removing redundant `any` usage. - Updated `params` in `OrganizationMembersPage` for Promise resolution and async handling. - Cleaned up unused variables and streamlined form handling in `AddMemberDialog`.
This commit is contained in:
@@ -69,7 +69,7 @@ export function AddMemberDialog({
|
||||
},
|
||||
});
|
||||
|
||||
const { register, handleSubmit, formState: { errors }, setValue, watch } = form;
|
||||
const { handleSubmit, formState: { errors }, setValue, watch } = form;
|
||||
const selectedRole = watch('role');
|
||||
const selectedEmail = watch('userEmail');
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@ import { OrganizationFormDialog } from './OrganizationFormDialog';
|
||||
export function OrganizationManagementContent() {
|
||||
const router = useRouter();
|
||||
const searchParams = useSearchParams();
|
||||
const { user: currentUser } = useAuth();
|
||||
|
||||
// URL state
|
||||
const page = parseInt(searchParams.get('page') || '1', 10);
|
||||
|
||||
@@ -26,7 +26,6 @@ interface OrganizationMembersContentProps {
|
||||
export function OrganizationMembersContent({ organizationId }: OrganizationMembersContentProps) {
|
||||
const router = useRouter();
|
||||
const searchParams = useSearchParams();
|
||||
const { user: currentUser } = useAuth();
|
||||
|
||||
// URL state
|
||||
const page = parseInt(searchParams.get('page') || '1', 10);
|
||||
|
||||
@@ -168,7 +168,7 @@ export function UserFormDialog({
|
||||
|
||||
await updateUser.mutateAsync({
|
||||
userId: user.id,
|
||||
userData: updateData as any,
|
||||
userData: updateData,
|
||||
});
|
||||
|
||||
toast.success(`User ${data.first_name} ${data.last_name || ''} updated successfully`);
|
||||
@@ -181,9 +181,8 @@ export function UserFormDialog({
|
||||
first_name: data.first_name,
|
||||
last_name: data.last_name || undefined,
|
||||
password: data.password,
|
||||
is_active: data.is_active,
|
||||
is_superuser: data.is_superuser,
|
||||
} as any);
|
||||
});
|
||||
|
||||
toast.success(`User ${data.first_name} ${data.last_name || ''} created successfully`);
|
||||
onOpenChange(false);
|
||||
|
||||
@@ -76,7 +76,6 @@ export function UserListTable({
|
||||
|
||||
const allSelected =
|
||||
users.length > 0 && users.every((user) => selectedUsers.includes(user.id));
|
||||
const someSelected = users.some((user) => selectedUsers.includes(user.id));
|
||||
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
|
||||
@@ -86,8 +86,8 @@ export function UserManagementContent() {
|
||||
const handleSelectAll = (selected: boolean) => {
|
||||
if (selected) {
|
||||
const selectableUsers = users
|
||||
.filter((u: any) => u.id !== currentUser?.id)
|
||||
.map((u: any) => u.id);
|
||||
.filter((u) => u.id !== currentUser?.id)
|
||||
.map((u) => u.id);
|
||||
setSelectedUsers(selectableUsers);
|
||||
} else {
|
||||
setSelectedUsers([]);
|
||||
|
||||
Reference in New Issue
Block a user