R: Rework all mutations to mutateAsync
This commit is contained in:
parent
0e62a49fa7
commit
9d09560a17
|
@ -45,12 +45,12 @@ function UserDropdown({ isOpen, hideDropdown }: UserDropdownProps) {
|
||||||
|
|
||||||
function logoutAndRedirect() {
|
function logoutAndRedirect() {
|
||||||
hideDropdown();
|
hideDropdown();
|
||||||
logout(() => router.push(urls.login));
|
void logout().then(() => router.push(urls.login));
|
||||||
}
|
}
|
||||||
|
|
||||||
function gotoAdmin() {
|
function gotoAdmin() {
|
||||||
hideDropdown();
|
hideDropdown();
|
||||||
logout(() => router.push(urls.admin, true));
|
void logout().then(() => router.push(urls.admin, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
function gotoIcons(event: CProps.EventMouse) {
|
function gotoIcons(event: CProps.EventMouse) {
|
||||||
|
|
|
@ -10,10 +10,7 @@ export const useChangePassword = () => {
|
||||||
onSettled: () => client.invalidateQueries({ queryKey: [authApi.baseKey] })
|
onSettled: () => client.invalidateQueries({ queryKey: [authApi.baseKey] })
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
changePassword: (
|
changePassword: (data: IChangePasswordDTO) => mutation.mutateAsync(data),
|
||||||
data: IChangePasswordDTO, //
|
|
||||||
onSuccess?: () => void
|
|
||||||
) => mutation.mutate(data, { onSuccess }),
|
|
||||||
isPending: mutation.isPending,
|
isPending: mutation.isPending,
|
||||||
error: mutation.error,
|
error: mutation.error,
|
||||||
reset: mutation.reset
|
reset: mutation.reset
|
||||||
|
|
|
@ -11,7 +11,7 @@ export const useLogin = () => {
|
||||||
onSuccess: () => client.resetQueries()
|
onSuccess: () => client.resetQueries()
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
login: (data: IUserLoginDTO, onSuccess?: () => void) => mutation.mutate(data, { onSuccess }),
|
login: (data: IUserLoginDTO) => mutation.mutateAsync(data),
|
||||||
isPending: mutation.isPending,
|
isPending: mutation.isPending,
|
||||||
error: mutation.error,
|
error: mutation.error,
|
||||||
reset: mutation.reset
|
reset: mutation.reset
|
||||||
|
|
|
@ -9,5 +9,5 @@ export const useLogout = () => {
|
||||||
mutationFn: authApi.logout,
|
mutationFn: authApi.logout,
|
||||||
onSuccess: () => client.resetQueries()
|
onSuccess: () => client.resetQueries()
|
||||||
});
|
});
|
||||||
return { logout: (onSuccess?: () => void) => mutation.mutate(undefined, { onSuccess }) };
|
return { logout: () => mutation.mutateAsync() };
|
||||||
};
|
};
|
||||||
|
|
|
@ -8,10 +8,7 @@ export const useRequestPasswordReset = () => {
|
||||||
mutationFn: authApi.requestPasswordReset
|
mutationFn: authApi.requestPasswordReset
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
requestPasswordReset: (
|
requestPasswordReset: (data: IRequestPasswordDTO) => mutation.mutateAsync(data),
|
||||||
data: IRequestPasswordDTO, //
|
|
||||||
onSuccess?: () => void
|
|
||||||
) => mutation.mutate(data, { onSuccess }),
|
|
||||||
isPending: mutation.isPending,
|
isPending: mutation.isPending,
|
||||||
error: mutation.error,
|
error: mutation.error,
|
||||||
reset: mutation.reset
|
reset: mutation.reset
|
||||||
|
|
|
@ -12,14 +12,8 @@ export const useResetPassword = () => {
|
||||||
mutationFn: authApi.resetPassword
|
mutationFn: authApi.resetPassword
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
validateToken: (
|
validateToken: (data: IPasswordTokenDTO) => validateMutation.mutateAsync(data),
|
||||||
data: IPasswordTokenDTO, //
|
resetPassword: (data: IResetPasswordDTO) => resetMutation.mutateAsync(data),
|
||||||
onSuccess?: () => void
|
|
||||||
) => validateMutation.mutate(data, { onSuccess }),
|
|
||||||
resetPassword: (
|
|
||||||
data: IResetPasswordDTO, //
|
|
||||||
onSuccess?: () => void
|
|
||||||
) => resetMutation.mutate(data, { onSuccess }),
|
|
||||||
isPending: resetMutation.isPending || validateMutation.isPending,
|
isPending: resetMutation.isPending || validateMutation.isPending,
|
||||||
error: resetMutation.error ?? validateMutation.error,
|
error: resetMutation.error ?? validateMutation.error,
|
||||||
reset: resetMutation.reset
|
reset: resetMutation.reset
|
||||||
|
|
|
@ -10,7 +10,7 @@ function ExpectedAnonymous() {
|
||||||
const router = useConceptNavigation();
|
const router = useConceptNavigation();
|
||||||
|
|
||||||
function logoutAndRedirect() {
|
function logoutAndRedirect() {
|
||||||
logout(() => router.push(urls.login));
|
void logout().then(() => router.push(urls.login));
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -37,7 +37,7 @@ function LoginPage() {
|
||||||
const { login, isPending, error: serverError, reset: clearServerError } = useLogin();
|
const { login, isPending, error: serverError, reset: clearServerError } = useLogin();
|
||||||
|
|
||||||
function onSubmit(data: IUserLoginDTO) {
|
function onSubmit(data: IUserLoginDTO) {
|
||||||
login(data, () => {
|
return login(data).then(() => {
|
||||||
resetField('password');
|
resetField('password');
|
||||||
if (router.canBack()) {
|
if (router.canBack()) {
|
||||||
router.back();
|
router.back();
|
||||||
|
|
|
@ -19,7 +19,7 @@ export function Component() {
|
||||||
|
|
||||||
const { validateToken, resetPassword, isPending, error: serverError } = useResetPassword();
|
const { validateToken, resetPassword, isPending, error: serverError } = useResetPassword();
|
||||||
|
|
||||||
const [isTokenValidated, setIsTokenValidated] = useState(false);
|
const [isTokenValidating, setIsTokenValidating] = useState(false);
|
||||||
const [newPassword, setNewPassword] = useState('');
|
const [newPassword, setNewPassword] = useState('');
|
||||||
const [newPasswordRepeat, setNewPasswordRepeat] = useState('');
|
const [newPasswordRepeat, setNewPasswordRepeat] = useState('');
|
||||||
|
|
||||||
|
@ -31,25 +31,22 @@ export function Component() {
|
||||||
function handleSubmit(event: React.FormEvent<HTMLFormElement>) {
|
function handleSubmit(event: React.FormEvent<HTMLFormElement>) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
if (!isPending) {
|
if (!isPending) {
|
||||||
resetPassword(
|
void resetPassword({
|
||||||
{
|
|
||||||
password: newPassword,
|
password: newPassword,
|
||||||
token: token
|
token: token
|
||||||
},
|
}).then(() => {
|
||||||
() => {
|
|
||||||
router.replace(urls.home);
|
router.replace(urls.home);
|
||||||
router.push(urls.login);
|
router.push(urls.login);
|
||||||
}
|
});
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!isTokenValidated && !isPending) {
|
if (!isTokenValidating && !isPending) {
|
||||||
validateToken({ token: token });
|
void validateToken({ token: token });
|
||||||
setIsTokenValidated(true);
|
setIsTokenValidating(true);
|
||||||
}
|
}
|
||||||
}, [token, validateToken, isTokenValidated, isPending]);
|
}, [token, validateToken, isTokenValidating, isPending]);
|
||||||
|
|
||||||
if (isPending) {
|
if (isPending) {
|
||||||
return <Loader />;
|
return <Loader />;
|
||||||
|
|
|
@ -19,7 +19,7 @@ export function Component() {
|
||||||
function handleSubmit(event: React.FormEvent<HTMLFormElement>) {
|
function handleSubmit(event: React.FormEvent<HTMLFormElement>) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
if (!isPending) {
|
if (!isPending) {
|
||||||
requestPasswordReset({ email: email }, () => setIsCompleted(true));
|
void requestPasswordReset({ email: email }).then(() => setIsCompleted(true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
||||||
|
|
||||||
import { DataCallback } from '@/backend/apiTransport';
|
|
||||||
import { IRSFormDTO } from '@/features/rsform/backend/api';
|
|
||||||
|
|
||||||
import { ICloneLibraryItemDTO, libraryApi } from './api';
|
import { ICloneLibraryItemDTO, libraryApi } from './api';
|
||||||
|
|
||||||
export const useCloneItem = () => {
|
export const useCloneItem = () => {
|
||||||
|
@ -13,9 +10,6 @@ export const useCloneItem = () => {
|
||||||
onSuccess: () => client.invalidateQueries({ queryKey: [libraryApi.baseKey] })
|
onSuccess: () => client.invalidateQueries({ queryKey: [libraryApi.baseKey] })
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
cloneItem: (
|
cloneItem: (data: ICloneLibraryItemDTO) => mutation.mutateAsync(data)
|
||||||
data: ICloneLibraryItemDTO, //
|
|
||||||
onSuccess?: DataCallback<IRSFormDTO>
|
|
||||||
) => mutation.mutate(data, { onSuccess })
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
||||||
|
|
||||||
import { DataCallback } from '@/backend/apiTransport';
|
|
||||||
|
|
||||||
import { ILibraryItem } from '../models/library';
|
|
||||||
import { ICreateLibraryItemDTO, libraryApi } from './api';
|
import { ICreateLibraryItemDTO, libraryApi } from './api';
|
||||||
|
|
||||||
export const useCreateItem = () => {
|
export const useCreateItem = () => {
|
||||||
|
@ -13,10 +10,7 @@ export const useCreateItem = () => {
|
||||||
onSuccess: () => client.invalidateQueries({ queryKey: [libraryApi.baseKey] })
|
onSuccess: () => client.invalidateQueries({ queryKey: [libraryApi.baseKey] })
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
createItem: (
|
createItem: (data: ICreateLibraryItemDTO) => mutation.mutateAsync(data),
|
||||||
data: ICreateLibraryItemDTO, //
|
|
||||||
onSuccess?: DataCallback<ILibraryItem>
|
|
||||||
) => mutation.mutate(data, { onSuccess }),
|
|
||||||
isPending: mutation.isPending,
|
isPending: mutation.isPending,
|
||||||
error: mutation.error,
|
error: mutation.error,
|
||||||
reset: mutation.reset
|
reset: mutation.reset
|
||||||
|
|
|
@ -26,10 +26,7 @@ export const useDeleteItem = () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
deleteItem: (
|
deleteItem: (target: LibraryItemID) => mutation.mutateAsync(target),
|
||||||
target: LibraryItemID, //
|
|
||||||
onSuccess?: () => void
|
|
||||||
) => mutation.mutate(target, { onSuccess }),
|
|
||||||
isPending: mutation.isPending
|
isPending: mutation.isPending
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -18,9 +18,6 @@ export const useRenameLocation = () => {
|
||||||
])
|
])
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
renameLocation: (
|
renameLocation: (data: IRenameLocationDTO) => mutation.mutateAsync(data)
|
||||||
data: IRenameLocationDTO, //
|
|
||||||
onSuccess?: () => void
|
|
||||||
) => mutation.mutate(data, { onSuccess })
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -39,6 +39,6 @@ export const useSetAccessPolicy = () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
setAccessPolicy: (data: { itemID: LibraryItemID; policy: AccessPolicy }) => mutation.mutate(data)
|
setAccessPolicy: (data: { itemID: LibraryItemID; policy: AccessPolicy }) => mutation.mutateAsync(data)
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -36,6 +36,6 @@ export const useSetEditors = () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
setEditors: (data: { itemID: LibraryItemID; editors: UserID[] }) => mutation.mutate(data)
|
setEditors: (data: { itemID: LibraryItemID; editors: UserID[] }) => mutation.mutateAsync(data)
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -39,12 +39,6 @@ export const useSetLocation = () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
setLocation: (
|
setLocation: (data: { itemID: LibraryItemID; location: string }) => mutation.mutateAsync(data)
|
||||||
data: {
|
|
||||||
itemID: LibraryItemID; //
|
|
||||||
location: string;
|
|
||||||
},
|
|
||||||
onSuccess?: () => void
|
|
||||||
) => mutation.mutate(data, { onSuccess })
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -40,6 +40,6 @@ export const useSetOwner = () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
setOwner: (data: { itemID: LibraryItemID; owner: UserID }) => mutation.mutate(data)
|
setOwner: (data: { itemID: LibraryItemID; owner: UserID }) => mutation.mutateAsync(data)
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -32,6 +32,6 @@ export const useUpdateItem = () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
updateItem: (data: IUpdateLibraryItemDTO, onSuccess?: () => void) => mutation.mutate(data, { onSuccess })
|
updateItem: (data: IUpdateLibraryItemDTO) => mutation.mutateAsync(data)
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
||||||
|
|
||||||
import { DataCallback } from '@/backend/apiTransport';
|
|
||||||
import { rsformsApi } from '@/features/rsform/backend/api';
|
import { rsformsApi } from '@/features/rsform/backend/api';
|
||||||
|
|
||||||
import { LibraryItemID, VersionID } from '../models/library';
|
import { LibraryItemID } from '../models/library';
|
||||||
import { IVersionCreateDTO, libraryApi } from './api';
|
import { IVersionCreateDTO, libraryApi } from './api';
|
||||||
import { useUpdateTimestamp } from './useUpdateTimestamp';
|
import { useUpdateTimestamp } from './useUpdateTimestamp';
|
||||||
|
|
||||||
|
@ -19,12 +18,7 @@ export const useVersionCreate = () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
versionCreate: (
|
versionCreate: (data: { itemID: LibraryItemID; data: IVersionCreateDTO }) =>
|
||||||
data: {
|
mutation.mutateAsync(data).then(response => response.version)
|
||||||
itemID: LibraryItemID; //
|
|
||||||
data: IVersionCreateDTO;
|
|
||||||
},
|
|
||||||
onSuccess?: DataCallback<VersionID>
|
|
||||||
) => mutation.mutate(data, { onSuccess: response => onSuccess?.(response.version) })
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -24,12 +24,6 @@ export const useVersionDelete = () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
versionDelete: (
|
versionDelete: (data: { itemID: LibraryItemID; versionID: VersionID }) => mutation.mutateAsync(data)
|
||||||
data: {
|
|
||||||
itemID: LibraryItemID; //
|
|
||||||
versionID: VersionID;
|
|
||||||
},
|
|
||||||
onSuccess?: () => void
|
|
||||||
) => mutation.mutate(data, { onSuccess })
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -16,6 +16,6 @@ export const useVersionRestore = () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
versionRestore: (data: { versionID: VersionID }, onSuccess?: () => void) => mutation.mutate(data, { onSuccess })
|
versionRestore: (data: { versionID: VersionID }) => mutation.mutateAsync(data)
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -27,6 +27,6 @@ export const useVersionUpdate = () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
versionUpdate: (data: IVersionUpdateDTO, onSuccess?: () => void) => mutation.mutate(data, { onSuccess })
|
versionUpdate: (data: IVersionUpdateDTO) => mutation.mutateAsync(data)
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -86,7 +86,7 @@ function FormCreateItem() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function onSubmit(data: ICreateLibraryItemDTO) {
|
function onSubmit(data: ICreateLibraryItemDTO) {
|
||||||
createItem(data, newItem => {
|
return createItem(data).then(newItem => {
|
||||||
setSearchLocation(data.location);
|
setSearchLocation(data.location);
|
||||||
if (newItem.item_type == LibraryItemType.RSFORM) {
|
if (newItem.item_type == LibraryItemType.RSFORM) {
|
||||||
router.push(urls.schema(newItem.id));
|
router.push(urls.schema(newItem.id));
|
||||||
|
|
|
@ -35,13 +35,10 @@ export function LibraryPage() {
|
||||||
const showChangeLocation = useDialogsStore(state => state.showChangeLocation);
|
const showChangeLocation = useDialogsStore(state => state.showChangeLocation);
|
||||||
|
|
||||||
function handleRenameLocation(newLocation: string) {
|
function handleRenameLocation(newLocation: string) {
|
||||||
renameLocation(
|
void renameLocation({
|
||||||
{
|
|
||||||
target: location,
|
target: location,
|
||||||
new_location: newLocation
|
new_location: newLocation
|
||||||
},
|
}).then(() => setLocation(newLocation));
|
||||||
() => setLocation(newLocation)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleDownloadCSV() {
|
function handleDownloadCSV() {
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import { useMutation } from '@tanstack/react-query';
|
import { useMutation } from '@tanstack/react-query';
|
||||||
|
|
||||||
import { DataCallback } from '@/backend/apiTransport';
|
import { ITargetCst } from '@/features/rsform/models/rsform';
|
||||||
import { IConstituentaReference, ITargetCst } from '@/features/rsform/models/rsform';
|
|
||||||
|
|
||||||
import { ossApi } from './api';
|
import { ossApi } from './api';
|
||||||
|
|
||||||
|
@ -11,9 +10,6 @@ export const useFindPredecessor = () => {
|
||||||
mutationFn: ossApi.getPredecessor
|
mutationFn: ossApi.getPredecessor
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
findPredecessor: (
|
findPredecessor: (data: ITargetCst) => mutation.mutateAsync(data)
|
||||||
data: ITargetCst, //
|
|
||||||
onSuccess?: DataCallback<IConstituentaReference>
|
|
||||||
) => mutation.mutate(data, { onSuccess })
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
||||||
|
|
||||||
import { DataCallback } from '@/backend/apiTransport';
|
|
||||||
import { libraryApi } from '@/features/library/backend/api';
|
import { libraryApi } from '@/features/library/backend/api';
|
||||||
import { ILibraryItem, LibraryItemID } from '@/features/library/models/library';
|
import { LibraryItemID } from '@/features/library/models/library';
|
||||||
import { rsformsApi } from '@/features/rsform/backend/api';
|
import { rsformsApi } from '@/features/rsform/backend/api';
|
||||||
|
|
||||||
import { ITargetOperation, ossApi } from './api';
|
import { ITargetOperation, ossApi } from './api';
|
||||||
|
@ -21,12 +20,7 @@ export const useInputCreate = () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
inputCreate: (
|
inputCreate: (data: { itemID: LibraryItemID; data: ITargetOperation }) =>
|
||||||
data: {
|
mutation.mutateAsync(data).then(response => response.new_schema)
|
||||||
itemID: LibraryItemID; //
|
|
||||||
data: ITargetOperation;
|
|
||||||
},
|
|
||||||
onSuccess?: DataCallback<ILibraryItem>
|
|
||||||
) => mutation.mutate(data, { onSuccess: response => onSuccess?.(response.new_schema) })
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -20,6 +20,6 @@ export const useInputUpdate = () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
inputUpdate: (data: { itemID: LibraryItemID; data: IInputUpdateDTO }) => mutation.mutate(data)
|
inputUpdate: (data: { itemID: LibraryItemID; data: IInputUpdateDTO }) => mutation.mutateAsync(data)
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -20,6 +20,6 @@ export const useOperationDelete = () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
operationDelete: (data: { itemID: LibraryItemID; data: IOperationDeleteDTO }) => mutation.mutate(data)
|
operationDelete: (data: { itemID: LibraryItemID; data: IOperationDeleteDTO }) => mutation.mutateAsync(data)
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -20,6 +20,6 @@ export const useOperationExecute = () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
operationExecute: (data: { itemID: LibraryItemID; data: ITargetOperation }) => mutation.mutate(data)
|
operationExecute: (data: { itemID: LibraryItemID; data: ITargetOperation }) => mutation.mutateAsync(data)
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -30,6 +30,6 @@ export const useOperationUpdate = () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
operationUpdate: (data: { itemID: LibraryItemID; data: IOperationUpdateDTO }) => mutation.mutate(data)
|
operationUpdate: (data: { itemID: LibraryItemID; data: IOperationUpdateDTO }) => mutation.mutateAsync(data)
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -19,6 +19,6 @@ export const useRelocateConstituents = () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
relocateConstituents: (data: ICstRelocateDTO) => mutation.mutate(data)
|
relocateConstituents: (data: ICstRelocateDTO) => mutation.mutateAsync(data)
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -13,13 +13,10 @@ export const useUpdatePositions = () => {
|
||||||
onSuccess: (_, variables) => updateTimestamp(variables.itemID)
|
onSuccess: (_, variables) => updateTimestamp(variables.itemID)
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
updatePositions: (
|
updatePositions: (data: {
|
||||||
data: {
|
|
||||||
itemID: LibraryItemID; //
|
itemID: LibraryItemID; //
|
||||||
positions: IOperationPosition[];
|
positions: IOperationPosition[];
|
||||||
isSilent?: boolean;
|
isSilent?: boolean;
|
||||||
},
|
}) => mutation.mutateAsync(data)
|
||||||
onSuccess?: () => void
|
|
||||||
) => mutation.mutate(data, { onSuccess })
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -45,7 +45,7 @@ function DlgChangeInputSchema() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function onSubmit(data: IInputUpdateDTO) {
|
function onSubmit(data: IInputUpdateDTO) {
|
||||||
inputUpdate({ itemID: oss.id, data: data });
|
return inputUpdate({ itemID: oss.id, data: data });
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -68,9 +68,7 @@ function DlgCreateOperation() {
|
||||||
});
|
});
|
||||||
data.item_data.position_x = target.x;
|
data.item_data.position_x = target.x;
|
||||||
data.item_data.position_y = target.y;
|
data.item_data.position_y = target.y;
|
||||||
operationCreate({ itemID: oss.id, data: data })
|
void operationCreate({ itemID: oss.id, data: data }).then(response => onCreate?.(response.new_operation.id));
|
||||||
.then(response => onCreate?.(response.new_operation.id))
|
|
||||||
.catch(console.error);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleSelectTab(newTab: TabID, last: TabID) {
|
function handleSelectTab(newTab: TabID, last: TabID) {
|
||||||
|
|
|
@ -34,7 +34,7 @@ function DlgDeleteOperation() {
|
||||||
});
|
});
|
||||||
|
|
||||||
function onSubmit(data: IOperationDeleteDTO) {
|
function onSubmit(data: IOperationDeleteDTO) {
|
||||||
operationDelete({ itemID: oss.id, data: data });
|
return operationDelete({ itemID: oss.id, data: data });
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -104,16 +104,13 @@ function DlgRelocateConstituents() {
|
||||||
return operation.position_x === item.position_x && operation.position_y === item.position_y;
|
return operation.position_x === item.position_x && operation.position_y === item.position_y;
|
||||||
});
|
});
|
||||||
if (positionsUnchanged) {
|
if (positionsUnchanged) {
|
||||||
relocateConstituents(data);
|
return relocateConstituents(data);
|
||||||
} else {
|
} else {
|
||||||
updatePositions(
|
return updatePositions({
|
||||||
{
|
|
||||||
isSilent: true,
|
isSilent: true,
|
||||||
itemID: oss.id,
|
itemID: oss.id,
|
||||||
positions: positions
|
positions: positions
|
||||||
},
|
}).then(() => relocateConstituents(data));
|
||||||
() => relocateConstituents(data)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ function FormOSS() {
|
||||||
}, [isDirty, setIsModified]);
|
}, [isDirty, setIsModified]);
|
||||||
|
|
||||||
function onSubmit(data: IUpdateLibraryItemDTO) {
|
function onSubmit(data: IUpdateLibraryItemDTO) {
|
||||||
updateOss(data, () => reset({ ...data }));
|
return updateOss(data).then(() => reset({ ...data }));
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -123,7 +123,7 @@ function OssFlow() {
|
||||||
|
|
||||||
function handleSavePositions() {
|
function handleSavePositions() {
|
||||||
const positions = getPositions();
|
const positions = getPositions();
|
||||||
updatePositions({ itemID: controller.schema.id, positions: positions }, () => {
|
void updatePositions({ itemID: controller.schema.id, positions: positions }).then(() => {
|
||||||
positions.forEach(item => {
|
positions.forEach(item => {
|
||||||
const operation = controller.schema.operationByID.get(item.id);
|
const operation = controller.schema.operationByID.get(item.id);
|
||||||
if (operation) {
|
if (operation) {
|
||||||
|
@ -170,9 +170,10 @@ function OssFlow() {
|
||||||
toast.error(errors.inputAlreadyExists);
|
toast.error(errors.inputAlreadyExists);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
inputCreate({ itemID: controller.schema.id, data: { target: target, positions: getPositions() } }, new_schema =>
|
void inputCreate({
|
||||||
router.push(urls.schema(new_schema.id))
|
itemID: controller.schema.id,
|
||||||
);
|
data: { target: target, positions: getPositions() }
|
||||||
|
}).then(new_schema => router.push(urls.schema(new_schema.id)));
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleEditSchema(target: OperationID) {
|
function handleEditSchema(target: OperationID) {
|
||||||
|
@ -184,7 +185,7 @@ function OssFlow() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleOperationExecute(target: OperationID) {
|
function handleOperationExecute(target: OperationID) {
|
||||||
operationExecute({
|
void operationExecute({
|
||||||
itemID: controller.schema.id, //
|
itemID: controller.schema.id, //
|
||||||
data: { target: target, positions: getPositions() }
|
data: { target: target, positions: getPositions() }
|
||||||
});
|
});
|
||||||
|
|
|
@ -128,7 +128,7 @@ export const OssEditState = ({ itemID, children }: React.PropsWithChildren<OssEd
|
||||||
if (!window.confirm(prompts.deleteOSS)) {
|
if (!window.confirm(prompts.deleteOSS)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
deleteItem(schema.id, () => {
|
void deleteItem(schema.id).then(() => {
|
||||||
if (searchLocation === schema.location) {
|
if (searchLocation === schema.location) {
|
||||||
setSearchLocation('');
|
setSearchLocation('');
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
import { useMutation } from '@tanstack/react-query';
|
import { useMutation } from '@tanstack/react-query';
|
||||||
|
|
||||||
import { DataCallback } from '@/backend/apiTransport';
|
import { cctextApi } from './api';
|
||||||
|
|
||||||
import { cctextApi, ILexemeResponse } from './api';
|
|
||||||
|
|
||||||
export const useGenerateLexeme = () => {
|
export const useGenerateLexeme = () => {
|
||||||
const mutation = useMutation({
|
const mutation = useMutation({
|
||||||
|
@ -10,9 +8,6 @@ export const useGenerateLexeme = () => {
|
||||||
mutationFn: cctextApi.generateLexeme
|
mutationFn: cctextApi.generateLexeme
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
generateLexeme: (
|
generateLexeme: (data: { text: string }) => mutation.mutateAsync(data)
|
||||||
data: { text: string }, //
|
|
||||||
onSuccess?: DataCallback<ILexemeResponse>
|
|
||||||
) => mutation.mutate(data, { onSuccess })
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
import { useMutation } from '@tanstack/react-query';
|
import { useMutation } from '@tanstack/react-query';
|
||||||
|
|
||||||
import { DataCallback } from '@/backend/apiTransport';
|
import { cctextApi, IWordFormDTO } from './api';
|
||||||
|
|
||||||
import { cctextApi, ITextResult, IWordFormDTO } from './api';
|
|
||||||
|
|
||||||
export const useInflectText = () => {
|
export const useInflectText = () => {
|
||||||
const mutation = useMutation({
|
const mutation = useMutation({
|
||||||
|
@ -10,9 +8,6 @@ export const useInflectText = () => {
|
||||||
mutationFn: cctextApi.inflectText
|
mutationFn: cctextApi.inflectText
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
inflectText: (
|
inflectText: (data: IWordFormDTO) => mutation.mutateAsync(data)
|
||||||
data: IWordFormDTO, //
|
|
||||||
onSuccess?: DataCallback<ITextResult>
|
|
||||||
) => mutation.mutate(data, { onSuccess })
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
import { useMutation } from '@tanstack/react-query';
|
import { useMutation } from '@tanstack/react-query';
|
||||||
|
|
||||||
import { DataCallback } from '@/backend/apiTransport';
|
import { cctextApi } from './api';
|
||||||
|
|
||||||
import { cctextApi, ITextResult } from './api';
|
|
||||||
|
|
||||||
export const useParseText = () => {
|
export const useParseText = () => {
|
||||||
const mutation = useMutation({
|
const mutation = useMutation({
|
||||||
|
@ -10,9 +8,6 @@ export const useParseText = () => {
|
||||||
mutationFn: cctextApi.parseText
|
mutationFn: cctextApi.parseText
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
parseText: (
|
parseText: (data: { text: string }) => mutation.mutateAsync(data)
|
||||||
data: { text: string }, //
|
|
||||||
onSuccess?: DataCallback<ITextResult>
|
|
||||||
) => mutation.mutate(data, { onSuccess })
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
import { useMutation } from '@tanstack/react-query';
|
import { useMutation } from '@tanstack/react-query';
|
||||||
|
|
||||||
import { DataCallback } from '@/backend/apiTransport';
|
|
||||||
import { LibraryItemID } from '@/features/library/models/library';
|
import { LibraryItemID } from '@/features/library/models/library';
|
||||||
|
|
||||||
import { IExpressionParse } from '../models/rslang';
|
|
||||||
import { ICheckConstituentaDTO, rsformsApi } from './api';
|
import { ICheckConstituentaDTO, rsformsApi } from './api';
|
||||||
|
|
||||||
export const useCheckConstituenta = () => {
|
export const useCheckConstituenta = () => {
|
||||||
|
@ -12,13 +10,7 @@ export const useCheckConstituenta = () => {
|
||||||
mutationFn: rsformsApi.checkConstituenta
|
mutationFn: rsformsApi.checkConstituenta
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
checkConstituenta: (
|
checkConstituenta: (data: { itemID: LibraryItemID; data: ICheckConstituentaDTO }) => mutation.mutateAsync(data),
|
||||||
data: {
|
|
||||||
itemID: LibraryItemID; //
|
|
||||||
data: ICheckConstituentaDTO;
|
|
||||||
},
|
|
||||||
onSuccess?: DataCallback<IExpressionParse>
|
|
||||||
) => mutation.mutate(data, { onSuccess }),
|
|
||||||
isPending: mutation.isPending,
|
isPending: mutation.isPending,
|
||||||
error: mutation.error
|
error: mutation.error
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
||||||
|
|
||||||
import { DataCallback } from '@/backend/apiTransport';
|
|
||||||
import { useUpdateTimestamp } from '@/features/library/backend/useUpdateTimestamp';
|
import { useUpdateTimestamp } from '@/features/library/backend/useUpdateTimestamp';
|
||||||
import { LibraryItemID } from '@/features/library/models/library';
|
import { LibraryItemID } from '@/features/library/models/library';
|
||||||
import { ossApi } from '@/features/oss/backend/api';
|
import { ossApi } from '@/features/oss/backend/api';
|
||||||
|
|
||||||
import { IConstituentaMeta } from '../models/rsform';
|
|
||||||
import { ICstCreateDTO, rsformsApi } from './api';
|
import { ICstCreateDTO, rsformsApi } from './api';
|
||||||
|
|
||||||
export const useCstCreate = () => {
|
export const useCstCreate = () => {
|
||||||
|
@ -28,12 +26,7 @@ export const useCstCreate = () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
cstCreate: (
|
cstCreate: (data: { itemID: LibraryItemID; data: ICstCreateDTO }) =>
|
||||||
data: {
|
mutation.mutateAsync(data).then(response => response.new_cst)
|
||||||
itemID: LibraryItemID; //
|
|
||||||
data: ICstCreateDTO;
|
|
||||||
},
|
|
||||||
onSuccess?: DataCallback<IConstituentaMeta>
|
|
||||||
) => mutation.mutate(data, { onSuccess: response => onSuccess?.(response.new_cst) })
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -27,12 +27,6 @@ export const useCstDelete = () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
cstDelete: (
|
cstDelete: (data: { itemID: LibraryItemID; data: IConstituentaList }) => mutation.mutateAsync(data)
|
||||||
data: {
|
|
||||||
itemID: LibraryItemID; //
|
|
||||||
data: IConstituentaList;
|
|
||||||
},
|
|
||||||
onSuccess?: () => void
|
|
||||||
) => mutation.mutate(data, { onSuccess })
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -17,12 +17,6 @@ export const useCstMove = () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
cstMove: (
|
cstMove: (data: { itemID: LibraryItemID; data: ICstMoveDTO }) => mutation.mutateAsync(data)
|
||||||
data: {
|
|
||||||
itemID: LibraryItemID; //
|
|
||||||
data: ICstMoveDTO;
|
|
||||||
},
|
|
||||||
onSuccess?: () => void
|
|
||||||
) => mutation.mutate(data, { onSuccess })
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -26,6 +26,6 @@ export const useCstRename = () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
cstRename: (data: { itemID: LibraryItemID; data: ICstRenameDTO }) => mutation.mutate(data)
|
cstRename: (data: { itemID: LibraryItemID; data: ICstRenameDTO }) => mutation.mutateAsync(data)
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -27,12 +27,6 @@ export const useCstSubstitute = () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
cstSubstitute: (
|
cstSubstitute: (data: { itemID: LibraryItemID; data: ICstSubstitutions }) => mutation.mutateAsync(data)
|
||||||
data: {
|
|
||||||
itemID: LibraryItemID; //
|
|
||||||
data: ICstSubstitutions;
|
|
||||||
},
|
|
||||||
onSuccess?: () => void
|
|
||||||
) => mutation.mutate(data, { onSuccess })
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -22,7 +22,6 @@ export const useCstUpdate = () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
cstUpdate: (data: { itemID: LibraryItemID; data: ICstUpdateDTO }, onSuccess?: () => void) =>
|
cstUpdate: (data: { itemID: LibraryItemID; data: ICstUpdateDTO }) => mutation.mutateAsync(data)
|
||||||
mutation.mutate(data, { onSuccess })
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -10,12 +10,6 @@ export const useDownloadRSForm = () => {
|
||||||
mutationFn: rsformsApi.download
|
mutationFn: rsformsApi.download
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
download: (
|
download: (data: { itemID: LibraryItemID; version?: VersionID }) => mutation.mutateAsync(data)
|
||||||
data: {
|
|
||||||
itemID: LibraryItemID; //
|
|
||||||
version?: VersionID;
|
|
||||||
},
|
|
||||||
onSuccess?: (data: Blob) => void
|
|
||||||
) => mutation.mutate(data, { onSuccess })
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
||||||
|
|
||||||
import { DataCallback } from '@/backend/apiTransport';
|
|
||||||
import { useUpdateTimestamp } from '@/features/library/backend/useUpdateTimestamp';
|
import { useUpdateTimestamp } from '@/features/library/backend/useUpdateTimestamp';
|
||||||
import { LibraryItemID } from '@/features/library/models/library';
|
import { LibraryItemID } from '@/features/library/models/library';
|
||||||
import { ossApi } from '@/features/oss/backend/api';
|
import { ossApi } from '@/features/oss/backend/api';
|
||||||
|
|
||||||
import { IInlineSynthesisDTO, IRSFormDTO, rsformsApi } from './api';
|
import { IInlineSynthesisDTO, rsformsApi } from './api';
|
||||||
|
|
||||||
export const useInlineSynthesis = () => {
|
export const useInlineSynthesis = () => {
|
||||||
const client = useQueryClient();
|
const client = useQueryClient();
|
||||||
|
@ -27,12 +26,6 @@ export const useInlineSynthesis = () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
inlineSynthesis: (
|
inlineSynthesis: (data: { itemID: LibraryItemID; data: IInlineSynthesisDTO }) => mutation.mutateAsync(data)
|
||||||
data: {
|
|
||||||
itemID: LibraryItemID; //
|
|
||||||
data: IInlineSynthesisDTO;
|
|
||||||
},
|
|
||||||
onSuccess?: DataCallback<IRSFormDTO>
|
|
||||||
) => mutation.mutate(data, { onSuccess })
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
||||||
|
|
||||||
import { DataCallback } from '@/backend/apiTransport';
|
|
||||||
import { useUpdateTimestamp } from '@/features/library/backend/useUpdateTimestamp';
|
import { useUpdateTimestamp } from '@/features/library/backend/useUpdateTimestamp';
|
||||||
import { LibraryItemID } from '@/features/library/models/library';
|
import { LibraryItemID } from '@/features/library/models/library';
|
||||||
import { ossApi } from '@/features/oss/backend/api';
|
import { ossApi } from '@/features/oss/backend/api';
|
||||||
|
|
||||||
import { ConstituentaID, ITargetCst } from '../models/rsform';
|
import { ITargetCst } from '../models/rsform';
|
||||||
import { rsformsApi } from './api';
|
import { rsformsApi } from './api';
|
||||||
|
|
||||||
export const useProduceStructure = () => {
|
export const useProduceStructure = () => {
|
||||||
|
@ -28,12 +27,7 @@ export const useProduceStructure = () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
produceStructure: (
|
produceStructure: (data: { itemID: LibraryItemID; data: ITargetCst }) =>
|
||||||
data: {
|
mutation.mutateAsync(data).then(response => response.cst_list)
|
||||||
itemID: LibraryItemID; //
|
|
||||||
data: ITargetCst;
|
|
||||||
},
|
|
||||||
onSuccess?: DataCallback<ConstituentaID[]>
|
|
||||||
) => mutation.mutate(data, { onSuccess: response => onSuccess?.(response.cst_list) })
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -26,6 +26,6 @@ export const useResetAliases = () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
resetAliases: (data: { itemID: LibraryItemID }) => mutation.mutate(data)
|
resetAliases: (data: { itemID: LibraryItemID }) => mutation.mutateAsync(data)
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -17,6 +17,6 @@ export const useRestoreOrder = () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
restoreOrder: (data: { itemID: LibraryItemID }) => mutation.mutate(data)
|
restoreOrder: (data: { itemID: LibraryItemID }) => mutation.mutateAsync(data)
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -27,6 +27,6 @@ export const useUploadTRS = () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
upload: (data: IRSFormUploadDTO) => mutation.mutate(data)
|
upload: (data: IRSFormUploadDTO) => mutation.mutateAsync(data)
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -60,7 +60,7 @@ function DlgCloneLibraryItem() {
|
||||||
});
|
});
|
||||||
|
|
||||||
function onSubmit(data: ICloneLibraryItemDTO) {
|
function onSubmit(data: ICloneLibraryItemDTO) {
|
||||||
cloneItem(data, newSchema => router.push(urls.schema(newSchema.id)));
|
return cloneItem(data).then(newSchema => router.push(urls.schema(newSchema.id)));
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -45,7 +45,7 @@ function DlgCreateVersion() {
|
||||||
const canSubmit = !versions.find(ver => ver.version === version);
|
const canSubmit = !versions.find(ver => ver.version === version);
|
||||||
|
|
||||||
function onSubmit(data: IVersionCreateDTO) {
|
function onSubmit(data: IVersionCreateDTO) {
|
||||||
versionCreate({ itemID, data }, onCreate);
|
return versionCreate({ itemID, data }).then(onCreate);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -66,7 +66,7 @@ function DlgEditVersions() {
|
||||||
|
|
||||||
function handleDeleteVersion(targetVersion: VersionID) {
|
function handleDeleteVersion(targetVersion: VersionID) {
|
||||||
const nextVer = schema.versions.find(ver => ver.id !== targetVersion);
|
const nextVer = schema.versions.find(ver => ver.id !== targetVersion);
|
||||||
versionDelete({ itemID: itemID, versionID: targetVersion }, () => {
|
void versionDelete({ itemID: itemID, versionID: targetVersion }).then(() => {
|
||||||
if (!nextVer) {
|
if (!nextVer) {
|
||||||
hideDialog();
|
hideDialog();
|
||||||
} else if (targetVersion === versionID) {
|
} else if (targetVersion === versionID) {
|
||||||
|
@ -80,7 +80,7 @@ function DlgEditVersions() {
|
||||||
if (!isDirty || isProcessing || !isValid) {
|
if (!isDirty || isProcessing || !isValid) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
versionUpdate(data, () => reset({ ...data }));
|
void versionUpdate(data).then(() => reset({ ...data }));
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -78,17 +78,14 @@ function DlgEditWordForms() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleInflect() {
|
function handleInflect() {
|
||||||
inflectText(
|
void inflectText({
|
||||||
{
|
|
||||||
text: term,
|
text: term,
|
||||||
grams: inputGrams.map(gram => gram.value).join(',')
|
grams: inputGrams.map(gram => gram.value).join(',')
|
||||||
},
|
}).then(response => setInputText(response.result));
|
||||||
response => setInputText(response.result)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleParse() {
|
function handleParse() {
|
||||||
parseText({ text: inputText }, response => {
|
void parseText({ text: inputText }).then(response => {
|
||||||
const grams = parseGrammemes(response.result);
|
const grams = parseGrammemes(response.result);
|
||||||
setInputGrams(supportedGrammeOptions.filter(gram => grams.find(test => test === gram.value)));
|
setInputGrams(supportedGrammeOptions.filter(gram => grams.find(test => test === gram.value)));
|
||||||
});
|
});
|
||||||
|
@ -100,14 +97,17 @@ function DlgEditWordForms() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
generateLexeme({ text: inputText }, response => {
|
void generateLexeme({ text: inputText }).then(response => {
|
||||||
const lexeme: IWordForm[] = [];
|
const lexeme: IWordForm[] = [];
|
||||||
response.items.forEach(form => {
|
response.items.forEach(form => {
|
||||||
|
const grams = parseGrammemes(form.grams).filter(gram =>
|
||||||
|
supportedGrammemes.find(item => item === (gram as Grammeme))
|
||||||
|
);
|
||||||
const newForm: IWordForm = {
|
const newForm: IWordForm = {
|
||||||
text: form.text,
|
text: form.text,
|
||||||
grams: parseGrammemes(form.grams).filter(gram => supportedGrammemes.find(item => item === (gram as Grammeme)))
|
grams: grams
|
||||||
};
|
};
|
||||||
if (newForm.grams.length === 2 && !lexeme.some(test => wordFormEquals(test, newForm))) {
|
if (grams.length === 2 && !lexeme.some(test => wordFormEquals(test, newForm))) {
|
||||||
lexeme.push(newForm);
|
lexeme.push(newForm);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -97,7 +97,7 @@ function FormConstituenta({ disabled, id, toggleReset, schema, activeCst, onOpen
|
||||||
}, [isDirty, activeCst, setIsModified]);
|
}, [isDirty, activeCst, setIsModified]);
|
||||||
|
|
||||||
function onSubmit(data: ICstUpdateDTO) {
|
function onSubmit(data: ICstUpdateDTO) {
|
||||||
cstUpdate({ itemID: schema.id, data }, () => reset({ ...data }));
|
return cstUpdate({ itemID: schema.id, data }).then(() => reset({ ...data }));
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleTypeGraph(event: CProps.EventMouse) {
|
function handleTypeGraph(event: CProps.EventMouse) {
|
||||||
|
|
|
@ -55,7 +55,7 @@ function ToolbarConstituenta({
|
||||||
const isProcessing = useMutatingRSForm();
|
const isProcessing = useMutatingRSForm();
|
||||||
|
|
||||||
function viewPredecessor(target: ConstituentaID) {
|
function viewPredecessor(target: ConstituentaID) {
|
||||||
findPredecessor({ target: target }, reference =>
|
void findPredecessor({ target: target }).then(reference =>
|
||||||
router.push(
|
router.push(
|
||||||
urls.schema_props({
|
urls.schema_props({
|
||||||
id: reference.schema,
|
id: reference.schema,
|
||||||
|
|
|
@ -75,7 +75,7 @@ function EditorRSExpression({
|
||||||
alias: activeCst.alias,
|
alias: activeCst.alias,
|
||||||
cst_type: activeCst.cst_type
|
cst_type: activeCst.cst_type
|
||||||
};
|
};
|
||||||
checkInternal({ itemID: controller.schema.id, data }, parse => {
|
void checkInternal({ itemID: controller.schema.id, data }).then(parse => {
|
||||||
setParseData(parse);
|
setParseData(parse);
|
||||||
onSuccess?.(parse);
|
onSuccess?.(parse);
|
||||||
});
|
});
|
||||||
|
|
|
@ -60,7 +60,7 @@ function FormRSForm() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function onSubmit(data: IUpdateLibraryItemDTO) {
|
function onSubmit(data: IUpdateLibraryItemDTO) {
|
||||||
updateSchema(data, () => reset({ ...data }));
|
return updateSchema(data).then(() => reset({ ...data }));
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -30,7 +30,7 @@ function ToolbarVersioning({ blockReload }: ToolbarVersioningProps) {
|
||||||
if (!controller.schema.version || !window.confirm(prompts.restoreArchive)) {
|
if (!controller.schema.version || !window.confirm(prompts.restoreArchive)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
versionRestore({ versionID: controller.schema.version }, () => controller.navigateVersion(undefined));
|
void versionRestore({ versionID: controller.schema.version }).then(() => controller.navigateVersion(undefined));
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleCreateVersion() {
|
function handleCreateVersion() {
|
||||||
|
|
|
@ -109,19 +109,16 @@ function MenuRSTabs() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const fileName = (controller.schema.alias ?? 'Schema') + EXTEOR_TRS_FILE;
|
const fileName = (controller.schema.alias ?? 'Schema') + EXTEOR_TRS_FILE;
|
||||||
download(
|
void download({
|
||||||
{
|
itemID: controller.schema.id,
|
||||||
itemID: controller.schema.id, //
|
|
||||||
version: controller.schema.version
|
version: controller.schema.version
|
||||||
},
|
}).then((data: Blob) => {
|
||||||
(data: Blob) => {
|
|
||||||
try {
|
try {
|
||||||
fileDownload(data, fileName);
|
fileDownload(data, fileName);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleUpload() {
|
function handleUpload() {
|
||||||
|
@ -154,12 +151,12 @@ function MenuRSTabs() {
|
||||||
|
|
||||||
function handleReindex() {
|
function handleReindex() {
|
||||||
editMenu.hide();
|
editMenu.hide();
|
||||||
resetAliases({ itemID: controller.schema.id });
|
void resetAliases({ itemID: controller.schema.id });
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleRestoreOrder() {
|
function handleRestoreOrder() {
|
||||||
editMenu.hide();
|
editMenu.hide();
|
||||||
restoreOrder({ itemID: controller.schema.id });
|
void restoreOrder({ itemID: controller.schema.id });
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleSubstituteCst() {
|
function handleSubstituteCst() {
|
||||||
|
@ -170,14 +167,8 @@ function MenuRSTabs() {
|
||||||
showSubstituteCst({
|
showSubstituteCst({
|
||||||
schema: controller.schema,
|
schema: controller.schema,
|
||||||
onSubstitute: data =>
|
onSubstitute: data =>
|
||||||
cstSubstitute(
|
void cstSubstitute({ itemID: controller.schema.id, data }).then(() =>
|
||||||
{
|
controller.setSelected(prev => prev.filter(id => !data.substitutions.find(sub => sub.original === id)))
|
||||||
itemID: controller.schema.id,
|
|
||||||
data
|
|
||||||
},
|
|
||||||
() => {
|
|
||||||
controller.setSelected(prev => prev.filter(id => !data.substitutions.find(sub => sub.original === id)));
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -195,17 +186,14 @@ function MenuRSTabs() {
|
||||||
if (isModified && !promptUnsaved()) {
|
if (isModified && !promptUnsaved()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
produceStructure(
|
void produceStructure({
|
||||||
{
|
itemID: controller.schema.id,
|
||||||
itemID: controller.schema.id, //
|
|
||||||
data: { target: controller.activeCst.id }
|
data: { target: controller.activeCst.id }
|
||||||
},
|
}).then(cstList => {
|
||||||
cstList => {
|
|
||||||
if (cstList.length !== 0) {
|
if (cstList.length !== 0) {
|
||||||
controller.setSelected(cstList);
|
controller.setSelected(cstList);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleInlineSynthesis() {
|
function handleInlineSynthesis() {
|
||||||
|
@ -216,7 +204,7 @@ function MenuRSTabs() {
|
||||||
showInlineSynthesis({
|
showInlineSynthesis({
|
||||||
receiver: controller.schema,
|
receiver: controller.schema,
|
||||||
onInlineSynthesis: data => {
|
onInlineSynthesis: data => {
|
||||||
inlineSynthesis({ itemID: controller.schema.id, data }, () => controller.deselectAll());
|
void inlineSynthesis({ itemID: controller.schema.id, data }).then(() => controller.deselectAll());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -170,7 +170,7 @@ export const RSEditState = ({
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const ossID = schema.oss.length > 0 ? schema.oss[0].id : undefined;
|
const ossID = schema.oss.length > 0 ? schema.oss[0].id : undefined;
|
||||||
deleteItem(schema.id, () => {
|
void deleteItem(schema.id).then(() => {
|
||||||
if (ossID) {
|
if (ossID) {
|
||||||
router.push(urls.oss(ossID, OssTabID.GRAPH));
|
router.push(urls.oss(ossID, OssTabID.GRAPH));
|
||||||
} else {
|
} else {
|
||||||
|
@ -184,7 +184,7 @@ export const RSEditState = ({
|
||||||
|
|
||||||
function handleCreateCst(data: ICstCreateDTO) {
|
function handleCreateCst(data: ICstCreateDTO) {
|
||||||
data.alias = data.alias || generateAlias(data.cst_type, schema);
|
data.alias = data.alias || generateAlias(data.cst_type, schema);
|
||||||
cstCreate({ itemID: itemID, data }, newCst => {
|
void cstCreate({ itemID: itemID, data }).then(newCst => {
|
||||||
setSelected([newCst.id]);
|
setSelected([newCst.id]);
|
||||||
navigateRSForm({ tab: activeTab, activeID: newCst.id });
|
navigateRSForm({ tab: activeTab, activeID: newCst.id });
|
||||||
if (activeTab === RSTabID.CST_LIST) {
|
if (activeTab === RSTabID.CST_LIST) {
|
||||||
|
@ -210,7 +210,7 @@ export const RSEditState = ({
|
||||||
const isEmpty = deleted.length === schema.items.length;
|
const isEmpty = deleted.length === schema.items.length;
|
||||||
const nextActive = isEmpty ? undefined : getNextActiveOnDelete(activeCst?.id, schema.items, deleted);
|
const nextActive = isEmpty ? undefined : getNextActiveOnDelete(activeCst?.id, schema.items, deleted);
|
||||||
|
|
||||||
cstDelete({ itemID: itemID, data }, () => {
|
void cstDelete({ itemID: itemID, data }).then(() => {
|
||||||
setSelected(nextActive ? [nextActive] : []);
|
setSelected(nextActive ? [nextActive] : []);
|
||||||
if (!nextActive) {
|
if (!nextActive) {
|
||||||
navigateRSForm({ tab: RSTabID.CST_LIST });
|
navigateRSForm({ tab: RSTabID.CST_LIST });
|
||||||
|
@ -235,7 +235,7 @@ export const RSEditState = ({
|
||||||
return Math.min(prev, index);
|
return Math.min(prev, index);
|
||||||
}, -1);
|
}, -1);
|
||||||
const target = Math.max(0, currentIndex - 1);
|
const target = Math.max(0, currentIndex - 1);
|
||||||
cstMove({
|
void cstMove({
|
||||||
itemID: itemID,
|
itemID: itemID,
|
||||||
data: {
|
data: {
|
||||||
items: selected,
|
items: selected,
|
||||||
|
@ -261,7 +261,7 @@ export const RSEditState = ({
|
||||||
}
|
}
|
||||||
}, -1);
|
}, -1);
|
||||||
const target = Math.min(schema.items.length - 1, currentIndex - count + 2);
|
const target = Math.min(schema.items.length - 1, currentIndex - count + 2);
|
||||||
cstMove({
|
void cstMove({
|
||||||
itemID: itemID,
|
itemID: itemID,
|
||||||
data: {
|
data: {
|
||||||
items: selected,
|
items: selected,
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
||||||
|
|
||||||
import { DataCallback } from '@/backend/apiTransport';
|
|
||||||
|
|
||||||
import { IUserProfile } from '../models/user';
|
|
||||||
import { IUserSignupDTO, usersApi } from './api';
|
import { IUserSignupDTO, usersApi } from './api';
|
||||||
|
|
||||||
export const useSignup = () => {
|
export const useSignup = () => {
|
||||||
|
@ -13,10 +10,7 @@ export const useSignup = () => {
|
||||||
onSuccess: () => client.invalidateQueries({ queryKey: usersApi.getUsersQueryOptions().queryKey })
|
onSuccess: () => client.invalidateQueries({ queryKey: usersApi.getUsersQueryOptions().queryKey })
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
signup: (
|
signup: (data: IUserSignupDTO) => mutation.mutateAsync(data),
|
||||||
data: IUserSignupDTO, //
|
|
||||||
onSuccess?: DataCallback<IUserProfile>
|
|
||||||
) => mutation.mutate(data, { onSuccess }),
|
|
||||||
isPending: mutation.isPending,
|
isPending: mutation.isPending,
|
||||||
error: mutation.error,
|
error: mutation.error,
|
||||||
reset: mutation.reset
|
reset: mutation.reset
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
||||||
|
|
||||||
import { DataCallback } from '@/backend/apiTransport';
|
|
||||||
|
|
||||||
import { IUserProfile } from '../models/user';
|
|
||||||
import { IUpdateProfileDTO, usersApi } from './api';
|
import { IUpdateProfileDTO, usersApi } from './api';
|
||||||
|
|
||||||
export const useUpdateProfile = () => {
|
export const useUpdateProfile = () => {
|
||||||
|
@ -16,8 +13,7 @@ export const useUpdateProfile = () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
updateProfile: (data: IUpdateProfileDTO, onSuccess?: DataCallback<IUserProfile>) =>
|
updateProfile: (data: IUpdateProfileDTO) => mutation.mutateAsync(data),
|
||||||
mutation.mutate(data, { onSuccess }),
|
|
||||||
isPending: mutation.isPending,
|
isPending: mutation.isPending,
|
||||||
error: mutation.error,
|
error: mutation.error,
|
||||||
reset: mutation.reset
|
reset: mutation.reset
|
||||||
|
|
|
@ -50,7 +50,7 @@ function FormSignup() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function onSubmit(data: IUserSignupDTO) {
|
function onSubmit(data: IUserSignupDTO) {
|
||||||
signup(data, createdUser => router.push(urls.login_hint(createdUser.username)));
|
return signup(data).then(createdUser => router.push(urls.login_hint(createdUser.username)));
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -31,7 +31,7 @@ function EditorPassword() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function onSubmit(data: IChangePasswordDTO) {
|
function onSubmit(data: IChangePasswordDTO) {
|
||||||
changePassword(data, () => router.push(urls.login));
|
return changePassword(data).then(() => router.push(urls.login));
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -40,7 +40,7 @@ function EditorProfile() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function onSubmit(data: IUpdateProfileDTO) {
|
function onSubmit(data: IUpdateProfileDTO) {
|
||||||
updateProfile(data, () => resetForm({ ...data }));
|
return updateProfile(data).then(() => resetForm({ ...data }));
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
Loading…
Reference in New Issue
Block a user