<commit_before>import React, { Component } from "react"
import { Login as LoginContainer } from "dicty-components-login"
import OauthSignHandler from "components/authentication/OauthSignHandler"
import oauthConfig from "utils/oauthConfig"
import Grid from "@material-ui/core/Grid"

// list of buttons to display
const buttons = ["orcid", "google", "linkedin"]

/**
 * Component that displays all of the social login buttons with click handlers for each one
 */

class Login extends Component {
  handleClick = (name: string) => {
    const config = oauthConfig[name]
    let url = `${config.authorizationEndpoint}?client_id=${config.clientId}`
    url += `&scope=${config.scopes.join(config.scopeDelimiter)}`
    if (config.requiredUrlParams) {
      config.requiredUrlParams.forEach(element => {
        url += `&${element[0]}=${element[1]}`
      })
    }
    if (config.optionalUrlParams) {
      config.optionalUrlParams.forEach(element => {
        url += `&${element[0]}=${element[1]}`
      })
    }
    url += `&redirect_uri=${config.redirectUrl}`
    window.open(
      url,
      name,
      `width=${config.popupOptions.width},
                    height=${config.popupOptions.height}`,
    )
  }
  render() {
    return (
      <Grid container justify="center">
        <Grid item xs={8}>
          <div style={{ textAlign: "center" }}><commit_msg>refactor: use helper function for formatting url params<commit_after>import React, { Component } from "react"
import { Login as LoginContainer } from "dicty-components-login"
import OauthSignHandler from "components/authentication/OauthSignHandler"
import oauthConfig from "utils/oauthConfig"
import Grid from "@material-ui/core/Grid"

// list of buttons to display
const buttons = ["orcid", "google", "linkedin"]

const formatURLParams = (params: Array<string>) => {
  let url = ""
  params.forEach(element => {
    url += `&${element[0]}=${element[1]}`
  })
  return url
}

/**
 * Component that displays all of the social login buttons with click handlers for each one
 */

class Login extends Component {
  handleClick = (name: string) => {
    const config = oauthConfig[name]
    let url = `${config.authorizationEndpoint}?client_id=${config.clientId}`
    url += `&scope=${config.scopes.join(config.scopeDelimiter)}`
    if (config.requiredUrlParams) {
      url += formatURLParams(config.requiredUrlParams)
    }
    if (config.optionalUrlParams) {
      url += formatURLParams(config.optionalUrlParams)
    }
    url += `&redirect_uri=${config.redirectUrl}`
    window.open(
      url,
      name,
      `width=${config.popupOptions.width},
                    height=${config.popupOptions.height}`,
    )
  }
  render() {
    return (
      <Grid container justify="center">
        <Grid item xs={8}>
          <div style={{ textAlign: "center" }}>
{'fraction_non_alphanumeric': 0.14012061014544164, 'fraction_numerical': 0.002837885775097552, 'mean_word_length': 3.4976076555023923, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1872219', 'n_tokens_mistral': 822, 'n_tokens_neox': 824, 'n_words': 200}