'use client' import type { FC } from 'react' import React, { useState } from 'react' import { useTranslation } from 'react-i18next' import { RiArrowDownSLine } from '@remixicon/react' import { Method } from '../types' import Selector from '../../_base/components/selector' import useAvailableVarList from '../../_base/hooks/use-available-var-list' import { VarType } from '../../../types' import type { Var } from '../../../types' import cn from '@/utils/classnames' import Input from '@/app/components/workflow/nodes/_base/components/input-support-select-var' const MethodOptions = [ { label: 'GET', value: Method.get }, { label: 'POST', value: Method.post }, { label: 'HEAD', value: Method.head }, { label: 'PATCH', value: Method.patch }, { label: 'PUT', value: Method.put }, { label: 'DELETE', value: Method.delete }, ] type Props = { nodeId: string readonly: boolean method: Method onMethodChange: (method: Method) => void url: string onUrlChange: (url: string) => void } const ApiInput: FC = ({ nodeId, readonly, method, onMethodChange, url, onUrlChange, }) => { const { t } = useTranslation() const [isFocus, setIsFocus] = useState(false) const { availableVars, availableNodesWithParent } = useAvailableVarList(nodeId, { onlyLeafNodeVar: false, filterVar: (varPayload: Var) => { return [VarType.string, VarType.number, VarType.secret].includes(varPayload.type) }, }) return (
{method}
{!readonly && }
} popupClassName='top-[34px] w-[108px]' showChecked readonly={readonly} /> ) } export default React.memo(ApiInput)