Home Reference Source

application/components/draftable/draft-last-autosave.js

import React from 'react';
import {timeToFormat} from './../../util/strings';

/**
 * Last autosave notification, accepts properties:
 * * label - notification text
 * * format - timeformat (moment)
 * * lastsave - date object
 */
class DraftLastAutosave extends React.Component {
    constructor(props) {

        super(props);

    }

    render() {

        if (this.props.lastsave) {
            let format = 'hh:mm:ss';
            if (this.props.format) {
                format = this.props.format;
            }

            return (
                <div style={{display:'inline-block'}}>
                    {this.props.label ? this.props.label + ' ' : 'Draft saved '}
                    {timeToFormat(this.props.lastsave, format)}
                </div>
            );
        }

        return (
            <span></span>
        );
    }
}

export default DraftLastAutosave;