"use client"; import { FormEvent, useState } from "react"; // types import { FileText } from "lucide-react"; import { TPage } from "@plane/types"; // ui import { Button, EmojiIconPicker, EmojiIconPickerTypes, Input, Tooltip } from "@plane/ui"; import { Logo } from "@/components/common"; // constants import { PAGE_ACCESS_SPECIFIERS } from "@/constants/page"; // helpers import { cn } from "@/helpers/common.helper"; import { convertHexEmojiToDecimal } from "@/helpers/emoji.helper"; // hooks import { usePlatformOS } from "@/hooks/use-platform-os"; type Props = { formData: Partial; handleFormData: (key: T, value: TPage[T]) => void; handleModalClose: () => void; handleFormSubmit: () => Promise; }; export const PageForm: React.FC = (props) => { const { formData, handleFormData, handleModalClose, handleFormSubmit } = props; // hooks const { isMobile } = usePlatformOS(); // state const [isOpen, setIsOpen] = useState(false); const [isSubmitting, setIsSubmitting] = useState(false); const handlePageFormSubmit = async (e: FormEvent) => { e.preventDefault(); try { setIsSubmitting(true); await handleFormSubmit(); setIsSubmitting(false); } catch { setIsSubmitting(false); } }; const isTitleLengthMoreThan255Character = formData.name ? formData.name.length > 255 : false; return (

Create Page

setIsOpen(val)} className="flex items-center justify-center flex-shrink0" buttonClassName="flex items-center justify-center" label={ <> {formData?.logo_props?.in_use ? ( ) : ( )} } onChange={(val: any) => { let logoValue = {}; if (val?.type === "emoji") logoValue = { value: convertHexEmojiToDecimal(val.value.unified), url: val.value.imageUrl, }; else if (val?.type === "icon") logoValue = val.value; handleFormData("logo_props", { in_use: val?.type, [val?.type]: logoValue, }); setIsOpen(false); }} defaultIconColor={ formData?.logo_props?.in_use && formData?.logo_props?.in_use === "icon" ? formData?.logo_props?.icon?.color : undefined } defaultOpen={ formData?.logo_props?.in_use && formData?.logo_props?.in_use === "emoji" ? EmojiIconPickerTypes.EMOJI : EmojiIconPickerTypes.ICON } />
handleFormData("name", e.target.value)} placeholder="Title" className="w-full resize-none text-base" tabIndex={1} required autoFocus /> {isTitleLengthMoreThan255Character && ( Max length of the name should be less than 255 characters )}
{PAGE_ACCESS_SPECIFIERS.map((access, index) => ( ))}
{PAGE_ACCESS_SPECIFIERS.find((access) => access.key === formData.access)?.label}
); };