import { queryString } from "educoder";
export function updatePageParams(pageNum, props) {
  const url = props.match.url;

  const _search = props.location.search;
  let parsed = {};
  if (_search) {
    parsed = queryString.parse(_search);
  }

  // 修改page參數
  parsed.page = pageNum;

  props.history.push(`${url}?${queryString.stringify(parsed)}`);
}

export function goUser(login) {
	const main_web_site_url =
    localStorage.chromesetting &&
    JSON.parse(localStorage.chromesetting).main_web_site_url;
  	window.location.href = `${main_web_site_url}/accounts/${login}`;
}

export function goUserMes(user_id) {
  const main_web_site_url =
    localStorage.chromesetting &&
    JSON.parse(localStorage.chromesetting).main_web_site_url;
	const login =sessionStorage.current_user &&JSON.parse(sessionStorage.current_user).login;
  	window.location.href = `${main_web_site_url}/users/${login}/message_detail?user_id=${user_id}`;
}
