import { Button, Field } from '@rocket.chat/fuselage';
import React from 'react';
import { useMethod } from '../../../../contexts/ServerContext';
import { useToastMessageDispatch } from '../../../../contexts/ToastMessagesContext';
import { useTranslation } from '../../../../contexts/TranslationContext';
export function ActionSettingInput({
_id,
actionText,
value,
disabled,
sectionChanged,
}) {
const t = useTranslation();
const dispatchToastMessage = useToastMessageDispatch();
const actionMethod = useMethod(value);
const handleClick = async () => {
try {
const data = await actionMethod();
const args = [data.message].concat(data.params);
dispatchToastMessage({ type: 'success', message: t(...args) });
} catch (error) {
dispatchToastMessage({ type: 'error', message: error });
}
};
return <>
{sectionChanged && {t('Save_to_enable_this_action')}}
>;
}