import { useMemo } from "react"; import { Method } from "@/components/method"; import { splitStringBracket } from "@/utils"; import { ApiRoute } from "@/utils/type"; import { Parameter } from "./parameter"; export const Endpoint = ({ method, path, initialPath, children, onChange, }: { method: ApiRoute["method"]; path: string; initialPath: ApiRoute["path"]; children: React.ReactElement; onChange: (value: string) => void; }) => { const path_formatted = useMemo( () => splitStringBracket(initialPath), [initialPath] ); const handleChange = (value: string, key: string) => { onChange(path.replace(key, value)); }; return (
{path_formatted.map((p, i) => { return p.editable ? ( handleChange(value, p.key)} /> ) : (

{p.content}

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