Skip to content

Commit

Permalink
chore: adjusted types for availability handler
Browse files Browse the repository at this point in the history
  • Loading branch information
alashchev17 committed Dec 9, 2024
1 parent bf9ea97 commit 232ec6f
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ function jsonHasWhenIsolated(
);
}

function areAllFieldsBoolean(json: unknown): json is Record<string, boolean> {
return (
typeof json === "object" &&
json !== null &&
Object.entries(json).every((value) => typeof value === "boolean")
);
}

type IntegrationFormProps = {
integrationPath: string;
isApplying: boolean;
Expand Down Expand Up @@ -76,7 +84,8 @@ export const IntegrationForm: FC<IntegrationFormProps> = ({
useEffect(() => {
if (
integration.data?.integr_values.available &&
typeof integration.data.integr_values.available === "object"
typeof integration.data.integr_values.available === "object" &&
areAllFieldsBoolean(integration.data.integr_values.available)
) {
Object.entries(integration.data.integr_values.available).forEach(
([key, value]) => {
Expand Down

0 comments on commit 232ec6f

Please sign in to comment.