updated format and lint scripts and applied them

This commit is contained in:
JJ Kasper
2018-06-01 16:52:12 -05:00
parent 53ac8a6793
commit 017a9993ee
58 changed files with 1711 additions and 1568 deletions

View File

@@ -1,53 +1,64 @@
import React, { Component } from 'react';
import Link from 'next/link';
import Router from 'next/router';
import fetch from 'isomorphic-unfetch';
import Page from '../comps/Page';
import Markdown from '../comps/Markdown';
import AddDoc from '../comps/AddDoc';
import getUrl from '../util/getUrl';
import getJwt from '../util/getJwt';
import React, { Component } from 'react'
import Link from 'next/link'
import Router from 'next/router'
import fetch from 'isomorphic-unfetch'
import Page from '../comps/Page'
import Markdown from '../comps/Markdown'
import AddDoc from '../comps/AddDoc'
import getUrl from '../util/getUrl'
import getJwt from '../util/getJwt'
class k extends Component {
delete = async () => {
const sure = window.confirm('Are you sure you want to delete this doc? This can not be undone.');
if(!sure) return;
const sure = window.confirm(
'Are you sure you want to delete this doc? This can not be undone.'
)
if (!sure) return
const del = await fetch(getUrl('docs/' + this.props.id), {
headers: { Authorization: getJwt() },
method: 'DELETE'
}).catch(({ message }) => ({ ok: false, message }));
if(del.ok) Router.push('/');
method: 'DELETE',
}).catch(({ message }) => ({ ok: false, message }))
if (del.ok) Router.push('/')
else {
if(!del.message) {
const data = await del.json();
del.message = data.message;
if (!del.message) {
const data = await del.json()
del.message = data.message
}
window.alert(`Could not delete doc, ${del.message}`);
window.alert(`Could not delete doc, ${del.message}`)
}
}
render() {
const { found, id, doc } = this.props;
if(!found) return (
<Page>
<h3>Doc not found...</h3>
</Page>
);
const { found, id, doc } = this.props
if (!found)
return (
<Page>
<h3>Doc not found...</h3>
</Page>
)
return (
<Page>
<h5 style={{ marginBottom: '1rem' }}>
{doc.dir}{doc.dir.length > 0 ? '/' : ''}{doc.name}{' - '}
<Link as={getUrl('edit/' + id)}
href={{ pathname: '/edit', query: { id }}}
{doc.dir}
{doc.dir.length > 0 ? '/' : ''}
{doc.name}
{' - '}
<Link
as={getUrl('edit/' + id)}
href={{ pathname: '/edit', query: { id } }}
>
<a id='edit'>edit</a>
<a id="edit">edit</a>
</Link>
<button className='float-right' onClick={this.delete}
<button
className="float-right"
onClick={this.delete}
style={{ margin: '5px 0 0' }}
>Delete</button>
>
Delete
</button>
</h5>
<Markdown source={doc.md} className='Markdown' />
<Markdown source={doc.md} className="Markdown" />
</Page>
);
)
}
}
export default AddDoc(k);
export default AddDoc(k)