<commit_before>"use strict";
// This component contains the edit feautures of the dictionary documents.
// We need the ability to delete and edit pur documents.
// The component is used in the finalResult component( Should be called finalDocument? )
import React from "react";
import localOrSessionToken from '../../../functionality/localOrSession.js';

export default class EditDocument extends React.Component {


    handleDeleteButton(e) {
        e.preventDefault()

        // need to fetch, but to an address.

        //Data the server needs
        let data = {
            document_id: this.props.document._id,
            topic: this.props.document.topic,
            auth: {
                "token": localOrSessionToken()
            }
        }

        //Fetch returns a promise
        fetch("/api/dictionary/delete", {
            method: 'POST',
            body: JSON.stringify(data),
            headers: new Headers({
                'Content-type': 'application/json'
            })
        }).then(
            // Fullfilment
            function(response) {
                return response = response.json();
            },
            function( err ) {
                console.error("Something went wrong on server", err);
            }
        )
        .then(
            function(response) {
                console.log("response:", response)
            },
            function(err) {
                console.error("Error in converting response to json", err);
            }
        )
    }

    render() {
        return (<commit_msg>Skal prøve og lage den til promise.<commit_after>"use strict";
// This component contains the edit feautures of the dictionary documents.
// We need the ability to delete and edit pur documents.
// The component is used in the finalResult component( Should be called finalDocument? )
import React from "react";
import localOrSessionToken from '../../../functionality/localOrSession.js';

export default class EditDocument extends React.Component {


    handleDeleteButton(e) {
        e.preventDefault()

        // need to fetch, but to an address.

        //Data the server needs
        let data = {
            document_id: this.props.document._id,
            topic: this.props.document.topic,
            auth: {
                "token": localOrSessionToken()
            }
        }

        //Fetch returns a promise
        fetch("/api/dictionary/delete", {
            method: 'POST',
            body: JSON.stringify(data),
            headers: new Headers({
                'Content-type': 'application/json'
            })
        }).then(
            // Fullfilment
            function(response) {
                return response = response.json();
            },
            // Fetch noes not return reject?
            function( err ) {
                console.error("Something went wrong on server", err);
            }
        )
        .then(
            function(response) {
                console.log("response:", response)
            },
            function(err) {
                console.error("Error in converting response to json", err);
            }
        )
    }

    render() {
        return (
{'fraction_non_alphanumeric': 0.10084559974945193, 'fraction_numerical': 0.0, 'mean_word_length': 1.5841423948220066, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, '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': '7250577', 'n_tokens_mistral': 774, 'n_tokens_neox': 748, 'n_words': 235}