// react import { useCallback } from "react"; // react-hook-form import { UseFormRegister, UseFormSetError } from "react-hook-form"; // services import projectServices from "lib/services/project.service"; // hooks import useUser from "lib/hooks/useUser"; // ui import { Button, Input, Select, TextArea } from "ui"; // types import { IProject } from "types"; // constants import { debounce } from "constants/common"; type Props = { register: UseFormRegister; errors: any; setError: UseFormSetError; isSubmitting: boolean; }; const NETWORK_CHOICES = { "0": "Secret", "2": "Public" }; const GeneralSettings: React.FC = ({ register, errors, setError, isSubmitting }) => { const { activeWorkspace } = useUser(); const checkIdentifier = (slug: string, value: string) => { projectServices.checkProjectIdentifierAvailability(slug, value).then((response) => { console.log(response); if (response.exists) setError("identifier", { message: "Identifier already exists" }); }); }; // eslint-disable-next-line react-hooks/exhaustive-deps const checkIdentifierAvailability = useCallback(debounce(checkIdentifier, 1500), []); return ( <>

General

This information will be displayed to every member of the project.

{ if (!activeWorkspace || !e.target.value) return; checkIdentifierAvailability(activeWorkspace.slug, e.target.value); }} validations={{ required: "Identifier is required", minLength: { value: 1, message: "Identifier must at least be of 1 character", }, maxLength: { value: 9, message: "Identifier must at most be of 9 characters", }, }} />