ajout bouton annuler

This commit is contained in:
AntoninoP 2024-07-09 15:03:58 +02:00
parent 96a4407ecf
commit 3e40eb7b25
2 changed files with 17 additions and 2 deletions

View File

@ -3,7 +3,7 @@ import styles from './CreateServer.module.scss';
import { getUserSubdomain } from "../../service/firebase";
import serviiApi from "../../service/api.tsx";
const CreateServer = ({ user, onCreateServer, onSubdomainUpdate }) => {
const CreateServer = ({ user, onCreateServer, onSubdomainUpdate, onCancel }) => {
const [subdomain, setSubdomain] = useState(null);
const [subdomainInput, setSubdomainInput] = useState('');
const [serverName, setServerName] = useState('');
@ -71,6 +71,9 @@ const CreateServer = ({ user, onCreateServer, onSubdomainUpdate }) => {
<button className={styles.btnSubCreate} onClick={handleSaveSubdomain}>
Envoyer
</button>
<button className={styles.btnCancel} onClick={onCancel}>
Annuler
</button>
</div>
</div>
) : (
@ -98,6 +101,9 @@ const CreateServer = ({ user, onCreateServer, onSubdomainUpdate }) => {
<button className={styles.btnServCreate} onClick={handleCreateServer}>
Créer
</button>
<button className={styles.btnServCreate} onClick={onCancel}>
Annuler
</button>
</div>
</div>
</div>

View File

@ -54,6 +54,10 @@ const DashboardPage = ({ user }) => {
setShowCreateServer(true);
};
const handleCancelCreateServer = () => {
setShowCreateServer(false);
};
const handleRunServer = async (serverName) => {
try {
await serviiApi.serverRun(serverName);
@ -94,7 +98,12 @@ const DashboardPage = ({ user }) => {
<div className={styles.dashboardContainer}>
<Navbar user={user} />
{showCreateServer ? (
<CreateServer user={user} onCreateServer={handleCreateServer} onSubdomainUpdate={setSubdomain} />
<CreateServer
user={user}
onCreateServer={handleCreateServer}
onSubdomainUpdate={setSubdomain}
onCancel={handleCancelCreateServer}
/>
) : (
<div className={styles.cardsContainer}>
{servers.length === 0 ? (