import { useMemo } from "react"; import classNames from "classnames"; import { Method } from "@/components/method"; import { splitStringBracket } from "@/utils"; import { ApiRoute } from "@/utils/type"; import { Parameter } from "./parameter"; export const Endpoint = ({ endpoint, children, onChange, }: { endpoint: ApiRoute; children: React.ReactElement; onChange: (value: string) => void; }) => { const path_formatted = useMemo( () => splitStringBracket(endpoint.path), [endpoint.path] ); const handleChange = (value: string, index: number) => { const currentString = splitStringBracket(endpoint.path); currentString[index] = value; onChange(currentString.join("")); }; return (
{path_formatted.map((p, i) => { const isCustomizable = p.startsWith("{") && p.endsWith("}"); return isCustomizable ? ( handleChange(value, i)} /> ) : (

{p}

); })}
{children}
); };