Migrations and initial data stuff

This commit is contained in:
Gregory Schier
2023-02-25 16:39:18 -08:00
parent ba3b899115
commit 93105a3e89
17 changed files with 1082 additions and 129 deletions

View File

@@ -9,6 +9,7 @@ import { Sidebar } from './components/Sidebar';
import { UrlBar } from './components/UrlBar';
import { Grid } from './components/Grid';
import { motion } from 'framer-motion';
import { useRequests, useWorkspace, useWorkspaces } from './hooks/useWorkspaces';
interface Response {
url: string;
@@ -21,6 +22,8 @@ interface Response {
}
function App() {
const { data } = useWorkspace();
console.log('DATA', data);
const [loading, setLoading] = useState<boolean>(false);
const [error, setError] = useState<string | null>(null);
const [response, setResponse] = useState<Response | null>(null);
@@ -31,6 +34,19 @@ function App() {
value: 'GET',
});
useEffect(() => {
const listener = async (e: KeyboardEvent) => {
if (e.metaKey && (e.key === 'Enter' || e.key === 'r')) {
await sendRequest();
}
};
document.documentElement.addEventListener('keypress', listener);
return () => document.documentElement.removeEventListener('keypress', listener);
}, []);
if (!data) return null;
const { requests, workspace } = data;
async function sendRequest() {
setLoading(true);
setError(null);
@@ -54,20 +70,10 @@ function App() {
const contentType = response?.headers['content-type']?.split(';')[0] ?? 'text/plain';
useEffect(() => {
const listener = async (e: KeyboardEvent) => {
if (e.metaKey && (e.key === 'Enter' || e.key === 'r')) {
await sendRequest();
}
};
document.documentElement.addEventListener('keypress', listener);
return () => document.documentElement.removeEventListener('keypress', listener);
}, []);
return (
<>
<div className="grid grid-cols-[auto_1fr] h-full text-gray-900">
<Sidebar />
<Sidebar requests={requests ?? []} workspaceId={workspace.id} />
<Grid cols={2}>
<VStack className="w-full">
<HStack as={WindowDragRegion} items="center" className="pl-3 pr-1.5">