fix(lint): fix type errors

This commit is contained in:
lemmyMwaura
2024-08-07 22:59:50 +03:00
parent b0a5023723
commit 9061ec2dff
5 changed files with 22 additions and 20 deletions
+11 -12
View File
@@ -43,32 +43,31 @@ export const useGetActiveSharedSecretById = ({
sharedSecretId: string;
hashedHex: string;
}) => {
return useQuery<TViewSharedSecretResponse, [string]>({
enabled: Boolean(sharedSecretId) && Boolean(hashedHex),
queryFn: async () => {
const params = new URLSearchParams({
hashedHex
});
return useQuery<TViewSharedSecretResponse | null>(
[`sharedSecret-${sharedSecretId}`],
async () => {
const params = new URLSearchParams({ hashedHex });
const { data } = await apiRequest.get<TViewSharedSecretResponse>(
`/api/v1/secret-sharing/public/${sharedSecretId}`,
{
params
}
);
if (!data) return null;
if (!data) return null
return {
encryptedValue: data.encryptedValue,
password: data.password,
iv: data.iv,
tag: data.tag,
accessType: data.accessType,
orgName: data.orgName
};
},
{
enabled: Boolean(sharedSecretId) && Boolean(hashedHex)
}
});
);
};
// returns a secret (secret or undefined if password doesn't match)
@@ -10,8 +10,7 @@ import { TViewSharedSecretResponse, useGetActiveSharedSecretById } from "@app/ho
import { SecretContainer, SecretErrorContainer, PasswordContainer } from "./components";
export const ViewSecretPublicPage = () => {
const [secret, setSecret] = useState(null)
const [error, setError] = useState(null)
const [secret, setSecret] = useState<TViewSharedSecretResponse | null>(null);
const router = useRouter();
const { id, key: urlEncodedPublicKey } = router.query;
@@ -19,15 +18,14 @@ export const ViewSecretPublicPage = () => {
? urlEncodedPublicKey.toString().split("-")
: ["", ""];
const { data: fetchSecret, error: fetchError, isLoading } = useGetActiveSharedSecretById({
const { data: fetchSecret, error, isLoading } = useGetActiveSharedSecretById({
sharedSecretId: id as string,
hashedHex
});
useEffect(() => {
if (fetchSecret) setSecret(fetchSecret)
if (fetchError) setError(fetchError)
}, [fetchSecret, fetchError])
}, [fetchSecret, error])
const handleSecret = useCallback((value: TViewSharedSecretResponse) => {
setSecret(value)