41 lines
1.1 KiB
TypeScript
41 lines
1.1 KiB
TypeScript
import { type CipherInfo } from "@/models/CipherInfo";
|
|
import type { TrifidProps } from "@/models/PolySubstitutionProps";
|
|
import api from "@/util/AxiosUtil";
|
|
import { useMutation, useQuery } from "@tanstack/react-query";
|
|
|
|
|
|
export function useGetTrifidInfo(){
|
|
return useQuery({
|
|
queryKey: [ "Trifid", "Info" ],
|
|
queryFn: async () => {
|
|
const response = await api.get(`${import.meta.env.VITE_API_URL}/trifid`);
|
|
|
|
return response.data as CipherInfo;
|
|
}
|
|
});
|
|
}
|
|
|
|
export function useEncodeTrifid(){
|
|
return useMutation({
|
|
mutationKey: [ "Trifid", "Encode" ],
|
|
scope: { id: "Trifid Encode" },
|
|
mutationFn: async (props: TrifidProps) => {
|
|
const response = await api.post(`${import.meta.env.VITE_API_URL}/trifid/encode`, props);
|
|
|
|
return response.data as TrifidProps;
|
|
}
|
|
});
|
|
}
|
|
|
|
export function useDecodeTrifid(){
|
|
return useMutation({
|
|
mutationKey: [ "Trifid", "Decode" ],
|
|
scope: { id: "Trifid Decode" },
|
|
mutationFn: async (props: TrifidProps) => {
|
|
const response = await api.post(`${import.meta.env.VITE_API_URL}/trifid/decode`, props);
|
|
|
|
return response.data as TrifidProps;
|
|
}
|
|
});
|
|
}
|