import ActionTypes from '../constants/ActionTypes';
import cookie from 'cookie';
import assign from 'object-assign';

export const setCookie = (name, value, options) => {
  options = assign({
    path: '/',
  }, options);
  return (dispatch, getState) => {
    return Promise
      .resolve(dispatch({
        type: ActionTypes.SET_COOKIE,
        cookie: {
          name,
          value,
          options,
        },
      }))
      .then(() => {
        if (process.env.BROWSER) {
          document.cookie = cookie.serialize(
            name, getState().cookies[name], options);
        }
        return Promise.resolve();
      });
  };
};

export const setCookies = (cookies) => {
  return (dispatch) => {
    return Promise.all(
      Object
        .keys(cookies)
        .map((name) => dispatch(setCookie(name, cookies[name])))
    );
  };
};

export const removeCookie = (name) => {
  return (dispatch, getState) => {
    return Promise
      .resolve(dispatch({
        type: ActionTypes.REMOVE_COOKIE,
        name,
      }))
      .then(() => {
        if (process.env.BROWSER) {
          document.cookie = cookie.serialize(name, '', {
            expires: new Date(1970, 1, 1, 0, 0, 1),
          });
        }
        return Promise.resolve();
      });
  };
};

@@ -932,212 +932,65 @@
     
-return Promise%0A      .resolve(dispatch(%7B%0A        type: ActionTypes.REMOVE_COOKIE,%0A        name,%0A      %7D))%0A      .then(() =%3E %7B%0A        if (process.env.BROWSER) %7B%0A          document.cookie = cookie.serializ
+if (process.env.BROWSER) %7B%0A      return dispatch(setCooki
 e(na
@@ -1007,20 +1007,16 @@
         
-  
-  
 expires:
@@ -1057,34 +1057,23 @@
     
-    
 %7D
+)
 );%0A    
- 
-   %7D%0A  
+%7D%0A
     
-  
 retu
@@ -1090,30 +1090,20 @@
 .resolve();%0A
-      %7D);%0A
   %7D;%0A%7D;%0A

Fix action creator `removeCookie`