CipherStreamWeb converted to use Vite
This commit is contained in:
40
src/hooks/monosubstitution/AutokeyHooks.ts
Normal file
40
src/hooks/monosubstitution/AutokeyHooks.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import type { CipherInfo } from "@/models/CipherInfo";
|
||||
import type { AutokeyProps } from "@/models/MonoSubstitutionProps";
|
||||
import api from "@/util/AxiosUtil";
|
||||
import { useMutation, useQuery } from "@tanstack/react-query";
|
||||
|
||||
|
||||
export function useGetAutokeyInfo(){
|
||||
return useQuery({
|
||||
queryKey: [ "Autokey", "Info" ],
|
||||
queryFn: async () => {
|
||||
const response = await api.get(`${import.meta.env.VITE_API_URL}/autokey`);
|
||||
|
||||
return response.data as CipherInfo;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export function useEncodeAutokey(){
|
||||
return useMutation({
|
||||
mutationKey: [ "Autokey", "Encode" ],
|
||||
scope: { id: "Autokey Encode" },
|
||||
mutationFn: async (props: AutokeyProps) => {
|
||||
const response = await api.post(`${import.meta.env.VITE_API_URL}/autokey/encode`, props);
|
||||
|
||||
return response.data as AutokeyProps;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export function useDecodeAutokey(){
|
||||
return useMutation({
|
||||
mutationKey: [ "Autokey", "Decode" ],
|
||||
scope: { id: "Autokey Decode" },
|
||||
mutationFn: async (props: AutokeyProps) => {
|
||||
const response = await api.post(`${import.meta.env.VITE_API_URL}/autokey/decode`, props);
|
||||
|
||||
return response.data as AutokeyProps;
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user