<commit_before>/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

import * as React from 'react';
import { FormattedMessage } from 'react-intl';
//import VERSION from '../../../server/version';
import { versionApi } from '../utils/api';


/**
 * React component that controls the footer strip at the bottom of all pages
 */
export default function FooterComponent() {
	const footerStyle: React.CSSProperties = {
		position: 'absolute',
		bottom: '30px',
		height: '10px',
		lineHeight: '10px',
		paddingTop: '20px',
		borderTop: '1px #e1e4e8 solid',
		textAlign: 'center',
		width: '100%'
	};
	const phantomStyle: React.CSSProperties = {
		display: 'block',
		height: '60px',
		width: '100%'
	};
	return (
		<div>
			<div style={phantomStyle} />
			<footer className='footer' style={footerStyle}>
				<span>
					<FormattedMessage id='oed.description' />
					<a href='mailto:<EMAIL>'>
						<FormattedMessage id='contact.us' />
					</a>
					<FormattedMessage id='visit'/>
					<a target='_blank' rel='noopener noreferrer' href='https://openenergydashboard.github.io/'>
						<FormattedMessage id='website' />
					</a>
					<FormattedMessage id='info' />
					<FormattedMessage id='oed.version'/> <span id="myspan"> 0.0.0 </span>
				</span>
			</footer>
		</div>
	);
}

async function getVersion() {
    try {
		const versionObj = await versionApi.getVersion();
        const version = versionObj.toString();
		console.log("VERSIONNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN");
		console.log(version);
    }
    catch(err) {
        console.log('Error: ', err.message);
    }<commit_msg>Adjusted footer CSS, rewrote async API call in convention, and handled promise in render body<commit_after>/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

import * as React from 'react';
import { FormattedMessage } from 'react-intl';
import { versionApi } from '../utils/api';
import VersionComponent from './VersionComponent';


/**
 * React component that controls the footer strip at the bottom of all pages
 */
export default function FooterComponent() {
	const footerStyle: React.CSSProperties = {
		position: 'absolute',
		bottom: '60px',
		height: '10px',
		lineHeight: '20px',
		paddingTop: '20px',
		borderTop: '1px #e1e4e8 solid',
		textAlign: 'center',
		width: '100%'
	};
	const phantomStyle: React.CSSProperties = {
		display: 'block',
		height: '100px',
		width: '100%'
	};
	let versionString = "";
	fetchVersion().then(function (result) {
		console.log("Second checkpoint");
		versionString = result;
		console.log(versionString);
	});
	console.log("Third checkpoint")
	console.log(versionString);
	return (
		<div>
			<div style={phantomStyle} />
			<footer className='footer' style={footerStyle}>
				<span>
					<FormattedMessage id='oed.description' />
					<a href='mailto:<EMAIL>'>
						<FormattedMessage id='contact.us' />
					</a>
					<FormattedMessage id='visit'/>
					<a target='_blank' rel='noopener noreferrer' href='https://openenergydashboard.github.io/'>
						<FormattedMessage id='website' />
					</a>
					<FormattedMessage id='info' />
					<VersionComponent version={versionString}/>
				</span>
			</footer>
		</div>
	);
}

// async functions always return a promise
async function fetchVersion() {
	// the await call contains and relies on a promise already
	// await: if it succeeds, returns result, otherwise, throws error
	const versionPromise = await versionApi.getVersion();
	console.log("This is the version promise")
	console.log(versionPromise);
	return versionPromise;
{'fraction_non_alphanumeric': 0.14341590612777053, 'fraction_numerical': 0.013559322033898305, 'mean_word_length': 3.7358024691358023, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 41, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 1, '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': '4883246', 'n_tokens_mistral': 1386, 'n_tokens_neox': 1197, 'n_words': 348}