From d5527bb2d0ee2a38b90e7f5bd181f62dabc7f437 Mon Sep 17 00:00:00 2001 From: Nour Balaha Date: Fri, 27 Oct 2023 19:09:06 +0900 Subject: [PATCH] fix(web): disable boolean field validation (#908) fix: disable boolean field validation --- .../FieldModal/FieldCreationModal/index.tsx | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/web/src/components/molecules/Schema/FieldModal/FieldCreationModal/index.tsx b/web/src/components/molecules/Schema/FieldModal/FieldCreationModal/index.tsx index c307ae03f3..33891ca9ea 100644 --- a/web/src/components/molecules/Schema/FieldModal/FieldCreationModal/index.tsx +++ b/web/src/components/molecules/Schema/FieldModal/FieldCreationModal/index.tsx @@ -1,6 +1,6 @@ import styled from "@emotion/styled"; import { CheckboxChangeEvent } from "antd/lib/checkbox"; -import { useCallback, useEffect, useState } from "react"; +import { useCallback, useEffect, useMemo, useState } from "react"; import Checkbox from "@reearth-cms/components/atoms/Checkbox"; import Form, { FieldError } from "@reearth-cms/components/atoms/Form"; @@ -260,6 +260,16 @@ const FieldCreationModal: React.FC = ({ onClose?.(true); }, [onClose]); + const isRequiredDisabled = useMemo( + () => selectedType === "Group" || selectedType === "Bool", + [selectedType], + ); + + const isUniqueDisabled = useMemo( + () => selectedType === "Group" || selectedType === "Bool", + [selectedType], + ); + return ( = ({ name="required" valuePropName="checked" extra={t("Prevents saving an entry if this field is empty")}> - {t("Make field required")} + {t("Make field required")} - {t("Set field as unique")} + {t("Set field as unique")}