misc_pterodactyl-panel/resources/scripts/components/server/files/FileEditContainer.tsx

26 lines
814 B
TypeScript
Raw Normal View History

import React, { useEffect, useState } from 'react';
2019-08-17 18:40:51 +00:00
import useRouter from 'use-react-router';
import { ServerContext } from '@/state/server';
import getFileContents from '@/api/server/files/getFileContents';
2019-08-17 18:40:51 +00:00
export default () => {
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'}>
<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>
);
};