fix: application crash on zod api error

This commit is contained in:
Daniel Hougaard
2024-11-20 00:00:30 +04:00
parent 9a62efea4f
commit 0d295a2824
@@ -63,32 +63,21 @@ export const IdentityClientSecretModal = ({ popUp, handlePopUpToggle }: Props) =
}; };
const onFormSubmit = async ({ description, ttl, numUsesLimit }: FormData) => { const onFormSubmit = async ({ description, ttl, numUsesLimit }: FormData) => {
try { const { clientSecret } = await createClientSecret({
const { clientSecret } = await createClientSecret({ identityId: popUpData.identityId,
identityId: popUpData.identityId, description,
description, ttl: Number(ttl),
ttl: Number(ttl), numUsesLimit: Number(numUsesLimit)
numUsesLimit: Number(numUsesLimit) });
});
setToken(clientSecret); setToken(clientSecret);
createNotification({ createNotification({
text: "Successfully created client secret", text: "Successfully created client secret",
type: "success" type: "success"
}); });
reset(); reset();
} catch (err) {
console.error(err);
const error = err as any;
const text = error?.response?.data?.message ?? "Failed to create client secret";
createNotification({
text,
type: "error"
});
}
}; };
return ( return (