import React from 'react';

export default ({ field1c, fieldCb, id, saveValue, changeValue, editMode, editId }) => {
    const closeBtnHidden = (editId && fieldCb == editId) ? (!editMode ? ' hidden' : '') : ' hidden';
    const editBtnHidden = (editId && fieldCb == editId) ? (editMode ? ' hidden' : '') : '';
    
    return (
        <>
            <button
                type="button"
                className={`user-data__close-edit-btn table-settings-btn${closeBtnHidden}`}
                id={`save-btn${id}`}
                field_type="table-part"
                onClick={(e) => {
                    $(e.target).parent().parent().find('.chosen-container').each((i, item) => {
                        $(item).css('display', 'none');
                    });
                    saveValue(e);
                }}
                field_1c={field1c}
                field_cb={fieldCb}
 
            />
            <button
                type="button"
                className={`user-data__save-value-btn table-settings-btn${editBtnHidden}`} 
                id={`edit-btn${id}`} 
                field_type="table-part" 
                onClick={changeValue}
                field_1c={field1c} 
                field_cb={fieldCb} 
            />
        </>
    )
};