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