refetch after user default access changed (#58)

This commit is contained in:
Nate Kelley 2025-01-22 15:11:07 -08:00 committed by GitHub
parent bc36758fea
commit db43289d71
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 8 deletions

View File

@ -4,14 +4,16 @@ import { Text, Title } from '@/components/text';
import { Card, Select } from 'antd'; import { Card, Select } from 'antd';
import { useMemoizedFn } from 'ahooks'; import { useMemoizedFn } from 'ahooks';
export const UserDefaultAccess: React.FC<{ user: OrganizationUser; isAdmin: boolean }> = ({ export const UserDefaultAccess: React.FC<{
user, user: OrganizationUser;
isAdmin isAdmin: boolean;
}) => { refetchUser: () => void;
}> = ({ user, isAdmin, refetchUser }) => {
const { mutateAsync, isPending } = useUpdateUser(); const { mutateAsync, isPending } = useUpdateUser();
const onChange = useMemoizedFn((value: string) => { const onChange = useMemoizedFn(async (value: string) => {
mutateAsync({ userId: user.id, role: value as OrganizationUser['role'] }); await mutateAsync({ userId: user.id, role: value as OrganizationUser['role'] });
refetchUser();
}); });
return ( return (

View File

@ -8,14 +8,14 @@ import { UserLineageHeader } from './UserLineageHeader';
import { UserDatasetSearch } from './UserDatasetSearch'; import { UserDatasetSearch } from './UserDatasetSearch';
export const UserOverviewController = React.memo(({ userId }: { userId: string }) => { export const UserOverviewController = React.memo(({ userId }: { userId: string }) => {
const { data: user } = useGetUser({ userId }); const { data: user, refetch: refetchUser } = useGetUser({ userId });
const isAdmin = useUserConfigContextSelector((x) => x.isAdmin); const isAdmin = useUserConfigContextSelector((x) => x.isAdmin);
if (!user) return null; if (!user) return null;
return ( return (
<> <>
<UserDefaultAccess user={user} isAdmin={isAdmin} /> <UserDefaultAccess user={user} isAdmin={isAdmin} refetchUser={refetchUser} />
<UserLineageHeader className="!mt-[48px]" user={user} /> <UserLineageHeader className="!mt-[48px]" user={user} />
<UserDatasetSearch user={user} /> <UserDatasetSearch user={user} />
</> </>