"use client"; import React from "react"; import EventButton from "@/components/ContextComponents/Commons/ButtonEvent"; import { Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, } from "@/components/ui/form"; import { z } from "zod"; import { zodResolver } from "@hookform/resolvers/zod"; import { useForm } from "react-hook-form"; import { retrieveValidationsByEndpoint } from "@/components/ContextComponents/functions/retrieveEndpointAndValidations"; interface BuildCreateProps { pageInfo: any; endpoint: string; } const BuildCreate: React.FC = ({ pageInfo, endpoint }) => { const [zodValidation, setZodValidation] = React.useState(z.object({})); const [apiValidation, setApiValidation] = React.useState>( {} ); const [apiHeaders, setApiHeaders] = React.useState>( {} ); React.useEffect(() => { retrieveValidationsByEndpoint(endpoint).then((validations: any) => { setZodValidation(validations.zodValidation as any); setApiHeaders(validations.apiValidation?.headers); setApiValidation(validations.apiValidation?.validated); }); }, []); const form = useForm>({ resolver: zodResolver(zodValidation), }); function closeFormPage() {} function onClickAction() {} return (
<>

{pageInfo.description}

closeFormPage()} label="Dashboarda Dön" bgColor="bg-red-700" icon={ } />
onClickAction()} label="Kaydet" bgColor="bg-emerald-700" icon={ } />
{
{Object.entries(apiValidation).map( ([key, value]: [string, any]) => { console.log("key", key); const keyValidation = apiValidation[key] || { fieldType: { type: "string" }, required: false, }; const fieldType = keyValidation.fieldType?.type || "string"; if (fieldType === "string" && apiHeaders[key]) { return ( <>
( )} />
); } else if (fieldType === "integer" && apiHeaders[key]) { return ( <>
( )} />
); } } )}
}
); }; export default BuildCreate;