<commit_before>import React from 'react';
import { readAddress } from 'consus-core/identifiers';
import { searchItemForCheckout } from '../../lib/api-client';
import { searchItem } from '../../lib/api-client';
import { checkInItem } from '../../lib/api-client';
import { assert } from 'chai';

export default class CartPanel extends React.Component {

    constructor(props) {
        super(props);
        this.state = {
            address: ''
        };
    }

    changeAddress(e) {
        try {
            let result = readAddress(e.target.value);
            assert.strictEqual(result.type, 'item');
            let student = this.props.student;
            if( student.itemAddresses.indexOf(e.target.value) ===  -1) {
              searchItemForCheckout(e.target.value);
            } else {
              checkInItem(student.id, e.target.value)
            }
            this.setState({
                address: ''
            });
        } catch(f) {
            this.setState({
                address: e.target.value
            });
        }
    }

    renderEquipment() {
        if(this.props.itemAddresses.length === 0) {
            return <div><br/><i>Cart is empty.</i><br/><br/></div>;
        }
        return (
            <ul>
                {this.props.itemAddresses.map((itemAddress, i) => {
                    return <li key={i}>{itemAddress}</li>;
                })}
            </ul>
        );
    }

    render() {
        return (
            <div className='cart'>
                <h3>Cart</h3>
                <input type='text' onChange={this.changeAddress.bind(this)} value={this.state.address} placeholder='Equipment ID' autoFocus/><commit_msg>Fix broken UI after merge<commit_after>import React from 'react';
import { readAddress } from 'consus-core/identifiers';
import { searchItemForCheckout } from '../../lib/api-client';
import { searchItem } from '../../lib/api-client';
import { checkInItem } from '../../lib/api-client';
import { assert } from 'chai';

export default class CartPanel extends React.Component {

    constructor(props) {
        super(props);
        this.state = {
            address: ''
        };
    }

    changeAddress(e) {
        try {
            let result = readAddress(e.target.value);
            assert.strictEqual(result.type, 'item');
            let student = this.props.student;
            if (student.items.some(item => item.address === e.target.value)) {
                checkInItem(student.id, e.target.value);
            } else {
                searchItemForCheckout(e.target.value);
            }
            this.setState({
                address: ''
            });
        } catch(f) {
            this.setState({
                address: e.target.value
            });
        }
    }

    renderEquipment() {
        if(this.props.itemAddresses.length === 0) {
            return <div><br/><i>Cart is empty.</i><br/><br/></div>;
        }
        return (
            <ul>
                {this.props.itemAddresses.map((itemAddress, i) => {
                    return <li key={i}>{itemAddress}</li>;
                })}
            </ul>
        );
    }

    render() {
        return (
            <div className='cart'>
                <h3>Cart</h3>
                <input type='text' onChange={this.changeAddress.bind(this)} value={this.state.address} placeholder='Equipment ID' autoFocus/>
{'fraction_non_alphanumeric': 0.1483338248304335, 'fraction_numerical': 0.0020642878207018578, 'mean_word_length': 1.6213292117465223, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 36, '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': '4422630', 'n_tokens_mistral': 960, 'n_tokens_neox': 939, 'n_words': 172}