@@ -63,8 +73,23 @@ const CreateServer = ({ user, onCreateServer }) => {
diff --git a/src/pages/DashboardPage/DashboardPage.jsx b/src/pages/DashboardPage/DashboardPage.jsx
index 2adbfdb..097f74c 100644
--- a/src/pages/DashboardPage/DashboardPage.jsx
+++ b/src/pages/DashboardPage/DashboardPage.jsx
@@ -4,24 +4,25 @@ import Navbar from '../../components/navbar/Navbar';
import styles from './DashboardPage.module.scss';
import NoServer from '../NoServer/NoServer';
import { getUserSubdomain } from "../../service/firebase";
-import '../../service/api.tsx';
import serviiApi from "../../service/api.tsx";
-import Api from "../../service/api.tsx";
-
+import Loading from '../Loading/loading';
const DashboardPage = ({ user }) => {
const [servers, setServers] = useState([]);
const [subdomain, setSubdomain] = useState("");
+ const [loading, setLoading] = useState(true);
const loadServers = async () => {
try {
const ApiResponse = await serviiApi.fetchServers();
- const data = ApiResponse.message
+ const data = ApiResponse.message;
setServers(data);
const userSubdomain = await getUserSubdomain(user.uid);
setSubdomain(userSubdomain);
} catch (error) {
console.error('Error fetching data:', error);
+ } finally {
+ setLoading(false);
}
};
@@ -29,11 +30,10 @@ const DashboardPage = ({ user }) => {
loadServers();
}, []);
- const handleCreateServer = async () => {
+ const handleCreateServer = async (serverName, serverVersion) => {
try {
- const serverName = prompt('Enter the name for the new server:');
- if (!serverName) return;
- await serviiApi.serverCreate(serverName, "1.20.6", "paper");
+ if (!serverName || !serverVersion) return;
+ await serviiApi.serverCreate(serverName, serverVersion, "paper");
await loadServers();
} catch (error) {
console.error('Error creating server:', error);
@@ -68,25 +68,29 @@ const DashboardPage = ({ user }) => {
return (
-
- {servers.length === 0 ? (
-
- ) : (
- servers.map((server, index) => (
- handleRunServer(server.name)}
- onStopClick={() => handleStopServer(server.name)}
- onDeleteClick={() => handleDeleteServer(server.name)}
- />
- ))
- )}
-
+ {loading ? (
+
+ ) : (
+
+ {servers.length === 0 ? (
+
+ ) : (
+ servers.map((server, index) => (
+ handleRunServer(server.name)}
+ onStopClick={() => handleStopServer(server.name)}
+ onDeleteClick={() => handleDeleteServer(server.name)}
+ />
+ ))
+ )}
+
+ )}
);
};
diff --git a/src/pages/Loading/loading.jsx b/src/pages/Loading/loading.jsx
new file mode 100644
index 0000000..2818fa0
--- /dev/null
+++ b/src/pages/Loading/loading.jsx
@@ -0,0 +1,10 @@
+import styles from './loading.module.scss';
+
+const Loading = () => (
+
+ );
+
+export default Loading;
\ No newline at end of file
diff --git a/src/pages/Loading/loading.module.scss b/src/pages/Loading/loading.module.scss
new file mode 100644
index 0000000..9cb534d
--- /dev/null
+++ b/src/pages/Loading/loading.module.scss
@@ -0,0 +1,28 @@
+
+.loading {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ justify-content: center;
+ height: 100vh;
+ font-size: 1.5rem;
+ }
+
+ .spinner {
+ border: 4px solid rgba(0, 0, 0, 0.1);
+ width: 6rem;
+ height: 6rem;
+ border-radius: 50%;
+ border-left-color: #09f;
+ animation: spin 1s ease infinite;
+ }
+
+ @keyframes spin {
+ 0% {
+ transform: rotate(0deg);
+ }
+ 100% {
+ transform: rotate(360deg);
+ }
+ }
+
\ No newline at end of file
diff --git a/src/pages/NoServer/NoServer.jsx b/src/pages/NoServer/NoServer.jsx
index 7aea1f8..be33ef7 100644
--- a/src/pages/NoServer/NoServer.jsx
+++ b/src/pages/NoServer/NoServer.jsx
@@ -8,15 +8,15 @@ const NoServer = ({ user, onCreateServer }) => {
return (
- { isCreating === false ? (
+ {isCreating === false ? (
<>
-
Erreur
+
Erreur
Aucun serveur possédé
>
) : (
<>
-
{}
+
>
)}