<commit_before>import React from 'react'
import { Link } from 'react-router-dom'
import { calcDonationPercentage, getDonationBarColour } from '../../utils/donations'

import css from './MemberPreview.scss'

class MemberPreview extends React.Component {

	createCompletedBanner(percentage) {
		if (percentage >= 100) {
			return <div className="completed-banner">{"Completed!"}</div>
		}
	}

	createMatchedBanner(){
		if(this.props.member.sponsors){
			return (
				<div className="matched-icon">
					<img
						src="./images/matchedX2.png"
						alt="All donations are matched by a sponsor icon"/>
				</div>
			)
		}
	}

	createDonateButton(percentage) {
		if (percentage < 100) {
			return <button className="donate-button">{"Donate"}</button>
		}
	}

	// generateRandomBear() {
	// 	const bearImages = ["images/bear-blue.png", "images/bear-red.png", "images/bear-green.png", "images/bear-yellow.png"]
	// 	console.log(bearImages[Math.floor(Math.random() * 4)]);
	// }

	renderMembersImage() {
		if (this.props.member.url_image == undefined) {
			return `images/${this.props.member.name}.png`
		} else {
			return this.props.member.url_image
		}
	}

	getContainerClassName(){
		let className = "member-preview"
		if(this.props.className) className += " " + this.props.className
		return className
	}

	render() {
		let previewStyle = this.props.style || {}
		const {member} = this.props
		const percentage = calcDonationPercentage(member)
		const donationBarStyles = {
			"width": percentage.toString() + "%",
			"backgroundColor": getDonationBarColour(percentage)
		}

		return (
			<div className={this.getContainerClassName()} style={previewStyle}>
				<div className="member-photo-container">
					{this.createMatchedBanner()}
					<div className="overflow-container">
						{this.createCompletedBanner(percentage)}<commit_msg>MemberPreview: added logic so matched icon only appears if there is a sponsor<commit_after>import React from 'react'
import { Link } from 'react-router-dom'
import { calcDonationPercentage, getDonationBarColour } from '../../utils/donations'

import css from './MemberPreview.scss'

class MemberPreview extends React.Component {

	createCompletedBanner(percentage) {
		if (percentage >= 100) {
			return <div className="completed-banner">{"Completed!"}</div>
		}
	}

	createMatchedIcon(){
		if(this.props.member.sponsors.length > 0){
			return (
				<div className="matched-icon">
					<img
						src="./images/matchedX2.png"
						alt="All donations are matched by a sponsor icon"/>
				</div>
			)
		}
	}

	createDonateButton(percentage) {
		if (percentage < 100) {
			return <button className="donate-button">{"Donate"}</button>
		}
	}

	// generateRandomBear() {
	// 	const bearImages = ["images/bear-blue.png", "images/bear-red.png", "images/bear-green.png", "images/bear-yellow.png"]
	// 	console.log(bearImages[Math.floor(Math.random() * 4)]);
	// }

	renderMembersImage() {
		if (this.props.member.url_image == undefined) {
			return `images/${this.props.member.name}.png`
		} else {
			return this.props.member.url_image
		}
	}

	getContainerClassName(){
		let className = "member-preview"
		if(this.props.className) className += " " + this.props.className
		return className
	}

	render() {
		let previewStyle = this.props.style || {}
		const {member} = this.props
		const percentage = calcDonationPercentage(member)
		const donationBarStyles = {
			"width": percentage.toString() + "%",
			"backgroundColor": getDonationBarColour(percentage)
		}

		return (
			<div className={this.getContainerClassName()} style={previewStyle}>
				<div className="member-photo-container">
					{this.createMatchedIcon()}
					<div className="overflow-container">
						{this.createCompletedBanner(percentage)}
{'fraction_non_alphanumeric': 0.15057502005883927, 'fraction_numerical': 0.004546670232682536, 'mean_word_length': 4.0, 'pattern_counts': {'":': 4, '<': 25, '<?xml version=': 0, '>': 26, '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': '968986', 'n_tokens_mistral': 1359, 'n_tokens_neox': 1182, 'n_words': 220}