import React, {PropTypes, Component} from 'react'; import {Cookie} from 'tough-cookie'; import CookieInput from '../CookieInput'; import {cookieToString} from '../../../common/cookies'; class CookiesEditor extends Component { _handleCookieAdd = () => { const newCookie = new Cookie({ key: 'foo', value: 'bar', domain: this.props.newCookieDomainName, path: '/' }); this.props.onCookieAdd(newCookie); }; _handleCookieUpdate (cookie, cookieStr) { const newCookie = Cookie.parse(cookieStr); this.props.onCookieUpdate(cookie, newCookie); } _handleDeleteCookie (cookie) { this.props.onCookieDelete(cookie); } render () { const {cookies} = this.props; return (
{cookies.map((cookie, i) => { const cookieString = cookieToString(Cookie.fromJSON(JSON.stringify(cookie))); return ( ) })}
Domain Cookie
{cookie.domain}
this._handleCookieUpdate(cookie, value)} />
{cookies.length === 0 ? (

I couldn't find any cookies for you.

) : null}
); } } CookiesEditor.propTypes = { onCookieUpdate: PropTypes.func.isRequired, onCookieAdd: PropTypes.func.isRequired, onCookieDelete: PropTypes.func.isRequired, cookies: PropTypes.array.isRequired, newCookieDomainName: PropTypes.string.isRequired }; export default CookiesEditor;