{"size": 1567, "ext": "js", "max_stars_repo_path": "src/moduler/mal/aktivitetsmal-endre.js", "max_stars_repo_name": "jan-berge-ommedal/aktivitetsplan", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/moduler/mal/aktivitetsmal-endre.js", "max_issues_repo_name": "jan-berge-ommedal/aktivitetsplan", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/moduler/mal/aktivitetsmal-endre.js", "max_forks_repo_name": "jan-berge-ommedal/aktivitetsplan", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 27.0172413793, "max_line_length": 75, "alphanum_fraction": 0.6388002553}
import React, { Component } from 'react';
import PT from 'prop-types';
import { connect } from 'react-redux';
import * as AppPT from '../../proptypes';
import AktivitetsmalForm from './aktivitetsmal-form';
import Innholdslaster from '../../felles-komponenter/utils/innholdslaster';
import AktivitetsmalModal from './aktivitetsmal-modal';
import {
    hentMal,
    selectMalStatus,
    selectGjeldendeMal,
} from './aktivitetsmal-reducer';

class AktivitetmalEndre extends Component {
    componentDidMount() {
        this.props.doHentMal();
    }

    render() {
        const { mal, avhengigheter, history } = this.props;

        return (
            <Innholdslaster avhengigheter={avhengigheter}>
                <section className="aktivitetmal aktivitetmal__innhold">
                    <AktivitetsmalForm
                        mal={mal}
                        handleComplete={() => history.push('mal/')}
                    />
                </section>
            </Innholdslaster>
        );
    }
}

AktivitetmalEndre.defaultProps = {
    mal: null,
};

AktivitetmalEndre.propTypes = {
    mal: AppPT.mal,
    doHentMal: PT.func.isRequired,
    avhengigheter: AppPT.avhengigheter.isRequired,
    history: AppPT.history.isRequired,
};

const mapStateToProps = state => ({
    mal: selectGjeldendeMal(state),
    avhengigheter: [selectMalStatus(state)],
});

const mapDispatchToProps = dispatch => ({
    doHentMal: () => hentMal()(dispatch),
});

export default AktivitetsmalModal(
    connect(mapStateToProps, mapDispatchToProps)(AktivitetmalEndre)
);
