forked from baron/baron-sso
style: apply backend go fmt and frontend biome auto-fixes
This commit is contained in:
@@ -83,16 +83,27 @@ export function TenantAdminsAndOwnersTab() {
|
||||
const addOwnerMutation = useMutation({
|
||||
mutationFn: (userId: string) => addTenantOwner(tenantId, userId),
|
||||
onMutate: async (userId) => {
|
||||
await queryClient.cancelQueries({ queryKey: ["tenant-owners", tenantId] });
|
||||
const previousOwners = queryClient.getQueryData<any[]>(["tenant-owners", tenantId]);
|
||||
|
||||
await queryClient.cancelQueries({
|
||||
queryKey: ["tenant-owners", tenantId],
|
||||
});
|
||||
const previousOwners = queryClient.getQueryData<any[]>([
|
||||
"tenant-owners",
|
||||
tenantId,
|
||||
]);
|
||||
|
||||
// Optimistically add to the list to prevent immediate double clicks
|
||||
const addedUser = searchResults.find(u => u.id === userId);
|
||||
const addedUser = searchResults.find((u) => u.id === userId);
|
||||
if (addedUser) {
|
||||
queryClient.setQueryData<any[]>(["tenant-owners", tenantId], old => {
|
||||
if (!old) return [{ id: userId, name: addedUser.name, email: addedUser.email }];
|
||||
if (old.some(o => o.id === userId)) return old;
|
||||
return [...old, { id: userId, name: addedUser.name, email: addedUser.email }];
|
||||
queryClient.setQueryData<any[]>(["tenant-owners", tenantId], (old) => {
|
||||
if (!old)
|
||||
return [
|
||||
{ id: userId, name: addedUser.name, email: addedUser.email },
|
||||
];
|
||||
if (old.some((o) => o.id === userId)) return old;
|
||||
return [
|
||||
...old,
|
||||
{ id: userId, name: addedUser.name, email: addedUser.email },
|
||||
];
|
||||
});
|
||||
}
|
||||
return { previousOwners };
|
||||
@@ -100,7 +111,9 @@ export function TenantAdminsAndOwnersTab() {
|
||||
onSuccess: () => {
|
||||
// Delay invalidation slightly to give the backend outbox time to process
|
||||
setTimeout(() => {
|
||||
queryClient.invalidateQueries({ queryKey: ["tenant-owners", tenantId] });
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: ["tenant-owners", tenantId],
|
||||
});
|
||||
}, 1000);
|
||||
toast.success(
|
||||
t("msg.admin.tenants.owners.add_success", "소유자가 추가되었습니다."),
|
||||
@@ -109,7 +122,10 @@ export function TenantAdminsAndOwnersTab() {
|
||||
},
|
||||
onError: (err: AxiosError<{ error?: string }>, userId, context) => {
|
||||
if (context?.previousOwners) {
|
||||
queryClient.setQueryData(["tenant-owners", tenantId], context.previousOwners);
|
||||
queryClient.setQueryData(
|
||||
["tenant-owners", tenantId],
|
||||
context.previousOwners,
|
||||
);
|
||||
}
|
||||
toast.error(
|
||||
err.response?.data?.error ||
|
||||
@@ -121,16 +137,23 @@ export function TenantAdminsAndOwnersTab() {
|
||||
const removeOwnerMutation = useMutation({
|
||||
mutationFn: (userId: string) => removeTenantOwner(tenantId, userId),
|
||||
onMutate: async (userId) => {
|
||||
await queryClient.cancelQueries({ queryKey: ["tenant-owners", tenantId] });
|
||||
const previousOwners = queryClient.getQueryData<any[]>(["tenant-owners", tenantId]);
|
||||
queryClient.setQueryData<any[]>(["tenant-owners", tenantId], old =>
|
||||
old ? old.filter(o => o.id !== userId) : []
|
||||
await queryClient.cancelQueries({
|
||||
queryKey: ["tenant-owners", tenantId],
|
||||
});
|
||||
const previousOwners = queryClient.getQueryData<any[]>([
|
||||
"tenant-owners",
|
||||
tenantId,
|
||||
]);
|
||||
queryClient.setQueryData<any[]>(["tenant-owners", tenantId], (old) =>
|
||||
old ? old.filter((o) => o.id !== userId) : [],
|
||||
);
|
||||
return { previousOwners };
|
||||
},
|
||||
onSuccess: () => {
|
||||
setTimeout(() => {
|
||||
queryClient.invalidateQueries({ queryKey: ["tenant-owners", tenantId] });
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: ["tenant-owners", tenantId],
|
||||
});
|
||||
}, 1000);
|
||||
toast.success(
|
||||
t(
|
||||
@@ -141,7 +164,10 @@ export function TenantAdminsAndOwnersTab() {
|
||||
},
|
||||
onError: (err: AxiosError<{ error?: string }>, userId, context) => {
|
||||
if (context?.previousOwners) {
|
||||
queryClient.setQueryData(["tenant-owners", tenantId], context.previousOwners);
|
||||
queryClient.setQueryData(
|
||||
["tenant-owners", tenantId],
|
||||
context.previousOwners,
|
||||
);
|
||||
}
|
||||
toast.error(
|
||||
err.response?.data?.error ||
|
||||
@@ -153,22 +179,35 @@ export function TenantAdminsAndOwnersTab() {
|
||||
const addAdminMutation = useMutation({
|
||||
mutationFn: (userId: string) => addTenantAdmin(tenantId, userId),
|
||||
onMutate: async (userId) => {
|
||||
await queryClient.cancelQueries({ queryKey: ["tenant-admins", tenantId] });
|
||||
const previousAdmins = queryClient.getQueryData<any[]>(["tenant-admins", tenantId]);
|
||||
|
||||
const addedUser = searchResults.find(u => u.id === userId);
|
||||
await queryClient.cancelQueries({
|
||||
queryKey: ["tenant-admins", tenantId],
|
||||
});
|
||||
const previousAdmins = queryClient.getQueryData<any[]>([
|
||||
"tenant-admins",
|
||||
tenantId,
|
||||
]);
|
||||
|
||||
const addedUser = searchResults.find((u) => u.id === userId);
|
||||
if (addedUser) {
|
||||
queryClient.setQueryData<any[]>(["tenant-admins", tenantId], old => {
|
||||
if (!old) return [{ id: userId, name: addedUser.name, email: addedUser.email }];
|
||||
if (old.some(a => a.id === userId)) return old;
|
||||
return [...old, { id: userId, name: addedUser.name, email: addedUser.email }];
|
||||
queryClient.setQueryData<any[]>(["tenant-admins", tenantId], (old) => {
|
||||
if (!old)
|
||||
return [
|
||||
{ id: userId, name: addedUser.name, email: addedUser.email },
|
||||
];
|
||||
if (old.some((a) => a.id === userId)) return old;
|
||||
return [
|
||||
...old,
|
||||
{ id: userId, name: addedUser.name, email: addedUser.email },
|
||||
];
|
||||
});
|
||||
}
|
||||
return { previousAdmins };
|
||||
},
|
||||
onSuccess: () => {
|
||||
setTimeout(() => {
|
||||
queryClient.invalidateQueries({ queryKey: ["tenant-admins", tenantId] });
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: ["tenant-admins", tenantId],
|
||||
});
|
||||
}, 1000);
|
||||
toast.success(
|
||||
t("msg.admin.tenants.admins.add_success", "관리자가 추가되었습니다."),
|
||||
@@ -177,7 +216,10 @@ export function TenantAdminsAndOwnersTab() {
|
||||
},
|
||||
onError: (err: AxiosError<{ error?: string }>, userId, context) => {
|
||||
if (context?.previousAdmins) {
|
||||
queryClient.setQueryData(["tenant-admins", tenantId], context.previousAdmins);
|
||||
queryClient.setQueryData(
|
||||
["tenant-admins", tenantId],
|
||||
context.previousAdmins,
|
||||
);
|
||||
}
|
||||
toast.error(
|
||||
err.response?.data?.error ||
|
||||
@@ -189,16 +231,23 @@ export function TenantAdminsAndOwnersTab() {
|
||||
const removeAdminMutation = useMutation({
|
||||
mutationFn: (userId: string) => removeTenantAdmin(tenantId, userId),
|
||||
onMutate: async (userId) => {
|
||||
await queryClient.cancelQueries({ queryKey: ["tenant-admins", tenantId] });
|
||||
const previousAdmins = queryClient.getQueryData<any[]>(["tenant-admins", tenantId]);
|
||||
queryClient.setQueryData<any[]>(["tenant-admins", tenantId], old =>
|
||||
old ? old.filter(a => a.id !== userId) : []
|
||||
await queryClient.cancelQueries({
|
||||
queryKey: ["tenant-admins", tenantId],
|
||||
});
|
||||
const previousAdmins = queryClient.getQueryData<any[]>([
|
||||
"tenant-admins",
|
||||
tenantId,
|
||||
]);
|
||||
queryClient.setQueryData<any[]>(["tenant-admins", tenantId], (old) =>
|
||||
old ? old.filter((a) => a.id !== userId) : [],
|
||||
);
|
||||
return { previousAdmins };
|
||||
},
|
||||
onSuccess: () => {
|
||||
setTimeout(() => {
|
||||
queryClient.invalidateQueries({ queryKey: ["tenant-admins", tenantId] });
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: ["tenant-admins", tenantId],
|
||||
});
|
||||
}, 1000);
|
||||
toast.success(
|
||||
t("msg.admin.tenants.admins.remove_success", "권한이 회수되었습니다."),
|
||||
@@ -206,7 +255,10 @@ export function TenantAdminsAndOwnersTab() {
|
||||
},
|
||||
onError: (err: AxiosError<{ error?: string }>, userId, context) => {
|
||||
if (context?.previousAdmins) {
|
||||
queryClient.setQueryData(["tenant-admins", tenantId], context.previousAdmins);
|
||||
queryClient.setQueryData(
|
||||
["tenant-admins", tenantId],
|
||||
context.previousAdmins,
|
||||
);
|
||||
}
|
||||
toast.error(
|
||||
err.response?.data?.error ||
|
||||
|
||||
Reference in New Issue
Block a user