mirror of
https://github.com/aykhans/slash-e.git
synced 2025-07-06 21:22:36 +00:00
feat: install mui
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
import { useEffect } from "react";
|
||||
import { useEffect, useState } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { userService, workspaceService } from "../services";
|
||||
import { useAppSelector } from "../store";
|
||||
@ -6,11 +6,18 @@ import useLoading from "../hooks/useLoading";
|
||||
import Icon from "../components/Icon";
|
||||
import Header from "../components/Header";
|
||||
import WorkspaceListView from "../components/WorkspaceListView";
|
||||
import showCreateWorkspaceDialog from "../components/CreateWorkspaceDialog";
|
||||
import CreateWorkspaceDialog from "../components/CreateWorkspaceDialog";
|
||||
|
||||
interface State {
|
||||
showCreateWorkspaceDialog: boolean;
|
||||
}
|
||||
|
||||
const Home: React.FC = () => {
|
||||
const navigate = useNavigate();
|
||||
const { workspaceList } = useAppSelector((state) => state.workspace);
|
||||
const [state, setState] = useState<State>({
|
||||
showCreateWorkspaceDialog: false,
|
||||
});
|
||||
const loadingState = useLoading();
|
||||
|
||||
useEffect(() => {
|
||||
@ -24,29 +31,49 @@ const Home: React.FC = () => {
|
||||
});
|
||||
}, []);
|
||||
|
||||
const handleCreateWorkspaceButtonClick = () => {
|
||||
setState({
|
||||
...state,
|
||||
showCreateWorkspaceDialog: true,
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="w-full h-full flex flex-col justify-start items-start">
|
||||
<Header />
|
||||
<div className="mx-auto max-w-4xl w-full px-3 py-6 flex flex-col justify-start items-start">
|
||||
<div className="mb-4 w-full flex flex-row justify-between items-center">
|
||||
<span className="font-mono text-gray-400">Workspace List</span>
|
||||
<button
|
||||
className="text-sm flex flex-row justify-start items-center border px-3 leading-10 rounded-lg cursor-pointer hover:shadow"
|
||||
onClick={() => showCreateWorkspaceDialog()}
|
||||
>
|
||||
<Icon.Plus className="w-5 h-auto mr-1" /> Create Workspace
|
||||
</button>
|
||||
</div>
|
||||
{loadingState.isLoading ? (
|
||||
<div className="py-4 w-full flex flex-row justify-center items-center">
|
||||
<Icon.Loader className="mr-2 w-5 h-auto animate-spin" />
|
||||
loading
|
||||
<>
|
||||
<div className="w-full h-full flex flex-col justify-start items-start">
|
||||
<Header />
|
||||
<div className="mx-auto max-w-4xl w-full px-3 py-6 flex flex-col justify-start items-start">
|
||||
<div className="mb-4 w-full flex flex-row justify-between items-center">
|
||||
<span className="font-mono text-gray-400">Workspace List</span>
|
||||
<button
|
||||
className="text-sm flex flex-row justify-start items-center border px-3 leading-10 rounded-lg cursor-pointer hover:shadow"
|
||||
onClick={handleCreateWorkspaceButtonClick}
|
||||
>
|
||||
<Icon.Plus className="w-5 h-auto mr-1" /> Create Workspace
|
||||
</button>
|
||||
</div>
|
||||
) : (
|
||||
<WorkspaceListView workspaceList={workspaceList} />
|
||||
)}
|
||||
{loadingState.isLoading ? (
|
||||
<div className="py-4 w-full flex flex-row justify-center items-center">
|
||||
<Icon.Loader className="mr-2 w-5 h-auto animate-spin" />
|
||||
loading
|
||||
</div>
|
||||
) : (
|
||||
<WorkspaceListView workspaceList={workspaceList} />
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{state.showCreateWorkspaceDialog && (
|
||||
<CreateWorkspaceDialog
|
||||
onClose={() => {
|
||||
setState({
|
||||
...state,
|
||||
showCreateWorkspaceDialog: false,
|
||||
});
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user