laconic-deploy/packages/frontend/src/components/projects/project/settings/AddEnvironmentVariableRow.tsx
2024-05-14 20:17:54 +00:00

52 lines
1.3 KiB
TypeScript

import { UseFormRegister } from 'react-hook-form';
import { EnvironmentVariablesFormValues } from '../../../../types';
import { Button } from 'components/shared/Button';
import { TrashIcon } from 'components/shared/CustomIcon';
import { Input } from 'components/shared/Input';
interface AddEnvironmentVariableRowProps {
onDelete: () => void;
register: UseFormRegister<EnvironmentVariablesFormValues>;
index: number;
isDeleteDisabled: boolean;
}
const AddEnvironmentVariableRow = ({
onDelete,
register,
index,
isDeleteDisabled,
}: AddEnvironmentVariableRowProps) => {
return (
<div className="flex py-4 self-stretch">
<Input
size="md"
register={register(`variables.${index}.key`, {
required: 'Key field cannot be empty',
})}
label={index === 0 ? 'Key' : undefined}
/>
<Input
size="md"
label={index === 0 ? 'Value' : undefined}
register={register(`variables.${index}.value`, {
required: 'Value field cannot be empty',
})}
/>
<div className="self-end">
<Button
size="md"
iconOnly
onClick={onDelete}
disabled={isDeleteDisabled}
>
<TrashIcon />
</Button>
</div>
</div>
);
};
export default AddEnvironmentVariableRow;