refactor: convert usequery hook to normal fetch fn (no need for caching)

This commit is contained in:
lemmyMwaura
2024-08-07 08:27:17 +03:00
parent da45e132a3
commit 406da1b5f0
2 changed files with 20 additions and 32 deletions
+13 -24
View File
@@ -68,29 +68,18 @@ export const useGetActiveSharedSecretById = ({
});
};
export const useValidateSecretPassword = ({
sharedSecretId,
hashedHex,
userPassword,
}: {
sharedSecretId: string;
hashedHex: string;
userPassword: string;
}) => {
return useQuery(
[`validateSecretPass-${sharedSecretId}`],
async () => {
const { data } = await apiRequest.post<ValidateSecretPassword>(
`/api/v1/secret-sharing/public/${sharedSecretId}/validate`,
{
hashedHex,
password: userPassword
}
);
return data;
},
export const fetchIsSecretPasswordValid = async (
sharedSecretId: string,
hashedHex: string,
password: string,
) => {
const { data } = await apiRequest.post<ValidateSecretPassword>(
`/api/v1/secret-sharing/public/${sharedSecretId}/validate`,
{
enabled: Boolean(sharedSecretId) && Boolean(userPassword),
hashedHex,
password
}
)
}
);
return data;
};