feat: add UI for migration from EnvKey

This commit is contained in:
Meet
2024-10-01 01:34:24 +05:30
parent be02617855
commit d00b1847cc
5 changed files with 243 additions and 2 deletions
@@ -0,0 +1,31 @@
import { useMutation } from "@tanstack/react-query";
import { AxiosError } from "axios";
import { apiRequest } from "@app/config/request";
export const useImportEnvKey = () => {
return useMutation({
mutationFn: async ({ encryptedJson, decryptionKey }: { encryptedJson: {
nonce: string,
data: string
}, decryptionKey: string }) : Promise<{ success: boolean, message:string }>=> {
try{
const { data } = await apiRequest.post<{
success: boolean,
message: string
}>("/api/v3/migrate/envkey/", {
encryptedJson,
decryptionKey
});
return data;
} catch (err) {
if ((err as AxiosError<{
message: string
}>).response) {
return { success: false, message: (err as AxiosError<{message: string}>).response?.data?.message as string};
}
}
return { success: false, message: "Something went wrong" };
}
});
};