2019-09-28 21:59:05 +00:00
|
|
|
import React, { useEffect, useState } from 'react';
|
2019-08-17 18:40:51 +00:00
|
|
|
import useRouter from 'use-react-router';
|
2019-09-28 21:59:05 +00:00
|
|
|
import { ServerContext } from '@/state/server';
|
|
|
|
import getFileContents from '@/api/server/files/getFileContents';
|
2019-08-17 18:40:51 +00:00
|
|
|
|
|
|
|
export default () => {
|
2019-09-28 21:59:05 +00:00
|
|
|
const { location: { hash } } = useRouter();
|
|
|
|
const [content, setContent] = useState('');
|
|
|
|
const uuid = ServerContext.useStoreState(state => state.server.data!.uuid);
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
getFileContents(uuid, hash.replace(/^#/, ''))
|
|
|
|
.then(setContent)
|
|
|
|
.catch(error => console.error(error));
|
|
|
|
}, []);
|
2019-08-17 18:40:51 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<div className={'my-10'}>
|
2019-09-28 21:59:05 +00:00
|
|
|
<textarea
|
|
|
|
value={content}
|
|
|
|
className={'rounded bg-black h-32 w-full text-neutral-100 text-sm font-mono'}
|
|
|
|
/>
|
2019-08-17 18:40:51 +00:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|